mini canvas
This commit is contained in:
parent
8597a9f736
commit
474fce2278
@ -13,6 +13,12 @@ const canvas_t canvas = {
|
|||||||
.canvas = canvasStorage
|
.canvas = canvasStorage
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint8_t miniCanvasStorage[MINI_CANVAS_WIDTH * MINI_CANVAS_HEIGHT];
|
||||||
|
const canvas_t miniCanvas = {
|
||||||
|
.height = MINI_CANVAS_HEIGHT,
|
||||||
|
.width = MINI_CANVAS_WIDTH,
|
||||||
|
.canvas = miniCanvasStorage
|
||||||
|
};
|
||||||
|
|
||||||
inline static void spiSendOctet(uint8_t v) {
|
inline static void spiSendOctet(uint8_t v) {
|
||||||
// wait for TX buffer empty
|
// wait for TX buffer empty
|
||||||
@ -32,6 +38,13 @@ void canvasShow() {
|
|||||||
spiSendOctet(*((canvas.canvas)+i));
|
spiSendOctet(*((canvas.canvas)+i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (uint8_t i = 0; i < (MINI_CANVAS_WIDTH*MINI_CANVAS_HEIGHT); i++) {
|
||||||
|
if ((*((miniCanvas.canvas)+i) & 0x80) != 0) {
|
||||||
|
*((miniCanvas.canvas)+i) &= ~0x80;
|
||||||
|
spiSendOctet(i + (CANVAS_HEIGHT*CANVAS_WIDTH));
|
||||||
|
spiSendOctet(*((miniCanvas.canvas)+i));
|
||||||
|
}
|
||||||
|
}
|
||||||
spiSendOctet(0xfe);
|
spiSendOctet(0xfe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +76,7 @@ void canvasInit() {
|
|||||||
|
|
||||||
|
|
||||||
canvasClear();
|
canvasClear();
|
||||||
|
miniCanvasClear();
|
||||||
canvasShow();
|
canvasShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,14 +84,22 @@ void canvasClear() {
|
|||||||
memset(canvas.canvas, 0x80, CANVAS_WIDTH*CANVAS_HEIGHT);
|
memset(canvas.canvas, 0x80, CANVAS_WIDTH*CANVAS_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void canvasSetAll(uint8_t color) {
|
void miniCanvasClear() {
|
||||||
memset(canvas.canvas, color + 0x80, CANVAS_WIDTH*CANVAS_HEIGHT);
|
memset(miniCanvas.canvas, 0x80, MINI_CANVAS_WIDTH*MINI_CANVAS_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void canvasSetAll(uint8_t color) {
|
||||||
|
// memset(canvas.canvas, color + 0x80, CANVAS_WIDTH*CANVAS_HEIGHT);
|
||||||
|
//}
|
||||||
|
|
||||||
void canvasSetPixel(uint8_t column, uint8_t row, uint8_t color) {
|
void canvasSetPixel(uint8_t column, uint8_t row, uint8_t color) {
|
||||||
*((canvas.canvas) + (row * canvas.width + column)) = (color + 0x80);
|
*((canvas.canvas) + (row * canvas.width + column)) = (color + 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void miniCanvasSetPixel(uint8_t column, uint8_t row, uint8_t color) {
|
||||||
|
*((miniCanvas.canvas) + (row * miniCanvas.width + column)) = (color + 0x80);
|
||||||
|
}
|
||||||
|
|
||||||
void canvasWipeRow(uint8_t row) {
|
void canvasWipeRow(uint8_t row) {
|
||||||
memmove(((canvas.canvas)+canvas.width), canvas.canvas, canvas.width*row);
|
memmove(((canvas.canvas)+canvas.width), canvas.canvas, canvas.width*row);
|
||||||
for (uint8_t i = 10; i < canvas.width*(row+1); i++) {
|
for (uint8_t i = 10; i < canvas.width*(row+1); i++) {
|
||||||
|
@ -17,9 +17,11 @@ typedef struct {
|
|||||||
|
|
||||||
void canvasInit();
|
void canvasInit();
|
||||||
void canvasClear();
|
void canvasClear();
|
||||||
void canvasSetAll(uint8_t color);
|
void miniCanvasClear();
|
||||||
|
//void canvasSetAll(uint8_t color);
|
||||||
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 miniCanvasSetPixel(uint8_t column, uint8_t row, uint8_t color);
|
||||||
uint8_t canvasIsPixelFree(uint8_t column, uint8_t row);
|
uint8_t canvasIsPixelFree(uint8_t column, uint8_t row);
|
||||||
void canvasWipeRow(uint8_t row);
|
void canvasWipeRow(uint8_t row);
|
||||||
uint8_t canvasIsRowFilled(uint8_t row);
|
uint8_t canvasIsRowFilled(uint8_t row);
|
||||||
|
@ -423,7 +423,25 @@ static uint8_t move(direction_t direction) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t stoneDraw() {
|
void nextStoneDraw() {
|
||||||
|
miniCanvasClear();
|
||||||
|
miniCanvasSetPixel(motions[nextShape].draw[0].x,
|
||||||
|
motions[nextShape].draw[0].y,
|
||||||
|
motions[nextShape].color);
|
||||||
|
miniCanvasSetPixel(motions[nextShape].draw[1].x,
|
||||||
|
motions[nextShape].draw[1].y,
|
||||||
|
motions[nextShape].color);
|
||||||
|
miniCanvasSetPixel(motions[nextShape].draw[2].x,
|
||||||
|
motions[nextShape].draw[2].y,
|
||||||
|
motions[nextShape].color);
|
||||||
|
miniCanvasSetPixel(motions[nextShape].draw[3].x,
|
||||||
|
motions[nextShape].draw[3].y,
|
||||||
|
motions[nextShape].color);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t stoneDraw() {
|
||||||
|
nextStoneDraw();
|
||||||
|
|
||||||
uint8_t res = 0;
|
uint8_t res = 0;
|
||||||
// check if the pixels the shape should be drawn at are free
|
// check if the pixels the shape should be drawn at are free
|
||||||
if (canvasIsPixelFree(stone.x + motions[stone.shape].draw[0].x,
|
if (canvasIsPixelFree(stone.x + motions[stone.shape].draw[0].x,
|
||||||
|
@ -4,4 +4,7 @@
|
|||||||
#define CANVAS_WIDTH 10
|
#define CANVAS_WIDTH 10
|
||||||
#define CANVAS_HEIGHT 20
|
#define CANVAS_HEIGHT 20
|
||||||
|
|
||||||
|
#define MINI_CANVAS_WIDTH 3
|
||||||
|
#define MINI_CANVAS_HEIGHT 4
|
||||||
|
|
||||||
#endif // _CANVAS_SIZE_H_
|
#endif // _CANVAS_SIZE_H_
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
.section ".data"
|
.section ".data"
|
||||||
screendata:
|
screendata:
|
||||||
.rept CANVAS_HEIGHT*CANVAS_WIDTH ;; number of leds in hardward
|
.rept (CANVAS_HEIGHT*CANVAS_WIDTH) + (MINI_CANVAS_HEIGHT*MINI_CANVAS_WIDTH) ;; number of leds in hardward
|
||||||
.byte 0
|
.byte 0
|
||||||
.endr
|
.endr
|
||||||
screendataend:
|
screendataend:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user