From f3bee5cc1b5ce711003a55aca107d49d6f96469e Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 20:19:58 +0300 Subject: [PATCH 01/13] my server conf --- lighthub/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 993bacb..cf57872 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -763,7 +763,7 @@ int getConfig (int arg_cnt, char **args) int returnCode =0; char ch; char URI [32]; - char server[32] = "lazyhome.ru"; + char server[32] = "ri48.ru/tid"; if (arg_cnt>0) { strncpy(server,args[1],sizeof(server)-1); saveFlash(0,server); From 6371895430e01ff96f6837af45725953d1c5b6bc Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 20:45:29 +0300 Subject: [PATCH 02/13] MY_CONFIG_SERVER --- lighthub/main.cpp | 7 ++++++- platformio.ini | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lighthub/main.cpp b/lighthub/main.cpp index cf57872..d89862a 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -755,6 +755,11 @@ void saveFlash(short n, char* str) void loadFlash(short n, char* str) {} +#ifndef MY_CONFIG_SERVER +#define CONFIG_SERVER "lazyhome.ru" +#else +#define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER) +#endif int getConfig (int arg_cnt, char **args) //(char *tokens) { @@ -763,7 +768,7 @@ int getConfig (int arg_cnt, char **args) int returnCode =0; char ch; char URI [32]; - char server[32] = "ri48.ru/tid"; + char server[sizeof(CONFIG_SERVER)+21] = CONFIG_SERVER; if (arg_cnt>0) { strncpy(server,args[1],sizeof(server)-1); saveFlash(0,server); diff --git a/platformio.ini b/platformio.ini index 6a330ef..c5d2eee 100644 --- a/platformio.ini +++ b/platformio.ini @@ -42,6 +42,7 @@ platform = atmelavr board = megaatmega2560 framework = arduino ;lib_ldf_mode = chain+ +build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD) lib_deps = https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/DS2482_OneWire From 98607b7e6465e36b9ef2ca7e86641ea00a458db8 Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 21:02:59 +0300 Subject: [PATCH 03/13] WDT --- lighthub/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthub/main.cpp b/lighthub/main.cpp index d89862a..e94dec2 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -88,7 +88,7 @@ Config webserver #include #endif -#ifdef WATCH_DOG_TICKER_DISABLE +#if defined(WATCH_DOG_TICKER_DISABLE) #define wdt_en() wdt_disable() #define wdt_dis() wdt_disable() #define wdt_res() wdt_disable() From b403f0e7db3fc56727e8c8a1fe32df715dc304f6 Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 21:14:37 +0300 Subject: [PATCH 04/13] WDT --- lighthub/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthub/main.cpp b/lighthub/main.cpp index e94dec2..db4333c 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -161,7 +161,7 @@ extern Artnet *artnet; #define inprefix "/myhome/in/" const char outprefix[] PROGMEM = "/myhome/s_out/"; -#define subprefix "/myhome/in/#" +const char subprefix[] PROGMEM = "/myhome/in/#"; aJsonObject *root = NULL; aJsonObject *items = NULL; From f9e4def56d832e5285d7a0d922457db3e9daa02c Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 21:25:52 +0300 Subject: [PATCH 05/13] readme.md --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 332c980..9a236b5 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,17 @@ First attempt to use platformio toolchain for compiling (work not completed yet) # Due compilation issue "USART0_Handler redefinition" Please, open /variants/arduino_due_x/variant.cpp file, then edit USART0_Handler method definition like this -void USART0_Handler(void) __attribute__((weak)); \ No newline at end of file +void USART0_Handler(void) __attribute__((weak)); + +# Platformio +First of all install platformio framework. http://docs.platformio.org/en/latest/installation.html +git clone https://github.com/anklimov/lighthub.git +pio init --ide clion // prepare CMake build files for Intellij CLion IDE, look list if suppoerted ide here: http://docs.platformio.org/en/latest/ide.html +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 + + +export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" +set ip address for your configuration server and completely disable wdt feature for AVR. From 770788bb56eb454c2336ec43ae0f02f97d729de6 Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 21:55:16 +0300 Subject: [PATCH 06/13] readme.md --- README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9a236b5..381223c 100644 --- a/README.md +++ b/README.md @@ -79,15 +79,28 @@ Please, open /variants/arduino_due_x/variant.cpp file, then edit USART0_Handler void USART0_Handler(void) __attribute__((weak)); -# Platformio +# Platformio command line build instructions First of all install platformio framework. http://docs.platformio.org/en/latest/installation.html + +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 -pio init --ide clion // prepare CMake build files for Intellij CLion IDE, look list if suppoerted ide here: http://docs.platformio.org/en/latest/ide.html + +cd lighthub + +pio init --ide clion // prepare CMake build files for Intellij CLion IDE or look if your ide here: http://docs.platformio.org/en/latest/ide.html + 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 export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" -set ip address for your configuration server and completely disable wdt feature for AVR. + +set ip address for your configuration server and completely disable wdt feature for AVR in case bootloader of your mega2560 is stock From 4ca608a1cf949639916c55106018cfedae1836d9 Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 21:58:26 +0300 Subject: [PATCH 07/13] readme.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 381223c..a5e52ed 100644 --- a/README.md +++ b/README.md @@ -86,21 +86,21 @@ 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 +*git clone https://github.com/anklimov/lighthub.git -cd lighthub +*cd lighthub -pio init --ide clion // prepare CMake build files for Intellij CLion IDE or look if your ide here: http://docs.platformio.org/en/latest/ide.html +*pio init --ide clion // prepare CMake build files for Intellij CLion IDE or look if your ide here: http://docs.platformio.org/en/latest/ide.html -pio run -e due // this will build firmware for arduino due board +*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 +*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 megaatmega2560 //build for arduino mega -pio run -e due -t upload //build and upload firmware to arduino due +*pio run -e due -t upload //build and upload firmware to arduino due -export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" +*export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" set ip address for your configuration server and completely disable wdt feature for AVR in case bootloader of your mega2560 is stock From 4c1cad4f0aeb6ff78d2d9a8719f08f3c6bdbbbbe Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 21:59:47 +0300 Subject: [PATCH 08/13] readme.md --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a5e52ed..4c20800 100644 --- a/README.md +++ b/README.md @@ -86,21 +86,20 @@ 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 +* git clone https://github.com/anklimov/lighthub.git -*cd lighthub +* cd lighthub -*pio init --ide clion // prepare CMake build files for Intellij CLion IDE or look if your ide here: http://docs.platformio.org/en/latest/ide.html +* pio init --ide clion // prepare CMake build files for Intellij CLion IDE or look if your ide here: http://docs.platformio.org/en/latest/ide.html -*pio run -e due // this will build firmware for arduino due board +* 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 +* 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 megaatmega2560 //build for arduino mega -*pio run -e due -t upload //build and upload firmware to arduino due +* pio run -e due -t upload //build and upload firmware to arduino due - -*export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" +* export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" set ip address for your configuration server and completely disable wdt feature for AVR in case bootloader of your mega2560 is stock From 2b78f127d0c5ad0d24123db5cc14b0192afc463e Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 22:01:39 +0300 Subject: [PATCH 09/13] readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c20800..abc733c 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ In linux you can open terminal, navigate to your programming directory, then * cd lighthub -* pio init --ide clion // prepare CMake build files for Intellij CLion IDE or look if your ide here: http://docs.platformio.org/en/latest/ide.html +* pio init --ide clion // use your IDE, others here: http://docs.platformio.org/en/latest/ide.html * pio run -e due // this will build firmware for arduino due board From de0f3ba5462679d21ce127a0835a164b24cb7f5f Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 22:02:50 +0300 Subject: [PATCH 10/13] readme.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index abc733c..abc59d2 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ In linux you can open terminal, navigate to your programming directory, then * 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 for your configuration server and completely disable wdt feature for AVR 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 @@ -99,7 +103,3 @@ In linux you can open terminal, navigate to your programming directory, then * pio run -e megaatmega2560 //build for arduino mega * pio run -e due -t upload //build and upload firmware to arduino due - -* export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" - -set ip address for your configuration server and completely disable wdt feature for AVR in case bootloader of your mega2560 is stock From 7a6e5591ea7a0a27cf4bf06d07f772ba3032e6ef Mon Sep 17 00:00:00 2001 From: livello Date: Sun, 18 Mar 2018 22:04:34 +0300 Subject: [PATCH 11/13] readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index abc59d2..1295506 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ In linux you can open terminal, navigate to your programming directory, then * export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1" -set ip address for your configuration server and completely disable wdt feature for AVR in case bootloader of your mega2560 is stock +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 From 39655a8d7a175bc017a26a94d1c36dc66a0f9c9f Mon Sep 17 00:00:00 2001 From: livello Date: Wed, 21 Mar 2018 17:21:19 +0300 Subject: [PATCH 12/13] common_defitinitons->options custom 1w pin and direct connection without DS2482-100 instructions to README --- README.md | 19 +++++++++---------- lighthub/main.cpp | 12 ++++++------ lighthub/main.h | 6 +++++- lighthub/options.h | 3 +++ lighthub/owTerm.cpp | 9 ++++++--- lighthub/owTerm.h | 13 +++++-------- platformio.ini | 4 ++-- 7 files changed, 36 insertions(+), 30 deletions(-) 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 From 5e21cd03ccd17a93fb337982ef37da8a98828b2b Mon Sep 17 00:00:00 2001 From: livello Date: Wed, 21 Mar 2018 17:30:41 +0300 Subject: [PATCH 13/13] README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95f5522..0c17f19 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ In linux you can open terminal, navigate to your programming directory, then * 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 +* SD_CARD_INSERTED=1 // enable sd-card support and fix lan starting +* SERIAL_BAUD=115200 // set baud rate for console on Serial0 -export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1 -DUSE_1W_PIN=49" +export PLATFORMIO_BUILD_FLAGS="-DMY_CONFIG_SERVER=192.168.1.1 -DWATCH_DOG_TICKER_DISABLE=1 -DUSE_1W_PIN=49 -DSERIAL_BAUD=115200 -DSD_CARD_INSERTED=1"