More powersaving/queue-working
This commit is contained in:
parent
c896b4645e
commit
f79d3b49f4
|
@ -93,7 +93,6 @@ int lcdInitConfig(){
|
|||
|
||||
void main_default(void) {
|
||||
systickInit(10);
|
||||
randomInit();
|
||||
|
||||
if(getInputRaw()==BTN_ENTER){
|
||||
ISPandReset();
|
||||
|
@ -105,8 +104,8 @@ void main_default(void) {
|
|||
getInputWait();
|
||||
}else{
|
||||
lcdDisplay();
|
||||
delayms(300);
|
||||
};
|
||||
randomInit();
|
||||
|
||||
return;
|
||||
};
|
||||
|
@ -145,4 +144,3 @@ void tick_default(void) {
|
|||
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ void s_ticks(void) {
|
|||
|
||||
void b_one(void){
|
||||
gpioSetValue (RB_LED2, 0);
|
||||
delayms(100);
|
||||
delayms_power(100);
|
||||
gpioSetValue (RB_LED2, 1);
|
||||
delayms(100);
|
||||
delayms_power(1000);
|
||||
gpioSetValue (RB_LED2, 0);
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ void do_qone(void) {
|
|||
};
|
||||
|
||||
void do_q(void) {
|
||||
idle_queue(500);
|
||||
delayms_queue(500);
|
||||
};
|
||||
|
||||
void push_qone(void) {
|
||||
|
|
|
@ -25,7 +25,7 @@ void work_queue(void){
|
|||
elem();
|
||||
};
|
||||
|
||||
void idle_queue(uint32_t ms){
|
||||
void delayms_queue(uint32_t ms){
|
||||
int end=_timectr+ms/10;
|
||||
do {
|
||||
if (the_queue.qstart == the_queue.qend){
|
||||
|
@ -36,6 +36,13 @@ void idle_queue(uint32_t ms){
|
|||
} while (end >_timectr);
|
||||
};
|
||||
|
||||
void delayms_power(uint32_t ms){
|
||||
do {
|
||||
ms-=10;
|
||||
__asm volatile ("WFI");
|
||||
} while(ms>10);
|
||||
};
|
||||
|
||||
int push_queue(void (*new)(void)){
|
||||
int end;
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ extern QUEUE the_queue;
|
|||
extern volatile uint32_t _timectr;
|
||||
|
||||
void work_queue(void);
|
||||
void idle_queue(uint32_t delayms);
|
||||
void delayms_queue(uint32_t delayms);
|
||||
void delayms_power(uint32_t delayms);
|
||||
int push_queue(void (*new)(void));
|
||||
int magic(void *new);
|
||||
#define incTimer(void) do{_timectr++;}while(0);
|
||||
|
|
|
@ -31,8 +31,13 @@ uint8_t getInput(void) {
|
|||
uint8_t key = BTN_NONE;
|
||||
|
||||
key=getInputRaw();
|
||||
/* XXX: we should probably debounce the joystick.
|
||||
Any ideas how to do this properly?
|
||||
For now wait for any release.
|
||||
*/
|
||||
if(key != BTN_NONE)
|
||||
while(key==getInputRaw()); // Wait for any release
|
||||
while(key==getInputRaw())
|
||||
work_queue();
|
||||
|
||||
return key;
|
||||
}
|
||||
|
@ -41,6 +46,7 @@ uint8_t getInputWait(void) {
|
|||
uint8_t key;
|
||||
while ((key=getInput())==BTN_NONE)
|
||||
work_queue();
|
||||
delayms_queue(10); /* Delay a little more to debounce */
|
||||
return key;
|
||||
};
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ int selectFile(char *filename, char *extension)
|
|||
}
|
||||
lcdRefresh();
|
||||
key=getInputWait();
|
||||
delayms(20);
|
||||
if( key==BTN_DOWN ){
|
||||
if( selected < 6 ){
|
||||
selected++;
|
||||
|
|
Loading…
Reference in New Issue