a funny light show
This commit is contained in:
parent
a4adf6ac27
commit
26db6bf03d
4
canvas.c
4
canvas.c
@ -28,4 +28,6 @@ void canvasShow() {
|
||||
displayDriverTransferCanvas();
|
||||
}
|
||||
|
||||
|
||||
void canvasSetPixel(uint8_t column, uint8_t row, uint8_t color) {
|
||||
*((canvas.canvas) + (row * canvas.width + column)) = (color + 0x80);
|
||||
}
|
||||
|
1
canvas.h
1
canvas.h
@ -17,6 +17,7 @@ typedef struct {
|
||||
void canvasInit();
|
||||
canvas_t *canvasGet();
|
||||
void canvasShow();
|
||||
void canvasSetPixel(uint8_t column, uint8_t row, uint8_t color);
|
||||
|
||||
|
||||
|
||||
|
@ -4,19 +4,84 @@
|
||||
|
||||
|
||||
static canvas_t *canvas;
|
||||
static uint8_t lastPixel = 0xff;
|
||||
static uint8_t currentPixel = 0;
|
||||
|
||||
#define MAX_COLOR 0x0d
|
||||
|
||||
void displayTestExec(void *args) {
|
||||
if (lastPixel != 0xff) {
|
||||
*((canvas->canvas)+lastPixel) = 0x80;
|
||||
static uint8_t last = 0xff;
|
||||
static uint8_t current = 0;
|
||||
static uint8_t color = 0x01;
|
||||
static uint8_t state = 1;
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
for (uint16_t i = 0; i < canvas->height; i++) {
|
||||
canvasSetPixel(last, i, 0);
|
||||
}
|
||||
last = 0xff;
|
||||
state = 1;
|
||||
case 1:
|
||||
if (last != 0xff) {
|
||||
*((canvas->canvas)+last) = 0x80;
|
||||
}
|
||||
|
||||
last = current;
|
||||
*((canvas->canvas)+current) = (color + 0x80);
|
||||
current++;
|
||||
if (current >= canvas->size) {
|
||||
current = 0;
|
||||
state = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
*((canvas->canvas)+last) = 0x80;
|
||||
last = 0xff;
|
||||
state = 3;
|
||||
case 3:
|
||||
if (last != 0xff) {
|
||||
for (uint16_t i = 0; i < canvas->width; i++) {
|
||||
canvasSetPixel(i, last, 0);
|
||||
}
|
||||
}
|
||||
|
||||
last = current;
|
||||
for (uint16_t i = 0; i < canvas->width; i++) {
|
||||
canvasSetPixel(i, current, color);
|
||||
}
|
||||
current++;
|
||||
if (current >= canvas->height) {
|
||||
current = 0;
|
||||
state = 4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (uint16_t i = 0; i < canvas->width; i++) {
|
||||
canvasSetPixel(i, last, 0);
|
||||
}
|
||||
last = 0xff;
|
||||
state = 5;
|
||||
case 5:
|
||||
if (last != 0xff) {
|
||||
for (uint16_t i = 0; i < canvas->height; i++) {
|
||||
canvasSetPixel(last, i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
last = current;
|
||||
for (uint16_t i = 0; i < canvas->height; i++) {
|
||||
canvasSetPixel(current, i, color);
|
||||
}
|
||||
current++;
|
||||
if (current >= canvas->width) {
|
||||
current = 0;
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
lastPixel = currentPixel;
|
||||
*((canvas->canvas)+currentPixel) = 0x81;
|
||||
currentPixel++;
|
||||
if (currentPixel >= canvas->size) {
|
||||
currentPixel = 0;
|
||||
color++;
|
||||
if (color > MAX_COLOR) {
|
||||
color = 1;
|
||||
}
|
||||
|
||||
canvasShow();
|
||||
|
Loading…
x
Reference in New Issue
Block a user