sparkling
This commit is contained in:
parent
087af69592
commit
8eb06c8eab
2 changed files with 23 additions and 26 deletions
40
App/App.cpp
40
App/App.cpp
|
@ -12,8 +12,9 @@
|
|||
#include "gpio.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "App/Pixel.h"
|
||||
#include "App/LedBuffers.h"
|
||||
#include "Pixel.h"
|
||||
#include "LedBuffers.h"
|
||||
#include "Sparkle.h"
|
||||
|
||||
void convert(uint8_t *src, uint8_t *dst, uint16_t size)
|
||||
{
|
||||
|
@ -31,38 +32,31 @@ void convert(uint8_t *src, uint8_t *dst, uint16_t size)
|
|||
|
||||
extern "C" void App()
|
||||
{
|
||||
#define BRIGHTNESS 4
|
||||
#define DELAY 10
|
||||
|
||||
g_ledBits[sizeof(g_ledBits)-1] = 0;
|
||||
memset(g_pixels, 0, sizeof(g_pixels));
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
for(uint16_t idx=0; idx < NUMPIXELS; idx++)
|
||||
{
|
||||
if(idx % 3 == 0) g_pixels[idx].r = BRIGHTNESS;
|
||||
else if(idx % 3 == 1) g_pixels[idx].g = BRIGHTNESS;
|
||||
else g_pixels[idx].b = BRIGHTNESS;
|
||||
|
||||
convert((uint8_t*)g_pixels, g_ledBits, sizeof(g_pixels));
|
||||
|
||||
HAL_SPI_Transmit_DMA(&hspi1, g_ledBits, sizeof(g_ledBits));
|
||||
while(!g_done);
|
||||
HAL_Delay(DELAY);
|
||||
}
|
||||
Sparkle s;
|
||||
Pixel_t color = {0xff, 0xff, 0xff};
|
||||
Pixel_t fadeSpeed = {1,2,3};
|
||||
|
||||
for(uint16_t idx=0; idx < NUMPIXELS; idx++)
|
||||
{
|
||||
if(idx % 3 == 0) g_pixels[idx].r = 0;
|
||||
else if(idx % 3 == 1) g_pixels[idx].g = 0;
|
||||
else g_pixels[idx].b = 0;
|
||||
|
||||
s.Start(&g_pixels[idx], color, fadeSpeed);
|
||||
convert((uint8_t*)g_pixels, g_ledBits, sizeof(g_pixels));
|
||||
|
||||
HAL_SPI_Transmit_DMA(&hspi1, g_ledBits, sizeof(g_ledBits));
|
||||
while(!g_done);
|
||||
HAL_Delay(DELAY);
|
||||
HAL_Delay(1);
|
||||
|
||||
do {
|
||||
s.Step();
|
||||
convert((uint8_t*)g_pixels, g_ledBits, sizeof(g_pixels));
|
||||
HAL_SPI_Transmit_DMA(&hspi1, g_ledBits, sizeof(g_ledBits));
|
||||
while(!g_done);
|
||||
HAL_Delay(1);
|
||||
} while( static_cast<Pixel_t*>( s ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue