diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index d55d6118..c053b68b 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -29,6 +29,12 @@ void setup() { board.begin(); +#if defined(MESH_DEBUG) && defined(NRF52_PLATFORM) + // give some extra time for serial to settle so + // boot debug messages can be seen on terminal + delay(5000); +#endif + // For power saving lastActive = millis(); // mark last active time since boot @@ -42,6 +48,7 @@ void setup() { #endif if (!radio_init()) { + MESH_DEBUG_PRINTLN("Radio init failed!"); halt(); } diff --git a/variants/heltec_t114/platformio.ini b/variants/heltec_t114/platformio.ini index dd1f8bb3..b985030f 100644 --- a/variants/heltec_t114/platformio.ini +++ b/variants/heltec_t114/platformio.ini @@ -29,15 +29,13 @@ build_flags = ${nrf52_base.build_flags} -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 - -D DISPLAY_CLASS=NullDisplayDriver - -D ST7789 -D PIN_GPS_RX=39 -D PIN_GPS_TX=37 -D PIN_GPS_EN=21 -D PIN_GPS_RESET=38 -D PIN_GPS_RESET_ACTIVE=LOW - -D PIN_BOARD_SDA=16 - -D PIN_BOARD_SCL=13 + -D ENV_PIN_SDA=PIN_WIRE1_SDA + -D ENV_PIN_SCL=PIN_WIRE1_SCL build_src_filter = ${nrf52_base.build_src_filter} + + @@ -45,8 +43,6 @@ build_src_filter = ${nrf52_base.build_src_filter} lib_deps = ${nrf52_base.lib_deps} ${sensor_base.lib_deps} - stevemarple/MicroNMEA @ ^2.0.6 - adafruit/Adafruit GFX Library @ ^1.12.1 debug_tool = jlink upload_protocol = nrfutil @@ -105,6 +101,7 @@ board_upload.maximum_size = 712704 build_flags = ${Heltec_t114.build_flags} -I examples/companion_radio/ui-new + -D DISPLAY_CLASS=NullDisplayDriver -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 -D BLE_PIN_CODE=123456 @@ -127,6 +124,7 @@ board_upload.maximum_size = 712704 build_flags = ${Heltec_t114.build_flags} -I examples/companion_radio/ui-new + -D DISPLAY_CLASS=NullDisplayDriver -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 ; -D BLE_PIN_CODE=123456 @@ -149,6 +147,7 @@ extends = Heltec_t114 board = heltec_t114 board_build.ldscript = boards/nrf52840_s140_v6.ld build_flags = ${Heltec_t114.build_flags} + -D ST7789 -D HELTEC_T114_WITH_DISPLAY -D DISPLAY_CLASS=ST7789Display build_src_filter = ${Heltec_t114.build_src_filter} @@ -158,6 +157,7 @@ build_src_filter = ${Heltec_t114.build_src_filter} + lib_deps = ${Heltec_t114.lib_deps} + adafruit/Adafruit SSD1306 @ ^2.5.13 debug_tool = jlink upload_protocol = nrfutil diff --git a/variants/heltec_t114/target.cpp b/variants/heltec_t114/target.cpp index 23b9b667..cd280dda 100644 --- a/variants/heltec_t114/target.cpp +++ b/variants/heltec_t114/target.cpp @@ -1,28 +1,46 @@ -#include #include "target.h" + +#include #include + +#ifdef ENV_INCLUDE_GPS #include +#endif T114Board board; +#if defined(P_LORA_SCLK) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#else +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); +#endif WRAPPER_CLASS radio_driver(radio, board); VolatileRTCClock fallback_clock; AutoDiscoverRTCClock rtc_clock(fallback_clock); -MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); -T114SensorManager sensors = T114SensorManager(nmea); + +#if ENV_INCLUDE_GPS +#include +MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1); +EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); +#else +EnvironmentSensorManager sensors; +#endif #ifdef DISPLAY_CLASS - DISPLAY_CLASS display; - MomentaryButton user_btn(PIN_USER_BTN, 1000, true); +DISPLAY_CLASS display; +MomentaryButton user_btn(PIN_USER_BTN, 1000, true); #endif bool radio_init() { rtc_clock.begin(Wire); +#if defined(P_LORA_SCLK) return radio.std_init(&SPI); +#else + return radio.std_init(); +#endif } uint32_t radio_get_rng_seed() { @@ -42,37 +60,5 @@ void radio_set_tx_power(uint8_t dbm) { mesh::LocalIdentity radio_new_identity() { RadioNoiseListener rng(radio); - return mesh::LocalIdentity(&rng); // create new random identity -} - -bool T114SensorManager::begin() { - Serial1.begin(9600); - - // Try to detect if GPS is physically connected to determine if we should expose the setting - pinMode(PIN_GPS_EN, OUTPUT); - digitalWrite(PIN_GPS_EN, HIGH); // Power on GPS - - // Give GPS a moment to power up and send data - delay(1500); - - // We'll consider GPS detected if we see any data on Serial1 - gps_detected = (Serial1.available() > 0); - - if (gps_detected) { - MESH_DEBUG_PRINTLN("GPS detected"); - } else { - MESH_DEBUG_PRINTLN("No GPS detected"); - } - digitalWrite(PIN_GPS_EN, LOW); // Power off GPS until the setting is changed - - return EnvironmentSensorManager::begin(); -} - -bool T114SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { - EnvironmentSensorManager::querySensors(requester_permissions, telemetry); - - if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission? - telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); - } - return true; + return mesh::LocalIdentity(&rng); // create new random identity } diff --git a/variants/heltec_t114/target.h b/variants/heltec_t114/target.h index 24de81ee..94f990ec 100644 --- a/variants/heltec_t114/target.h +++ b/variants/heltec_t114/target.h @@ -2,10 +2,10 @@ #define RADIOLIB_STATIC_ONLY 1 #include -#include #include -#include #include +#include +#include #include #include @@ -18,21 +18,14 @@ #endif #endif -class T114SensorManager : public EnvironmentSensorManager { -public: - T114SensorManager(LocationProvider &location): EnvironmentSensorManager(location) { } - bool begin() override; - bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override; -}; - extern T114Board board; extern WRAPPER_CLASS radio_driver; extern AutoDiscoverRTCClock rtc_clock; -extern T114SensorManager sensors; +extern EnvironmentSensorManager sensors; #ifdef DISPLAY_CLASS - extern DISPLAY_CLASS display; - extern MomentaryButton user_btn; +extern DISPLAY_CLASS display; +extern MomentaryButton user_btn; #endif bool radio_init(); diff --git a/variants/heltec_t114/variant.h b/variants/heltec_t114/variant.h index aa7f4022..bfb4484d 100644 --- a/variants/heltec_t114/variant.h +++ b/variants/heltec_t114/variant.h @@ -14,7 +14,7 @@ #define USE_LFXO // 32.768 kHz crystal oscillator #define VARIANT_MCK (64000000ul) -#define WIRE_INTERFACES_COUNT (1) +#define WIRE_INTERFACES_COUNT (2) //////////////////////////////////////////////////////////////////////////////// // Power @@ -58,8 +58,11 @@ //////////////////////////////////////////////////////////////////////////////// // I2C pin definition -#define PIN_WIRE_SDA (26) // P0.26 -#define PIN_WIRE_SCL (27) // P0.27 +#define PIN_WIRE_SDA (26) // P0.26 +#define PIN_WIRE_SCL (27) // P0.27 + +#define PIN_WIRE1_SDA (7) // P0.8 +#define PIN_WIRE1_SCL (8) // P0.7 //////////////////////////////////////////////////////////////////////////////// // SPI pin definition