cleanups
This commit is contained in:
parent
3c0af4d146
commit
e01d4c2100
@ -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.
|
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]
|
[common_env_data]
|
||||||
build_flags =
|
build_flags =
|
||||||
; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework
|
; 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! <---
|
; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <---
|
||||||
; otherwise device may crash in dense environments due to serial buffer overflow
|
; 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_INFO
|
||||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
|
||||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
; -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_
|
-D_lmic_config_h_
|
||||||
-include "src/main.h"
|
-include "src/main.h"
|
||||||
;
|
;
|
||||||
lib_deps_builtin =
|
lib_deps_display =
|
||||||
U8g2@2.22.10
|
U8g2@>=2.22.14
|
||||||
|
lib_deps_rgbled =
|
||||||
|
SmartLeds
|
||||||
|
;
|
||||||
|
;
|
||||||
|
;----------- hardware specific part -----------
|
||||||
|
|
||||||
[env:heltec_wifi_lora_32]
|
[env:heltec_wifi_lora_32]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@ -46,7 +51,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_display}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dheltec_wifi_lora_32
|
-Dheltec_wifi_lora_32
|
||||||
@ -59,7 +64,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_display}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dttgov1
|
-Dttgov1
|
||||||
@ -72,7 +77,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_display}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dttgov2
|
-Dttgov2
|
||||||
@ -85,8 +90,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_rgbled}
|
||||||
SmartLeds
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dlopy
|
-Dlopy
|
||||||
@ -99,8 +103,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_rgbled}
|
||||||
SmartLeds
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dlopy4
|
-Dlopy4
|
||||||
@ -113,8 +116,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 256000
|
upload_speed = 256000
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_rgbled}
|
||||||
SmartLeds
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dlolin32lite_lora
|
-Dlolin32lite_lora
|
||||||
@ -127,8 +129,7 @@ framework = arduino
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_builtin}
|
${common_env_data.lib_deps_rgbled}
|
||||||
SmartLeds
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-Dlolin32_lora
|
-Dlolin32_lora
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// OLED Display
|
#ifdef HAS_DISPLAY
|
||||||
#include <U8x8lib.h>
|
// OLED Display
|
||||||
|
#include <U8x8lib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// LMIC-Arduino LoRaWAN Stack
|
// LMIC-Arduino LoRaWAN Stack
|
||||||
#include <lmic.h>
|
#include <lmic.h>
|
||||||
@ -52,8 +54,6 @@ extern std::set<uint16_t> macs;
|
|||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
extern HAS_DISPLAY u8x8;
|
extern HAS_DISPLAY u8x8;
|
||||||
#else
|
|
||||||
extern U8X8_NULL u8x8;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
|
15
src/main.cpp
15
src/main.cpp
@ -27,9 +27,8 @@ Refer to LICENSE.txt file in repository for more details.
|
|||||||
// std::set for unified array functions
|
// std::set for unified array functions
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
// OLED driver
|
// Does nothing and avoid any compilation error with I2C
|
||||||
#include <U8x8lib.h>
|
#include <Wire.h>
|
||||||
#include <Wire.h> // Does nothing and avoid any compilation error with I2C
|
|
||||||
|
|
||||||
// LMIC-Arduino LoRaWAN Stack
|
// LMIC-Arduino LoRaWAN Stack
|
||||||
#include "loraconf.h"
|
#include "loraconf.h"
|
||||||
@ -207,8 +206,6 @@ void lorawan_loop(void * pvParameters) {
|
|||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
HAS_DISPLAY u8x8(OLED_RST, OLED_SCL, OLED_SDA);
|
HAS_DISPLAY u8x8(OLED_RST, OLED_SCL, OLED_SDA);
|
||||||
#else
|
|
||||||
U8X8_NULL u8x8;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_ANTENNA_SWITCH
|
#ifdef HAS_ANTENNA_SWITCH
|
||||||
@ -332,6 +329,7 @@ uint64_t uptime() {
|
|||||||
return (uint64_t) high32 << 32 | low32;
|
return (uint64_t) high32 << 32 | low32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DISPLAY
|
||||||
// Print a key on display
|
// Print a key on display
|
||||||
void DisplayKey(const uint8_t * key, uint8_t len, bool lsb) {
|
void DisplayKey(const uint8_t * key, uint8_t len, bool lsb) {
|
||||||
uint8_t start=lsb?len:0;
|
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) {
|
void init_display(const char *Productname, const char *Version) {
|
||||||
|
uint8_t buf[32];
|
||||||
u8x8.begin();
|
u8x8.begin();
|
||||||
u8x8.setFont(u8x8_font_chroma48medium8_r);
|
u8x8.setFont(u8x8_font_chroma48medium8_r);
|
||||||
#ifdef HAS_DISPLAY
|
|
||||||
uint8_t buf[32];
|
|
||||||
u8x8.clear();
|
u8x8.clear();
|
||||||
u8x8.setFlipMode(0);
|
u8x8.setFlipMode(0);
|
||||||
u8x8.setInverseFont(1);
|
u8x8.setInverseFont(1);
|
||||||
@ -392,8 +389,8 @@ void init_display(const char *Productname, const char *Version) {
|
|||||||
DisplayKey(buf, 8, true);
|
DisplayKey(buf, 8, true);
|
||||||
delay(5000);
|
delay(5000);
|
||||||
u8x8.clear();
|
u8x8.clear();
|
||||||
#endif // HAS_DISPLAY
|
|
||||||
}
|
}
|
||||||
|
#endif // HAS_DISPLAY
|
||||||
|
|
||||||
/* begin Aruino SETUP ------------------------------------------------------------ */
|
/* begin Aruino SETUP ------------------------------------------------------------ */
|
||||||
|
|
||||||
@ -461,6 +458,7 @@ void setup() {
|
|||||||
antenna_init();
|
antenna_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DISPLAY
|
||||||
// initialize display
|
// initialize display
|
||||||
init_display(PROGNAME, PROGVERSION);
|
init_display(PROGNAME, PROGVERSION);
|
||||||
u8x8.setPowerSave(!cfg.screenon); // set display off if disabled
|
u8x8.setPowerSave(!cfg.screenon); // set display off if disabled
|
||||||
@ -474,6 +472,7 @@ void setup() {
|
|||||||
u8x8.setCursor(0,5);
|
u8x8.setCursor(0,5);
|
||||||
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %d", cfg.rssilimit);
|
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %d", cfg.rssilimit);
|
||||||
sprintf(display_lora, "Join wait");
|
sprintf(display_lora, "Join wait");
|
||||||
|
#endif
|
||||||
|
|
||||||
// output LoRaWAN keys to console
|
// output LoRaWAN keys to console
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
Loading…
Reference in New Issue
Block a user