Fix time updates from client device and potentially incorrect UI frame receiving 'toggle watch face' button tap (#3974)

This commit is contained in:
andrew-moroz
2024-05-26 08:04:31 -04:00
committed by GitHub
parent aa33ad1d58
commit 77cf5c6200
5 changed files with 41 additions and 22 deletions

View File

@@ -1459,18 +1459,13 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
const char *username = node->has_user ? node->user.long_name : "Unknown Name";
static char signalStr[20];
//section here to choose whether to display hops away rather than signal strength if more than 0 hops away.
if(node->hops_away>0)
{
// section here to choose whether to display hops away rather than signal strength if more than 0 hops away.
if (node->hops_away > 0) {
snprintf(signalStr, sizeof(signalStr), "Hops Away: %d", node->hops_away);
}
else
{
} else {
snprintf(signalStr, sizeof(signalStr), "Signal: %d%%", clamp((int)((node->snr + 10) * 5), 0, 100));
}
uint32_t agoSecs = sinceLastSeen(node);
static char lastStr[20];
@@ -2099,6 +2094,10 @@ void Screen::setFrames()
if (error_code)
normalFrames[numframes++] = drawCriticalFaultFrame;
#ifdef T_WATCH_S3
normalFrames[numframes++] = screen->digitalWatchFace ? &Screen::drawDigitalClockFrame : &Screen::drawAnalogClockFrame;
#endif
// If we have a text message - show it next, unless it's a phone message and we aren't using any special modules
if (devicestate.has_rx_text_message && shouldDrawMessage(&devicestate.rx_text_message)) {
normalFrames[numframes++] = drawTextMessageFrame;
@@ -2108,10 +2107,6 @@ void Screen::setFrames()
normalFrames[numframes++] = drawWaypointFrame;
}
#ifdef T_WATCH_S3
normalFrames[numframes++] = screen->digitalWatchFace ? &Screen::drawDigitalClockFrame : &Screen::drawAnalogClockFrame;
#endif
// then all the nodes
// We only show a few nodes in our scrolling list - because meshes with many nodes would have too many screens
size_t numToShow = min(numMeshNodes, 4U);
@@ -2686,8 +2681,10 @@ int Screen::handleInputEvent(const InputEvent *event)
#ifdef T_WATCH_S3
// For the T-Watch, intercept touches to the 'toggle digital/analog watch face' button
if (this->ui->getUiState()->currentFrame == 0 && event->touchX >= 204 && event->touchX <= 240 && event->touchY >= 204 &&
event->touchY <= 240) {
uint8_t watchFaceFrame = error_code ? 1 : 0;
if (this->ui->getUiState()->currentFrame == watchFaceFrame && event->touchX >= 204 && event->touchX <= 240 &&
event->touchY >= 204 && event->touchY <= 240) {
screen->digitalWatchFace = !screen->digitalWatchFace;
setFrames();