diff --git a/src/BluetoothStatus.h b/src/BluetoothStatus.h index f6bb43cc2..680aec929 100644 --- a/src/BluetoothStatus.h +++ b/src/BluetoothStatus.h @@ -89,14 +89,22 @@ class BluetoothStatus : public Status case ConnectionState::CONNECTED: LOG_DEBUG("BluetoothStatus CONNECTED"); #ifdef BLE_LED +#ifdef BLE_LED_INVERTED + digitalWrite(BLE_LED, LOW); +#else digitalWrite(BLE_LED, HIGH); +#endif #endif break; case ConnectionState::DISCONNECTED: LOG_DEBUG("BluetoothStatus DISCONNECTED"); #ifdef BLE_LED +#ifdef BLE_LED_INVERTED + digitalWrite(BLE_LED, HIGH); +#else digitalWrite(BLE_LED, LOW); +#endif #endif break; } diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index a627a42cc..1c9f290b6 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -140,13 +140,13 @@ bool EInkDisplay::connect() #endif #endif -#if defined(TTGO_T_ECHO) || defined(ELECROW_ThinkNode_M1) +#if defined(TTGO_T_ECHO) || defined(ELECROW_ThinkNode_M1) || defined(T_ECHO_LITE) { auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, SPI1); adafruitDisplay = new GxEPD2_BW(*lowLevel); adafruitDisplay->init(); -#ifdef ELECROW_ThinkNode_M1 +#if defined(ELECROW_ThinkNode_M1) || defined(T_ECHO_LITE) adafruitDisplay->setRotation(4); #else adafruitDisplay->setRotation(3); diff --git a/src/main.cpp b/src/main.cpp index c5be175c4..c53877e37 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -325,8 +325,12 @@ void setup() #ifdef BLE_LED pinMode(BLE_LED, OUTPUT); +#ifdef BLE_LED_INVERTED + digitalWrite(BLE_LED, HIGH); +#else digitalWrite(BLE_LED, LOW); #endif +#endif #if defined(T_DECK) // GPIO10 manages all peripheral power supplies diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 39b297965..866497ecc 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -60,7 +60,7 @@ SerialModule *serialModule; SerialModuleRadio *serialModuleRadio; -#if defined(TTGO_T_ECHO) || defined(CANARYONE) || defined(MESHLINK) || defined(ELECROW_ThinkNode_M1) || \ +#if defined(TTGO_T_ECHO) || defined(T_ECHO_LITE) || defined(CANARYONE) || defined(MESHLINK) || defined(ELECROW_ThinkNode_M1) || \ defined(ELECROW_ThinkNode_M5) SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("Serial") {} static Print *serialPrint = &Serial; @@ -179,8 +179,8 @@ int32_t SerialModule::runOnce() Serial.begin(baud); Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT); } -#elif !defined(TTGO_T_ECHO) && !defined(CANARYONE) && !defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && \ - !defined(ELECROW_ThinkNode_M5) +#elif !defined(TTGO_T_ECHO) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && !defined(MESHLINK) && \ + !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M5) if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { #ifdef ARCH_RP2040 Serial2.setFIFOSize(RX_BUFFER); @@ -236,8 +236,8 @@ int32_t SerialModule::runOnce() } } -#if !defined(TTGO_T_ECHO) && !defined(CANARYONE) && !defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && \ - !defined(ELECROW_ThinkNode_M5) +#if !defined(TTGO_T_ECHO) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && !defined(MESHLINK) && \ + !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M5) else if ((moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_WS85)) { processWXSerial(); @@ -496,8 +496,8 @@ ParsedLine parseLine(const char *line) */ void SerialModule::processWXSerial() { -#if !defined(TTGO_T_ECHO) && !defined(CANARYONE) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(MESHLINK) && \ - !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M5) +#if !defined(TTGO_T_ECHO) && !defined(T_ECHO_LITE) && !defined(CANARYONE) && !defined(CONFIG_IDF_TARGET_ESP32C6) && \ + !defined(MESHLINK) && !defined(ELECROW_ThinkNode_M1) && !defined(ELECROW_ThinkNode_M5) static unsigned int lastAveraged = 0; static unsigned int averageIntervalMillis = 300000; // 5 minutes hard coded. static double dir_sum_sin = 0; diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 834184292..95e191c8e 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -223,9 +223,12 @@ void NimbleBluetooth::deinit() LOG_INFO("Disable bluetooth until reboot"); #ifdef BLE_LED +#ifdef BLE_LED_INVERTED + digitalWrite(BLE_LED, HIGH); +#else digitalWrite(BLE_LED, LOW); #endif - +#endif NimBLEDevice::deinit(); #endif } diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index ce42bf849..064bd8ef0 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -60,6 +60,8 @@ #define HW_VENDOR meshtastic_HardwareModel_RAK4631 #elif defined(TTGO_T_ECHO) #define HW_VENDOR meshtastic_HardwareModel_T_ECHO +#elif defined(T_ECHO_LITE) +#define HW_VENDOR meshtastic_HardwareModel_T_ECHO_LITE #elif defined(ELECROW_ThinkNode_M1) #define HW_VENDOR meshtastic_HardwareModel_THINKNODE_M1 #elif defined(NANO_G2_ULTRA) diff --git a/variants/nrf52840/t-echo-lite/platformio.ini b/variants/nrf52840/t-echo-lite/platformio.ini new file mode 100644 index 000000000..68ae59dcb --- /dev/null +++ b/variants/nrf52840/t-echo-lite/platformio.ini @@ -0,0 +1,25 @@ +; Using original screen class +[env:t-echo-lite] +extends = nrf52840_base +board = t-echo +board_check = true +debug_tool = jlink + +# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling. +build_flags = ${nrf52840_base.build_flags} + -Ivariants/nrf52840/t-echo-lite + -D T_ECHO_LITE + -D GPS_POWER_TOGGLE + -D EINK_DISPLAY_MODEL=GxEPD2_122_T61 + -D EINK_WIDTH=192 + -D EINK_HEIGHT=176 + -D USE_EINK + -D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk + -D EINK_LIMIT_FASTREFRESH=20 ; How many consecutive fast-refreshes are permitted + -D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. + +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/t-echo-lite> +lib_deps = + ${nrf52840_base.lib_deps} + https://github.com/meshtastic/GxEPD2/archive/a05c11c02862624266b61599b0d6ba93e33c6f24.zip +;upload_protocol = fs diff --git a/variants/nrf52840/t-echo-lite/variant.cpp b/variants/nrf52840/t-echo-lite/variant.cpp new file mode 100644 index 000000000..cae079b74 --- /dev/null +++ b/variants/nrf52840/t-echo-lite/variant.cpp @@ -0,0 +1,44 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + // P0 - pins 0 and 1 are hardwired for xtal and should never be enabled + 0xff, 0xff, 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, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); + + pinMode(PIN_LED3, OUTPUT); + ledOff(PIN_LED3); +} diff --git a/variants/nrf52840/t-echo-lite/variant.h b/variants/nrf52840/t-echo-lite/variant.h new file mode 100644 index 000000000..2e2cdce72 --- /dev/null +++ b/variants/nrf52840/t-echo-lite/variant.h @@ -0,0 +1,207 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_TTGO_EINK_V1_0_ +#define _VARIANT_TTGO_EINK_V1_0_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (1) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (32 + 7) // Green LED +#define PIN_LED2 (32 + 5) // Blue LED +// Unused(by firmware) LEDs: +#define PIN_LED3 (32 + 14) // Red LED inside, under the display. + +#define LED_RED PIN_LED3 +#define LED_BLUE PIN_LED2 +#define LED_GREEN PIN_LED1 + +#define BLE_LED LED_BLUE +#define BLE_LED_INVERTED 1 +#define LED_BUILTIN LED_GREEN +#define LED_CONN LED_GREEN +#define LED_STATE_ON 0 // State when LED is lit + +// Buttons +#define PIN_BUTTON1 (0 + 24) +#define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO + +#define BUTTON_CLICK_MS 400 + +// Analog pins +#define PIN_A0 (0 + 2) // Battery ADC + +#define BATTERY_PIN PIN_A0 + +static const uint8_t A0 = PIN_A0; + +#define ADC_RESOLUTION 14 + +#define ADC_CTRL (0 + 31) +#define ADC_CTRL_ENABLED HIGH + +// NFC +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +// Wire Interfaces +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (32 + 4) +#define PIN_WIRE_SCL (32 + 2) + +/* + Internal, PCB PAD interrupt PIN. Currently not used. (Not built in my device) +*/ +// #define PIN_IMU_INT (0 + 16) // Interrupt from the IMU, macro name correct?! + +// External serial flash ZD25WQ32CEIGR +// QSPI Pins +#define PIN_QSPI_SCK (0 + 4) +#define PIN_QSPI_CS (0 + 12) +#define PIN_QSPI_IO0 (0 + 6) // MOSI if using two bit interface +#define PIN_QSPI_IO1 (0 + 8) // MISO if using two bit interface +#define PIN_QSPI_IO2 (32 + 9) // WP if using two bit interface (i.e. not used) +#define PIN_QSPI_IO3 (0 + 26) // HOLD if using two bit interface (i.e. not used) + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES ZD25WQ32CEIGR +#define EXTERNAL_FLASH_USE_QSPI + +// Lora radio + +#define USE_SX1262 +// #define USE_SX1268 // currently only available with XS1262. +#define SX126X_CS (0 + 11) +#define SX126X_DIO1 (32 + 8) +#define SX126X_DIO2 (0 + 5) +#define SX126X_BUSY (0 + 14) +#define SX126X_RESET (0 + 7) +#define SX126X_RXEN (32 + 1) +#define SX126X_TXEN (0 + 27) +// #define TCXO_OPTIONAL +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +// eink display pins +#define VEXT_ENABLE (32 + 12) +#define VEXT_ON_VALUE LOW +#define PIN_EINK_CS (0 + 22) +#define PIN_EINK_BUSY (0 + 3) +#define PIN_EINK_DC (0 + 21) +#define PIN_EINK_RES (0 + 28) +#define PIN_EINK_SCLK (0 + 19) +#define PIN_EINK_MOSI (0 + 20) + +// Controls power 3V3 for all peripherals (eink + GPS + LoRa + Sensor) +#define PIN_POWER_EN (0 + 30) // 3V3 POWER Enable + +#define PIN_SPI1_MISO (-1) // The display does not use MISO. +#define PIN_SPI1_MOSI PIN_EINK_MOSI +#define PIN_SPI1_SCK PIN_EINK_SCLK + +// GPS pins +// #define GPS_DEBUG +#define GPS_L76K +#define GPS_BAUDRATE 9600 +#define HAS_GPS 1 +// #define PIN_GPS_REINIT (32 + 5) // An output to reset L76K GPS. As per datasheet, low for > 100ms will reset the L76K + +#define PIN_GPS_STANDBY (32 + 10) // An output to wake GPS, low means allow sleep, high means force wake +// Seems to be missing on this new board +#define PIN_GPS_PPS (0 + 29) // Pulse per second input from the GPS +#define GPS_TX_PIN (32 + 15) // This is for bits going TOWARDS the CPU +#define GPS_RX_PIN (32 + 13) // This is for bits going TOWARDS the GPS + +#define GPS_THREAD_INTERVAL 50 + +#define PIN_SERIAL1_RX GPS_TX_PIN +#define PIN_SERIAL1_TX GPS_RX_PIN + +// SPI Interfaces +#define SPI_INTERFACES_COUNT 2 + +// For LORA, SPI 0 +#define PIN_SPI_MISO (0 + 17) +#define PIN_SPI_MOSI (0 + 15) +#define PIN_SPI_SCK (0 + 13) + +// Battery +// The battery sense is hooked to pin A0 (2) +// it is defined in the analogue pin section of this file +// and has 12 bit resolution +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER (2.0F) + +// #define NO_EXT_GPIO 1 +// PINs back side +// Batt & solar connector left up corner +/* +------------------------------- +| VDDH, VBAT, 0.23, SCL , 1.06 | +| GND , SDA , 0.09, 0.10, 0.25 | +------------------------------- + -------- + | VDDH | + | GND | + | 1.13 | - Wake Up/standby + | 1.15 | - PPS + | 0.29 | - TX + | 1.10 | - RX + | 1.11 | - EN + -------- +------------------------------- +| 3V3 , GND , 0.16, 1.03, G_WU | 0.16 internal solder pad interrupt PIN, +| G_EN, G_RX, G_TX, GND , PPS | +------------------------------- +*/ + +// To debug via the segger JLINK console rather than the CDC-ACM serial device +// #define USE_SEGGER + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file