mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-20 03:52:39 +00:00
Optionally set the initial selection for the chooser popup
This commit is contained in:
parent
1d60769f64
commit
e43d8a12a7
@ -134,7 +134,8 @@ extern bool hasUnreadMessage;
|
|||||||
// The banner appears in the center of the screen and disappears after the specified duration
|
// The banner appears in the center of the screen and disappears after the specified duration
|
||||||
|
|
||||||
// Called to trigger a banner with custom message and duration
|
// Called to trigger a banner with custom message and duration
|
||||||
void Screen::showOverlayBanner(const char *message, uint32_t durationMs, uint8_t options, std::function<void(int)> bannerCallback)
|
void Screen::showOverlayBanner(const char *message, uint32_t durationMs, uint8_t options, std::function<void(int)> bannerCallback,
|
||||||
|
int8_t InitialSelected)
|
||||||
{
|
{
|
||||||
// Store the message and set the expiration timestamp
|
// Store the message and set the expiration timestamp
|
||||||
strncpy(NotificationRenderer::alertBannerMessage, message, 255);
|
strncpy(NotificationRenderer::alertBannerMessage, message, 255);
|
||||||
@ -142,7 +143,7 @@ void Screen::showOverlayBanner(const char *message, uint32_t durationMs, uint8_t
|
|||||||
NotificationRenderer::alertBannerUntil = (durationMs == 0) ? 0 : millis() + durationMs;
|
NotificationRenderer::alertBannerUntil = (durationMs == 0) ? 0 : millis() + durationMs;
|
||||||
NotificationRenderer::alertBannerOptions = options;
|
NotificationRenderer::alertBannerOptions = options;
|
||||||
NotificationRenderer::alertBannerCallback = bannerCallback;
|
NotificationRenderer::alertBannerCallback = bannerCallback;
|
||||||
NotificationRenderer::curSelected = 0;
|
NotificationRenderer::curSelected = InitialSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
@ -1316,6 +1317,8 @@ int Screen::handleUIFrameEvent(const UIFrameEvent *event)
|
|||||||
int Screen::handleInputEvent(const InputEvent *event)
|
int Screen::handleInputEvent(const InputEvent *event)
|
||||||
{
|
{
|
||||||
LOG_WARN("event %u", event->inputEvent);
|
LOG_WARN("event %u", event->inputEvent);
|
||||||
|
if (!screenOn)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (NotificationRenderer::isOverlayBannerShowing()) {
|
if (NotificationRenderer::isOverlayBannerShowing()) {
|
||||||
NotificationRenderer::inEvent = event->inputEvent;
|
NotificationRenderer::inEvent = event->inputEvent;
|
||||||
@ -1375,17 +1378,20 @@ int Screen::handleInputEvent(const InputEvent *event)
|
|||||||
#endif
|
#endif
|
||||||
#if HAS_GPS
|
#if HAS_GPS
|
||||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.gps && gps) {
|
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.gps && gps) {
|
||||||
showOverlayBanner("Toggle GPS\nENABLED\nDISABLED", 30000, 2, [](int selected) -> void {
|
showOverlayBanner(
|
||||||
if (selected == 0) {
|
"Toggle GPS\nENABLED\nDISABLED", 30000, 2,
|
||||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
[](int selected) -> void {
|
||||||
playGPSEnableBeep();
|
if (selected == 0) {
|
||||||
gps->enable();
|
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||||
} else if (selected == 1) {
|
playGPSEnableBeep();
|
||||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
|
gps->enable();
|
||||||
playGPSDisableBeep();
|
} else if (selected == 1) {
|
||||||
gps->disable();
|
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
|
||||||
}
|
playGPSDisableBeep();
|
||||||
});
|
gps->disable();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED ? 0 : 1);
|
||||||
#endif
|
#endif
|
||||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.clock) {
|
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.clock) {
|
||||||
showOverlayBanner(
|
showOverlayBanner(
|
||||||
|
@ -285,7 +285,7 @@ class Screen : public concurrency::OSThread
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showOverlayBanner(const char *message, uint32_t durationMs = 3000, uint8_t options = 0,
|
void showOverlayBanner(const char *message, uint32_t durationMs = 3000, uint8_t options = 0,
|
||||||
std::function<void(int)> bannerCallback = NULL);
|
std::function<void(int)> bannerCallback = NULL, int8_t InitialSelected = 0);
|
||||||
|
|
||||||
void startFirmwareUpdateScreen()
|
void startFirmwareUpdateScreen()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user