random blue
This commit is contained in:
44
pattern.c
44
pattern.c
@ -4,7 +4,8 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* traversing the whole matrix
|
||||
void patternExec() {
|
||||
static uint8_t i = 0;
|
||||
static uint8_t j = 0;
|
||||
@ -21,7 +22,48 @@ void patternExec() {
|
||||
}
|
||||
ledSetMatrix(i, j, BLUE);
|
||||
}
|
||||
*/
|
||||
|
||||
void patternExec() {
|
||||
static uint8_t state = 0;
|
||||
static uint8_t column = 0;
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
// initialize
|
||||
ledSetMatrix(0, 0, BLUE);
|
||||
ledSetMatrix(1, 0, BLUE);
|
||||
ledSetMatrix(2, 0, BLUE);
|
||||
ledSetMatrix(3, 0, BLUE);
|
||||
state = 1;
|
||||
break;
|
||||
case 1:
|
||||
// select new column, row 1
|
||||
column = ((uint8_t) rand()) & 0x3;
|
||||
ledSetMatrix(column, 1, BLUE);
|
||||
state = 2;
|
||||
break;
|
||||
case 2:
|
||||
// same column, row 2
|
||||
ledSetMatrix(column, 2, BLUE);
|
||||
ledSetMatrix(column, 1, OFF);
|
||||
state = 3;
|
||||
break;
|
||||
case 3:
|
||||
// same column, row 3
|
||||
ledSetMatrix(column, 3, BLUE);
|
||||
ledSetMatrix(column, 2, OFF);
|
||||
state = 4;
|
||||
break;
|
||||
case 4:
|
||||
// same column, row 3 off
|
||||
ledSetMatrix(column, 3, OFF);
|
||||
state = 1;
|
||||
default:
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void patternInit() {
|
||||
schAdd(patternExec, NULL, 0, 500);
|
||||
|
Reference in New Issue
Block a user