From e01d4c2100d1a4f52c09cc4d370ad7f849810ebf Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Mon, 16 Apr 2018 20:56:29 +0200 Subject: [PATCH 1/3] cleanups --- platformio.ini | 33 +++++++++++++++++---------------- src/globals.h | 8 ++++---- src/main.cpp | 15 +++++++-------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8f4d829a..9d54a245 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,24 +20,29 @@ env_default = heltec_wifi_lora_32 ; description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. +;----------- common part ----------- [common_env_data] build_flags = ; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework ; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <--- ; otherwise device may crash in dense environments due to serial buffer overflow ; + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE - -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG ; -;override lora settings from LMiC library in lmic/config.h and use main.h instead +; override lora settings from LMiC library in lmic/config.h and use main.h instead -D_lmic_config_h_ -include "src/main.h" ; -lib_deps_builtin = - U8g2@2.22.10 - +lib_deps_display = + U8g2@>=2.22.14 +lib_deps_rgbled = + SmartLeds +; +; +;----------- hardware specific part ----------- [env:heltec_wifi_lora_32] platform = espressif32 @@ -46,7 +51,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 115200 lib_deps = - ${common_env_data.lib_deps_builtin} + ${common_env_data.lib_deps_display} build_flags = ${common_env_data.build_flags} -Dheltec_wifi_lora_32 @@ -59,7 +64,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 115200 lib_deps = - ${common_env_data.lib_deps_builtin} + ${common_env_data.lib_deps_display} build_flags = ${common_env_data.build_flags} -Dttgov1 @@ -72,7 +77,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 921600 lib_deps = - ${common_env_data.lib_deps_builtin} + ${common_env_data.lib_deps_display} build_flags = ${common_env_data.build_flags} -Dttgov2 @@ -85,8 +90,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 921600 lib_deps = - ${common_env_data.lib_deps_builtin} - SmartLeds + ${common_env_data.lib_deps_rgbled} build_flags = ${common_env_data.build_flags} -Dlopy @@ -99,8 +103,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 921600 lib_deps = - ${common_env_data.lib_deps_builtin} - SmartLeds + ${common_env_data.lib_deps_rgbled} build_flags = ${common_env_data.build_flags} -Dlopy4 @@ -113,8 +116,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 256000 lib_deps = - ${common_env_data.lib_deps_builtin} - SmartLeds + ${common_env_data.lib_deps_rgbled} build_flags = ${common_env_data.build_flags} -Dlolin32lite_lora @@ -127,8 +129,7 @@ framework = arduino monitor_baud = 115200 upload_speed = 921600 lib_deps = - ${common_env_data.lib_deps_builtin} - SmartLeds + ${common_env_data.lib_deps_rgbled} build_flags = ${common_env_data.build_flags} -Dlolin32_lora diff --git a/src/globals.h b/src/globals.h index 06a3de38..72598669 100644 --- a/src/globals.h +++ b/src/globals.h @@ -6,8 +6,10 @@ #include #include -// OLED Display -#include +#ifdef HAS_DISPLAY + // OLED Display + #include +#endif // LMIC-Arduino LoRaWAN Stack #include @@ -52,8 +54,6 @@ extern std::set macs; #ifdef HAS_DISPLAY extern HAS_DISPLAY u8x8; -#else - extern U8X8_NULL u8x8; #endif #ifdef BLECOUNTER diff --git a/src/main.cpp b/src/main.cpp index 56249126..31ac22aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,9 +27,8 @@ Refer to LICENSE.txt file in repository for more details. // std::set for unified array functions #include -// OLED driver -#include -#include // Does nothing and avoid any compilation error with I2C +// Does nothing and avoid any compilation error with I2C +#include // LMIC-Arduino LoRaWAN Stack #include "loraconf.h" @@ -207,8 +206,6 @@ void lorawan_loop(void * pvParameters) { #ifdef HAS_DISPLAY HAS_DISPLAY u8x8(OLED_RST, OLED_SCL, OLED_SDA); -#else - U8X8_NULL u8x8; #endif #ifdef HAS_ANTENNA_SWITCH @@ -332,6 +329,7 @@ uint64_t uptime() { return (uint64_t) high32 << 32 | low32; } +#ifdef HAS_DISPLAY // Print a key on display void DisplayKey(const uint8_t * key, uint8_t len, bool lsb) { uint8_t start=lsb?len:0; @@ -345,10 +343,9 @@ void DisplayKey(const uint8_t * key, uint8_t len, bool lsb) { } void init_display(const char *Productname, const char *Version) { + uint8_t buf[32]; u8x8.begin(); u8x8.setFont(u8x8_font_chroma48medium8_r); -#ifdef HAS_DISPLAY - uint8_t buf[32]; u8x8.clear(); u8x8.setFlipMode(0); u8x8.setInverseFont(1); @@ -392,8 +389,8 @@ void init_display(const char *Productname, const char *Version) { DisplayKey(buf, 8, true); delay(5000); u8x8.clear(); -#endif // HAS_DISPLAY } +#endif // HAS_DISPLAY /* begin Aruino SETUP ------------------------------------------------------------ */ @@ -461,6 +458,7 @@ void setup() { antenna_init(); #endif +#ifdef HAS_DISPLAY // initialize display init_display(PROGNAME, PROGVERSION); u8x8.setPowerSave(!cfg.screenon); // set display off if disabled @@ -474,6 +472,7 @@ void setup() { u8x8.setCursor(0,5); u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %d", cfg.rssilimit); sprintf(display_lora, "Join wait"); +#endif // output LoRaWAN keys to console #ifdef VERBOSE From 84cc1c937ad510be5d8fa5a9335250516add6123 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Mon, 16 Apr 2018 21:16:24 +0200 Subject: [PATCH 2/3] cleanups --- platformio.ini | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9d54a245..5e9d4d94 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,6 +8,7 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/page/projectconf.html + ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] env_default = heltec_wifi_lora_32 @@ -20,8 +21,12 @@ env_default = heltec_wifi_lora_32 ; description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. -;----------- common part ----------- [common_env_data] +monitor_baud = 115200 +lib_deps_display = + U8g2@>=2.22.14 +lib_deps_rgbled = + SmartLeds build_flags = ; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework ; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <--- @@ -35,20 +40,11 @@ build_flags = ; override lora settings from LMiC library in lmic/config.h and use main.h instead -D_lmic_config_h_ -include "src/main.h" -; -lib_deps_display = - U8g2@>=2.22.14 -lib_deps_rgbled = - SmartLeds -; -; -;----------- hardware specific part ----------- [env:heltec_wifi_lora_32] platform = espressif32 -board = heltec_wifi_lora_32 framework = arduino -monitor_baud = 115200 +board = heltec_wifi_lora_32 upload_speed = 115200 lib_deps = ${common_env_data.lib_deps_display} @@ -59,9 +55,8 @@ build_flags = [env:ttgov1] platform = espressif32 -board = esp32dev framework = arduino -monitor_baud = 115200 +board = esp32dev upload_speed = 115200 lib_deps = ${common_env_data.lib_deps_display} @@ -72,9 +67,8 @@ build_flags = [env:ttgov2] platform = espressif32 -board = esp32dev framework = arduino -monitor_baud = 115200 +board = esp32dev upload_speed = 921600 lib_deps = ${common_env_data.lib_deps_display} @@ -85,9 +79,8 @@ build_flags = [env:lopy] platform = espressif32 -board = esp32dev framework = arduino -monitor_baud = 115200 +board = esp32dev upload_speed = 921600 lib_deps = ${common_env_data.lib_deps_rgbled} @@ -98,9 +91,8 @@ build_flags = [env:lopy4] platform = espressif32 -board = esp32dev framework = arduino -monitor_baud = 115200 +board = esp32dev upload_speed = 921600 lib_deps = ${common_env_data.lib_deps_rgbled} @@ -111,9 +103,8 @@ build_flags = [env:lolin32lite_lora] platform = espressif32 -board = lolin32 framework = arduino -monitor_baud = 115200 +board = lolin32 upload_speed = 256000 lib_deps = ${common_env_data.lib_deps_rgbled} @@ -124,9 +115,8 @@ build_flags = [env:lolin32_lora] platform = espressif32 +framework = arduino board = lolin32 -framework = arduino -monitor_baud = 115200 upload_speed = 921600 lib_deps = ${common_env_data.lib_deps_rgbled} From b973de716bd9ecf12f1b4464c26e5b0b1f5dd2ca Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Mon, 16 Apr 2018 21:27:11 +0200 Subject: [PATCH 3/3] cleanups --- README.md | 4 ++-- platformio.ini | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bf03b766..3c6c35f7 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ If your device has silicon **Unique ID** which is stored in serial EEPROM Microc To upload the code to your ESP32 board this needs to be switched from run to bootloader mode. Boards with USB bridge like Heltec and TTGO usually have an onboard logic which allows soft switching by the upload tool. In PlatformIO this happenes automatically.

The LoPy/LoPy4 board needs to be set manually. See these -instructions how to do it.

-For the LoPy/LoPy4 the original Pycom firmware is not needed here, so there is no need to update it before flashing Paxcounter. Just flash the paxcounter code on your LoPy/LoPy4. If you want to go back to the Pycom firmware, no problem. Download the firmware from Pycom and flash it over. +instructions how to do it. Don't forget to press on board reset button after switching between run and bootloader mode.

+The original Pycom firmware is not needed, so there is no need to update it before flashing Paxcounter. Just flash the compiled paxcounter binary (.elf file) on your LoPy/LoPy4. If you later want to go back to the Pycom firmware, download the firmware from Pycom and flash it over. # Legal note diff --git a/platformio.ini b/platformio.ini index 5e9d4d94..c92a9060 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,10 +11,10 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -env_default = heltec_wifi_lora_32 +;env_default = heltec_wifi_lora_32 ;env_default = ttgov1 ;env_default = ttgov2 -;env_default = lopy +env_default = lopy ;env_default = lopy4 ;env_default = lolin32lite_lora ;env_default = lolin32_lora