Generate blinking pattern based on LED index

This commit is contained in:
fruchti 2020-07-16 18:37:15 +02:00
parent ddc5c5f1f1
commit 40d303f7b5
3 changed files with 50 additions and 6 deletions

View file

@ -1 +1 @@
288
297

View file

@ -13,19 +13,61 @@ int main(void)
LED_Init();
uint8_t *data = (uint8_t*)LED_PixelData;
unsigned int counter = 0;
const unsigned int blink_period = 1000;
const unsigned int group_size = 6;
while(1)
{
__WFI();
LightSensor_Poll();
uint8_t brightness = LightSensor_RelativeBrightness * 255;
if(LED_FrameFlag)
{
for(int i = 0; i < LED_COLUMNS * LED_ROWS; i++)
memset(LED_PixelData, 0, sizeof(LED_PixelData));
for(unsigned int i = 0; i < LED_COUNT; i++)
{
data[i] = brightness;
uint8_t brightness = 0;
if((counter / blink_period) <= (i % group_size))
{
if(counter / (blink_period / 2) % 2)
{
brightness = 30;
}
}
switch(i / group_size)
{
case 0:
LED_PixelData[i].r = brightness;
break;
case 1:
LED_PixelData[i].g = brightness;
break;
case 2:
LED_PixelData[i].b = brightness;
break;
case 3:
LED_PixelData[i].r = brightness;
LED_PixelData[i].g = brightness;
break;
case 4:
LED_PixelData[i].g = brightness;
LED_PixelData[i].b = brightness;
break;
case 5:
LED_PixelData[i].b = brightness;
LED_PixelData[i].r = brightness;
break;
}
counter++;
if(counter > blink_period * (group_size + 2))
{
counter = 0;
}
}
LED_FrameFlag = false;
LED_Commit();
}

View file

@ -1,5 +1,7 @@
#pragma once
#include <string.h>
#include "stm32f030x6.h"
#include "buildid.h"
#include "led.h"