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){
/*
if(GLOBAL(chargeled)){
IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output);
if(GetChrgStat())
gpioSetValue (RB_LED3, 1);
else
gpioSetValue (RB_LED3, 0);
char iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0;
if(GetChrgStat()) {
if (iodir == gpioDirection_Input){
IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output);
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){
IOCON_PIO1_11 = 0x0;

View File

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