reenable charge led and workaround for daytrig

This commit is contained in:
Benjamin Neff 2011-08-12 06:43:01 +02:00 committed by Stefan `Sec` Zehl
parent 198d91a86e
commit 0397197d60
2 changed files with 31 additions and 19 deletions

View File

@ -108,16 +108,24 @@ void tick_default(void) {
EVERY(50,0){ EVERY(50,0){
/*
if(GLOBAL(chargeled)){ if(GLOBAL(chargeled)){
IOCON_PIO1_11 = 0x0; char iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0;
gpioSetDir(RB_LED3, gpioDirection_Output); if(GetChrgStat()) {
if(GetChrgStat()) if (iodir == gpioDirection_Input){
gpioSetValue (RB_LED3, 1); IOCON_PIO1_11 = 0x0;
else gpioSetDir(RB_LED3, gpioDirection_Output);
gpioSetValue (RB_LED3, 0); gpioSetValue (RB_LED3, 1);
LightCheck();
}
} else {
if (iodir != gpioDirection_Input){
gpioSetValue (RB_LED3, 0);
gpioSetDir(RB_LED3, gpioDirection_Input);
IOCON_PIO1_11 = 0x41;
LightCheck();
}
}
}; };
*/
if(GetVoltage()<3600){ if(GetVoltage()<3600){
IOCON_PIO1_11 = 0x0; IOCON_PIO1_11 = 0x0;

View File

@ -15,23 +15,27 @@ void LightCheck(void){
char iodir; char iodir;
iocon=IOCON_PIO1_11; iocon=IOCON_PIO1_11;
// iodir=gpioGetDir(RB_LED3);
//LED3 is on pin 11 //LED3 is on pin 11
iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0; iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0;
gpioSetDir(RB_LED3, gpioDirection_Input); //gpioSetDir(RB_LED3, gpioDirection_Input);
IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG; if (iodir == gpioDirection_Input) {
light-=light/SAMPCT; IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG;
light += (adcRead(7)/2); light-=light/SAMPCT;
light += (adcRead(7)/2);
gpioSetDir(RB_LED3, iodir);
IOCON_PIO1_11=iocon;
if(_isnight && light/SAMPCT>(threshold+RANGE)) gpioSetDir(RB_LED3, iodir);
_isnight=0; IOCON_PIO1_11=iocon;
if(!_isnight && light/SAMPCT<threshold) if(_isnight && light/SAMPCT>(threshold+RANGE))
_isnight=0;
if(!_isnight && light/SAMPCT<threshold)
_isnight=1;
} else {
_isnight=1; _isnight=1;
}
}; };
uint32_t GetLight(void){ uint32_t GetLight(void){