Show a time countdown on OLED with option to exit countdown #86
-
Hello, again. I would like to show a minute:second countdown timer on one of my OLED menu screens. Here is the code in my current project: Note: I had trouble pasting the full code so I have removed it from this post (something with the formatting). Here is the project on Wokwi: https://wokwi.com/projects/392458742047807489. As you can see on line 312, I am sending the countdown to the serial monitor. I would like to show that countdown, in large text, on one of the screens after the user picks the Start item from the main menu. Almost like the "Let's Rock" girl rocker graphic in one of the demos except I just need text. To be clear, I don't believe this is the same as a menu item like in most of the examples but it is the result of clicking one of the main menu items. I would also like to let the user know that they can exit the countdown back to the previous menu by pushing the rotary button. Can anyone point me to the area in the docs or an example that might get me moving in the right direction? Thank you for any guidance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
👋 I think I will be able to look into it on a weekend. For starters, this task seems more in line with Blink example rather than Party Hard!, although they bear a lot of similarities in terms of using context. And you probably wouldn't want to use U8g2 built-in key detection here (line 297, myKeyDetector.detect();
if (myKeyDetector.trigger == ROTARY_BUTTON_SIGNAL_KEY) {
menu.context.exit();
} else {
// Code to draw timer on the screen
} |
Beta Was this translation helpful? Give feedback.
Looks good to me! U8g2 do loop looks fine.
If by text sizing you mean larger font for countdown, U8g2 got you covered. You can use any of the supported fonts shipped with U8g2 library (assuming it will fit into memory). Just call
u8g2.setFont();
with font name of your choice before printing to the screen. For example, modified version of do loop can look like this: