blue and red

This commit is contained in:
2019-02-03 22:52:25 +01:00
parent bb993a6366
commit f6f69dd9b2

View File

@ -24,6 +24,8 @@ void patternExec() {
}
*/
/*
* BLUE
void patternExec() {
static uint8_t state = 0;
static uint8_t column = 0;
@ -35,6 +37,7 @@ void patternExec() {
ledSetMatrix(1, 0, BLUE);
ledSetMatrix(2, 0, BLUE);
ledSetMatrix(3, 0, BLUE);
srand(13);
state = 1;
break;
case 1:
@ -59,12 +62,59 @@ void patternExec() {
// same column, row 3 off
ledSetMatrix(column, 3, OFF);
state = 1;
break;
default:
state = 0;
break;
}
}
*/
void patternExec() {
static uint8_t state = 0;
static uint8_t column = 0;
switch (state) {
case 0:
// initialize
ledSetMatrix(0, 3, RED);
ledSetMatrix(1, 3, RED);
ledSetMatrix(2, 3, RED);
ledSetMatrix(3, 3, RED);
srand(13);
state = 1;
break;
case 1:
// select new column, row 2
column = ((uint8_t) rand()) & 0x3;
ledSetMatrix(column, 2, RED);
state = 2;
break;
case 2:
// same column, row 1
ledSetMatrix(column, 1, RED);
ledSetMatrix(column, 2, OFF);
state = 3;
break;
case 3:
// same column, row 0
ledSetMatrix(column, 0, RED);
ledSetMatrix(column, 1, OFF);
state = 4;
break;
case 4:
// same column, row 0 off
ledSetMatrix(column, 0, OFF);
state = 1;
break;
default:
state = 0;
break;
}
}
void patternInit() {
schAdd(patternExec, NULL, 0, 500);
schAdd(patternExec, NULL, 0, 1000);
}