up and down

This commit is contained in:
Wolfgang Hottgenroth 2024-03-08 15:54:34 +01:00
parent fb16cfaa6f
commit d3846c3e08

View File

@ -7,20 +7,37 @@ static canvas_t *canvas;
#define MAX_COLOR 0x0d #define MAX_COLOR 0x0d
typedef enum {
e_WIPE_LAST_COLUMN_DOWN,
e_PIXELS_UP,
e_WIPE_LAST_PIXEL_UP,
e_PIXELS_DOWN,
e_WIPE_LAST_PIXEL_DOWN,
e_ROWS_UP,
e_WIPE_LAST_ROW_UP,
e_ROWS_DOWN,
e_WIPE_LAST_ROW_DOWN,
e_COLUMNS_UP,
e_WIPE_LAST_COLUMN_UP,
e_COLUMNS_DOWN
} t_State;
void displayTestExec(void *args) { void displayTestExec(void *args) {
static uint8_t last = 0xff; static int16_t last = 0xff;
static uint8_t current = 0; static int16_t current = 0;
static uint8_t color = 0x01; static uint8_t color = 0x01;
static uint8_t state = 1; static t_State state = e_PIXELS_UP;
switch (state) { switch (state) {
case 0: // wipe last column
case e_WIPE_LAST_COLUMN_DOWN:
for (uint16_t i = 0; i < canvas->height; i++) { for (uint16_t i = 0; i < canvas->height; i++) {
canvasSetPixel(last, i, 0); canvasSetPixel(last, i, 0);
} }
last = 0xff; last = 0xff;
state = 1; state = e_PIXELS_UP;
case 1: // pixels up
case e_PIXELS_UP:
if (last != 0xff) { if (last != 0xff) {
*((canvas->canvas)+last) = 0x80; *((canvas->canvas)+last) = 0x80;
} }
@ -30,14 +47,36 @@ void displayTestExec(void *args) {
current++; current++;
if (current >= canvas->size) { if (current >= canvas->size) {
current = 0; current = 0;
state = 2; state = e_WIPE_LAST_PIXEL_UP;
} }
break; break;
case 2: // wipe last pixel
case e_WIPE_LAST_PIXEL_UP:
*((canvas->canvas)+last) = 0x80; *((canvas->canvas)+last) = 0x80;
last = 0xff; last = 0xff;
state = 3; current = canvas->size - 1;
case 3: state = e_PIXELS_DOWN;
// pixels down
case e_PIXELS_DOWN:
if (last != 0xff) {
*((canvas->canvas)+last) = 0x80;
}
last = current;
*((canvas->canvas)+current) = (color + 0x80);
current--;
if (current < 0) {
current = 0;
state = e_WIPE_LAST_PIXEL_DOWN;
}
break;
// wipe last pixel
case e_WIPE_LAST_PIXEL_DOWN:
*((canvas->canvas)+last) = 0x80;
last = 0xff;
state = e_ROWS_UP;
// rows up
case e_ROWS_UP:
if (last != 0xff) { if (last != 0xff) {
for (uint16_t i = 0; i < canvas->width; i++) { for (uint16_t i = 0; i < canvas->width; i++) {
canvasSetPixel(i, last, 0); canvasSetPixel(i, last, 0);
@ -51,16 +90,44 @@ void displayTestExec(void *args) {
current++; current++;
if (current >= canvas->height) { if (current >= canvas->height) {
current = 0; current = 0;
state = 4; state = e_WIPE_LAST_ROW_UP;
} }
break; break;
case 4: // wipe last row
case e_WIPE_LAST_ROW_UP:
for (uint16_t i = 0; i < canvas->width; i++) { for (uint16_t i = 0; i < canvas->width; i++) {
canvasSetPixel(i, last, 0); canvasSetPixel(i, last, 0);
} }
last = 0xff; last = 0xff;
state = 5; current = canvas->height - 1;
case 5: state = e_ROWS_DOWN;
// rows down
case e_ROWS_DOWN:
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 < 0) {
current = 0;
state = e_WIPE_LAST_ROW_DOWN;
}
break;
// wipe last row
case e_WIPE_LAST_ROW_DOWN:
for (uint16_t i = 0; i < canvas->width; i++) {
canvasSetPixel(i, last, 0);
}
last = 0xff;
state = e_COLUMNS_UP;
// columns up
case e_COLUMNS_UP:
if (last != 0xff) { if (last != 0xff) {
for (uint16_t i = 0; i < canvas->height; i++) { for (uint16_t i = 0; i < canvas->height; i++) {
canvasSetPixel(last, i, 0); canvasSetPixel(last, i, 0);
@ -74,7 +141,33 @@ void displayTestExec(void *args) {
current++; current++;
if (current >= canvas->width) { if (current >= canvas->width) {
current = 0; current = 0;
state = 0; state = e_WIPE_LAST_COLUMN_UP;
}
break;
// wipe last column
case e_WIPE_LAST_COLUMN_UP:
for (uint16_t i = 0; i < canvas->height; i++) {
canvasSetPixel(last, i, 0);
}
last = 0xff;
current = canvas->width - 1;
state = e_COLUMNS_DOWN;
// columns down
case e_COLUMNS_DOWN:
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 < 0) {
current = 0;
state = e_WIPE_LAST_COLUMN_DOWN;
} }
break; break;
} }