diff --git a/boards/seeed-wio-tracker-l1.json b/boards/seeed-wio-tracker-l1.json index 6235b8bf..56e3b424 100644 --- a/boards/seeed-wio-tracker-l1.json +++ b/boards/seeed-wio-tracker-l1.json @@ -46,6 +46,7 @@ "speed": 115200, "protocols": [ "jlink", + "stlink", "nrfjprog", "nrfutil", "cmsis-dap", diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index a2c2f8f8..509b0c63 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -175,15 +175,34 @@ void MyMesh::updateContactFromFrame(ContactInfo &contact, uint32_t& last_mod, co } } +bool MyMesh::Frame::isChannelMsg() const { + return buf[0] == RESP_CODE_CHANNEL_MSG_RECV || buf[0] == RESP_CODE_CHANNEL_MSG_RECV_V3; +} + void MyMesh::addToOfflineQueue(const uint8_t frame[], int len) { if (offline_queue_len >= OFFLINE_QUEUE_SIZE) { - MESH_DEBUG_PRINTLN("ERROR: offline_queue is full!"); + MESH_DEBUG_PRINTLN("WARN: offline_queue is full!"); + int pos = 0; + while (pos < offline_queue_len) { + if (offline_queue[pos].isChannelMsg()) { + for (int i = pos; i < offline_queue_len - 1; i++) { // delete oldest channel msg from queue + offline_queue[i] = offline_queue[i + 1]; + } + MESH_DEBUG_PRINTLN("INFO: removed oldest channel message from queue."); + offline_queue[offline_queue_len - 1].len = len; + memcpy(offline_queue[offline_queue_len - 1].buf, frame, len); + return; + } + pos++; + } + MESH_DEBUG_PRINTLN("INFO: no channel messages to remove from queue."); } else { offline_queue[offline_queue_len].len = len; memcpy(offline_queue[offline_queue_len].buf, frame, len); offline_queue_len++; } } + int MyMesh::getFromOfflineQueue(uint8_t frame[]) { if (offline_queue_len > 0) { // check offline queue size_t len = offline_queue[0].len; // take from top of queue diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 0dc9ad61..20efb46b 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -198,6 +198,8 @@ private: struct Frame { uint8_t len; uint8_t buf[MAX_FRAME_SIZE]; + + bool isChannelMsg() const; }; int offline_queue_len; Frame offline_queue[OFFLINE_QUEUE_SIZE]; diff --git a/src/helpers/ui/GxEPDDisplay.h b/src/helpers/ui/GxEPDDisplay.h index d53446d5..4fe6c0f2 100644 --- a/src/helpers/ui/GxEPDDisplay.h +++ b/src/helpers/ui/GxEPDDisplay.h @@ -24,7 +24,7 @@ class GxEPDDisplay : public DisplayDriver { -#if defined(HELTEC_MESH_POCKET) +#if defined(EINK_DISPLAY_MODEL) GxEPD2_BW display; const float scale_x = EINK_SCALE_X; const float scale_y = EINK_SCALE_Y; @@ -45,7 +45,7 @@ class GxEPDDisplay : public DisplayDriver { public: // there is a margin in y... -#if defined(HELTEC_MESH_POCKET) +#if defined(EINK_DISPLAY_MODEL) GxEPDDisplay() : DisplayDriver(128, 128), display(EINK_DISPLAY_MODEL(PIN_DISPLAY_CS, PIN_DISPLAY_DC, PIN_DISPLAY_RST, PIN_DISPLAY_BUSY)) {} #else GxEPDDisplay() : DisplayDriver(128, 128), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {} diff --git a/variants/wio-tracker-l1-eink/platformio.ini b/variants/wio-tracker-l1-eink/platformio.ini new file mode 100644 index 00000000..fa672f99 --- /dev/null +++ b/variants/wio-tracker-l1-eink/platformio.ini @@ -0,0 +1,66 @@ +[WioTrackerL1Eink] +extends = nrf52_base +board = seeed-wio-tracker-l1 +board_build.ldscript = boards/nrf52840_s140_v7.ld +build_flags = ${nrf52_base.build_flags} + -I lib/nrf52/s140_nrf52_7.3.0_API/include + -I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52 + -I variants/wio-tracker-l1 + -D WIO_TRACKER_L1 + -D WIO_TRACKER_L1_EINK + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D SX126X_CURRENT_LIMIT=140 + -D SX126X_RX_BOOSTED_GAIN=1 + -D PIN_OLED_RESET=-1 + -D EINK_DISPLAY_MODEL=GxEPD2_213_B74 + -D EINK_SCALE_X=1.953125f + -D EINK_SCALE_Y=1.28f + -D EINK_X_OFFSET=0 + -D EINK_Y_OFFSET=10 + -D DISPLAY_ROTATION=1 + -D DISABLE_DIAGNOSTIC_OUTPUT + -D AUTO_OFF_MILLIS=0 +build_src_filter = ${nrf52_base.build_src_filter} + + + +<../variants/wio-tracker-l1> + + + + +lib_deps= ${nrf52_base.lib_deps} + adafruit/Adafruit SH110X @ ^2.1.13 + adafruit/Adafruit GFX Library @ ^1.12.1 + stevemarple/MicroNMEA @ ^2.0.6 + zinggjm/GxEPD2 @ 1.6.2 + bakercp/CRC32 @ ^2.0.0 + adafruit/Adafruit BME280 Library @ ^2.3.0 + +[env:WioTrackerL1Eink_companion_radio_ble] +extends = WioTrackerL1Eink +board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld +board_upload.maximum_size = 708608 +build_flags = ${WioTrackerL1Eink.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 + -D OFFLINE_QUEUE_SIZE=256 + -D DISPLAY_CLASS=GxEPDDisplay + -D PIN_BUZZER=12 + -D QSPIFLASH=1 + ; -D MESH_PACKET_LOGGING=1 + ; -D MESH_DEBUG=1 + -D UI_RECENT_LIST_SIZE=9 + -D UI_SENSORS_PAGE=1 +build_src_filter = ${WioTrackerL1Eink.build_src_filter} + + + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = ${WioTrackerL1Eink.lib_deps} + adafruit/RTClib @ ^2.1.3 + densaugeo/base64 @ ~1.4.0 + end2endzone/NonBlockingRTTTL@^1.3.0 +debug_tool=stlink diff --git a/variants/wio-tracker-l1/target.h b/variants/wio-tracker-l1/target.h index 6f5da7c6..14e4591f 100644 --- a/variants/wio-tracker-l1/target.h +++ b/variants/wio-tracker-l1/target.h @@ -8,7 +8,11 @@ #include #include #ifdef DISPLAY_CLASS - #include + #if defined(WIO_TRACKER_L1_EINK) + #include + #else + #include + #endif #include #endif #include diff --git a/variants/wio-tracker-l1/variant.cpp b/variants/wio-tracker-l1/variant.cpp index 3db5ec9a..4fc2606a 100644 --- a/variants/wio-tracker-l1/variant.cpp +++ b/variants/wio-tracker-l1/variant.cpp @@ -52,6 +52,15 @@ const uint32_t g_ADigitalPinMap[] = { // VBAT ENABLE 4, // D30 BAT_CTL + + // EINK + 13, // 31 SCK + 14, // 32 RST + 15, // 33 MOSI + 16, // 34 DC + 17, // 35 BUSY + 19, // 36 CS + 0xFF, // 37 MISO }; void initVariant() { diff --git a/variants/wio-tracker-l1/variant.h b/variants/wio-tracker-l1/variant.h index af01177e..5cb0d97a 100644 --- a/variants/wio-tracker-l1/variant.h +++ b/variants/wio-tracker-l1/variant.h @@ -12,8 +12,8 @@ #include "WVariant.h" -#define PINS_COUNT (33) -#define NUM_DIGITAL_PINS (33) +#define PINS_COUNT (38) +#define NUM_DIGITAL_PINS (38) #define NUM_ANALOG_INPUTS (8) #define NUM_ANALOG_OUTPUTS (0) @@ -54,7 +54,7 @@ #define PIN_SERIAL1_TX (6) // SPI Interfaces -#define SPI_INTERFACES_COUNT (1) +#define SPI_INTERFACES_COUNT (2) #define PIN_SPI_MISO (9) #define PIN_SPI_MOSI (10) @@ -101,4 +101,19 @@ #define EXTERNAL_FLASH_DEVICES P25Q16H #define EXTERNAL_FLASH_USE_QSPI +// EInk on SPI1 +#define PIN_DISPLAY_CS (36) +#define PIN_DISPLAY_BUSY (35) +#define PIN_DISPLAY_DC (34) +#define PIN_DISPLAY_RST (32) + +#define PIN_SPI1_MISO (37) +#define PIN_SPI1_MOSI (33) +#define PIN_SPI1_SCK (31) + +// GxEPD2 needs that for a panel that is not even used ! +extern const int MISO; +extern const int MOSI; +extern const int SCK; + #endif \ No newline at end of file