1st version with c implementation of state engine
This commit is contained in:
93
src/AnimationConfig.c
Normal file
93
src/AnimationConfig.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/* AnimationConfig.cpp */
|
||||
|
||||
#include "LEDDefinition.h"
|
||||
#include "AnimationConfig.h"
|
||||
|
||||
AnimationConfig theAnimationConfig;
|
||||
|
||||
uint16_t getNumberOfAnimationSteps() { return theAnimationConfig.numberAnimationSteps; };
|
||||
|
||||
static uint8_t verifyAnimationStepIndex(uint8_t index) {
|
||||
if (/*index < 0 ||*/ index >= MAX_ANIMATION_STEPS) {
|
||||
LOG(LL_ERROR, ("Invalid animation step index %d, set to 0", index));
|
||||
index = 0;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
static void AnimationStep_init(uint16_t animationStepIndex, uint8_t ledIndex, LEDMode m, uint32_t duration) {
|
||||
animationStepIndex = verifyAnimationStepIndex(animationStepIndex);
|
||||
theAnimationConfig.animationStep[animationStepIndex].ledIndex = ledIndex;
|
||||
theAnimationConfig.animationStep[animationStepIndex].ledMode = m;
|
||||
theAnimationConfig.animationStep[animationStepIndex].durationTicks = duration;
|
||||
}
|
||||
|
||||
void AnimationStep_add(uint8_t ledIndex, LEDMode m, uint32_t duration) {
|
||||
uint16_t index = theAnimationConfig.numberAnimationSteps;
|
||||
if (index >= MAX_ANIMATION_STEPS) {
|
||||
LOG(LL_ERROR, ("AnimationStep_add: too many animation steps! ledIndex=%d", ledIndex));
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
theAnimationConfig.numberAnimationSteps++;
|
||||
theAnimationConfig.animationStep[index].ledIndex = ledIndex;
|
||||
theAnimationConfig.animationStep[index].ledMode = m;
|
||||
theAnimationConfig.animationStep[index].durationTicks = duration;
|
||||
}
|
||||
|
||||
|
||||
void AnimationConfig_init(bool loadDefaultData) {
|
||||
int i;
|
||||
|
||||
for (i=0; i<MAX_ANIMATION_STEPS; ++i) {
|
||||
AnimationStep_init(i, -1, LEDMode_off, 0);
|
||||
}
|
||||
theAnimationConfig.numberAnimationSteps = 0;
|
||||
|
||||
if (loadDefaultData) {
|
||||
AnimationStep_add(0, LEDMode_on, 30);
|
||||
AnimationStep_add(0, LEDMode_off, 30);
|
||||
AnimationStep_add(0, LEDMode_on, 10);
|
||||
AnimationStep_add(0, LEDMode_off, 20);
|
||||
AnimationStep_add(0, LEDMode_on, 50);
|
||||
AnimationStep_add(0, LEDMode_off, 10);
|
||||
AnimationStep_add(0, LEDMode_on, 5);
|
||||
AnimationStep_add(0, LEDMode_off, 5);
|
||||
AnimationStep_add(1, LEDMode_on, 20);
|
||||
AnimationStep_add(1, LEDMode_off, 60);
|
||||
AnimationStep_add(1, LEDMode_on, 10);
|
||||
AnimationStep_add(1, LEDMode_off, 70);
|
||||
AnimationStep_add(2, LEDMode_off, 20);
|
||||
AnimationStep_add(2, LEDMode_on, 80);
|
||||
AnimationStep_add(2, LEDMode_off, 5);
|
||||
AnimationStep_add(2, LEDMode_on, 60);
|
||||
AnimationStep_add(2, LEDMode_off, 10);
|
||||
AnimationStep_add(3, LEDMode_on, 11);
|
||||
AnimationStep_add(3, LEDMode_off, 11);
|
||||
AnimationStep_add(4, LEDMode_on, 12);
|
||||
AnimationStep_add(4, LEDMode_off, 12);
|
||||
AnimationStep_add(4, LEDMode_on, 13);
|
||||
AnimationStep_add(4, LEDMode_off, 13);
|
||||
|
||||
for (i=5; i<LEDStateEngine_getNumberOfLeds(); ++i) {
|
||||
AnimationStep_add(i, LEDMode_on, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t AnimationConfig_getNextAnimationStepForLED(uint8_t led, uint16_t currentAnimationStep) {
|
||||
for (uint16_t i=currentAnimationStep+1; i<MAX_ANIMATION_STEPS; ++i) {
|
||||
if (theAnimationConfig.animationStep[i].ledIndex == led) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// nothing found, thus start from beginning again
|
||||
for (uint16_t i=0; i<=currentAnimationStep; ++i) {
|
||||
if (theAnimationConfig.animationStep[i].ledIndex == led) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// ERROR, should never reach this code
|
||||
LOG(LL_ERROR, ("getNextAnimationStepForLED -- could not find entry for led %d, current step=%d", led, currentAnimationStep));
|
||||
return 0;
|
||||
}
|
33
src/AnimationConfig.h
Normal file
33
src/AnimationConfig.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* AnimationConfig.h */
|
||||
|
||||
#ifndef AnimationConfig_loaded
|
||||
#define AnimationConfig_loaded
|
||||
|
||||
#include <stdio.h>
|
||||
#include "fw/src/mgos.h"
|
||||
#include "common/cs_dbg.h"
|
||||
#include "mjs.h"
|
||||
#include "LEDDefinition.h"
|
||||
#include "LEDState.h"
|
||||
|
||||
#define MAX_ANIMATION_STEPS 100
|
||||
|
||||
typedef struct AnimationStep_t {
|
||||
uint8_t ledIndex;
|
||||
LEDMode ledMode;
|
||||
uint32_t durationTicks;
|
||||
} AnimationStep;
|
||||
|
||||
typedef struct AnimationConfig_t {
|
||||
uint16_t numberAnimationSteps;
|
||||
AnimationStep animationStep[MAX_ANIMATION_STEPS];
|
||||
} AnimationConfig;
|
||||
|
||||
extern AnimationConfig theAnimationConfig;
|
||||
|
||||
extern void AnimationConfig_init(bool loadDefaultData);
|
||||
extern uint16_t getNumberOfAnimationSteps();
|
||||
extern void AnimationStep_add(uint8_t ledIndex, LEDMode m, uint32_t duration);
|
||||
extern uint16_t AnimationConfig_getNextAnimationStepForLED(uint8_t led, uint16_t currentAnimationStep);
|
||||
|
||||
#endif
|
97
src/LEDDefinition.c
Normal file
97
src/LEDDefinition.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/* LEDDefinition.cpp */
|
||||
|
||||
#include "LEDDefinition.h"
|
||||
|
||||
LEDColor offColor = { name: "off", red: 0, green: 0, blue: 0};
|
||||
LEDColor dimmedRedColor = { name: "dimmedRed", red: 80, green: 0, blue: 0};
|
||||
|
||||
#define MAX_COLORS 20
|
||||
static LEDColor ledColor[MAX_COLORS];
|
||||
static int numberOfColors = 0;
|
||||
|
||||
LEDColor *LEDColor_get(char *name) {
|
||||
for (int i=0; i<numberOfColors; ++i) {
|
||||
if (strcmp(name, ledColor[i].name) == 0)
|
||||
return &ledColor[i];
|
||||
}
|
||||
LOG(LL_ERROR, ("Error: Color not found: %s", name));
|
||||
return &offColor;
|
||||
}
|
||||
|
||||
void LEDColor_add(char *name, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (numberOfColors < MAX_COLORS) {
|
||||
ledColor[numberOfColors].name = name;
|
||||
ledColor[numberOfColors].red = red;
|
||||
ledColor[numberOfColors].green = green;
|
||||
ledColor[numberOfColors].blue = blue;
|
||||
++numberOfColors;
|
||||
} else {
|
||||
LOG(LL_ERROR, ("Too many color definitions, igrnoring %s (%d, %d, %d)", name, red, green, blue));
|
||||
}
|
||||
}
|
||||
|
||||
void LEDColor_init(bool loadDefaultData) {
|
||||
if (loadDefaultData) {
|
||||
LEDColor_add("off", 0, 0, 0);
|
||||
LEDColor_add("red", 255, 0, 0);
|
||||
LEDColor_add("green", 0, 255, 0);
|
||||
LEDColor_add("blue", 0, 0, 255);
|
||||
LEDColor_add("brightWhite", 255, 255, 255);
|
||||
LEDColor_add("white", 180, 180, 180);
|
||||
LEDColor_add("dimmedWhite", 100, 100, 100);
|
||||
LEDColor_add("dimmedRed", 100, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
LEDDefinition ledDefinition[MAX_LEDS];
|
||||
static int numberOfLEDDefinitions = 0;
|
||||
|
||||
static int verifyLedDefinitionNum(int ledNum) {
|
||||
if (ledNum < 0) {
|
||||
LOG(LL_ERROR, ("Error: verifyLedDefinitionNum failed for ledNum=%d", ledNum));
|
||||
return 0;
|
||||
}
|
||||
return ledNum % numberOfLEDDefinitions;
|
||||
}
|
||||
|
||||
LEDDefinition *LEDDefinition_get(int ledNum) {
|
||||
ledNum = verifyLedDefinitionNum(ledNum);
|
||||
return &ledDefinition[ledNum];
|
||||
}
|
||||
|
||||
void LEDDefinition_add(char *level, char *room, char *id, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (numberOfLEDDefinitions < MAX_LEDS) {
|
||||
ledDefinition[numberOfLEDDefinitions].level = level;
|
||||
ledDefinition[numberOfLEDDefinitions].room = room;
|
||||
ledDefinition[numberOfLEDDefinitions].id = id;
|
||||
ledDefinition[numberOfLEDDefinitions].onColor.red = red;
|
||||
ledDefinition[numberOfLEDDefinitions].onColor.green = green;
|
||||
ledDefinition[numberOfLEDDefinitions].onColor.blue = blue;
|
||||
++numberOfLEDDefinitions;
|
||||
} else {
|
||||
LOG(LL_ERROR, ("Error: Too many LED Definitions to load, ignoring level=%s, room=%s, id=%s", level, room, id));
|
||||
}
|
||||
}
|
||||
void LEDDefinition_init(int numberOfLeds, bool loadDefaultData) {
|
||||
// initialize
|
||||
numberOfLEDDefinitions = 0;
|
||||
if (loadDefaultData) {
|
||||
do {
|
||||
LEDDefinition_add("EG", "Wohnzimmer", "EG-WoZi", 200,200,200);
|
||||
LEDDefinition_add("EG", "Bad", "EG-Bad", 130,130,130);
|
||||
LEDDefinition_add("EG", "Schlafzimmer", "EG-Schlafen", 150,150,130);
|
||||
LEDDefinition_add("EG", "Buero 0.1", "EG-Buero-1", 150,130,130);
|
||||
LEDDefinition_add("EG", "Buero 0.2", "EG-Buero-2", 150,200,200);
|
||||
LEDDefinition_add("EG", "Flur", "EG-Flur-1", 100,100,100);
|
||||
LEDDefinition_add("EG", "Flur", "EG-Flur-2", 140,100,100);
|
||||
LEDDefinition_add("OG1", "Buero 1.1", "OG1-WoZi", 200,200,200);
|
||||
LEDDefinition_add("OG1", "Bad OG1", "OG1-Bad", 130,130,130);
|
||||
LEDDefinition_add("OG1", "Buero 1.2", "OG1-Schlafen", 150,150,130);
|
||||
LEDDefinition_add("OG1", "Buero 1.3", "OG1Buero-1", 150,150,130);
|
||||
LEDDefinition_add("OG1", "Buero 1.4", "OG1-Buero-2", 150,200,200);
|
||||
LEDDefinition_add("OG1", "Flur", "OG1-Flur-1", 100,100,100);
|
||||
LEDDefinition_add("OG1", "Flur", "OG1-Flur-2", 140,100,100);
|
||||
} while(numberOfLEDDefinitions < numberOfLeds);
|
||||
}
|
||||
}
|
||||
|
41
src/LEDDefinition.h
Normal file
41
src/LEDDefinition.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* LEDDefinition.h */
|
||||
|
||||
#ifndef LEDDefinition_included
|
||||
#define LEDDefinition_included
|
||||
|
||||
#include <stdio.h>
|
||||
#include "fw/src/mgos.h"
|
||||
#include "mjs.h"
|
||||
#include "mongoose/mongoose.h"
|
||||
#include "common/cs_dbg.h"
|
||||
|
||||
#define MAX_LEDS 100
|
||||
|
||||
typedef enum LEDMode_e { LEDMode_on, LEDMode_off, LEDMode_blink, LEDMode_tv, LEDMode_fire } LEDMode;
|
||||
|
||||
typedef struct LEDColor_t {
|
||||
char *name;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
} LEDColor;
|
||||
|
||||
extern LEDColor offColor, dimmedRedColor;
|
||||
extern void LEDColor_init(bool loadDefaultData);
|
||||
extern LEDColor *LEDColor_get(char *name);
|
||||
extern void LEDColor_add(char *name, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
typedef struct LEDDefinition_t {
|
||||
char *level;
|
||||
char *room;
|
||||
char *id;
|
||||
LEDColor onColor;
|
||||
} LEDDefinition;
|
||||
|
||||
extern LEDDefinition ledDefinition[MAX_LEDS];
|
||||
|
||||
extern LEDDefinition *LEDDefinition_get(int ledNum);
|
||||
extern void LEDDefinition_init(int numberOfLeds, bool loadDefaultData);
|
||||
void LEDDefinition_add(char *level, char *room, char *id, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
#endif
|
113
src/LEDState.c
Normal file
113
src/LEDState.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/* LEDState.c */
|
||||
|
||||
#include "LEDDefinition.h"
|
||||
#include "LEDState.h"
|
||||
#include "AnimationConfig.h"
|
||||
|
||||
|
||||
static LEDStateEngine theLEDStateEngine;
|
||||
|
||||
void LEDStateEngine_setNumberOfLeds(int numberOfLeds) {
|
||||
if (numberOfLeds < 1 || numberOfLeds > MAX_LEDS) {
|
||||
LOG(LL_ERROR, ("Invalid number of LEDs %d", numberOfLeds));
|
||||
numberOfLeds = MAX_LEDS;
|
||||
}
|
||||
theLEDStateEngine.numberOfLeds = numberOfLeds;
|
||||
}
|
||||
|
||||
void LEDStateEngine_init(int numberOfLeds) {
|
||||
LEDStateEngine_setNumberOfLeds(numberOfLeds);
|
||||
theLEDStateEngine.comment = "";
|
||||
for (int i=0; i<numberOfLeds; ++i) {
|
||||
LEDstate_init(i, LEDDefinition_get(i));
|
||||
}
|
||||
}
|
||||
|
||||
void LEDStateEngine_addComment(char *comment) {
|
||||
theLEDStateEngine.comment = comment;
|
||||
}
|
||||
|
||||
uint16_t LEDStateEngine_getNumberOfLeds() {
|
||||
return theLEDStateEngine.numberOfLeds;
|
||||
}
|
||||
|
||||
|
||||
void LEDStateEngine_tick() {
|
||||
for (int i=0; i<theLEDStateEngine.numberOfLeds; ++i) {
|
||||
LEDState_tick(i);
|
||||
}
|
||||
}
|
||||
|
||||
void LEDState_tick(int ledNum) {
|
||||
LEDState *state = &theLEDStateEngine.ledState[ledNum];
|
||||
if (/*state->index < 0 ||*/ state->index >= theLEDStateEngine.numberOfLeds)
|
||||
return; // ignore LED entries, that are not setup correctly
|
||||
state->currentTick++;
|
||||
if (state->currentTick == state->nextTick) {
|
||||
// perform/initiate next state change
|
||||
state->currentAnimationStep = AnimationConfig_getNextAnimationStepForLED(ledNum, state->currentAnimationStep);
|
||||
state->nextTick = state->currentTick + theAnimationConfig.animationStep[state->currentAnimationStep].durationTicks;
|
||||
state->mode = theAnimationConfig.animationStep[state->currentAnimationStep].ledMode;
|
||||
switch (state->mode) {
|
||||
case LEDMode_on:
|
||||
state->currentColor = state->onColor;
|
||||
break;
|
||||
case LEDMode_off:
|
||||
state->currentColor = offColor;
|
||||
break;
|
||||
default:
|
||||
state->currentColor = dimmedRedColor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// do animations, if necessary
|
||||
}
|
||||
|
||||
LEDState *LEDStateEngine_getLedState(int n) {
|
||||
if (n>=0 && n<theLEDStateEngine.numberOfLeds)
|
||||
return &theLEDStateEngine.ledState[n];
|
||||
LOG(LL_ERROR, ("*** LEDStateEngine_getLedState -- invalid LED number given: %d", n));
|
||||
return &theLEDStateEngine.ledState[0];
|
||||
}
|
||||
|
||||
/* LEDState */
|
||||
static int verifyLedNumber(int n) {
|
||||
if (n < 0 || n >= theLEDStateEngine.numberOfLeds) {
|
||||
LOG(LL_ERROR, ("*** Invalid LED number %d, set to zero", n));
|
||||
n = 0;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void LEDstate_initDefault(int n, LEDMode defaultMode) {
|
||||
n = verifyLedNumber(n);
|
||||
LEDState *state = &theLEDStateEngine.ledState[n];
|
||||
state->index = n;
|
||||
state->mode = defaultMode;
|
||||
state->nextTick = 0;
|
||||
state->ledDefinition = LEDDefinition_get(n);
|
||||
}
|
||||
|
||||
void LEDstate_init(int n, LEDDefinition *ledDefinition) {
|
||||
n = verifyLedNumber(n);
|
||||
LEDstate_initDefault(n, LEDMode_off);
|
||||
LEDState *state = LEDStateEngine_getLedState(n);
|
||||
state->index = n;
|
||||
state->ledDefinition = ledDefinition;
|
||||
state->onColor = ledDefinition->onColor;
|
||||
}
|
||||
|
||||
|
||||
int LEDState_getLedRed(int ledNum) {
|
||||
LEDState *state = LEDStateEngine_getLedState(ledNum);
|
||||
return state->currentColor.red;
|
||||
}
|
||||
int LEDState_getLedGreen(int ledNum) {
|
||||
LEDState *state = LEDStateEngine_getLedState(ledNum);
|
||||
return state->currentColor.green;
|
||||
}
|
||||
int LEDState_getLedBlue(int ledNum) {
|
||||
LEDState *state = LEDStateEngine_getLedState(ledNum);
|
||||
return state->currentColor.blue;
|
||||
}
|
||||
|
47
src/LEDState.h
Normal file
47
src/LEDState.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* LEDState.h */
|
||||
|
||||
#ifndef LEDState_loaded
|
||||
#define LEDState_loaded
|
||||
|
||||
#include "LEDDefinition.h"
|
||||
|
||||
typedef struct LEDState_t {
|
||||
uint8_t index;
|
||||
LEDDefinition *ledDefinition;
|
||||
uint32_t currentTick;
|
||||
uint32_t nextTick;
|
||||
uint8_t rampTickDelta;
|
||||
LEDMode mode;
|
||||
uint8_t currentLEDCtrlIndex; // ???????????
|
||||
uint16_t currentAnimationStep;
|
||||
uint8_t modeStep; // sub-state within a mode
|
||||
uint8_t clockEndHours;
|
||||
uint8_t clockEndMinutes;
|
||||
LEDColor currentColor;
|
||||
LEDColor onColor; // for target of on-mode
|
||||
LEDColor targetColor;
|
||||
} LEDState;
|
||||
|
||||
typedef struct LEDStateEngine_t {
|
||||
uint8_t numberOfLeds;
|
||||
LEDState ledState[MAX_LEDS];
|
||||
char *comment;
|
||||
} LEDStateEngine;
|
||||
|
||||
/* LEDStateEngine */
|
||||
extern void LEDStateEngine_init(int numberOfLeds);
|
||||
extern void LEDStateEngine_addComment(char *comment);
|
||||
|
||||
extern LEDState *LEDStateEngine_getLedState(int n);
|
||||
extern void LEDStateEngine_tick();
|
||||
extern uint16_t LEDStateEngine_getNumberOfLeds();
|
||||
|
||||
/* LEDState */
|
||||
extern void LEDstate_init(int n, LEDDefinition *ledDefinition);
|
||||
extern void LEDstate_initDefault(int n, LEDMode defaultMode);
|
||||
extern void LEDState_tick(int ledNum);
|
||||
extern int LEDState_getLedRed(int ledNum);
|
||||
extern int LEDState_getLedGreen(int ledNum);
|
||||
extern int LEDState_getLedBlue(int ledNum);
|
||||
|
||||
#endif
|
71
src/main.c
71
src/main.c
@@ -2,13 +2,17 @@
|
||||
|
||||
#include "common/platform.h"
|
||||
#include "common/cs_file.h"
|
||||
#include "fw/src/mgos_app.h"
|
||||
#include "fw/src/mgos_gpio.h"
|
||||
#include "fw/src/mgos_sys_config.h"
|
||||
#include "fw/src/mgos_timers.h"
|
||||
#include "mgos_app.h"
|
||||
#include "mgos_gpio.h"
|
||||
#include "mgos_sys_config.h"
|
||||
#include "mgos_system.h"
|
||||
#include "mgos_timers.h"
|
||||
#include "fw/src/mgos_hal.h"
|
||||
#include "fw/src/mgos_dlsym.h"
|
||||
#include "mjs.h"
|
||||
#include "LEDDefinition.h"
|
||||
#include "AnimationConfig.h"
|
||||
#include "LEDState.h"
|
||||
|
||||
#if CS_PLATFORM == CS_P_ESP8266
|
||||
#define LED_GPIO 2 /* On ESP-12E there is a blue LED connected to GPIO2 */
|
||||
@@ -27,9 +31,64 @@
|
||||
#endif
|
||||
|
||||
int get_led_gpio_pin(void) {
|
||||
return LED_GPIO;
|
||||
return LED_GPIO;
|
||||
}
|
||||
|
||||
LEDStateEngine ledStateEngine;
|
||||
static bool stateEngineRunning = false;
|
||||
|
||||
static void timer_cb() {
|
||||
if (stateEngineRunning) {
|
||||
LOG(LL_INFO, ("tick"));
|
||||
LEDStateEngine_tick();
|
||||
} else {
|
||||
LOG(LL_INFO, ("--paused--"));
|
||||
}
|
||||
}
|
||||
|
||||
static void delayed_boot() {
|
||||
mgos_set_timer(100, true, timer_cb, NULL); // every 0.1 second call timer_cb
|
||||
}
|
||||
|
||||
enum mgos_app_init_result mgos_app_init(void) {
|
||||
return MGOS_APP_INIT_SUCCESS;
|
||||
int numberOfLeds = 20; /*mgos_sys_config_get_led_count()*/
|
||||
bool loadDefaultData = true; /*mgos_sys_config_get_led_useDefaults()*/
|
||||
|
||||
LEDColor_init(loadDefaultData);
|
||||
LEDDefinition_init(numberOfLeds, loadDefaultData);
|
||||
AnimationConfig_init(loadDefaultData);
|
||||
LEDStateEngine_init(numberOfLeds);
|
||||
if (loadDefaultData) {
|
||||
stateEngineRunning = true;
|
||||
}
|
||||
|
||||
mgos_set_timer(5000, false, delayed_boot, NULL); // after 5 seconds boot the functions
|
||||
return MGOS_APP_INIT_SUCCESS;
|
||||
}
|
||||
|
||||
// javascript adapter functions:
|
||||
void addColor(char *name, int red, int green, int blue) {
|
||||
LEDColor_add(name, red, green, blue);
|
||||
}
|
||||
void addLedDefinition(char *level, char *room, char *id, int red, int green, int blue) {
|
||||
LEDDefinition_add(level, room, id, red, green, blue);
|
||||
}
|
||||
void addAnimationStep(int ledIndex, int ledMode, int duration) {
|
||||
LEDMode m = LEDMode_off;
|
||||
switch (ledMode) {
|
||||
case 1: m = LEDMode_on; break;
|
||||
case 2: m = LEDMode_off; break;
|
||||
case 3: m = LEDMode_blink; break;
|
||||
case 4: m = LEDMode_tv; break;
|
||||
case 5: m = LEDMode_fire; break;
|
||||
default: m = LEDMode_off;
|
||||
}
|
||||
AnimationStep_add(ledIndex, m, duration);
|
||||
}
|
||||
|
||||
void startLEDStateEngine(void) {
|
||||
stateEngineRunning = true;
|
||||
}
|
||||
void pauseLEDStateEngine(void) {
|
||||
stateEngineRunning = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user