From ca7436315ac9e742beddb8d95df62b7bbef6d34f Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 21 Aug 2015 16:56:06 +0200 Subject: wip --- Debug.h | 31 ++++++------------------------- trygvisio_soil_moisture.ino | 17 +++++++---------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/Debug.h b/Debug.h index 4883083..9bf82bf 100644 --- a/Debug.h +++ b/Debug.h @@ -3,15 +3,9 @@ #include "config-check.h" -template -struct conditional { typedef T type; }; +#include -template -struct conditional { typedef F type; }; - -#include - -#ifdef __AVR_ATtiny85__ +#ifdef ARDUINO_attiny class Serial { public: void begin(int); @@ -33,27 +27,14 @@ enum DebugSink { DEBUG_SINK_SOFTWARE_SERIAL, }; -struct DebugEmptyBase {}; -struct DebugSoftwareSerialBase { - // TODO: these should be customizable - static const int rx_pin = 1; - static const int tx_pin = 0; - -public: - SoftwareSerial ss; - - DebugSoftwareSerialBase() : ss(rx_pin, tx_pin) { - } -}; - -template -class Debug : public conditional::type +template +class Debug { - + AltSoftSerial ss; public: const enum DebugSink sink; - Debug() : sink(sink_) { + Debug() : ss(rx_pin, tx_pin), sink(sink_) { } inline void begin(const long baud_rate) { diff --git a/trygvisio_soil_moisture.ino b/trygvisio_soil_moisture.ino index 25baac0..929f220 100644 --- a/trygvisio_soil_moisture.ino +++ b/trygvisio_soil_moisture.ino @@ -7,8 +7,9 @@ #ifdef PERSISTENT_CONFIGURATION_SUPPORT #include #endif -#include +#include #include + #include #include #include @@ -73,7 +74,7 @@ static hal_aci_evt_t aci_data; static boolean timing_change_done = false; void __ble_assert(const char *file, uint16_t line) -{ +{ debug.print("ERROR "); debug.print(file); debug.print(": "); @@ -84,7 +85,6 @@ void __ble_assert(const char *file, uint16_t line) static void go_to_sleep(); -extern SoftwareSerial ss; void setup() { #ifdef TXLED0 // An attempt to make sure that the RX and TX LEDs are turned off when running normally. @@ -105,11 +105,7 @@ void setup() { if (debug.sink == DEBUG_SINK_SERIAL) { debug.begin(115200); } else if (debug.sink == DEBUG_SINK_SOFTWARE_SERIAL) { - debug.begin(9600); - - while(true) { - debug.println("hello debug world!"); - } + debug.begin(9600); } #if WAIT_FOR_SERIAL_BEFORE_STARING @@ -148,7 +144,7 @@ static void setup_rf() { // SPI_CLOCK_DIV8 = 2MHz SPI speed // SPI_CLOCK_DIV16 = 1MHz SPI speed -#ifdef ARDUINO_BLEND_MICRO +#if defined(ARDUINO_BLEND_MICRO) aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V1_1; aci_state.aci_pins.reqn_pin = 6; aci_state.aci_pins.rdyn_pin = 7; @@ -163,7 +159,7 @@ static void setup_rf() { aci_state.aci_pins.interface_is_interrupt = false; aci_state.aci_pins.interrupt_number = 4; -#elif ARDUINO_AVR_LEONARDO +#elif defined(ARDUINO_AVR_LEONARDO) // Assumes OLIMEXINO-32U4 and UEXT aci_state.aci_pins.board_name = BOARD_DEFAULT; aci_state.aci_pins.reqn_pin = 2; @@ -179,6 +175,7 @@ static void setup_rf() { aci_state.aci_pins.interface_is_interrupt = false; // aci_state.aci_pins.interrupt_number = 4; +#elif defined(ARDUINO_attiny) #else #error unknown board type #endif -- cgit v1.2.3