add matrix structure

This commit is contained in:
Wolfgang Hottgenroth 2019-01-27 22:12:04 +01:00
parent 459ad36b0d
commit ddb4a82165
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
2 changed files with 41 additions and 3 deletions

37
led.c
View File

@ -11,6 +11,21 @@
#include <stdlib.h>
#define SIZE 4
tColor matrix[SIZE][SIZE] = {
{ OFF, OFF, OFF, OFF },
{ OFF, OFF, OFF, OFF },
{ OFF, OFF, OFF, OFF },
{ OFF, OFF, OFF, OFF }
};
void ledSetMatrix(uint8_t col, uint8_t row, tColor color) {
if ((col < SIZE) && (row < SIZE)) {
matrix[col][row] = color;
}
}
/*
row0: P1.3
row1: P1.4
@ -164,7 +179,8 @@ void selectCol(uint8_t column, tColor color) {
}
}
void ledExec() {
/*
void testledExec() {
static uint8_t rowNum = 0;
static uint8_t colNum = 0;
@ -186,9 +202,26 @@ void ledExec() {
}
}
}
}
*/
void ledExec() {
static uint8_t rowNum = SIZE;
static uint8_t colNum = SIZE;
colNum++;
if (colNum >= SIZE) {
colNum = 0;
rowNum++;
if (rowNum >= SIZE) {
rowNum = 0;
}
selectRow(rowNum);
}
selectCol(colNum, matrix[colNum][rowNum]);
}
void ledInit() {
schAdd(ledExec, NULL, 0, 50);
schAdd(ledExec, NULL, 0, 10);
}

7
led.h
View File

@ -8,10 +8,15 @@
#ifndef LED_H_
#define LED_H_
#include <stdlib.h>
typedef enum { BLUE = 0, RED = 1, OFF = 2 } tColor;
void ledExec();
void ledInit();
void ledSetMatrix(uint8_t col, uint8_t row, tColor color);
#endif /* LED_H_ */