add matrix structure
This commit is contained in:
parent
459ad36b0d
commit
ddb4a82165
37
led.c
37
led.c
@ -11,6 +11,21 @@
|
|||||||
#include <stdlib.h>
|
#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
|
row0: P1.3
|
||||||
row1: P1.4
|
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 rowNum = 0;
|
||||||
static uint8_t colNum = 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() {
|
void ledInit() {
|
||||||
schAdd(ledExec, NULL, 0, 50);
|
schAdd(ledExec, NULL, 0, 10);
|
||||||
}
|
}
|
||||||
|
7
led.h
7
led.h
@ -8,10 +8,15 @@
|
|||||||
#ifndef LED_H_
|
#ifndef LED_H_
|
||||||
#define LED_H_
|
#define LED_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
typedef enum { BLUE = 0, RED = 1, OFF = 2 } tColor;
|
typedef enum { BLUE = 0, RED = 1, OFF = 2 } tColor;
|
||||||
|
|
||||||
|
|
||||||
void ledExec();
|
|
||||||
void ledInit();
|
void ledInit();
|
||||||
|
void ledSetMatrix(uint8_t col, uint8_t row, tColor color);
|
||||||
|
|
||||||
|
|
||||||
#endif /* LED_H_ */
|
#endif /* LED_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user