mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
add basic alert system to companion UI
Adds `_alert[80]` which can be set along with `_needs_refresh` to trigger a simple on screen alert that lasts 1s at this time. Implements POC with double press to advert action
This commit is contained in:
parent
e0483c0c82
commit
da5b0f8524
2 changed files with 17 additions and 1 deletions
|
|
@ -162,7 +162,16 @@ void UITask::renderCurrScreen() {
|
||||||
if (_display == NULL) return; // assert() ??
|
if (_display == NULL) return; // assert() ??
|
||||||
|
|
||||||
char tmp[80];
|
char tmp[80];
|
||||||
if (_origin[0] && _msg[0]) { // message preview
|
if (_alert[0]) {
|
||||||
|
uint16_t textWidth = _display->getTextWidth(_alert);
|
||||||
|
_display->setCursor((_display->width() - textWidth) / 2, 22);
|
||||||
|
_display->setTextSize(1.4);
|
||||||
|
_display->setColor(DisplayDriver::GREEN);
|
||||||
|
_display->print(_alert);
|
||||||
|
_alert[0] = 0;
|
||||||
|
_need_refresh = true;
|
||||||
|
return;
|
||||||
|
} else if (_origin[0] && _msg[0]) { // message preview
|
||||||
// render message preview
|
// render message preview
|
||||||
_display->setCursor(0, 0);
|
_display->setCursor(0, 0);
|
||||||
_display->setTextSize(1);
|
_display->setTextSize(1);
|
||||||
|
|
@ -343,11 +352,17 @@ void UITask::handleButtonShortPress() {
|
||||||
void UITask::handleButtonDoublePress() {
|
void UITask::handleButtonDoublePress() {
|
||||||
MESH_DEBUG_PRINTLN("UITask: double press triggered, sending advert");
|
MESH_DEBUG_PRINTLN("UITask: double press triggered, sending advert");
|
||||||
// ADVERT
|
// ADVERT
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
soundBuzzer(UIEventType::ack);
|
||||||
|
#endif
|
||||||
if (the_mesh.advert()) {
|
if (the_mesh.advert()) {
|
||||||
MESH_DEBUG_PRINTLN("Advert sent!");
|
MESH_DEBUG_PRINTLN("Advert sent!");
|
||||||
|
sprintf(_alert, "Advert sent!");
|
||||||
} else {
|
} else {
|
||||||
MESH_DEBUG_PRINTLN("Advert failed!");
|
MESH_DEBUG_PRINTLN("Advert failed!");
|
||||||
|
sprintf(_alert, "Advert failed..");
|
||||||
}
|
}
|
||||||
|
_need_refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::handleButtonTriplePress() {
|
void UITask::handleButtonTriplePress() {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class UITask {
|
||||||
char _version_info[32];
|
char _version_info[32];
|
||||||
char _origin[62];
|
char _origin[62];
|
||||||
char _msg[80];
|
char _msg[80];
|
||||||
|
char _alert[80];
|
||||||
int _msgcount;
|
int _msgcount;
|
||||||
bool _need_refresh = true;
|
bool _need_refresh = true;
|
||||||
bool _displayWasOn = false; // Track display state before button press
|
bool _displayWasOn = false; // Track display state before button press
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue