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)){
char iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0;
if(GetChrgStat()) {
if (iodir == gpioDirection_Input){
IOCON_PIO1_11 = 0x0; IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output); gpioSetDir(RB_LED3, gpioDirection_Output);
if(GetChrgStat())
gpioSetValue (RB_LED3, 1); gpioSetValue (RB_LED3, 1);
else LightCheck();
}
} else {
if (iodir != gpioDirection_Input){
gpioSetValue (RB_LED3, 0); 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,11 +15,11 @@ 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);
if (iodir == gpioDirection_Input) {
IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG; IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG;
light-=light/SAMPCT; light-=light/SAMPCT;
light += (adcRead(7)/2); light += (adcRead(7)/2);
@ -32,6 +32,10 @@ void LightCheck(void){
if(!_isnight && light/SAMPCT<threshold) if(!_isnight && light/SAMPCT<threshold)
_isnight=1; _isnight=1;
} else {
_isnight=1;
}
}; };
uint32_t GetLight(void){ uint32_t GetLight(void){