Fix the default background stuff properly.

This commit is contained in:
Stefan `Sec` Zehl 2011-08-01 23:49:41 +02:00
parent 21be4195eb
commit 5a6be961a0
1 changed files with 28 additions and 21 deletions

View File

@ -31,41 +31,49 @@ void main_default(void) {
return; return;
}; };
void queue_setinvert(void){
lcdSetInvert(1);
};
void queue_unsetinvert(void){
lcdSetInvert(0);
};
#define EVERY(x,y) if((ctr+y)%(x/SYSTICKSPEED)==0)
// every 10 ms // every 10 ms
void tick_default(void) { void tick_default(void) {
static int ctr; static int ctr;
ctr++; ctr++;
incTimer(); incTimer();
if(ctr>1000/SYSTICKSPEED){
EVERY(1000,0){
if(!adcMutex){ if(!adcMutex){
VoltageCheck(); VoltageCheck();
LightCheck(); LightCheck();
ctr=0;
}else{ }else{
ctr--; ctr--;
}; };
}; };
if(ctr>100/SYSTICKSPEED){ static char night=0;
if(isNight()){ EVERY(100,2){
if(night!=isNight()){
night=isNight();
if(night){
backlightSetBrightness(GLOBAL(lcdbacklight)); backlightSetBrightness(GLOBAL(lcdbacklight));
lcdSetInvert(0); push_queue(queue_setinvert);
}else{ }else{
backlightSetBrightness(0); backlightSetBrightness(0);
if(GLOBAL(dayinvert)) push_queue(queue_unsetinvert);
lcdSetInvert(1); };
else };
lcdSetInvert(0); };
}
}
if(ctr%(50/SYSTICKSPEED)==0){
if(GetVoltage()<3600 EVERY(50,0){
#ifdef SAFE if(GetVoltage()<3600){
|| GetVoltage() > 10000 // pin not connected
#endif
){
IOCON_PIO1_11 = 0x0; IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output); gpioSetDir(RB_LED3, gpioDirection_Output);
if( (ctr/(50/SYSTICKSPEED))%10 == 1 ) if( (ctr/(50/SYSTICKSPEED))%10 == 1 )
@ -74,6 +82,5 @@ void tick_default(void) {
gpioSetValue (RB_LED3, 0); gpioSetValue (RB_LED3, 0);
}; };
}; };
return; return;
}; };