Add power-down mode for LED driver
This commit is contained in:
parent
ee5a5b9f6c
commit
38d3a3846b
5 changed files with 62 additions and 1 deletions
13
src/main.c
13
src/main.c
|
|
@ -5,6 +5,8 @@ int main(void)
|
|||
LED_InitShiftRegister();
|
||||
LightSensor_Init();
|
||||
|
||||
bool powered_down = false;
|
||||
|
||||
// Delay a bit to make programming easier
|
||||
for(unsigned int i = 0; i < 1000; i++)
|
||||
{
|
||||
|
|
@ -18,6 +20,17 @@ int main(void)
|
|||
__WFI();
|
||||
LightSensor_Poll();
|
||||
Animation_Poll();
|
||||
|
||||
if(LightSensor_RelativeBrightness == 0 && !powered_down)
|
||||
{
|
||||
LED_Suspend();
|
||||
powered_down = true;
|
||||
}
|
||||
if(powered_down && LightSensor_RelativeBrightness > 0)
|
||||
{
|
||||
LED_WakeUp();
|
||||
powered_down = false;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue