diff --git a/firmware/applications/final.c b/firmware/applications/final.c index c2f757e..3e3bfa5 100644 --- a/firmware/applications/final.c +++ b/firmware/applications/final.c @@ -13,9 +13,19 @@ void init_nick(); void fancyNickname(); +#include "lcd/allfonts.h" +void forLoadables(int i){ + if(i){ + lcdSetPixel(0,0); + font=&Font_Invaders; + }; +}; + void main_final(void) { //checkFirstBoot(); init_final(); + forLoadables(0); + menuflags|=MENU_TIMEOUT; while(1){ #ifndef FINAL diff --git a/firmware/basic/basic.h b/firmware/basic/basic.h index df3f2c9..aa0e5c4 100644 --- a/firmware/basic/basic.h +++ b/firmware/basic/basic.h @@ -152,6 +152,7 @@ char isNight(void); uint8_t getInput(void); uint8_t getInputRaw(void); uint8_t getInputWait(void); +uint8_t getInputWaitTimeout(int timeout); void getInputWaitRelease(void); // stringin.c @@ -177,6 +178,9 @@ struct MENU { struct MENU_DEF entries[]; }; +#define MENU_TIMEOUT (1<<0) +extern uint8_t menuflags; + void handleMenu(const struct MENU *the_menu); diff --git a/firmware/basic/keyin.c b/firmware/basic/keyin.c index d4983c5..2a8562d 100644 --- a/firmware/basic/keyin.c +++ b/firmware/basic/keyin.c @@ -50,6 +50,18 @@ uint8_t getInputWait(void) { return key; }; +uint8_t getInputWaitTimeout(int timeout) { + uint8_t key; + int end=_timectr+timeout*(1000/SYSTICKSPEED); + while ((key=getInputRaw())==BTN_NONE){ + if(_timectr>end) + break; + work_queue(); + }; + delayms_queue(10); /* Delay a little more to debounce */ + return key; +}; + void getInputWaitRelease(void) { while (getInputRaw()!=BTN_NONE) work_queue(); diff --git a/firmware/basic/menu.c b/firmware/basic/menu.c index 253bb55..97b0b60 100644 --- a/firmware/basic/menu.c +++ b/firmware/basic/menu.c @@ -6,6 +6,8 @@ /**************************************************************************/ +uint8_t menuflags=0; + void handleMenu(const struct MENU *the_menu) { uint8_t back = 0; int8_t menuselection = 0; @@ -38,7 +40,7 @@ void handleMenu(const struct MENU *the_menu) { } lcdRefresh(); - switch (getInputWait()) { + switch (getInputWaitTimeout((menuflags&MENU_TIMEOUT)?15:0)) { case BTN_UP: menuselection--; if (menuselection < current_offset) { @@ -78,12 +80,13 @@ void handleMenu(const struct MENU *the_menu) { getInputWait(); break; + case BTN_NONE: /* timeout */ + return; default: - /* no button pressed */ + /* NOTREACHED */ break; } getInputWaitRelease(); - } return; }