mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-20 04:01:14 +00:00
Heltec boards sensor and low power features update (#4418)
* Update sensor drive and low power features. * Update ST7789 TFT control logic. * Update Heltec nRF board low power features. * Update the GPS UART port pointer
This commit is contained in:
parent
f97ae52263
commit
6e8300287b
@ -810,6 +810,16 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
|
|||||||
powerState = newState;
|
powerState = newState;
|
||||||
LOG_INFO("GPS power state moving from %s to %s\n", getGPSPowerStateString(oldState), getGPSPowerStateString(newState));
|
LOG_INFO("GPS power state moving from %s to %s\n", getGPSPowerStateString(oldState), getGPSPowerStateString(newState));
|
||||||
|
|
||||||
|
#ifdef HELTEC_MESH_NODE_T114
|
||||||
|
if( (oldState==GPS_OFF || oldState==GPS_HARDSLEEP) && (newState!=GPS_OFF && newState!=GPS_HARDSLEEP) )
|
||||||
|
{
|
||||||
|
_serial_gps->begin(serialSpeeds[speedSelect]);
|
||||||
|
}
|
||||||
|
else if( (newState==GPS_OFF || newState==GPS_HARDSLEEP) && (oldState!=GPS_OFF && oldState!=GPS_HARDSLEEP) )
|
||||||
|
{
|
||||||
|
_serial_gps->end();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case GPS_ACTIVE:
|
case GPS_ACTIVE:
|
||||||
case GPS_IDLE:
|
case GPS_IDLE:
|
||||||
|
@ -1591,6 +1591,9 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
|||||||
|
|
||||||
dispdev->displayOn();
|
dispdev->displayOn();
|
||||||
#ifdef USE_ST7789
|
#ifdef USE_ST7789
|
||||||
|
pinMode(VTFT_CTRL, OUTPUT);
|
||||||
|
digitalWrite(VTFT_CTRL,LOW);
|
||||||
|
ui->init();
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
analogWrite(VTFT_LEDA, BRIGHTNESS_DEFAULT);
|
analogWrite(VTFT_LEDA, BRIGHTNESS_DEFAULT);
|
||||||
#else
|
#else
|
||||||
@ -1609,10 +1612,21 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
|||||||
#endif
|
#endif
|
||||||
LOG_INFO("Turning off screen\n");
|
LOG_INFO("Turning off screen\n");
|
||||||
dispdev->displayOff();
|
dispdev->displayOff();
|
||||||
|
|
||||||
#ifdef USE_ST7789
|
#ifdef USE_ST7789
|
||||||
pinMode(VTFT_LEDA, OUTPUT);
|
SPI1.end();
|
||||||
digitalWrite(VTFT_LEDA, !TFT_BACKLIGHT_ON);
|
#if defined(ARCH_ESP32)
|
||||||
|
pinMode(VTFT_LEDA, ANALOG);
|
||||||
|
pinMode(VTFT_CTRL, ANALOG);
|
||||||
|
pinMode(ST7789_RESET,ANALOG);
|
||||||
|
pinMode(ST7789_RS,ANALOG);
|
||||||
|
pinMode(ST7789_NSS,ANALOG);
|
||||||
|
#else
|
||||||
|
nrf_gpio_cfg_default(VTFT_LEDA);
|
||||||
|
nrf_gpio_cfg_default(VTFT_CTRL);
|
||||||
|
nrf_gpio_cfg_default(ST7789_RESET);
|
||||||
|
nrf_gpio_cfg_default(ST7789_RS);
|
||||||
|
nrf_gpio_cfg_default(ST7789_NSS);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef T_WATCH_S3
|
#ifdef T_WATCH_S3
|
||||||
|
19
src/main.cpp
19
src/main.cpp
@ -319,6 +319,14 @@ void setup()
|
|||||||
digitalWrite(RESET_OLED, 1);
|
digitalWrite(RESET_OLED, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SENSOR_POWER_CTRL_PIN
|
||||||
|
pinMode(SENSOR_POWER_CTRL_PIN,OUTPUT);
|
||||||
|
digitalWrite(SENSOR_POWER_CTRL_PIN,SENSOR_POWER_ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SENSOR_GPS_CONFLICT
|
||||||
|
bool sensor_detected=false;
|
||||||
|
#endif
|
||||||
#ifdef PERIPHERAL_WARMUP_MS
|
#ifdef PERIPHERAL_WARMUP_MS
|
||||||
// Some peripherals may require additional time to stabilize after power is connected
|
// Some peripherals may require additional time to stabilize after power is connected
|
||||||
// e.g. I2C on Heltec Vision Master
|
// e.g. I2C on Heltec Vision Master
|
||||||
@ -458,6 +466,9 @@ void setup()
|
|||||||
LOG_INFO("No I2C devices found\n");
|
LOG_INFO("No I2C devices found\n");
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("%i I2C devices found\n", i2cCount);
|
LOG_INFO("%i I2C devices found\n", i2cCount);
|
||||||
|
#ifdef SENSOR_GPS_CONFLICT
|
||||||
|
sensor_detected=true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
@ -703,6 +714,10 @@ void setup()
|
|||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
// If we're taking on the repeater role, ignore GPS
|
// If we're taking on the repeater role, ignore GPS
|
||||||
|
#ifdef SENSOR_GPS_CONFLICT
|
||||||
|
if(sensor_detected==false)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
if (HAS_GPS) {
|
if (HAS_GPS) {
|
||||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||||
config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
||||||
@ -714,6 +729,10 @@ void setup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef SENSOR_GPS_CONFLICT
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nodeStatus->observe(&nodeDB->newStatus);
|
nodeStatus->observe(&nodeDB->newStatus);
|
||||||
|
@ -228,6 +228,9 @@ void cpuDeepSleep(uint32_t msecToWake)
|
|||||||
// FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead
|
// FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead
|
||||||
// of just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
// of just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
||||||
|
|
||||||
|
#ifdef ESP32S3_WAKE_TYPE
|
||||||
|
esp_sleep_enable_ext1_wakeup(gpioMask, ESP32S3_WAKE_TYPE);
|
||||||
|
#else
|
||||||
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||||
// ESP_EXT1_WAKEUP_ALL_LOW has been deprecated since esp-idf v5.4 for any other target.
|
// ESP_EXT1_WAKEUP_ALL_LOW has been deprecated since esp-idf v5.4 for any other target.
|
||||||
@ -236,6 +239,8 @@ void cpuDeepSleep(uint32_t msecToWake)
|
|||||||
esp_sleep_enable_ext1_wakeup(gpioMask, ESP_EXT1_WAKEUP_ANY_LOW);
|
esp_sleep_enable_ext1_wakeup(gpioMask, ESP_EXT1_WAKEUP_ANY_LOW);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif //#end ESP32S3_WAKE_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We want RTC peripherals to stay on
|
// We want RTC peripherals to stay on
|
||||||
|
@ -198,8 +198,15 @@ void NRF52Bluetooth::shutdown()
|
|||||||
{
|
{
|
||||||
// Shutdown bluetooth for minimum power draw
|
// Shutdown bluetooth for minimum power draw
|
||||||
LOG_INFO("Disable NRF52 bluetooth\n");
|
LOG_INFO("Disable NRF52 bluetooth\n");
|
||||||
if (connectionHandle != 0) {
|
uint8_t connection_num=Bluefruit.connected();
|
||||||
Bluefruit.disconnect(connectionHandle);
|
if(connection_num)
|
||||||
|
{
|
||||||
|
for(uint8_t i=0;i<connection_num;i++)
|
||||||
|
{
|
||||||
|
LOG_INFO("NRF52 bluetooth disconnecting handle %d\n",i);
|
||||||
|
Bluefruit.disconnect(i);
|
||||||
|
}
|
||||||
|
delay(100);//wait for ondisconnect;
|
||||||
}
|
}
|
||||||
Bluefruit.Advertising.stop();
|
Bluefruit.Advertising.stop();
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,12 @@ void cpuDeepSleep(uint32_t msecToWake)
|
|||||||
nrf_gpio_cfg_default(WB_I2C1_SCL);
|
nrf_gpio_cfg_default(WB_I2C1_SCL);
|
||||||
nrf_gpio_cfg_default(WB_I2C1_SDA);
|
nrf_gpio_cfg_default(WB_I2C1_SDA);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HELTEC_MESH_NODE_T114
|
||||||
|
nrf_gpio_cfg_default(PIN_GPS_PPS);
|
||||||
|
detachInterrupt(PIN_GPS_PPS);
|
||||||
|
detachInterrupt(PIN_BUTTON1);
|
||||||
#endif
|
#endif
|
||||||
// Sleepy trackers or sensors can low power "sleep"
|
// Sleepy trackers or sensors can low power "sleep"
|
||||||
// Don't enter this if we're sleeping portMAX_DELAY, since that's a shutdown event
|
// Don't enter this if we're sleeping portMAX_DELAY, since that's a shutdown event
|
||||||
|
@ -278,6 +278,13 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
|
|||||||
digitalWrite(LORA_CS, HIGH);
|
digitalWrite(LORA_CS, HIGH);
|
||||||
gpio_hold_en((gpio_num_t)LORA_CS);
|
gpio_hold_en((gpio_num_t)LORA_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(I2C_SDA)
|
||||||
|
Wire.end();
|
||||||
|
pinMode(I2C_SDA,ANALOG);
|
||||||
|
pinMode(I2C_SCL,ANALOG);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PMU
|
#ifdef HAS_PMU
|
||||||
|
@ -40,3 +40,13 @@
|
|||||||
|
|
||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
#define SX126X_DIO2_AS_RF_SWITCH
|
||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||||
|
|
||||||
|
#define I2C_SDA 1
|
||||||
|
#define I2C_SCL 2
|
||||||
|
#define HAS_SCREEN 0
|
||||||
|
#define SENSOR_POWER_CTRL_PIN 21
|
||||||
|
#define SENSOR_POWER_ON 1
|
||||||
|
|
||||||
|
#define SENSOR_GPS_CONFLICT
|
||||||
|
|
||||||
|
#define ESP32S3_WAKE_TYPE ESP_EXT1_WAKEUP_ANY_HIGH
|
@ -146,7 +146,7 @@ No longer populated on PCB
|
|||||||
|
|
||||||
#define GPS_L76K
|
#define GPS_L76K
|
||||||
|
|
||||||
#define PIN_GPS_RESET (32 + 6) // An output to reset L76K GPS. As per datasheet, low for > 100ms will reset the L76K
|
//#define PIN_GPS_RESET (32 + 6) // An output to reset L76K GPS. As per datasheet, low for > 100ms will reset the L76K
|
||||||
#define GPS_RESET_MODE LOW
|
#define GPS_RESET_MODE LOW
|
||||||
#define PIN_GPS_EN (21)
|
#define PIN_GPS_EN (21)
|
||||||
#define GPS_EN_ACTIVE HIGH
|
#define GPS_EN_ACTIVE HIGH
|
||||||
|
Loading…
Reference in New Issue
Block a user