|
|
@ -12,13 +12,6 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com> |
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
|
|
|
|
#define PWM_CHANNEL_NUM_MAX LIGHT_CHANNELS
|
|
|
|
extern "C" { |
|
|
|
#include "libs/pwm.h"
|
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Ticker _light_save_ticker; |
|
|
@ -47,6 +40,18 @@ my92xx * _my92xx; |
|
|
|
ARRAYINIT(unsigned char, _light_channel_map, MY92XX_MAPPING); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
|
|
|
|
#define PWM_CHANNEL_NUM_MAX LIGHT_CHANNELS
|
|
|
|
extern "C" { |
|
|
|
#include "libs/pwm.h"
|
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_FASTLED
|
|
|
|
#include <FastLED.h>
|
|
|
|
CRGB _fastleds[LIGHT_FASTLED_NUM]; |
|
|
|
#endif
|
|
|
|
|
|
|
|
// Gamma Correction lookup table (8 bit)
|
|
|
|
// TODO: move to PROGMEM
|
|
|
|
const unsigned char _light_gamma_table[] = { |
|
|
@ -413,6 +418,15 @@ void _lightProviderUpdate() { |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_FASTLED
|
|
|
|
|
|
|
|
for (CRGB & pixel : _fastleds) { |
|
|
|
pixel = CRGB(_toPWM(0), _toPWM(1), _toPWM(2)); |
|
|
|
} |
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
|
|
|
|
|
|
|
|
for (unsigned int i=0; i < _light_channel.size(); i++) { |
|
|
@ -871,6 +885,24 @@ void lightSetup() { |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_FASTLED
|
|
|
|
|
|
|
|
#if LIGHT_FASTLED_TYPE == NEOPIXEL
|
|
|
|
FastLED.addLeds<LIGHT_FASTLED_TYPE, LIGHT_FASTLED_DATA_PIN>(_fastleds, LIGHT_FASTLED_NUM); |
|
|
|
#else
|
|
|
|
#ifdef LIGHT_FASTLED_CLOCK_PIN
|
|
|
|
FastLED.addLeds<LIGHT_FASTLED_TYPE, LIGHT_FASTLED_DATA_PIN, LIGHT_FASTLED_CLOCK_PIN, LIGHT_FASTLED_ORDER>(_fastleds, LIGHT_FASTLED_NUM); |
|
|
|
#else
|
|
|
|
FastLED.addLeds<LIGHT_FASTLED_TYPE, LIGHT_FASTLED_DATA_PIN, LIGHT_FASTLED_ORDER>(_fastleds, LIGHT_FASTLED_NUM); |
|
|
|
#endif // LIGHT_FASTLED_CLOCK_PIN
|
|
|
|
#endif // LIGHT_FASTLED_TYPE == NEOPIXEL
|
|
|
|
|
|
|
|
for (unsigned char i=0; i<LIGHT_CHANNELS; i++) { |
|
|
|
_light_channel.push_back((channel_t) {0, false, 0, 0, 0}); |
|
|
|
} |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
|
|
|
|
|
|
|
|
#ifdef LIGHT_CH1_PIN
|
|
|
|