* add readme with comments on debugging
* add optional CFLAGS in Makefile for debugging * fix _patternChangeColor function in pattern.c * add debug variant for measure exec function
This commit is contained in:
32
pattern.c
32
pattern.c
@ -6,8 +6,8 @@
|
||||
#include "myrand.h"
|
||||
|
||||
|
||||
uint8_t temperature = 20;
|
||||
const uint8_t TEMPERATURE_THRESHOLD = 20;
|
||||
uint8_t temperature = 21;
|
||||
const uint8_t TEMPERATURE_THRESHOLD = 25;
|
||||
|
||||
tColor lockedColor = OFF;
|
||||
|
||||
@ -35,9 +35,7 @@ void patternExec() {
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* BLUE
|
||||
void patternExec() {
|
||||
void patternTestBlueExec() {
|
||||
static uint8_t state = 0;
|
||||
static uint8_t column = 0;
|
||||
|
||||
@ -48,12 +46,11 @@ void patternExec() {
|
||||
ledSetMatrix(1, 0, BLUE);
|
||||
ledSetMatrix(2, 0, BLUE);
|
||||
ledSetMatrix(3, 0, BLUE);
|
||||
srand(13);
|
||||
state = 1;
|
||||
break;
|
||||
case 1:
|
||||
// select new column, row 1
|
||||
column = ((uint8_t) rand()) & 0x3;
|
||||
column = 0;
|
||||
ledSetMatrix(column, 1, BLUE);
|
||||
state = 2;
|
||||
break;
|
||||
@ -79,7 +76,7 @@ void patternExec() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
static bool _patternChangeColor() {
|
||||
@ -101,7 +98,20 @@ static bool _patternChangeColor() {
|
||||
}
|
||||
|
||||
uint8_t _patternStayCnt() {
|
||||
return temperature;
|
||||
uint8_t s = 0;
|
||||
|
||||
if (temperature < TEMPERATURE_THRESHOLD) {
|
||||
s = TEMPERATURE_THRESHOLD - temperature;
|
||||
} else if (temperature > (TEMPERATURE_THRESHOLD * 2)) {
|
||||
s = 0;
|
||||
} else {
|
||||
s = (TEMPERATURE_THRESHOLD * 2) - temperature;
|
||||
}
|
||||
|
||||
if (s == 0) {
|
||||
s = 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void patternExec() {
|
||||
@ -129,7 +139,7 @@ void patternExec() {
|
||||
ledSetMatrix(1, baseRow, lockedColor);
|
||||
ledSetMatrix(2, baseRow, lockedColor);
|
||||
ledSetMatrix(3, baseRow, lockedColor);
|
||||
srand(13);
|
||||
|
||||
state = 1;
|
||||
break;
|
||||
case 1:
|
||||
@ -177,7 +187,7 @@ void patternExec() {
|
||||
case 7:
|
||||
// same column, row 0 off
|
||||
ledSetMatrix(column, (lockedColor == RED) ? 0 : 3, OFF);
|
||||
state = _patternChangeColor() ? 1 : 0;
|
||||
state = _patternChangeColor() ? 0 : 1;
|
||||
stay = _patternStayCnt();
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user