Add basic time-based light sensor code
This commit is contained in:
parent
dc7bdb006c
commit
6d63b76a02
6 changed files with 158 additions and 9 deletions
17
src/main.c
17
src/main.c
|
|
@ -8,25 +8,26 @@ int main(void)
|
|||
__asm__ volatile("nop");
|
||||
}
|
||||
|
||||
LightSensor_Init();
|
||||
LED_Init();
|
||||
|
||||
int ct = 0;
|
||||
uint8_t *data = (uint8_t*)LED_PixelData;
|
||||
while(1)
|
||||
{
|
||||
LightSensor_Poll();
|
||||
uint8_t brightness = LightSensor_RelativeBrightness * 255;
|
||||
if(LED_FrameFlag)
|
||||
{
|
||||
LED_FrameFlag = false;
|
||||
data[ct]++;
|
||||
data[ct] = brightness;
|
||||
LED_Commit();
|
||||
if(data[ct] == 255)
|
||||
|
||||
ct += 3;
|
||||
if(ct >= LED_COLUMNS * LED_ROWS)
|
||||
{
|
||||
ct += 3;
|
||||
if(ct >= LED_COLUMNS * LED_ROWS)
|
||||
{
|
||||
ct -= LED_COLUMNS * LED_ROWS;
|
||||
ct += 1;
|
||||
}
|
||||
ct -= LED_COLUMNS * LED_ROWS;
|
||||
ct += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue