Finalized on/off-animation mode
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#define AnimationConfig_loaded
|
||||
|
||||
#include <stdio.h>
|
||||
#include "fw/src/mgos.h"
|
||||
#include "mgos.h"
|
||||
#include "common/cs_dbg.h"
|
||||
#include "mjs.h"
|
||||
#include "LEDDefinition.h"
|
||||
@@ -30,4 +30,4 @@ 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
|
||||
#endif
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#define LEDDefinition_included
|
||||
|
||||
#include <stdio.h>
|
||||
#include "fw/src/mgos.h"
|
||||
#include "mgos.h"
|
||||
#include "mjs.h"
|
||||
#include "mongoose/mongoose.h"
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
static LEDStateEngine theLEDStateEngine;
|
||||
static int ticks = 0;
|
||||
static int brightness = 50;
|
||||
|
||||
int getTicks(void) { return ticks; }
|
||||
|
||||
@@ -26,6 +27,7 @@ void LEDStateEngine_setNumberOfLeds(int numberOfLeds) {
|
||||
void LEDStateEngine_init(int ledPin, int numberOfLeds) {
|
||||
theLEDStateEngine.comment = "";
|
||||
theLEDStateEngine.pin = ledPin;
|
||||
brightness = mgos_sys_config_get_led_brightness();
|
||||
LEDStateEngine_setNumberOfLeds(numberOfLeds);
|
||||
for (int i=0; i<numberOfLeds; ++i) {
|
||||
LEDState_init(i, LEDDefinition_get(i));
|
||||
@@ -56,16 +58,27 @@ void LEDStateEngine_tick() {
|
||||
if (usedTime > maxTickTime) maxTickTime = usedTime;
|
||||
if (usedTime < minTickTime) minTickTime = usedTime;
|
||||
}
|
||||
double LEDStateEngine_getMinTickTime() { return minTickTime; }
|
||||
double LEDStateEngine_getMaxTickTime() { return maxTickTime; }
|
||||
double LEDStateEngine_getMinTickTime() { return 1000 * minTickTime; }
|
||||
double LEDStateEngine_getMaxTickTime() { return 1000 * maxTickTime; }
|
||||
|
||||
static uint8_t adjustBrightness(uint8_t value) {
|
||||
return (value * mgos_sys_config_get_led_brightness()/100);
|
||||
return (value * brightness)/100;
|
||||
}
|
||||
|
||||
int LEDStateEngine_getBrightness() { return brightness; }
|
||||
void LEDStateEngine_setBrightness(int newBrightness) {
|
||||
if (newBrightness > 0 && newBrightness <= 100) {
|
||||
brightness = newBrightness;
|
||||
} else {
|
||||
LOG(LL_ERROR, ("invalid brightness value %d", newBrightness));
|
||||
}
|
||||
}
|
||||
|
||||
static void updateLedDisplay(LEDState *state) {
|
||||
NeoPixel_set(state->index,
|
||||
adjustBrightness(state->currentColor.red), adjustBrightness(state->currentColor.green), adjustBrightness(state->currentColor.blue));
|
||||
adjustBrightness(state->currentColor.red),
|
||||
adjustBrightness(state->currentColor.green),
|
||||
adjustBrightness(state->currentColor.blue));
|
||||
}
|
||||
|
||||
void LEDState_tick(int ledNum) {
|
||||
|
@@ -7,8 +7,8 @@
|
||||
#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 "mgos_hal.h"
|
||||
#include "mgos_dlsym.h"
|
||||
#include "mjs.h"
|
||||
#include "LEDDefinition.h"
|
||||
#include "AnimationConfig.h"
|
||||
@@ -35,7 +35,7 @@ int get_led_gpio_pin(void) {
|
||||
return LED_GPIO;
|
||||
}
|
||||
|
||||
LEDStateEngine ledStateEngine;
|
||||
// static LEDStateEngine ledStateEngine;
|
||||
static bool stateEngineRunning = false;
|
||||
static bool pausedReported = false;
|
||||
|
||||
|
Reference in New Issue
Block a user