diff --git a/README.md b/README.md index 1295506..95f5522 100644 --- a/README.md +++ b/README.md @@ -87,19 +87,18 @@ https://geektimes.ru/post/273852/ // Good tutorial for fast start in RUSSIAN In linux you can open terminal, navigate to your programming directory, then * git clone https://github.com/anklimov/lighthub.git - * cd lighthub - * pio init --ide clion // use your IDE, others here: http://docs.platformio.org/en/latest/ide.html - -* export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" - -set ip address of your configuration server and disable wdt feature in case bootloader of your mega2560 is stock - * pio run -e due // this will build firmware for arduino due board - * rm -Rf .piolibdeps // this will clean libraries folder. Try it if you have compilation problem - * pio run -e megaatmega2560 //build for arduino mega - * pio run -e due -t upload //build and upload firmware to arduino due + +# Custom build flags + +* MY_CONFIG_SERVER=192.168.1.1 // address of external JSON-config http://192.168.1.1/de-ad-be-ef-fe-00.config.json +* WATCH_DOG_TICKER_DISABLE=1 //disable wdt feature +* USE_1W_PIN=49 // use direct connection to 1W devices, no I2C bridge DS2482-100 + +export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1 -DUSE_1W_PIN=49" + diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 035984d..a51cad4 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -132,9 +132,6 @@ EthernetClient ethClient; #include "dmx.h" #endif -#define Q(x) #x -#define QUOTE(x) Q(x) - #ifndef PIO_SRC_REV #define PIO_SRC_REV v0.98 #endif @@ -148,7 +145,7 @@ EthernetClient ethClient; extern Artnet *artnet; #endif -#ifdef _sd +#ifdef SD_CARD_INSERTED #include "sd_card_w5100.h" #endif @@ -904,12 +901,15 @@ void postTransmission() } void setup_main() { - cmdInit(115200); + cmdInit(uint32_t(SERIAL_BAUD)); Serial.print(F("\nLazyhome.ru LightHub controller ")); Serial.println(F(QUOTE(PIO_SRC_REV))); +#ifdef WATCH_DOG_TICKER_DISABLE + Serial.println(F("WATCHDOG TICKER DISABLED")); +#endif -#ifdef _sd +#ifdef SD_CARD_INSERTED sd_card_w5100_setup(); #endif diff --git a/lighthub/main.h b/lighthub/main.h index 16ce1e9..2addc1c 100644 --- a/lighthub/main.h +++ b/lighthub/main.h @@ -5,7 +5,10 @@ #ifndef LIGHTHUB_MAIN_H #define LIGHTHUB_MAIN_H -#endif //LIGHTHUB_MAIN_H + +#ifndef SERIAL_BAUD +#define SERIAL_BAUD 115200 +#endif #include "Arduino.h" #include "DallasTemperature.h" @@ -45,3 +48,4 @@ void inputLoop(void); void modbusLoop(void); void thermoLoop(void); short thermoSetCurTemp(char * name, short t); +#endif //LIGHTHUB_MAIN_H \ No newline at end of file diff --git a/lighthub/options.h b/lighthub/options.h index 9517d24..ce8d76e 100644 --- a/lighthub/options.h +++ b/lighthub/options.h @@ -32,3 +32,6 @@ #ifndef _dmxout #undef _artnet #endif + +#define Q(x) #x +#define QUOTE(x) Q(x) \ No newline at end of file diff --git a/lighthub/owTerm.cpp b/lighthub/owTerm.cpp index 7bbcf87..a435a4c 100644 --- a/lighthub/owTerm.cpp +++ b/lighthub/owTerm.cpp @@ -80,10 +80,13 @@ while (net && net->wireSearch(term[t_count])>0 && (t_count mi int owSetup(owChangedType owCh) { //// todo - move memory allocation to here -#ifdef _2482 +#ifdef DS2482_100_I2C_TO_1W_BRIDGE + Serial.println(F("DS2482_100_I2C_TO_1W_BRIDGE init")); net = new OneWire; #else -net = new OneWire (ONE_WIRE_BUS); + Serial.print(F("One wire setup on PIN:")); + Serial.println(QUOTE(USE_1W_PIN)); +net = new OneWire (USE_1W_PIN); #endif @@ -97,7 +100,7 @@ wstat = new uint16_t [t_max]; - #ifdef _2482 + #ifdef DS2482_100_I2C_TO_1W_BRIDGE Wire.begin(); if (net->checkPresence()) { diff --git a/lighthub/owTerm.h b/lighthub/owTerm.h index 5ff225d..18cf543 100644 --- a/lighthub/owTerm.h +++ b/lighthub/owTerm.h @@ -47,8 +47,6 @@ e-mail anklimov@gmail.com #define recheck_interval 5 #define check_circle 2000/t_count - - #define t_max 20 //Maximum number of 1w devices #define TEMPERATURE_PRECISION 9 @@ -59,13 +57,12 @@ e-mail anklimov@gmail.com extern aJsonObject *owArr; typedef void (*owChangedType) (int , DeviceAddress, int) ; +#ifndef USE_1W_PIN +#define DS2482_100_I2C_TO_1W_BRIDGE // HW driver +#endif -#define _2482 // HW driver - -#ifdef _2482 -#include -#else -#define ONE_WIRE_BUS A0 +#ifdef DS2482_100_I2C_TO_1W_BRIDGE +#include #endif extern OneWire *net; diff --git a/platformio.ini b/platformio.ini index c5d2eee..031343f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,8 +10,8 @@ [platformio] src_dir = lighthub env_default = - megaatmega2560 -; due +; megaatmega2560 + due [env:due] platform = atmelsam