Skip to content

Commit 40985db

Browse files
committed
Tweak double-press user button behavior
If there is an active notification, go to it If there are no notifications, go to the first frame update pinned esp8266-oled-ssd1306
1 parent 741b9e0 commit 40985db

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ debug_tool = jlink
6868
; monitor adapter_khz 10000
6969

7070
lib_deps =
71-
https://github.com/meshtastic/esp8266-oled-ssd1306.git#4e724c42f22effdcaa7cdc707a6dceaf9fc10383 ; ESP8266_SSD1306
71+
https://github.com/meshtastic/esp8266-oled-ssd1306.git#22c7eef2025431ba5e1f5f8bd1720cfdcc49cadc ; ESP8266_SSD1306
7272
https://github.com/geeksville/OneButton.git ; OneButton library for non-blocking button debounce
7373
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
7474
https://github.com/meshtastic/arduino-fsm.git#2f106146071fc7bc620e1e8d4b88dc4e0266ce39

src/graphics/Screen.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,16 @@ int Screen::handleTextMessage(const MeshPacket *arg)
13661366

13671367
return 0;
13681368
}
1369+
bool Screen::goToNextNotification() {
1370+
uint32_t frame = ui.getFirstNotifyingFrame();
1371+
if (frame == -1) {
1372+
return false;
1373+
}
1374+
ui.switchToFrame(frame);
1375+
}
13691376

1370-
void Screen::goToNextNotificaiton() {
1371-
ui.switchToFrame(ui.getFirstNotifyingFrame());
1377+
void Screen::goToFirstUIFrame() {
1378+
ui.switchToFrame(0);
13721379
}
13731380

13741381
} // namespace graphics

src/graphics/Screen.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ class Screen : public concurrency::OSThread
196196

197197
int handleStatusUpdate(const meshtastic::Status *arg);
198198
int handleTextMessage(const MeshPacket *arg);
199-
void goToNextNotificaiton();
199+
bool goToNextNotification();
200+
void goToFirstUIFrame();
200201

201202
/// Used to force (super slow) eink displays to draw critical frames
202203
void forceDisplay();

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ class ButtonThread : public OSThread
252252
{
253253
#ifndef NO_ESP32
254254
disablePin();
255-
screen->goToNextNotificaiton();
255+
if (!screen->goToNextNotification()) {
256+
screen->goToFirstUIFrame();
257+
}
256258
#endif
257259
}
258260

0 commit comments

Comments
 (0)