more tests
This commit is contained in:
parent
05de9326d7
commit
19be1a6e48
20
canvas.c
20
canvas.c
@ -5,18 +5,16 @@
|
|||||||
#include "displayDriver.h"
|
#include "displayDriver.h"
|
||||||
|
|
||||||
|
|
||||||
static canvas_t canvas;
|
|
||||||
static uint8_t canvasStorage[CANVAS_WIDTH * CANVAS_HEIGHT];
|
static uint8_t canvasStorage[CANVAS_WIDTH * CANVAS_HEIGHT];
|
||||||
|
const canvas_t canvas = {
|
||||||
|
.height = CANVAS_HEIGHT,
|
||||||
|
.width = CANVAS_WIDTH,
|
||||||
|
.size = CANVAS_WIDTH * CANVAS_HEIGHT,
|
||||||
|
.canvas = canvasStorage
|
||||||
|
};
|
||||||
|
|
||||||
void canvasInit() {
|
void canvasInit() {
|
||||||
canvas.height = CANVAS_HEIGHT;
|
canvasClear();
|
||||||
canvas.width = CANVAS_WIDTH;
|
|
||||||
canvas.size = CANVAS_HEIGHT * CANVAS_WIDTH;
|
|
||||||
canvas.canvas = canvasStorage;
|
|
||||||
|
|
||||||
// Bit7 signals need to be transfered for octet
|
|
||||||
memset(canvasStorage, 0x80, canvas.size);
|
|
||||||
|
|
||||||
displayDriverTransferCanvas();
|
displayDriverTransferCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +26,6 @@ void canvasSetAll(uint8_t color) {
|
|||||||
memset(canvas.canvas, color + 0x80, canvas.size);
|
memset(canvas.canvas, color + 0x80, canvas.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas_t *canvasGet() {
|
|
||||||
return &canvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
void canvasShow() {
|
void canvasShow() {
|
||||||
displayDriverTransferCanvas();
|
displayDriverTransferCanvas();
|
||||||
}
|
}
|
||||||
|
10
canvas.h
10
canvas.h
@ -8,20 +8,20 @@
|
|||||||
#define CANVAS_HEIGHT 11
|
#define CANVAS_HEIGHT 11
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t width;
|
const uint8_t width;
|
||||||
uint8_t height;
|
const uint8_t height;
|
||||||
uint8_t size;
|
const uint8_t size;
|
||||||
uint8_t *canvas;
|
uint8_t * const canvas;
|
||||||
} canvas_t;
|
} canvas_t;
|
||||||
|
|
||||||
void canvasInit();
|
void canvasInit();
|
||||||
void canvasClear();
|
void canvasClear();
|
||||||
void canvasSetAll(uint8_t color);
|
void canvasSetAll(uint8_t color);
|
||||||
canvas_t *canvasGet();
|
|
||||||
void canvasShow();
|
void canvasShow();
|
||||||
void canvasSetPixel(uint8_t column, uint8_t row, uint8_t color);
|
void canvasSetPixel(uint8_t column, uint8_t row, uint8_t color);
|
||||||
void canvasWipeRow(uint8_t row);
|
void canvasWipeRow(uint8_t row);
|
||||||
uint8_t canvasIsRowFilled(uint8_t row);
|
uint8_t canvasIsRowFilled(uint8_t row);
|
||||||
|
|
||||||
|
extern const canvas_t canvas;
|
||||||
|
|
||||||
#endif // _CANVAS_H_
|
#endif // _CANVAS_H_
|
||||||
|
@ -18,12 +18,11 @@ void displayDriverTransferCanvas() {
|
|||||||
// wait for signal waiting for data
|
// wait for signal waiting for data
|
||||||
while ((P1IN & BIT3) == 0);
|
while ((P1IN & BIT3) == 0);
|
||||||
|
|
||||||
canvas_t *canvas = canvasGet();
|
for (uint8_t i = 0; i < canvas.size; i++) {
|
||||||
for (uint8_t i = 0; i < canvas->size; i++) {
|
if ((*((canvas.canvas)+i) & 0x80) != 0) {
|
||||||
if ((*((canvas->canvas)+i) & 0x80) != 0) {
|
*((canvas.canvas)+i) &= ~0x80;
|
||||||
*((canvas->canvas)+i) &= ~0x80;
|
|
||||||
spiSendOctet(i);
|
spiSendOctet(i);
|
||||||
spiSendOctet(*((canvas->canvas)+i));
|
spiSendOctet(*((canvas.canvas)+i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spiSendOctet(0xfe);
|
spiSendOctet(0xfe);
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
#include "PontCoopScheduler.h"
|
#include "PontCoopScheduler.h"
|
||||||
|
|
||||||
|
|
||||||
static canvas_t *canvas;
|
|
||||||
|
|
||||||
#define MAX_COLOR 0x0d
|
#define MAX_COLOR 0x0d
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -31,7 +29,7 @@ void displayTestExec(void *args) {
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
// wipe last column
|
// wipe last column
|
||||||
case e_WIPE_LAST_COLUMN_DOWN:
|
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;
|
||||||
@ -39,31 +37,31 @@ void displayTestExec(void *args) {
|
|||||||
// pixels up
|
// pixels up
|
||||||
case e_PIXELS_UP:
|
case e_PIXELS_UP:
|
||||||
if (last != 0xff) {
|
if (last != 0xff) {
|
||||||
*((canvas->canvas)+last) = 0x80;
|
*((canvas.canvas)+last) = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = current;
|
last = current;
|
||||||
*((canvas->canvas)+current) = (color + 0x80);
|
*((canvas.canvas)+current) = (color + 0x80);
|
||||||
current++;
|
current++;
|
||||||
if (current >= canvas->size) {
|
if (current >= canvas.size) {
|
||||||
current = 0;
|
current = 0;
|
||||||
state = e_WIPE_LAST_PIXEL_UP;
|
state = e_WIPE_LAST_PIXEL_UP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// wipe last pixel
|
// wipe last pixel
|
||||||
case e_WIPE_LAST_PIXEL_UP:
|
case e_WIPE_LAST_PIXEL_UP:
|
||||||
*((canvas->canvas)+last) = 0x80;
|
*((canvas.canvas)+last) = 0x80;
|
||||||
last = 0xff;
|
last = 0xff;
|
||||||
current = canvas->size - 1;
|
current = canvas.size - 1;
|
||||||
state = e_PIXELS_DOWN;
|
state = e_PIXELS_DOWN;
|
||||||
// pixels down
|
// pixels down
|
||||||
case e_PIXELS_DOWN:
|
case e_PIXELS_DOWN:
|
||||||
if (last != 0xff) {
|
if (last != 0xff) {
|
||||||
*((canvas->canvas)+last) = 0x80;
|
*((canvas.canvas)+last) = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = current;
|
last = current;
|
||||||
*((canvas->canvas)+current) = (color + 0x80);
|
*((canvas.canvas)+current) = (color + 0x80);
|
||||||
current--;
|
current--;
|
||||||
if (current < 0) {
|
if (current < 0) {
|
||||||
current = 0;
|
current = 0;
|
||||||
@ -72,45 +70,45 @@ void displayTestExec(void *args) {
|
|||||||
break;
|
break;
|
||||||
// wipe last pixel
|
// wipe last pixel
|
||||||
case e_WIPE_LAST_PIXEL_DOWN:
|
case e_WIPE_LAST_PIXEL_DOWN:
|
||||||
*((canvas->canvas)+last) = 0x80;
|
*((canvas.canvas)+last) = 0x80;
|
||||||
last = 0xff;
|
last = 0xff;
|
||||||
state = e_ROWS_UP;
|
state = e_ROWS_UP;
|
||||||
// rows up
|
// rows up
|
||||||
case e_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last = current;
|
last = current;
|
||||||
for (uint16_t i = 0; i < canvas->width; i++) {
|
for (uint16_t i = 0; i < canvas.width; i++) {
|
||||||
canvasSetPixel(i, current, color);
|
canvasSetPixel(i, current, color);
|
||||||
}
|
}
|
||||||
current++;
|
current++;
|
||||||
if (current >= canvas->height) {
|
if (current >= canvas.height) {
|
||||||
current = 0;
|
current = 0;
|
||||||
state = e_WIPE_LAST_ROW_UP;
|
state = e_WIPE_LAST_ROW_UP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// wipe last row
|
// wipe last row
|
||||||
case e_WIPE_LAST_ROW_UP:
|
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;
|
||||||
current = canvas->height - 1;
|
current = canvas.height - 1;
|
||||||
state = e_ROWS_DOWN;
|
state = e_ROWS_DOWN;
|
||||||
// rows down
|
// rows down
|
||||||
case e_ROWS_DOWN:
|
case e_ROWS_DOWN:
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last = current;
|
last = current;
|
||||||
for (uint16_t i = 0; i < canvas->width; i++) {
|
for (uint16_t i = 0; i < canvas.width; i++) {
|
||||||
canvasSetPixel(i, current, color);
|
canvasSetPixel(i, current, color);
|
||||||
}
|
}
|
||||||
current--;
|
current--;
|
||||||
@ -121,7 +119,7 @@ void displayTestExec(void *args) {
|
|||||||
break;
|
break;
|
||||||
// wipe last row
|
// wipe last row
|
||||||
case e_WIPE_LAST_ROW_DOWN:
|
case e_WIPE_LAST_ROW_DOWN:
|
||||||
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;
|
||||||
@ -129,39 +127,39 @@ void displayTestExec(void *args) {
|
|||||||
// columns up
|
// columns up
|
||||||
case e_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last = current;
|
last = current;
|
||||||
for (uint16_t i = 0; i < canvas->height; i++) {
|
for (uint16_t i = 0; i < canvas.height; i++) {
|
||||||
canvasSetPixel(current, i, color);
|
canvasSetPixel(current, i, color);
|
||||||
}
|
}
|
||||||
current++;
|
current++;
|
||||||
if (current >= canvas->width) {
|
if (current >= canvas.width) {
|
||||||
current = 0;
|
current = 0;
|
||||||
state = e_WIPE_LAST_COLUMN_UP;
|
state = e_WIPE_LAST_COLUMN_UP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// wipe last column
|
// wipe last column
|
||||||
case e_WIPE_LAST_COLUMN_UP:
|
case e_WIPE_LAST_COLUMN_UP:
|
||||||
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;
|
||||||
current = canvas->width - 1;
|
current = canvas.width - 1;
|
||||||
state = e_COLUMNS_DOWN;
|
state = e_COLUMNS_DOWN;
|
||||||
// columns down
|
// columns down
|
||||||
case e_COLUMNS_DOWN:
|
case e_COLUMNS_DOWN:
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last = current;
|
last = current;
|
||||||
for (uint16_t i = 0; i < canvas->height; i++) {
|
for (uint16_t i = 0; i < canvas.height; i++) {
|
||||||
canvasSetPixel(current, i, color);
|
canvasSetPixel(current, i, color);
|
||||||
}
|
}
|
||||||
current--;
|
current--;
|
||||||
@ -181,7 +179,6 @@ void displayTestExec(void *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void displayTestInit() {
|
void displayTestInit() {
|
||||||
canvas = canvasGet();
|
|
||||||
schAdd(displayTestExec, NULL, 0, 50);
|
schAdd(displayTestExec, NULL, 0, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
75
displayTest2.c
Normal file
75
displayTest2.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "canvas.h"
|
||||||
|
#include "PontCoopScheduler.h"
|
||||||
|
#include "displayTest2.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum { e_idle, e_start, e_fillArea, e_placeObject, e_wipeLines_7, e_wipeLines_8, e_wipeLines_9, e_wipeLines_10 } t_state;
|
||||||
|
|
||||||
|
void displayTest2Exec(void *args) {
|
||||||
|
static t_state state = e_start;
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case e_idle:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_start:
|
||||||
|
state = e_fillArea;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_fillArea:
|
||||||
|
memset((canvas.canvas)+(canvas.width*7), 0x81, canvas.width);
|
||||||
|
memset((canvas.canvas)+(canvas.width*8), 0x8d, canvas.width);
|
||||||
|
memset((canvas.canvas)+(canvas.width*9), 0x82, canvas.width);
|
||||||
|
memset((canvas.canvas)+(canvas.width*10), 0x88, canvas.width);
|
||||||
|
for (uint8_t i = 0; i < canvas.width; i++) {
|
||||||
|
if (i != 4 && i != 5) {
|
||||||
|
canvasSetPixel(i, 6, 0x05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state = e_placeObject;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_placeObject:
|
||||||
|
canvasSetPixel(4, 0, 0x04);
|
||||||
|
canvasSetPixel(5, 0, 0x04);
|
||||||
|
canvasSetPixel(6, 0, 0x04);
|
||||||
|
canvasSetPixel(5, 1, 0x04);
|
||||||
|
state = e_wipeLines_7;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_wipeLines_7:
|
||||||
|
canvasWipeRow(7);
|
||||||
|
state = e_wipeLines_8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_wipeLines_8:
|
||||||
|
canvasWipeRow(8);
|
||||||
|
state = e_wipeLines_9;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_wipeLines_9:
|
||||||
|
canvasWipeRow(9);
|
||||||
|
state = e_wipeLines_10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_wipeLines_10:
|
||||||
|
canvasWipeRow(10);
|
||||||
|
state = e_idle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
state = e_idle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvasShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayTest2Init() {
|
||||||
|
schAdd(displayTest2Exec, NULL, 0, 5000);
|
||||||
|
}
|
||||||
|
|
11
displayTest2.h
Normal file
11
displayTest2.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _DISPLAY_TEST_2_H_
|
||||||
|
#define _DISPLAY_TEST_2_H_
|
||||||
|
|
||||||
|
|
||||||
|
void displayTest2Init();
|
||||||
|
void displayTest2Exec();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _DISPLAY_TEST_2_H_
|
78
displayTest3.c
Normal file
78
displayTest3.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "canvas.h"
|
||||||
|
#include "PontCoopScheduler.h"
|
||||||
|
#include "displayTest3.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum { e_idle, e_delay, e_start, e_fillArea, e_placeObject, e_preWipeLines, e_wipeLines } t_state;
|
||||||
|
|
||||||
|
void displayTest3Exec(void *args) {
|
||||||
|
static t_state state = e_start;
|
||||||
|
static uint8_t wipeLineHelper = 0;
|
||||||
|
|
||||||
|
ledBlueToggle();
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case e_idle:
|
||||||
|
state = e_delay;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_delay:
|
||||||
|
canvasClear();
|
||||||
|
state = e_start;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_start:
|
||||||
|
state = e_fillArea;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_fillArea:
|
||||||
|
memset((canvas.canvas)+(canvas.width*7), 0x84, canvas.width);
|
||||||
|
memset((canvas.canvas)+(canvas.width*8), 0x8d, canvas.width);
|
||||||
|
memset((canvas.canvas)+(canvas.width*9), 0x82, canvas.width);
|
||||||
|
memset((canvas.canvas)+(canvas.width*10), 0x88, canvas.width);
|
||||||
|
for (uint8_t i = 0; i < canvas.width; i++) {
|
||||||
|
if (i != 4 && i != 5) {
|
||||||
|
canvasSetPixel(i, 6, 0x05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state = e_placeObject;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_placeObject:
|
||||||
|
canvasSetPixel(4, 0, 0x04);
|
||||||
|
canvasSetPixel(5, 0, 0x04);
|
||||||
|
canvasSetPixel(6, 0, 0x04);
|
||||||
|
canvasSetPixel(5, 1, 0x04);
|
||||||
|
state = e_preWipeLines;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case e_preWipeLines:
|
||||||
|
wipeLineHelper = 0;
|
||||||
|
state = e_wipeLines;
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case e_wipeLines:
|
||||||
|
if (canvasIsRowFilled(wipeLineHelper) == 1) {
|
||||||
|
canvasWipeRow(wipeLineHelper);
|
||||||
|
}
|
||||||
|
wipeLineHelper++;
|
||||||
|
if (wipeLineHelper >= canvas.height) {
|
||||||
|
state = e_idle;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
state = e_idle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvasShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayTest3Init() {
|
||||||
|
schAdd(displayTest3Exec, NULL, 0, 1000);
|
||||||
|
}
|
||||||
|
|
11
displayTest3.h
Normal file
11
displayTest3.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _DISPLAY_TEST_3_H_
|
||||||
|
#define _DISPLAY_TEST_3_H_
|
||||||
|
|
||||||
|
|
||||||
|
void displayTest3Init();
|
||||||
|
void displayTest3Exec();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _DISPLAY_TEST_3_H_
|
Reference in New Issue
Block a user