mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 06:02:05 +00:00
Check for null screen
This commit is contained in:
parent
212005bfe9
commit
f1440a27d7
@ -853,6 +853,7 @@ int32_t Power::runOnce()
|
|||||||
#ifndef T_WATCH_S3 // FIXME - why is this triggering on the T-Watch S3?
|
#ifndef T_WATCH_S3 // FIXME - why is this triggering on the T-Watch S3?
|
||||||
if (PMU->isPekeyLongPressIrq()) {
|
if (PMU->isPekeyLongPressIrq()) {
|
||||||
LOG_DEBUG("PEK long button press");
|
LOG_DEBUG("PEK long button press");
|
||||||
|
if (screen)
|
||||||
screen->setOn(false);
|
screen->setOn(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,6 +82,7 @@ static uint32_t secsSlept;
|
|||||||
static void lsEnter()
|
static void lsEnter()
|
||||||
{
|
{
|
||||||
LOG_INFO("lsEnter begin, ls_secs=%u", config.power.ls_secs);
|
LOG_INFO("lsEnter begin, ls_secs=%u", config.power.ls_secs);
|
||||||
|
if (screen)
|
||||||
screen->setOn(false);
|
screen->setOn(false);
|
||||||
secsSlept = 0; // How long have we been sleeping this time
|
secsSlept = 0; // How long have we been sleeping this time
|
||||||
|
|
||||||
@ -160,6 +161,7 @@ static void lsExit()
|
|||||||
static void nbEnter()
|
static void nbEnter()
|
||||||
{
|
{
|
||||||
LOG_DEBUG("State: NB");
|
LOG_DEBUG("State: NB");
|
||||||
|
if (screen)
|
||||||
screen->setOn(false);
|
screen->setOn(false);
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// Only ESP32 should turn off bluetooth
|
// Only ESP32 should turn off bluetooth
|
||||||
@ -190,6 +192,7 @@ static void serialExit()
|
|||||||
{
|
{
|
||||||
// Turn bluetooth back on when we leave serial stream API
|
// Turn bluetooth back on when we leave serial stream API
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
|
if (screen)
|
||||||
screen->print("Serial disconnected\n");
|
screen->print("Serial disconnected\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +204,7 @@ static void powerEnter()
|
|||||||
LOG_INFO("Loss of power in Powered");
|
LOG_INFO("Loss of power in Powered");
|
||||||
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
||||||
} else {
|
} else {
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR )
|
if (screen)
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
// within enter() the function getState() returns the state we came from
|
// within enter() the function getState() returns the state we came from
|
||||||
@ -237,6 +240,7 @@ static void powerExit()
|
|||||||
static void onEnter()
|
static void onEnter()
|
||||||
{
|
{
|
||||||
LOG_DEBUG("State: ON");
|
LOG_DEBUG("State: ON");
|
||||||
|
if (screen)
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
}
|
}
|
||||||
@ -251,6 +255,7 @@ static void onIdle()
|
|||||||
|
|
||||||
static void screenPress()
|
static void screenPress()
|
||||||
{
|
{
|
||||||
|
if (screen)
|
||||||
screen->onPress();
|
screen->onPress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ int32_t ScanAndSelectInput::runOnce()
|
|||||||
// Dismiss the alert screen several seconds after it appears
|
// Dismiss the alert screen several seconds after it appears
|
||||||
if (!Throttle::isWithinTimespanMs(alertingSinceMs, durationAlertMs)) {
|
if (!Throttle::isWithinTimespanMs(alertingSinceMs, durationAlertMs)) {
|
||||||
alertingNoMessage = false;
|
alertingNoMessage = false;
|
||||||
|
if (screen)
|
||||||
screen->endAlert();
|
screen->endAlert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,6 +184,7 @@ void ScanAndSelectInput::alertNoMessage()
|
|||||||
alertingSinceMs = millis();
|
alertingSinceMs = millis();
|
||||||
|
|
||||||
// Graphics code: the alert frame to show on screen
|
// Graphics code: the alert frame to show on screen
|
||||||
|
if (screen) {
|
||||||
screen->startAlert([](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
screen->startAlert([](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER_BOTH);
|
display->setTextAlignment(TEXT_ALIGN_CENTER_BOTH);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
@ -190,6 +192,7 @@ void ScanAndSelectInput::alertNoMessage()
|
|||||||
int16_t textY = display->getHeight() / 2;
|
int16_t textY = display->getHeight() / 2;
|
||||||
display->drawString(textX + x, textY + y, "No Canned Messages");
|
display->drawString(textX + x, textY + y, "No Canned Messages");
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the canned message frame from screen
|
// Remove the canned message frame from screen
|
||||||
|
@ -1227,6 +1227,7 @@ void setup()
|
|||||||
nodeDB->saveToDisk(SEGMENT_CONFIG);
|
nodeDB->saveToDisk(SEGMENT_CONFIG);
|
||||||
if (!rIf->reconfigure()) {
|
if (!rIf->reconfigure()) {
|
||||||
LOG_WARN("Reconfigure failed, rebooting");
|
LOG_WARN("Reconfigure failed, rebooting");
|
||||||
|
if (screen)
|
||||||
screen->startAlert("Rebooting...");
|
screen->startAlert("Rebooting...");
|
||||||
rebootAtMsec = millis() + 5000;
|
rebootAtMsec = millis() + 5000;
|
||||||
}
|
}
|
||||||
|
@ -903,6 +903,7 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if HAS_SCREEN
|
#if HAS_SCREEN
|
||||||
|
if (screen)
|
||||||
screen->blink();
|
screen->blink();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,7 @@ void createSSLCert()
|
|||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
#if HAS_SCREEN
|
#if HAS_SCREEN
|
||||||
if (millis() / 1000 >= 3) {
|
if (millis() / 1000 >= 3) {
|
||||||
|
if (screen)
|
||||||
screen->setSSLFrames();
|
screen->setSSLFrames();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -200,6 +200,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
#if defined(ARCH_ESP32)
|
#if defined(ARCH_ESP32)
|
||||||
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
if (!BleOta::getOtaAppVersion().isEmpty()) {
|
if (!BleOta::getOtaAppVersion().isEmpty()) {
|
||||||
|
if (screen)
|
||||||
screen->startFirmwareUpdateScreen();
|
screen->startFirmwareUpdateScreen();
|
||||||
BleOta::switchToOtaApp();
|
BleOta::switchToOtaApp();
|
||||||
LOG_INFO("Rebooting to BLE OTA");
|
LOG_INFO("Rebooting to BLE OTA");
|
||||||
@ -207,6 +208,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_WIFI
|
#if !MESHTASTIC_EXCLUDE_WIFI
|
||||||
if (WiFiOTA::trySwitchToOTA()) {
|
if (WiFiOTA::trySwitchToOTA()) {
|
||||||
|
if (screen)
|
||||||
screen->startFirmwareUpdateScreen();
|
screen->startFirmwareUpdateScreen();
|
||||||
WiFiOTA::saveConfig(&config.network);
|
WiFiOTA::saveConfig(&config.network);
|
||||||
LOG_INFO("Rebooting to WiFi OTA");
|
LOG_INFO("Rebooting to WiFi OTA");
|
||||||
@ -1111,6 +1113,7 @@ void AdminModule::handleGetDeviceUIConfig(const meshtastic_MeshPacket &req)
|
|||||||
void AdminModule::reboot(int32_t seconds)
|
void AdminModule::reboot(int32_t seconds)
|
||||||
{
|
{
|
||||||
LOG_INFO("Reboot in %d seconds", seconds);
|
LOG_INFO("Reboot in %d seconds", seconds);
|
||||||
|
if (screen)
|
||||||
screen->startAlert("Rebooting...");
|
screen->startAlert("Rebooting...");
|
||||||
rebootAtMsec = (seconds < 0) ? 0 : (millis() + seconds * 1000);
|
rebootAtMsec = (seconds < 0) ? 0 : (millis() + seconds * 1000);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const meshtastic_MeshPacket &r
|
|||||||
switch (p.type) {
|
switch (p.type) {
|
||||||
case meshtastic_HardwareMessage_Type_WRITE_GPIOS: {
|
case meshtastic_HardwareMessage_Type_WRITE_GPIOS: {
|
||||||
// Print notification to LCD screen
|
// Print notification to LCD screen
|
||||||
|
if (screen)
|
||||||
screen->print("Write GPIOs\n");
|
screen->print("Write GPIOs\n");
|
||||||
|
|
||||||
pinModes(p.gpio_mask, OUTPUT, availablePins);
|
pinModes(p.gpio_mask, OUTPUT, availablePins);
|
||||||
|
@ -14,7 +14,7 @@ meshtastic_MeshPacket *ReplyModule::allocReply()
|
|||||||
// The incoming message is in p.payload
|
// The incoming message is in p.payload
|
||||||
LOG_INFO("Received message from=0x%0x, id=%d, msg=%.*s", req.from, req.id, p.payload.size, p.payload.bytes);
|
LOG_INFO("Received message from=0x%0x, id=%d, msg=%.*s", req.from, req.id, p.payload.size, p.payload.bytes);
|
||||||
#endif
|
#endif
|
||||||
|
if (screen)
|
||||||
screen->print("Send reply\n");
|
screen->print("Send reply\n");
|
||||||
|
|
||||||
const char *replyStr = "Message Received";
|
const char *replyStr = "Message Received";
|
||||||
|
@ -37,6 +37,7 @@ int32_t BMX160Sensor::runOnce()
|
|||||||
if (!showingScreen) {
|
if (!showingScreen) {
|
||||||
powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration
|
powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration
|
||||||
showingScreen = true;
|
showingScreen = true;
|
||||||
|
if (screen)
|
||||||
screen->startAlert((FrameCallback)drawFrameCalibration);
|
screen->startAlert((FrameCallback)drawFrameCalibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ int32_t BMX160Sensor::runOnce()
|
|||||||
doCalibration = false;
|
doCalibration = false;
|
||||||
endCalibrationAt = 0;
|
endCalibrationAt = 0;
|
||||||
showingScreen = false;
|
showingScreen = false;
|
||||||
|
if (screen)
|
||||||
screen->endAlert();
|
screen->endAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ int32_t BMX160Sensor::runOnce()
|
|||||||
heading += 270;
|
heading += 270;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (screen)
|
||||||
screen->setHeading(heading);
|
screen->setHeading(heading);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -118,6 +120,7 @@ void BMX160Sensor::calibrate(uint16_t forSeconds)
|
|||||||
doCalibration = true;
|
doCalibration = true;
|
||||||
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
||||||
endCalibrationAt = millis() + calibrateFor;
|
endCalibrationAt = millis() + calibrateFor;
|
||||||
|
if (screen)
|
||||||
screen->setEndCalibration(endCalibrationAt);
|
screen->setEndCalibration(endCalibrationAt);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ int32_t ICM20948Sensor::runOnce()
|
|||||||
if (!showingScreen) {
|
if (!showingScreen) {
|
||||||
powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration
|
powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration
|
||||||
showingScreen = true;
|
showingScreen = true;
|
||||||
|
if (screen)
|
||||||
screen->startAlert((FrameCallback)drawFrameCalibration);
|
screen->startAlert((FrameCallback)drawFrameCalibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +82,7 @@ int32_t ICM20948Sensor::runOnce()
|
|||||||
doCalibration = false;
|
doCalibration = false;
|
||||||
endCalibrationAt = 0;
|
endCalibrationAt = 0;
|
||||||
showingScreen = false;
|
showingScreen = false;
|
||||||
|
if (screen)
|
||||||
screen->endAlert();
|
screen->endAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ int32_t ICM20948Sensor::runOnce()
|
|||||||
heading += 270;
|
heading += 270;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (screen)
|
||||||
screen->setHeading(heading);
|
screen->setHeading(heading);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -159,6 +161,7 @@ void ICM20948Sensor::calibrate(uint16_t forSeconds)
|
|||||||
doCalibration = true;
|
doCalibration = true;
|
||||||
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
||||||
endCalibrationAt = millis() + calibrateFor;
|
endCalibrationAt = millis() + calibrateFor;
|
||||||
|
if (screen)
|
||||||
screen->setEndCalibration(endCalibrationAt);
|
screen->setEndCalibration(endCalibrationAt);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
bluetoothStatus->updateStatus(new meshtastic::BluetoothStatus(std::to_string(passkey)));
|
bluetoothStatus->updateStatus(new meshtastic::BluetoothStatus(std::to_string(passkey)));
|
||||||
|
|
||||||
#if HAS_SCREEN // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
#if HAS_SCREEN // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
||||||
|
if (screen) {
|
||||||
screen->startAlert([passkey](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
screen->startAlert([passkey](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
||||||
char btPIN[16] = "888888";
|
char btPIN[16] = "888888";
|
||||||
snprintf(btPIN, sizeof(btPIN), "%06u", passkey);
|
snprintf(btPIN, sizeof(btPIN), "%06u", passkey);
|
||||||
@ -119,6 +120,7 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_LARGE - 6 : y_offset + FONT_HEIGHT_LARGE + 5;
|
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_LARGE - 6 : y_offset + FONT_HEIGHT_LARGE + 5;
|
||||||
display->drawString(x_offset + x, y_offset + y, deviceName);
|
display->drawString(x_offset + x, y_offset + y, deviceName);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
passkeyShowing = true;
|
passkeyShowing = true;
|
||||||
|
|
||||||
@ -134,6 +136,7 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
// Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
// Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
||||||
if (passkeyShowing) {
|
if (passkeyShowing) {
|
||||||
passkeyShowing = false;
|
passkeyShowing = false;
|
||||||
|
if (screen)
|
||||||
screen->endAlert();
|
screen->endAlert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ void powerCommandsCheck()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
|
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
|
||||||
if (shutdownAtMsec) {
|
if (shutdownAtMsec && screen) {
|
||||||
screen->startAlert("Shutting down...");
|
screen->startAlert("Shutting down...");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -221,7 +221,7 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false, bool skipSaveN
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
powerMon->setState(meshtastic_PowerMon_State_CPU_DeepSleep);
|
powerMon->setState(meshtastic_PowerMon_State_CPU_DeepSleep);
|
||||||
|
if (screen)
|
||||||
screen->doDeepSleep(); // datasheet says this will draw only 10ua
|
screen->doDeepSleep(); // datasheet says this will draw only 10ua
|
||||||
|
|
||||||
if (!skipSaveNodeDb) {
|
if (!skipSaveNodeDb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user