2019-02-02 16:54:24 +01:00
|
|
|
#include "pattern.h"
|
|
|
|
#include "led.h"
|
|
|
|
#include "PontCoopScheduler.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
2019-02-03 22:34:29 +01:00
|
|
|
/*
|
|
|
|
* traversing the whole matrix
|
2019-02-02 16:54:24 +01:00
|
|
|
void patternExec() {
|
|
|
|
static uint8_t i = 0;
|
|
|
|
static uint8_t j = 0;
|
|
|
|
|
2019-02-02 18:03:04 +01:00
|
|
|
ledSetMatrix(i, j, OFF);
|
2019-02-02 16:54:24 +01:00
|
|
|
|
|
|
|
i++;
|
|
|
|
if (i > 3) {
|
|
|
|
i = 0;
|
|
|
|
j++;
|
|
|
|
if (j > 3) {
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
2019-02-02 18:03:04 +01:00
|
|
|
ledSetMatrix(i, j, BLUE);
|
2019-02-02 16:54:24 +01:00
|
|
|
}
|
2019-02-03 22:34:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
void patternExec() {
|
|
|
|
static uint8_t state = 0;
|
|
|
|
static uint8_t column = 0;
|
2019-02-02 16:54:24 +01:00
|
|
|
|
2019-02-03 22:34:29 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2019-02-02 16:54:24 +01:00
|
|
|
|
|
|
|
void patternInit() {
|
2019-02-02 18:03:04 +01:00
|
|
|
schAdd(patternExec, NULL, 0, 500);
|
2019-02-02 16:54:24 +01:00
|
|
|
}
|