diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 34ba60e5..0f540878 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -202,8 +202,8 @@ public: display.print(tmp); } else if (_page == HomePage::BLUETOOTH) { display.setColor(DisplayDriver::GREEN); - display.drawXbm((display.width() - 32) / 2, 18, - _task->isSerialEnabled() ? bluetooth_on : bluetooth_off, + display.drawXbm((display.width() - 32) / 2, 18, + _task->isSerialEnabled() ? bluetooth_on : bluetooth_off, 32, 32); display.setTextSize(1); display.drawTextCentered(display.width() / 2, 64 - 11, "toggle: " PRESS_LABEL); @@ -455,8 +455,8 @@ void UITask::setCurrScreen(UIScreen* c) { _next_refresh = 100; } -/* - hardware-agnostic pre-shutdown activity should be done here +/* + hardware-agnostic pre-shutdown activity should be done here */ void UITask::shutdown(bool restart){ @@ -584,7 +584,7 @@ void UITask::loop() { // show low battery shutdown alert // we should only do this for eink displays, which will persist after power loss - #ifdef THINKNODE_M1 + #if defined(THINKNODE_M1) || defined(LILYGO_TECHO) if (_display != NULL) { _display->startFrame(); _display->setTextSize(2); diff --git a/variants/t1000-e/NullDisplayDriver.h b/src/helpers/ui/NullDisplayDriver.h similarity index 100% rename from variants/t1000-e/NullDisplayDriver.h rename to src/helpers/ui/NullDisplayDriver.h diff --git a/variants/generic-e22/target.cpp b/variants/generic-e22/target.cpp index d9b70c3a..e0253779 100644 --- a/variants/generic-e22/target.cpp +++ b/variants/generic-e22/target.cpp @@ -16,47 +16,15 @@ ESP32RTCClock fallback_clock; AutoDiscoverRTCClock rtc_clock(fallback_clock); SensorManager sensors; -#ifndef LORA_CR - #define LORA_CR 5 -#endif - bool radio_init() { fallback_clock.begin(); rtc_clock.begin(Wire); - -#ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; -#else - float tcxo = 1.6f; -#endif -#if defined(P_LORA_SCLK) - spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); -#endif - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); - if (status != RADIOLIB_ERR_NONE) { - Serial.print("ERROR: radio init failed: "); - Serial.println(status); - return false; // fail - } - - radio.setCRC(1); - -#if defined(SX126X_RXEN) && defined(SX126X_TXEN) - radio.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN); -#endif - -#ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); -#endif -#ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); -#endif -#ifdef SX126X_RX_BOOSTED_GAIN - radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN); -#endif - - return true; // success + #if defined(P_LORA_SCLK) + return radio.std_init(&spi); + #else + return radio.std_init(); + #endif } uint32_t radio_get_rng_seed() { diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index f545d898..2e7ac80c 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -106,7 +106,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=160 + -D MAX_CONTACTS=300 -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SSD1306Display -D BLE_PIN_CODE=123456 ; dynamic, random PIN diff --git a/src/helpers/nrf52/TechoBoard.cpp b/variants/lilygo_techo/TechoBoard.cpp similarity index 100% rename from src/helpers/nrf52/TechoBoard.cpp rename to variants/lilygo_techo/TechoBoard.cpp diff --git a/src/helpers/nrf52/TechoBoard.h b/variants/lilygo_techo/TechoBoard.h similarity index 78% rename from src/helpers/nrf52/TechoBoard.h rename to variants/lilygo_techo/TechoBoard.h index 2c05c4ed..4792153a 100644 --- a/src/helpers/nrf52/TechoBoard.h +++ b/variants/lilygo_techo/TechoBoard.h @@ -3,19 +3,6 @@ #include #include -// LoRa radio module pins for LilyGo T-Echo -#define P_LORA_DIO_1 20 -#define P_LORA_NSS 24 -#define P_LORA_RESET 25 -#define P_LORA_BUSY 17 -#define P_LORA_SCLK 19 -#define P_LORA_MISO 23 -#define P_LORA_MOSI 22 -#define SX126X_POWER_EN 37 - -#define SX126X_DIO2_AS_RF_SWITCH true -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 - // built-ins #define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 diff --git a/variants/techo/platformio.ini b/variants/lilygo_techo/platformio.ini similarity index 59% rename from variants/techo/platformio.ini rename to variants/lilygo_techo/platformio.ini index 812baa78..8a090a4d 100644 --- a/variants/techo/platformio.ini +++ b/variants/lilygo_techo/platformio.ini @@ -1,24 +1,26 @@ -[nrf52840_techo] +[LilyGo_T-Echo] extends = nrf52_base -platform_packages = framework-arduinoadafruitnrf52 +board = t-echo +board_build.ldscript = boards/nrf52840_s140_v6.ld build_flags = ${nrf52_base.build_flags} + -I variants/lilygo_techo -I src/helpers/nrf52 -I lib/nrf52/s140_nrf52_6.1.1_API/include -I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52 -lib_deps = - ${nrf52_base.lib_deps} - rweather/Crypto @ ^0.4.0 - -[LilyGo_Techo] -extends = nrf52840_techo -board = t-echo -board_build.ldscript = boards/nrf52840_s140_v6.ld -build_flags = ${nrf52840_techo.build_flags} - -I variants/techo - -DLILYGO_TECHO + -D LILYGO_TECHO -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 + -D P_LORA_DIO_1=20 + -D P_LORA_NSS=24 + -D P_LORA_RESET=25 + -D P_LORA_BUSY=17 + -D P_LORA_SCLK=19 + -D P_LORA_MISO=23 + -D P_LORA_MOSI=22 + -D SX126X_POWER_EN=37 + -D SX126X_DIO2_AS_RF_SWITCH=true + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D P_LORA_TX_LED=LED_GREEN @@ -28,23 +30,31 @@ build_flags = ${nrf52840_techo.build_flags} -D GPS_BAUD_RATE=9600 -D PIN_GPS_EN=GPS_EN -D TELEM_BME280_ADDRESS=0x77 -build_src_filter = ${nrf52840_techo.build_src_filter} + -D DISPLAY_CLASS=GxEPDDisplay + -D BACKLIGHT_BTN=PIN_BUTTON2 + -D AUTO_OFF_MILLIS=0 +build_src_filter = ${nrf52_base.build_src_filter} + - + + + + - +<../variants/techo> + + + + + +<../variants/lilygo_techo> lib_deps = - ${nrf52840_techo.lib_deps} + ${nrf52_base.lib_deps} stevemarple/MicroNMEA @ ^2.0.6 adafruit/Adafruit BME280 Library @ ^2.3.0 + zinggjm/GxEPD2 @ 1.6.2 + bakercp/CRC32 @ ^2.0.0 debug_tool = jlink upload_protocol = nrfutil [env:LilyGo_T-Echo_repeater] -extends = LilyGo_Techo -build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_repeater/main.cpp> +extends = LilyGo_T-Echo +build_src_filter = ${LilyGo_T-Echo.build_src_filter} + +<../examples/simple_repeater> build_flags = - ${LilyGo_Techo.build_flags} + ${LilyGo_T-Echo.build_flags} -D ADVERT_NAME='"T-Echo Repeater"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -54,10 +64,11 @@ build_flags = ; -D MESH_DEBUG=1 [env:LilyGo_T-Echo_room_server] -extends = LilyGo_Techo -build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_room_server/main.cpp> +extends = LilyGo_T-Echo +build_src_filter = ${LilyGo_T-Echo.build_src_filter} + +<../examples/simple_room_server> build_flags = - ${LilyGo_Techo.build_flags} + ${LilyGo_T-Echo.build_flags} -D ADVERT_NAME='"T-Echo Room"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -66,31 +77,41 @@ build_flags = ; -D MESH_DEBUG=1 [env:LilyGo_T-Echo_companion_radio_ble] -extends = LilyGo_Techo +extends = LilyGo_T-Echo build_flags = - ${LilyGo_Techo.build_flags} + ${LilyGo_T-Echo.build_flags} -I src/helpers/ui -I examples/companion_radio/ui-new -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 ; -D BLE_DEBUG_LOGGING=1 - -D DISPLAY_CLASS=GxEPDDisplay -D OFFLINE_QUEUE_SIZE=256 - -D UI_RECENT_LIST_SIZE=9 - -D BACKLIGHT_BTN=PIN_BUTTON2 - -D AUTO_OFF_MILLIS=0 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_Techo.build_src_filter} - + + -D AUTO_SHUTDOWN_MILLIVOLTS=3300 +build_src_filter = ${LilyGo_T-Echo.build_src_filter} + - + - + +<../examples/companion_radio/*.cpp> +<../examples/companion_radio/ui-new/*.cpp> lib_deps = - ${LilyGo_Techo.lib_deps} + ${LilyGo_T-Echo.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T-Echo_companion_radio_usb] +extends = LilyGo_T-Echo +build_flags = + ${LilyGo_T-Echo.build_flags} + -I src/helpers/ui + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 + -D OFFLINE_QUEUE_SIZE=256 + -D UI_RECENT_LIST_SIZE=9 + -D AUTO_SHUTDOWN_MILLIVOLTS=3300 +build_src_filter = ${LilyGo_T-Echo.build_src_filter} + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${LilyGo_T-Echo.lib_deps} densaugeo/base64 @ ~1.4.0 - zinggjm/GxEPD2 @ 1.6.2 - bakercp/CRC32 @ ^2.0.0 diff --git a/variants/techo/target.cpp b/variants/lilygo_techo/target.cpp similarity index 100% rename from variants/techo/target.cpp rename to variants/lilygo_techo/target.cpp diff --git a/variants/techo/target.h b/variants/lilygo_techo/target.h similarity index 95% rename from variants/techo/target.h rename to variants/lilygo_techo/target.h index 134f13b5..2b6ed45f 100644 --- a/variants/techo/target.h +++ b/variants/lilygo_techo/target.h @@ -3,7 +3,7 @@ #define RADIOLIB_STATIC_ONLY 1 #include #include -#include +#include #include #include #include diff --git a/variants/techo/variant.cpp b/variants/lilygo_techo/variant.cpp similarity index 100% rename from variants/techo/variant.cpp rename to variants/lilygo_techo/variant.cpp diff --git a/variants/techo/variant.h b/variants/lilygo_techo/variant.h similarity index 100% rename from variants/techo/variant.h rename to variants/lilygo_techo/variant.h diff --git a/variants/lilygo_tlora_c6/target.cpp b/variants/lilygo_tlora_c6/target.cpp index 1e60dc32..e12c58b5 100644 --- a/variants/lilygo_tlora_c6/target.cpp +++ b/variants/lilygo_tlora_c6/target.cpp @@ -16,49 +16,15 @@ ESP32RTCClock fallback_clock; AutoDiscoverRTCClock rtc_clock(fallback_clock); SensorManager sensors; -#ifndef LORA_CR - #define LORA_CR 5 -#endif - bool radio_init() { fallback_clock.begin(); rtc_clock.begin(Wire); -#ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; -#else - float tcxo = 1.6f; -#endif - #if defined(P_LORA_SCLK) - spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); + return radio.std_init(&spi); +#else + return radio.std_init(); #endif - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); - if (status != RADIOLIB_ERR_NONE) { - Serial.print("ERROR: radio init failed: "); - Serial.println(status); - return false; // fail - } - - radio.setCRC(1); - -#if defined(SX126X_RXEN) && defined(SX126X_TXEN) - radio.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN); -#endif - -#ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); -#endif - -#ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); -#endif - -#ifdef SX126X_RX_BOOSTED_GAIN - radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN); -#endif - - return true; // success } uint32_t radio_get_rng_seed() { diff --git a/src/helpers/rp2040/PicoWBoard.cpp b/variants/rpi_picow/PicoWBoard.cpp similarity index 100% rename from src/helpers/rp2040/PicoWBoard.cpp rename to variants/rpi_picow/PicoWBoard.cpp diff --git a/src/helpers/rp2040/PicoWBoard.h b/variants/rpi_picow/PicoWBoard.h similarity index 75% rename from src/helpers/rp2040/PicoWBoard.h rename to variants/rpi_picow/PicoWBoard.h index cdc9c9f7..708e9655 100644 --- a/src/helpers/rp2040/PicoWBoard.h +++ b/variants/rpi_picow/PicoWBoard.h @@ -3,19 +3,6 @@ #include #include -// LoRa radio module pins for PicoW -#define P_LORA_DIO_1 20 -#define P_LORA_NSS 3 -#define P_LORA_RESET 15 -#define P_LORA_BUSY 2 -#define P_LORA_SCLK 10 -#define P_LORA_MISO 12 -#define P_LORA_MOSI 11 -//#define SX126X_POWER_EN ??? // Not Sure - -#define SX126X_DIO2_AS_RF_SWITCH true -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 - // built-ins #define PIN_VBAT_READ 26 #define ADC_MULTIPLIER (3.1 * 3.3 * 1000) // MT Uses 3.1 diff --git a/variants/picow/platformio.ini b/variants/rpi_picow/platformio.ini similarity index 64% rename from variants/picow/platformio.ini rename to variants/rpi_picow/platformio.ini index 7b75c224..adec5d77 100644 --- a/variants/picow/platformio.ini +++ b/variants/rpi_picow/platformio.ini @@ -1,26 +1,35 @@ -[picow] +[rpi_picow] extends = rp2040_base platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = rpipicow board_build.core = earlephilhower board_build.filesystem_size = 0.5m build_flags = ${rp2040_base.build_flags} - -I variants/picow + -I variants/rpi_picow ; -D PICOW ; -D HW_SPI1_DEVICE + -D P_LORA_DIO_1=20 + -D P_LORA_NSS=3 + -D P_LORA_RESET=15 + -D P_LORA_BUSY=2 + -D P_LORA_SCLK=10 + -D P_LORA_MISO=12 + -D P_LORA_MOSI=11 + -D SX126X_DIO2_AS_RF_SWITCH=true + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130 + -D SX126X_RX_BOOSTED_GAIN=1 + -D LORA_TX_POWER=22 -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper - -D LORA_TX_POWER=22 - -D SX126X_RX_BOOSTED_GAIN=1 build_src_filter = ${rp2040_base.build_src_filter} - + - +<../variants/picow> + + + +<../variants/rpi_picow> lib_deps = ${rp2040_base.lib_deps} [env:PicoW_Repeater] -extends = picow -build_flags = ${picow.build_flags} +extends = rpi_picow +build_flags = ${rpi_picow.build_flags} -D ADVERT_NAME='"PicoW Repeater"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -28,12 +37,12 @@ build_flags = ${picow.build_flags} -D MAX_NEIGHBOURS=8 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${picow.build_src_filter} +build_src_filter = ${rpi_picow.build_src_filter} +<../examples/simple_repeater> [env:PicoW_room_server] -extends = picow -build_flags = ${picow.build_flags} +extends = rpi_picow +build_flags = ${rpi_picow.build_flags} -D ADVERT_NAME='"Test Room"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -41,38 +50,38 @@ build_flags = ${picow.build_flags} -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${picow.build_src_filter} +build_src_filter = ${rpi_picow.build_src_filter} +<../examples/simple_room_server> [env:PicoW_companion_radio_usb] -extends = picow -build_flags = ${picow.build_flags} +extends = rpi_picow +build_flags = ${rpi_picow.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=8 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${picow.build_src_filter} +build_src_filter = ${rpi_picow.build_src_filter} +<../examples/companion_radio/*.cpp> -lib_deps = ${picow.lib_deps} +lib_deps = ${rpi_picow.lib_deps} densaugeo/base64 @ ~1.4.0 ; [env:PicoW_companion_radio_ble] -; extends = picow -; build_flags = ${picow.build_flags} +; extends = rpi_picow +; build_flags = ${rpi_picow.build_flags} ; -D MAX_CONTACTS=100 ; -D MAX_GROUP_CHANNELS=8 ; -D BLE_PIN_CODE=123456 ; -D BLE_DEBUG_LOGGING=1 ; ; -D MESH_PACKET_LOGGING=1 ; ; -D MESH_DEBUG=1 -; build_src_filter = ${picow.build_src_filter} +; build_src_filter = ${rpi_picow.build_src_filter} ; +<../examples/companion_radio/*.cpp> -; lib_deps = ${picow.lib_deps} +; lib_deps = ${rpi_picow.lib_deps} ; densaugeo/base64 @ ~1.4.0 ; [env:PicoW_companion_radio_wifi] -; extends = picow -; build_flags = ${picow.build_flags} +; extends = rpi_picow +; build_flags = ${rpi_picow.build_flags} ; -D MAX_CONTACTS=100 ; -D MAX_GROUP_CHANNELS=8 ; -D WIFI_DEBUG_LOGGING=1 @@ -80,19 +89,19 @@ lib_deps = ${picow.lib_deps} ; -D WIFI_PWD='"mypwd"' ; ; -D MESH_PACKET_LOGGING=1 ; ; -D MESH_DEBUG=1 -; build_src_filter = ${picow.build_src_filter} +; build_src_filter = ${rpi_picow.build_src_filter} ; +<../examples/companion_radio/*.cpp> -; lib_deps = ${picow.lib_deps} +; lib_deps = ${rpi_picow.lib_deps} ; densaugeo/base64 @ ~1.4.0 [env:PicoW_terminal_chat] -extends = picow -build_flags = ${picow.build_flags} +extends = rpi_picow +build_flags = ${rpi_picow.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${picow.build_src_filter} +build_src_filter = ${rpi_picow.build_src_filter} +<../examples/simple_secure_chat/main.cpp> -lib_deps = ${picow.lib_deps} +lib_deps = ${rpi_picow.lib_deps} densaugeo/base64 @ ~1.4.0 diff --git a/variants/picow/target.cpp b/variants/rpi_picow/target.cpp similarity index 100% rename from variants/picow/target.cpp rename to variants/rpi_picow/target.cpp diff --git a/variants/picow/target.h b/variants/rpi_picow/target.h similarity index 93% rename from variants/picow/target.h rename to variants/rpi_picow/target.h index 7b1e7437..17dbb35f 100644 --- a/variants/picow/target.h +++ b/variants/rpi_picow/target.h @@ -3,7 +3,7 @@ #define RADIOLIB_STATIC_ONLY 1 #include #include -#include +#include #include #include #include diff --git a/variants/t1000-e/T1000eBoard.h b/variants/t1000-e/T1000eBoard.h index f87d71e0..090c1b90 100644 --- a/variants/t1000-e/T1000eBoard.h +++ b/variants/t1000-e/T1000eBoard.h @@ -3,22 +3,6 @@ #include #include -// LoRa and SPI pins -#define P_LORA_DIO_1 (32 + 1) // P1.1 -#define P_LORA_NSS (0 + 12) // P0.12 -#define P_LORA_RESET (32 + 10) // P1.10 -#define P_LORA_BUSY (0 + 7) // P0.7 -#define P_LORA_SCLK (0 + 11) // P0.11 -#define P_LORA_MISO (32 + 8) // P1.8 -#define P_LORA_MOSI (32 + 9) // P0.9 - -#define LR11X0_DIO_AS_RF_SWITCH true -#define LR11X0_DIO3_TCXO_VOLTAGE 1.6 - -// built-ins -//#define PIN_VBAT_READ 5 -//#define ADC_MULTIPLIER (3 * 1.73 * 1000) - class T1000eBoard : public mesh::MainBoard { protected: uint8_t startup_reason; @@ -75,11 +59,11 @@ public: pinMode(GPS_RESETB, OUTPUT); digitalWrite(GPS_RESETB, LOW); #endif - + #ifdef BUZZER_EN digitalWrite(BUZZER_EN, LOW); #endif - + #ifdef PIN_3V3_EN digitalWrite(PIN_3V3_EN, LOW); #endif diff --git a/variants/t1000-e/platformio.ini b/variants/t1000-e/platformio.ini index b1826139..044fffd8 100644 --- a/variants/t1000-e/platformio.ini +++ b/variants/t1000-e/platformio.ini @@ -1,25 +1,13 @@ -; ----------------- NRF52 T1000e--------------------- -[nrf52840_t1000e] +[t1000-e] extends = nrf52_base -platform_packages = framework-arduinoadafruitnrf52 +board = tracker-t1000-e +board_build.ldscript = boards/nrf52840_s140_v7.ld build_flags = ${nrf52_base.build_flags} -I src/helpers/nrf52 -I lib/nrf52/s140_nrf52_7.3.0_API/include -I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52 -lib_ignore = - BluetoothOTA - lvgl - lib5b4 -lib_deps = - ${nrf52_base.lib_deps} - rweather/Crypto @ ^0.4.0 - -[t1000-e] -extends = nrf52840_t1000e -board = tracker-t1000-e -board_build.ldscript = boards/nrf52840_s140_v7.ld -build_flags = ${nrf52840_t1000e.build_flags} -I variants/t1000-e + -I src/helpers/ui -D T1000_E -D PIN_USER_BTN=6 -D USER_BTN_PRESSED=HIGH @@ -27,7 +15,18 @@ build_flags = ${nrf52840_t1000e.build_flags} -D RADIO_CLASS=CustomLR1110 -D WRAPPER_CLASS=CustomLR1110Wrapper -D LORA_TX_POWER=22 -build_src_filter = ${nrf52840_t1000e.build_src_filter} + -D RF_SWITCH_TABLE + -D RX_BOOSTED_GAIN=true + -D P_LORA_BUSY=7 ; P0.7 + -D P_LORA_SCLK=11 ; P0.11 + -D P_LORA_NSS=12 ; P0.12 + -D P_LORA_DIO_1=33 ; P1.1 + -D P_LORA_MISO=40 ; P1.8 + -D P_LORA_MOSI=41 ; P0.9 + -D P_LORA_RESET=42 ; P1.10 + -D LR11X0_DIO_AS_RF_SWITCH=true + -D LR11X0_DIO3_TCXO_VOLTAGE=1.6 +build_src_filter = ${nrf52_base.build_src_filter} + + +<../variants/t1000-e> @@ -45,8 +44,6 @@ build_flags = ${t1000-e.build_flags} -D MAX_NEIGHBOURS=8 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 - -D RX_BOOSTED_GAIN=true - -D RF_SWITCH_TABLE build_src_filter = ${t1000-e.build_src_filter} +<../examples/simple_repeater> lib_deps = ${t1000-e.lib_deps} @@ -63,7 +60,6 @@ build_flags = ${t1000-e.build_flags} -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 - -D RX_BOOSTED_GAIN=true -D RF_SWITCH_TABLE build_src_filter = ${t1000-e.build_src_filter} +<../examples/simple_room_server> @@ -79,8 +75,6 @@ build_flags = ${t1000-e.build_flags} ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -D OFFLINE_QUEUE_SIZE=256 - -D RX_BOOSTED_GAIN=true - -D RF_SWITCH_TABLE -D DISPLAY_CLASS=NullDisplayDriver -D PIN_BUZZER=25 -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E @@ -104,8 +98,6 @@ build_flags = ${t1000-e.build_flags} ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -D OFFLINE_QUEUE_SIZE=256 - -D RX_BOOSTED_GAIN=true - -D RF_SWITCH_TABLE -D DISPLAY_CLASS=NullDisplayDriver -D PIN_BUZZER=25 -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E diff --git a/variants/t1000-e/t1000e_sensors.cpp b/variants/t1000-e/t1000e_sensors.cpp index 17693022..a5b443cf 100644 --- a/variants/t1000-e/t1000e_sensors.cpp +++ b/variants/t1000-e/t1000e_sensors.cpp @@ -1,119 +1,99 @@ -#include #include "t1000e_sensors.h" -#define HEATER_NTC_BX 4250 // thermistor coefficient B -#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor -#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin -#define NTC_REF_VCC 3000 // mV, output voltage of LDO -#define LIGHT_REF_VCC 2400 // - -static unsigned int ntc_res2[136]={ - 113347,107565,102116,96978,92132,87559,83242,79166,75316,71677, - 68237,64991,61919,59011,56258,53650,51178,48835,46613,44506, - 42506,40600,38791,37073,35442,33892,32420,31020,29689,28423, - 27219,26076,24988,23951,22963,22021,21123,20267,19450,18670, - 17926,17214,16534,15886,15266,14674,14108,13566,13049,12554, - 12081,11628,11195,10780,10382,10000,9634,9284,8947,8624, - 8315,8018,7734,7461,7199,6948,6707,6475,6253,6039, - 5834,5636,5445,5262,5086,4917,4754,4597,4446,4301, - 4161,4026,3896,3771,3651,3535,3423,3315,3211,3111, - 3014,2922,2834,2748,2666,2586,2509,2435,2364,2294, - 2228,2163,2100,2040,1981,1925,1870,1817,1766,1716, - 1669,1622,1578,1535,1493,1452,1413,1375,1338,1303, - 1268,1234,1202,1170,1139,1110,1081,1053,1026,999, - 974,949,925,902,880,858, -}; - -static char ntc_temp2[136]= -{ - -30,-29,-28,-27,-26,-25,-24,-23,-22,-21, - -20,-19,-18,-17,-16,-15,-14,-13,-12,-11, - -10,-9,-8,-7,-6,-5,-4,-3,-2,-1, - 0,1,2,3,4,5,6,7,8,9, - 10,11,12,13,14,15,16,17,18,19, - 20,21,22,23,24,25,26,27,28,29, - 30,31,32,33,34,35,36,37,38,39, - 40,41,42,43,44,45,46,47,48,49, - 50,51,52,53,54,55,56,57,58,59, - 60,61,62,63,64,65,66,67,68,69, - 70,71,72,73,74,75,76,77,78,79, - 80,81,82,83,84,85,86,87,88,89, - 90,91,92,93,94,95,96,97,98,99, - 100,101,102,103,104,105, +#include + +#define HEATER_NTC_BX 4250 // thermistor coefficient B +#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor +#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin +#define NTC_REF_VCC 3000 // mV, output voltage of LDO +#define LIGHT_REF_VCC 2400 // + +static unsigned int ntc_res2[136] = { + 113347, 107565, 102116, 96978, 92132, 87559, 83242, 79166, 75316, 71677, 68237, 64991, 61919, 59011, + 56258, 53650, 51178, 48835, 46613, 44506, 42506, 40600, 38791, 37073, 35442, 33892, 32420, 31020, + 29689, 28423, 27219, 26076, 24988, 23951, 22963, 22021, 21123, 20267, 19450, 18670, 17926, 17214, + 16534, 15886, 15266, 14674, 14108, 13566, 13049, 12554, 12081, 11628, 11195, 10780, 10382, 10000, + 9634, 9284, 8947, 8624, 8315, 8018, 7734, 7461, 7199, 6948, 6707, 6475, 6253, 6039, + 5834, 5636, 5445, 5262, 5086, 4917, 4754, 4597, 4446, 4301, 4161, 4026, 3896, 3771, + 3651, 3535, 3423, 3315, 3211, 3111, 3014, 2922, 2834, 2748, 2666, 2586, 2509, 2435, + 2364, 2294, 2228, 2163, 2100, 2040, 1981, 1925, 1870, 1817, 1766, 1716, 1669, 1622, + 1578, 1535, 1493, 1452, 1413, 1375, 1338, 1303, 1268, 1234, 1202, 1170, 1139, 1110, + 1081, 1053, 1026, 999, 974, 949, 925, 902, 880, 858, }; -static float get_heater_temperature( unsigned int vcc_volt, unsigned int ntc_volt ) -{ - int i = 0; - float Vout = 0, Rt = 0, temp = 0; - Vout = ntc_volt; - - Rt = ( HEATER_NTC_RP * vcc_volt ) / Vout - HEATER_NTC_RP; - - for( i = 0; i < 136; i++ ) - { - if( Rt >= ntc_res2[i] ) - { - break; - } +static char ntc_temp2[136] = { + -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, + -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, +}; + +static float get_heater_temperature(unsigned int vcc_volt, unsigned int ntc_volt) { + int i = 0; + float Vout = 0, Rt = 0, temp = 0; + Vout = ntc_volt; + + Rt = (HEATER_NTC_RP * vcc_volt) / Vout - HEATER_NTC_RP; + + for (i = 0; i < 136; i++) { + if (Rt >= ntc_res2[i]) { + break; } - - temp = ntc_temp2[i - 1] + 1 * ( ntc_res2[i - 1] - Rt ) / ( float )( ntc_res2[i - 1] - ntc_res2[i] ); - - temp = ( temp * 100 + 5 ) / 100; - return temp; + } + + temp = ntc_temp2[i - 1] + 1 * (ntc_res2[i - 1] - Rt) / (float)(ntc_res2[i - 1] - ntc_res2[i]); + + temp = (temp * 100 + 5) / 100; + return temp; } -static int get_light_lv( unsigned int light_volt ) -{ - float Vout = 0, Vin = 0, Rt = 0, temp = 0; - unsigned int light_level = 0; - - if( light_volt <= 80 ) - { - light_level = 0; - return light_level; - } - else if( light_volt >= 2480 ) - { - light_level = 100; - return light_level; - } - Vout = light_volt; - light_level = 100 * ( Vout - 80 ) / LIGHT_REF_VCC; - +static int get_light_lv(unsigned int light_volt) { + float Vout = 0, Vin = 0, Rt = 0, temp = 0; + unsigned int light_level = 0; + + if (light_volt <= 80) { + light_level = 0; return light_level; -} + } else if (light_volt >= 2480) { + light_level = 100; + return light_level; + } + Vout = light_volt; + light_level = 100 * (Vout - 80) / LIGHT_REF_VCC; -float t1000e_get_temperature( void ) -{ - unsigned int ntc_v, vcc_v; - - digitalWrite(PIN_3V3_EN, HIGH); - digitalWrite(SENSOR_EN, HIGH); - analogReference(AR_INTERNAL_3_0); - analogReadResolution(12); - delay(10); - vcc_v = (1000.0*(analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096; - ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096; - digitalWrite(PIN_3V3_EN, LOW); - digitalWrite(SENSOR_EN, LOW); - - return get_heater_temperature (vcc_v, ntc_v); + return light_level; } -uint32_t t1000e_get_light( void ) -{ - int lux = 0; - unsigned int lux_v = 0; - - digitalWrite(SENSOR_EN, HIGH); - analogReference(AR_INTERNAL_3_0); - analogReadResolution(12); - delay(10); - lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096; - lux = get_light_lv( lux_v ); - digitalWrite(SENSOR_EN, LOW); - - return lux; +float t1000e_get_temperature(void) { + unsigned int ntc_v, vcc_v; + + digitalWrite(PIN_3V3_EN, HIGH); + digitalWrite(SENSOR_EN, HIGH); + analogReference(AR_INTERNAL_3_0); + analogReadResolution(12); + delay(10); + vcc_v = (1000.0 * (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096; + ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096; + digitalWrite(PIN_3V3_EN, LOW); + digitalWrite(SENSOR_EN, LOW); + + return get_heater_temperature(vcc_v, ntc_v); +} + +uint32_t t1000e_get_light(void) { + int lux = 0; + unsigned int lux_v = 0; + + digitalWrite(SENSOR_EN, HIGH); + analogReference(AR_INTERNAL_3_0); + analogReadResolution(12); + delay(10); + lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096; + lux = get_light_lv(lux_v); + digitalWrite(SENSOR_EN, LOW); + + return lux; } \ No newline at end of file diff --git a/variants/t1000-e/t1000e_sensors.h b/variants/t1000-e/t1000e_sensors.h index 8f3967ca..e8f790b6 100644 --- a/variants/t1000-e/t1000e_sensors.h +++ b/variants/t1000-e/t1000e_sensors.h @@ -1,7 +1,8 @@ #pragma once +#include // Light and temperature sensors are on ADC ports -// functions adapted from Seeed examples to get values +// functions adapted from Seeed examples to get values // see : https://github.com/Seeed-Studio/Seeed-Tracker-T1000-E-for-LoRaWAN-dev-board extern uint32_t t1000e_get_light(); diff --git a/variants/wio-tracker-l1/platformio.ini b/variants/wio-tracker-l1/platformio.ini index ddf7cf47..be0086c4 100644 --- a/variants/wio-tracker-l1/platformio.ini +++ b/variants/wio-tracker-l1/platformio.ini @@ -60,6 +60,8 @@ build_flags = ${WioTrackerL1.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SH1106Display + -D OFFLINE_QUEUE_SIZE=256 + -D PIN_BUZZER=12 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${WioTrackerL1.build_src_filter} @@ -83,9 +85,9 @@ build_flags = ${WioTrackerL1.build_flags} -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 -D DISPLAY_CLASS=SH1106Display -; -D MESH_PACKET_LOGGING=1 - -D MESH_DEBUG=1 -D PIN_BUZZER=12 + ; -D MESH_PACKET_LOGGING=1 + ; -D MESH_DEBUG=1 build_src_filter = ${WioTrackerL1.build_src_filter} + +