Merge pull request #1711 from Aircoookie/dev-multipin-select
Multipin select working!
This commit is contained in:
commit
517a85f9e9
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
### Development versions after 0.11.1 release
|
### Development versions after 0.11.1 release
|
||||||
|
|
||||||
|
#### Build 2101310
|
||||||
|
|
||||||
|
- First alpha configurable multipin
|
||||||
|
|
||||||
#### Build 2101130
|
#### Build 2101130
|
||||||
|
|
||||||
- Added color transitions for all segments and slots and for segment brightness
|
- Added color transitions for all segments and slots and for segment brightness
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
#include <DallasTemperature.h> //DS18B20
|
#include <DallasTemperature.h> //DS18B20
|
||||||
|
|
||||||
//Pin defaults for QuinLed Dig-Uno
|
//Pin defaults for QuinLed Dig-Uno
|
||||||
|
#ifndef TEMPERATURE_PIN
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
#define TEMPERATURE_PIN 18
|
#define TEMPERATURE_PIN 18
|
||||||
#else //ESP8266 boards
|
#else //ESP8266 boards
|
||||||
#define TEMPERATURE_PIN 14
|
#define TEMPERATURE_PIN 14
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// the frequency to check temperature, 1 minute
|
// the frequency to check temperature, 1 minute
|
||||||
#ifndef USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL
|
#ifndef USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL
|
||||||
@ -58,6 +60,7 @@ class UsermodTemperature : public Usermod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getTemperature() {
|
void getTemperature() {
|
||||||
|
if (strip.isUpdating()) return;
|
||||||
#ifdef USERMOD_DALLASTEMPERATURE_CELSIUS
|
#ifdef USERMOD_DALLASTEMPERATURE_CELSIUS
|
||||||
temperature = sensor.getTempC(sensorDeviceAddress);
|
temperature = sensor.getTempC(sensorDeviceAddress);
|
||||||
#else
|
#else
|
||||||
@ -80,30 +83,28 @@ class UsermodTemperature : public Usermod {
|
|||||||
disabled = !sensor.getAddress(sensorDeviceAddress, 0);
|
disabled = !sensor.getAddress(sensorDeviceAddress, 0);
|
||||||
|
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
DEBUG_PRINTLN("Dallas Temperature found");
|
DEBUG_PRINTLN(F("Dallas Temperature found"));
|
||||||
// set the resolution for this specific device
|
// set the resolution for this specific device
|
||||||
sensor.setResolution(sensorDeviceAddress, 9, true);
|
sensor.setResolution(sensorDeviceAddress, 9, true);
|
||||||
// do not block waiting for reading
|
// do not block waiting for reading
|
||||||
sensor.setWaitForConversion(false);
|
sensor.setWaitForConversion(false);
|
||||||
|
// allocate pin & prevent other use
|
||||||
|
if (!pinManager.allocatePin(TEMPERATURE_PIN,false))
|
||||||
|
disabled = true;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_PRINTLN("Dallas Temperature not found");
|
DEBUG_PRINTLN(F("Dallas Temperature not found"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (disabled) {
|
if (disabled || strip.isUpdating()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
|
||||||
// check to see if we are due for taking a measurement
|
// check to see if we are due for taking a measurement
|
||||||
// lastMeasurement will not be updated until the conversion
|
// lastMeasurement will not be updated until the conversion
|
||||||
// is complete the the reading is finished
|
// is complete the the reading is finished
|
||||||
if (now - lastMeasurement < USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL)
|
if (now - lastMeasurement < USERMOD_DALLASTEMPERATURE_MEASUREMENT_INTERVAL) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we are due for a measurement, if we are not already waiting
|
// we are due for a measurement, if we are not already waiting
|
||||||
// for a conversion to complete, then make a new request for temps
|
// for a conversion to complete, then make a new request for temps
|
||||||
@ -125,7 +126,7 @@ class UsermodTemperature : public Usermod {
|
|||||||
// dont publish super low temperature as the graph will get messed up
|
// dont publish super low temperature as the graph will get messed up
|
||||||
// the DallasTemperature library returns -127C or -196.6F when problem
|
// the DallasTemperature library returns -127C or -196.6F when problem
|
||||||
// reading the sensor
|
// reading the sensor
|
||||||
strcat(subuf, "/temperature");
|
strcat_P(subuf, PSTR("/temperature"));
|
||||||
mqtt->publish(subuf, 0, true, String(temperature).c_str());
|
mqtt->publish(subuf, 0, true, String(temperature).c_str());
|
||||||
} else {
|
} else {
|
||||||
// publish something else to indicate status?
|
// publish something else to indicate status?
|
||||||
@ -136,34 +137,32 @@ class UsermodTemperature : public Usermod {
|
|||||||
|
|
||||||
void addToJsonInfo(JsonObject& root) {
|
void addToJsonInfo(JsonObject& root) {
|
||||||
// dont add temperature to info if we are disabled
|
// dont add temperature to info if we are disabled
|
||||||
if (disabled) {
|
if (disabled) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject user = root["u"];
|
JsonObject user = root[F("u")];
|
||||||
if (user.isNull()) user = root.createNestedObject("u");
|
if (user.isNull()) user = root.createNestedObject(F("u"));
|
||||||
|
|
||||||
JsonArray temp = user.createNestedArray("Temperature");
|
JsonArray temp = user.createNestedArray(F("Temperature"));
|
||||||
|
|
||||||
if (!getTemperatureComplete) {
|
if (!getTemperatureComplete) {
|
||||||
// if we haven't read the sensor yet, let the user know
|
// if we haven't read the sensor yet, let the user know
|
||||||
// that we are still waiting for the first measurement
|
// that we are still waiting for the first measurement
|
||||||
temp.add((USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT - millis()) / 1000);
|
temp.add((USERMOD_DALLASTEMPERATURE_FIRST_MEASUREMENT_AT - millis()) / 1000);
|
||||||
temp.add(" sec until read");
|
temp.add(F(" sec until read"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temperature <= -100) {
|
if (temperature <= -100) {
|
||||||
temp.add(0);
|
temp.add(0);
|
||||||
temp.add(" Sensor Error!");
|
temp.add(F(" Sensor Error!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.add(temperature);
|
temp.add(temperature);
|
||||||
#ifdef USERMOD_DALLASTEMPERATURE_CELSIUS
|
#ifdef USERMOD_DALLASTEMPERATURE_CELSIUS
|
||||||
temp.add("°C");
|
temp.add(F("°C"));
|
||||||
#else
|
#else
|
||||||
temp.add("°F");
|
temp.add(F("°F"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1265,7 +1265,7 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2, bool all)
|
|||||||
for (uint16_t i = idexB; i < idexR; i++) setPixelColor(i, color2);
|
for (uint16_t i = idexB; i < idexR; i++) setPixelColor(i, color2);
|
||||||
}
|
}
|
||||||
} else { //regular dot-only mode
|
} else { //regular dot-only mode
|
||||||
uint8_t size = 1 + SEGMENT.intensity >> 3;
|
uint8_t size = 1 + (SEGMENT.intensity >> 3);
|
||||||
if (size > SEGLEN/2) size = 1+ SEGLEN/2;
|
if (size > SEGLEN/2) size = 1+ SEGLEN/2;
|
||||||
for (uint8_t i=0; i <= size; i++) {
|
for (uint8_t i=0; i <= size; i++) {
|
||||||
setPixelColor(idexR+i, color1);
|
setPixelColor(idexR+i, color1);
|
||||||
|
49
wled00/FX.h
49
wled00/FX.h
@ -29,42 +29,6 @@
|
|||||||
#ifndef WS2812FX_h
|
#ifndef WS2812FX_h
|
||||||
#define WS2812FX_h
|
#define WS2812FX_h
|
||||||
|
|
||||||
//TEMPORARY DEFINES FOR TESTING - MAKE THESE RUNTIME CONFIGURABLE TOO!
|
|
||||||
#ifndef LEDPIN
|
|
||||||
#define LEDPIN 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BTNPIN
|
|
||||||
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TOUCHPIN
|
|
||||||
//#define TOUCHPIN T0 //touch pin. Behaves the same as button. ESP32 only.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IRPIN
|
|
||||||
#define IRPIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RLYPIN
|
|
||||||
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef AUXPIN
|
|
||||||
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RLYMDE
|
|
||||||
#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
|
|
||||||
#endif
|
|
||||||
//END OF TEMP DEFINES
|
|
||||||
|
|
||||||
#ifdef ESP32_MULTISTRIP
|
|
||||||
#include "../usermods/esp32_multistrip/NpbWrapper.h"
|
|
||||||
#else
|
|
||||||
#include "bus_manager.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
#define FASTLED_INTERNAL //remove annoying pragma messages
|
#define FASTLED_INTERNAL //remove annoying pragma messages
|
||||||
@ -616,12 +580,11 @@ class WS2812FX {
|
|||||||
ablMilliampsMax = 850;
|
ablMilliampsMax = 850;
|
||||||
currentMilliamps = 0;
|
currentMilliamps = 0;
|
||||||
timebase = 0;
|
timebase = 0;
|
||||||
busses = new BusManager();
|
|
||||||
resetSegments();
|
resetSegments();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(bool supportWhite, uint16_t countPixels, bool skipFirst),
|
finalizeInit(bool supportWhite, uint16_t countPixels, bool skipFirst),
|
||||||
service(void),
|
service(void),
|
||||||
blur(uint8_t),
|
blur(uint8_t),
|
||||||
fill(uint32_t),
|
fill(uint32_t),
|
||||||
@ -661,6 +624,8 @@ class WS2812FX {
|
|||||||
paletteFade = 0,
|
paletteFade = 0,
|
||||||
paletteBlend = 0,
|
paletteBlend = 0,
|
||||||
milliampsPerLed = 55,
|
milliampsPerLed = 55,
|
||||||
|
// getStripType(uint8_t strip=0),
|
||||||
|
// setStripType(uint8_t type, uint8_t strip=0),
|
||||||
getBrightness(void),
|
getBrightness(void),
|
||||||
getMode(void),
|
getMode(void),
|
||||||
getSpeed(void),
|
getSpeed(void),
|
||||||
@ -675,11 +640,17 @@ class WS2812FX {
|
|||||||
get_random_wheel_index(uint8_t);
|
get_random_wheel_index(uint8_t);
|
||||||
|
|
||||||
int8_t
|
int8_t
|
||||||
|
// setStripPin(uint8_t strip, int8_t pin),
|
||||||
|
// getStripPin(uint8_t strip=0),
|
||||||
|
// setStripPinClk(uint8_t strip, int8_t pin),
|
||||||
|
// getStripPinClk(uint8_t strip=0),
|
||||||
tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec);
|
tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec);
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
ablMilliampsMax,
|
ablMilliampsMax,
|
||||||
currentMilliamps,
|
currentMilliamps,
|
||||||
|
// setStripLen(uint8_t strip, uint16_t len),
|
||||||
|
// getStripLen(uint8_t strip=0),
|
||||||
triwave16(uint16_t);
|
triwave16(uint16_t);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
@ -826,8 +797,6 @@ class WS2812FX {
|
|||||||
mode_dynamic_smooth(void);
|
mode_dynamic_smooth(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BusManager *busses;
|
|
||||||
|
|
||||||
uint32_t crgb_to_col(CRGB fastled);
|
uint32_t crgb_to_col(CRGB fastled);
|
||||||
CRGB col_to_crgb(uint32_t);
|
CRGB col_to_crgb(uint32_t);
|
||||||
CRGBPalette16 currentPalette;
|
CRGBPalette16 currentPalette;
|
||||||
|
@ -49,7 +49,7 @@ const uint16_t customMappingSize = sizeof(customMappingTable)/sizeof(uint16_t);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//do not call this method from system context (network callback)
|
//do not call this method from system context (network callback)
|
||||||
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
void WS2812FX::finalizeInit(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
||||||
{
|
{
|
||||||
if (supportWhite == _useRgbw && countPixels == _length && _skipFirstMode == skipFirst) return;
|
if (supportWhite == _useRgbw && countPixels == _length && _skipFirstMode == skipFirst) return;
|
||||||
RESET_RUNTIME;
|
RESET_RUNTIME;
|
||||||
@ -62,11 +62,12 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
|||||||
_lengthRaw += LED_SKIP_AMOUNT;
|
_lengthRaw += LED_SKIP_AMOUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t pins[] = {LEDPIN};
|
//if busses failed to load, add default (FS issue...)
|
||||||
|
if (busses.getNumBusses() == 0) {
|
||||||
while (!busses->canAllShow()) yield();
|
uint8_t defPin[] = {LEDPIN};
|
||||||
busses->removeAll();
|
BusConfig defCfg = BusConfig(TYPE_WS2812_RGB, defPin, 0, _lengthRaw, COL_ORDER_GRB);
|
||||||
busses->add(supportWhite? TYPE_SK6812_RGBW : TYPE_WS2812_RGB, pins, 0, countPixels, COL_ORDER_GRB);
|
busses.add(defCfg);
|
||||||
|
}
|
||||||
|
|
||||||
_segments[0].start = 0;
|
_segments[0].start = 0;
|
||||||
_segments[0].stop = _length;
|
_segments[0].stop = _length;
|
||||||
@ -74,8 +75,8 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
|||||||
setBrightness(_brightness);
|
setBrightness(_brightness);
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
for (uint8_t i = 0; i < busses->getNumBusses(); i++) {
|
for (uint8_t i = 0; i < busses.getNumBusses(); i++) {
|
||||||
Bus* b = busses->getBus(i);
|
Bus* b = busses.getBus(i);
|
||||||
if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue;
|
if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue;
|
||||||
uint8_t pins[5];
|
uint8_t pins[5];
|
||||||
b->getPins(pins);
|
b->getPins(pins);
|
||||||
@ -205,12 +206,12 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
|||||||
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
||||||
#endif
|
#endif
|
||||||
if (indexSetRev >= SEGMENT.start && indexSetRev < SEGMENT.stop) {
|
if (indexSetRev >= SEGMENT.start && indexSetRev < SEGMENT.stop) {
|
||||||
busses->setPixelColor(indexSet + skip, col);
|
busses.setPixelColor(indexSet + skip, col);
|
||||||
if (IS_MIRROR) { //set the corresponding mirrored pixel
|
if (IS_MIRROR) { //set the corresponding mirrored pixel
|
||||||
if (reverseMode) {
|
if (reverseMode) {
|
||||||
busses->setPixelColor(REV(SEGMENT.start) - indexSet + skip + REV(SEGMENT.stop) + 1, col);
|
busses.setPixelColor(REV(SEGMENT.start) - indexSet + skip + REV(SEGMENT.stop) + 1, col);
|
||||||
} else {
|
} else {
|
||||||
busses->setPixelColor(SEGMENT.stop - indexSet + skip + SEGMENT.start - 1, col);
|
busses.setPixelColor(SEGMENT.stop - indexSet + skip + SEGMENT.start - 1, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,11 +222,11 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
|||||||
if (i < customMappingSize) i = customMappingTable[i];
|
if (i < customMappingSize) i = customMappingTable[i];
|
||||||
#endif
|
#endif
|
||||||
uint32_t col = ((w << 24) | (r << 16) | (g << 8) | (b));
|
uint32_t col = ((w << 24) | (r << 16) | (g << 8) | (b));
|
||||||
busses->setPixelColor(i + skip, col);
|
busses.setPixelColor(i + skip, col);
|
||||||
}
|
}
|
||||||
if (skip && i == 0) {
|
if (skip && i == 0) {
|
||||||
for (uint16_t j = 0; j < skip; j++) {
|
for (uint16_t j = 0; j < skip; j++) {
|
||||||
busses->setPixelColor(j, BLACK);
|
busses.setPixelColor(j, BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,7 +277,7 @@ void WS2812FX::show(void) {
|
|||||||
|
|
||||||
for (uint16_t i = 0; i < _length; i++) //sum up the usage of each LED
|
for (uint16_t i = 0; i < _length; i++) //sum up the usage of each LED
|
||||||
{
|
{
|
||||||
RgbwColor c = busses->getPixelColor(i);
|
RgbwColor c = busses.getPixelColor(i);
|
||||||
|
|
||||||
if(useWackyWS2815PowerModel)
|
if(useWackyWS2815PowerModel)
|
||||||
{
|
{
|
||||||
@ -305,24 +306,24 @@ void WS2812FX::show(void) {
|
|||||||
uint16_t scaleI = scale * 255;
|
uint16_t scaleI = scale * 255;
|
||||||
uint8_t scaleB = (scaleI > 255) ? 255 : scaleI;
|
uint8_t scaleB = (scaleI > 255) ? 255 : scaleI;
|
||||||
uint8_t newBri = scale8(_brightness, scaleB);
|
uint8_t newBri = scale8(_brightness, scaleB);
|
||||||
busses->setBrightness(newBri);
|
busses.setBrightness(newBri);
|
||||||
currentMilliamps = (powerSum0 * newBri) / puPerMilliamp;
|
currentMilliamps = (powerSum0 * newBri) / puPerMilliamp;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
currentMilliamps = powerSum / puPerMilliamp;
|
currentMilliamps = powerSum / puPerMilliamp;
|
||||||
busses->setBrightness(_brightness);
|
busses.setBrightness(_brightness);
|
||||||
}
|
}
|
||||||
currentMilliamps += MA_FOR_ESP; //add power of ESP back to estimate
|
currentMilliamps += MA_FOR_ESP; //add power of ESP back to estimate
|
||||||
currentMilliamps += _length; //add standby power back to estimate
|
currentMilliamps += _length; //add standby power back to estimate
|
||||||
} else {
|
} else {
|
||||||
currentMilliamps = 0;
|
currentMilliamps = 0;
|
||||||
busses->setBrightness(_brightness);
|
busses.setBrightness(_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some buses send asynchronously and this method will return before
|
// some buses send asynchronously and this method will return before
|
||||||
// all of the data has been sent.
|
// all of the data has been sent.
|
||||||
// See https://github.com/Makuna/NeoPixelBus/wiki/ESP32-NeoMethods#neoesp32rmt-methods
|
// See https://github.com/Makuna/NeoPixelBus/wiki/ESP32-NeoMethods#neoesp32rmt-methods
|
||||||
busses->show();
|
busses.show();
|
||||||
_lastShow = millis();
|
_lastShow = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +332,7 @@ void WS2812FX::show(void) {
|
|||||||
* On some hardware (ESP32), strip updates are done asynchronously.
|
* On some hardware (ESP32), strip updates are done asynchronously.
|
||||||
*/
|
*/
|
||||||
bool WS2812FX::isUpdating() {
|
bool WS2812FX::isUpdating() {
|
||||||
return !busses->canAllShow();
|
return !busses.canAllShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -492,7 +493,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
|
|||||||
|
|
||||||
if (i >= _lengthRaw) return 0;
|
if (i >= _lengthRaw) return 0;
|
||||||
|
|
||||||
return busses->getPixelColor(i);
|
return busses.getPixelColor(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
WS2812FX::Segment& WS2812FX::getSegment(uint8_t id) {
|
WS2812FX::Segment& WS2812FX::getSegment(uint8_t id) {
|
||||||
|
@ -10,6 +10,23 @@
|
|||||||
#include "bus_wrapper.h"
|
#include "bus_wrapper.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
//temporary struct for passing bus configuration to bus
|
||||||
|
struct BusConfig {
|
||||||
|
uint8_t type = TYPE_WS2812_RGB;
|
||||||
|
uint16_t count = 1;
|
||||||
|
uint16_t start = 0;
|
||||||
|
uint8_t colorOrder = COL_ORDER_GRB;
|
||||||
|
bool reversed = false;
|
||||||
|
uint8_t pins[5] = {LEDPIN, 255, 255, 255, 255};
|
||||||
|
BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false) {
|
||||||
|
type = busType; count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev;
|
||||||
|
uint8_t nPins = 1;
|
||||||
|
if (type > 47) nPins = 2;
|
||||||
|
else if (type > 41 && type < 46) nPins = NUM_PWM_PINS(type);
|
||||||
|
for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//parent class of BusDigital and BusPwm
|
//parent class of BusDigital and BusPwm
|
||||||
class Bus {
|
class Bus {
|
||||||
public:
|
public:
|
||||||
@ -73,23 +90,23 @@ class Bus {
|
|||||||
|
|
||||||
class BusDigital : public Bus {
|
class BusDigital : public Bus {
|
||||||
public:
|
public:
|
||||||
BusDigital(uint8_t type, uint8_t* pins, uint16_t start, uint16_t len, uint8_t colorOrder, uint8_t nr, bool rev) : Bus(type, start) {
|
BusDigital(BusConfig &bc, uint8_t nr) : Bus(bc.type, bc.start) {
|
||||||
if (!IS_DIGITAL(type) || !len) return;
|
if (!IS_DIGITAL(bc.type) || !bc.count) return;
|
||||||
_pins[0] = pins[0];
|
_pins[0] = bc.pins[0];
|
||||||
if (!pinManager.allocatePin(_pins[0])) return;
|
if (!pinManager.allocatePin(_pins[0])) return;
|
||||||
if (IS_2PIN(type)) {
|
if (IS_2PIN(bc.type)) {
|
||||||
_pins[1] = pins[1];
|
_pins[1] = bc.pins[1];
|
||||||
if (!pinManager.allocatePin(_pins[1])) {
|
if (!pinManager.allocatePin(_pins[1])) {
|
||||||
cleanup(); return;
|
cleanup(); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_len = len;
|
_len = bc.count;
|
||||||
reversed = rev;
|
reversed = bc.reversed;
|
||||||
_iType = PolyBus::getI(type, _pins, nr);
|
_iType = PolyBus::getI(bc.type, _pins, nr);
|
||||||
if (_iType == I_NONE) return;
|
if (_iType == I_NONE) return;
|
||||||
_busPtr = PolyBus::create(_iType, _pins, _len);
|
_busPtr = PolyBus::create(_iType, _pins, _len);
|
||||||
_valid = (_busPtr != nullptr);
|
_valid = (_busPtr != nullptr);
|
||||||
_colorOrder = colorOrder;
|
_colorOrder = bc.colorOrder;
|
||||||
//Serial.printf("Successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n",nr, len, type, pins[0],pins[1],_iType);
|
//Serial.printf("Successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n",nr, len, type, pins[0],pins[1],_iType);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,9 +187,9 @@ class BusDigital : public Bus {
|
|||||||
|
|
||||||
class BusPwm : public Bus {
|
class BusPwm : public Bus {
|
||||||
public:
|
public:
|
||||||
BusPwm(uint8_t type, uint8_t* pins, uint16_t start) : Bus(type, start) {
|
BusPwm(BusConfig &bc) : Bus(bc.type, bc.start) {
|
||||||
if (!IS_PWM(type)) return;
|
if (!IS_PWM(bc.type)) return;
|
||||||
uint8_t numPins = NUM_PWM_PINS(type);
|
uint8_t numPins = NUM_PWM_PINS(bc.type);
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
analogWriteRange(255); //same range as one RGB channel
|
analogWriteRange(255); //same range as one RGB channel
|
||||||
@ -185,7 +202,7 @@ class BusPwm : public Bus {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t i = 0; i < numPins; i++) {
|
for (uint8_t i = 0; i < numPins; i++) {
|
||||||
_pins[i] = pins[i];
|
_pins[i] = bc.pins[i];
|
||||||
if (!pinManager.allocatePin(_pins[i])) {
|
if (!pinManager.allocatePin(_pins[i])) {
|
||||||
deallocatePins(); return;
|
deallocatePins(); return;
|
||||||
}
|
}
|
||||||
@ -281,19 +298,22 @@ class BusManager {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int add(uint8_t busType, uint8_t* pins, uint16_t start, uint16_t len = 1, uint8_t colorOrder = COL_ORDER_GRB, bool rev = false) {
|
int add(BusConfig &bc) {
|
||||||
if (numBusses >= WLED_MAX_BUSSES) return -1;
|
if (numBusses >= WLED_MAX_BUSSES) return -1;
|
||||||
if (IS_DIGITAL(busType)) {
|
if (IS_DIGITAL(bc.type)) {
|
||||||
busses[numBusses] = new BusDigital(busType, pins, start, len, colorOrder, numBusses, rev);
|
busses[numBusses] = new BusDigital(bc, numBusses);
|
||||||
} else {
|
} else {
|
||||||
busses[numBusses] = new BusPwm(busType, pins, start);
|
busses[numBusses] = new BusPwm(bc);
|
||||||
}
|
}
|
||||||
numBusses++;
|
numBusses++;
|
||||||
return numBusses -1;
|
return numBusses -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//do not call this method from system context (network callback)
|
||||||
void removeAll() {
|
void removeAll() {
|
||||||
//Serial.println("Removing all.");
|
//Serial.println("Removing all.");
|
||||||
|
//prevents crashes due to deleting busses while in use.
|
||||||
|
while (!canAllShow()) yield();
|
||||||
for (uint8_t i = 0; i < numBusses; i++) delete busses[i];
|
for (uint8_t i = 0; i < numBusses; i++) delete busses[i];
|
||||||
numBusses = 0;
|
numBusses = 0;
|
||||||
}
|
}
|
||||||
@ -346,6 +366,12 @@ class BusManager {
|
|||||||
return numBusses;
|
return numBusses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isRgbw(uint8_t type) {
|
||||||
|
if (type == TYPE_SK6812_RGBW || type == TYPE_TM1814) return true;
|
||||||
|
if (type > TYPE_ONOFF && type <= TYPE_ANALOG_5CH && type != TYPE_ANALOG_3CH) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t numBusses = 0;
|
uint8_t numBusses = 0;
|
||||||
Bus* busses[WLED_MAX_BUSSES];
|
Bus* busses[WLED_MAX_BUSSES];
|
||||||
|
@ -17,9 +17,7 @@ void shortPressAction()
|
|||||||
|
|
||||||
bool isButtonPressed()
|
bool isButtonPressed()
|
||||||
{
|
{
|
||||||
#if defined(BTNPIN) && BTNPIN > -1
|
if (btnPin>=0 && digitalRead(btnPin) == LOW) return true;
|
||||||
if (digitalRead(BTNPIN) == LOW) return true;
|
|
||||||
#endif
|
|
||||||
#ifdef TOUCHPIN
|
#ifdef TOUCHPIN
|
||||||
if (touchRead(TOUCHPIN) <= TOUCH_THRESHOLD) return true;
|
if (touchRead(TOUCHPIN) <= TOUCH_THRESHOLD) return true;
|
||||||
#endif
|
#endif
|
||||||
@ -29,8 +27,7 @@ bool isButtonPressed()
|
|||||||
|
|
||||||
void handleButton()
|
void handleButton()
|
||||||
{
|
{
|
||||||
#if (defined(BTNPIN) && BTNPIN > -1) || defined(TOUCHPIN)
|
if (btnPin<0 || !buttonEnabled) return;
|
||||||
if (!buttonEnabled) return;
|
|
||||||
|
|
||||||
if (isButtonPressed()) //pressed
|
if (isButtonPressed()) //pressed
|
||||||
{
|
{
|
||||||
@ -75,7 +72,6 @@ void handleButton()
|
|||||||
buttonWaitTime = 0;
|
buttonWaitTime = 0;
|
||||||
shortPressAction();
|
shortPressAction();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIO()
|
void handleIO()
|
||||||
@ -88,37 +84,39 @@ void handleIO()
|
|||||||
lastOnTime = millis();
|
lastOnTime = millis();
|
||||||
if (offMode)
|
if (offMode)
|
||||||
{
|
{
|
||||||
#if RLYPIN >= 0
|
if (rlyPin>=0) {
|
||||||
digitalWrite(RLYPIN, RLYMDE);
|
pinMode(rlyPin, OUTPUT);
|
||||||
#endif
|
digitalWrite(rlyPin, rlyMde);
|
||||||
|
}
|
||||||
offMode = false;
|
offMode = false;
|
||||||
}
|
}
|
||||||
} else if (millis() - lastOnTime > 600)
|
} else if (millis() - lastOnTime > 600)
|
||||||
{
|
{
|
||||||
if (!offMode) {
|
if (!offMode) {
|
||||||
#if LEDPIN == LED_BUILTIN
|
#ifdef ESP8266
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
//turn off built-in LED if strip is turned off
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
#endif
|
#endif
|
||||||
#if RLYPIN >= 0
|
if (rlyPin>=0) {
|
||||||
digitalWrite(RLYPIN, !RLYMDE);
|
pinMode(rlyPin, OUTPUT);
|
||||||
#endif
|
digitalWrite(rlyPin, !rlyMde);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
offMode = true;
|
offMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if AUXPIN >= 0
|
|
||||||
//output
|
//output
|
||||||
if (auxActive || auxActiveBefore)
|
if (auxPin>=1 && (auxActive || auxActiveBefore))
|
||||||
{
|
{
|
||||||
if (!auxActiveBefore)
|
if (!auxActiveBefore)
|
||||||
{
|
{
|
||||||
auxActiveBefore = true;
|
auxActiveBefore = true;
|
||||||
switch (auxTriggeredState)
|
switch (auxTriggeredState)
|
||||||
{
|
{
|
||||||
case 0: pinMode(AUXPIN, INPUT); break;
|
case 0: pinMode(auxPin, INPUT); break;
|
||||||
case 1: pinMode(AUXPIN, OUTPUT); digitalWrite(AUXPIN, HIGH); break;
|
case 1: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, HIGH); break;
|
||||||
case 2: pinMode(AUXPIN, OUTPUT); digitalWrite(AUXPIN, LOW); break;
|
case 2: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, LOW); break;
|
||||||
}
|
}
|
||||||
auxStartTime = millis();
|
auxStartTime = millis();
|
||||||
}
|
}
|
||||||
@ -128,11 +126,10 @@ void handleIO()
|
|||||||
auxActiveBefore = false;
|
auxActiveBefore = false;
|
||||||
switch (auxDefaultState)
|
switch (auxDefaultState)
|
||||||
{
|
{
|
||||||
case 0: pinMode(AUXPIN, INPUT); break;
|
case 0: pinMode(auxPin, INPUT); break;
|
||||||
case 1: pinMode(AUXPIN, OUTPUT); digitalWrite(AUXPIN, HIGH); break;
|
case 1: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, HIGH); break;
|
||||||
case 2: pinMode(AUXPIN, OUTPUT); digitalWrite(AUXPIN, LOW); break;
|
case 2: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, LOW); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
161
wled00/cfg.cpp
161
wled00/cfg.cpp
@ -30,8 +30,6 @@ void deserializeConfig() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//deserializeJson(doc, json);
|
|
||||||
|
|
||||||
//int rev_major = doc[F("rev")][0]; // 1
|
//int rev_major = doc[F("rev")][0]; // 1
|
||||||
//int rev_minor = doc[F("rev")][1]; // 0
|
//int rev_minor = doc[F("rev")][1]; // 0
|
||||||
|
|
||||||
@ -89,7 +87,9 @@ void deserializeConfig() {
|
|||||||
|
|
||||||
JsonObject hw = doc[F("hw")];
|
JsonObject hw = doc[F("hw")];
|
||||||
|
|
||||||
|
// initialize LED pins and lengths prior to other HW
|
||||||
JsonObject hw_led = hw[F("led")];
|
JsonObject hw_led = hw[F("led")];
|
||||||
|
|
||||||
CJSON(ledCount, hw_led[F("total")]);
|
CJSON(ledCount, hw_led[F("total")]);
|
||||||
if (ledCount > MAX_LEDS) ledCount = MAX_LEDS;
|
if (ledCount > MAX_LEDS) ledCount = MAX_LEDS;
|
||||||
|
|
||||||
@ -98,22 +98,51 @@ void deserializeConfig() {
|
|||||||
CJSON(strip.reverseMode, hw_led[F("rev")]);
|
CJSON(strip.reverseMode, hw_led[F("rev")]);
|
||||||
CJSON(strip.rgbwMode, hw_led[F("rgbwm")]);
|
CJSON(strip.rgbwMode, hw_led[F("rgbwm")]);
|
||||||
|
|
||||||
JsonObject hw_led_ins_0 = hw_led[F("ins")][0];
|
JsonArray ins = hw_led["ins"];
|
||||||
//bool hw_led_ins_0_en = hw_led_ins_0[F("en")]; // true
|
uint8_t s = 0;
|
||||||
//int hw_led_ins_0_start = hw_led_ins_0[F("start")]; // 0
|
useRGBW = false;
|
||||||
//int hw_led_ins_0_len = hw_led_ins_0[F("len")]; // 1200
|
busses.removeAll();
|
||||||
|
for (JsonObject elm : ins) {
|
||||||
|
if (s >= WLED_MAX_BUSSES) break;
|
||||||
|
uint8_t pins[5] = {255, 255, 255, 255, 255};
|
||||||
|
JsonArray pinArr = elm[F("pin")];
|
||||||
|
if (pinArr.size() == 0) continue;
|
||||||
|
pins[0] = pinArr[0];
|
||||||
|
uint8_t i = 0;
|
||||||
|
for (int p : pinArr) {
|
||||||
|
pins[i] = p;
|
||||||
|
i++;
|
||||||
|
if (i>4) break;
|
||||||
|
}
|
||||||
|
|
||||||
//int hw_led_ins_0_pin_0 = hw_led_ins_0[F("pin")][0]; // 2
|
uint16_t length = elm[F("len")];
|
||||||
|
if (length==0) continue;
|
||||||
strip.setColorOrder(hw_led_ins_0[F("order")]);
|
uint8_t colorOrder = (int)elm[F("order")];
|
||||||
//bool hw_led_ins_0_rev = hw_led_ins_0[F("rev")]; // false
|
//only use skip from the first strip (this shouldn't have been in ins obj. but remains here for compatibility)
|
||||||
skipFirstLed = hw_led_ins_0[F("skip")]; // 0
|
if (s==0) skipFirstLed = elm[F("skip")];
|
||||||
useRGBW = (hw_led_ins_0[F("type")] == TYPE_SK6812_RGBW);
|
uint16_t start = elm[F("start")] | 0;
|
||||||
|
if (start >= ledCount) continue;
|
||||||
|
//limit length of strip if it would exceed total configured LEDs
|
||||||
|
if (start + length > ledCount) length = ledCount - start;
|
||||||
|
uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB;
|
||||||
|
bool reversed = elm[F("rev")];
|
||||||
|
//RGBW mode is enabled if at least one of the strips is RGBW
|
||||||
|
useRGBW = (useRGBW || BusManager::isRgbw(ledType));
|
||||||
|
s++;
|
||||||
|
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed);
|
||||||
|
busses.add(bc);
|
||||||
|
}
|
||||||
|
strip.finalizeInit(useRGBW, ledCount, skipFirstLed);
|
||||||
|
|
||||||
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
|
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
|
||||||
buttonEnabled = hw_btn_ins_0[F("en")] | buttonEnabled;
|
CJSON(buttonEnabled, hw_btn_ins_0[F("type")]);
|
||||||
|
int hw_btn_pin = hw_btn_ins_0[F("pin")][0];
|
||||||
//int hw_btn_ins_0_pin_0 = hw_btn_ins_0[F("pin")][0]; // 0
|
if (pinManager.allocatePin(hw_btn_pin,false)) {
|
||||||
|
btnPin = hw_btn_pin;
|
||||||
|
pinMode(btnPin, INPUT_PULLUP);
|
||||||
|
} else {
|
||||||
|
btnPin = -1;
|
||||||
|
}
|
||||||
|
|
||||||
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0[F("macros")];
|
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0[F("macros")];
|
||||||
CJSON(macroButton, hw_btn_ins_0_macros[0]);
|
CJSON(macroButton, hw_btn_ins_0_macros[0]);
|
||||||
@ -122,11 +151,24 @@ void deserializeConfig() {
|
|||||||
|
|
||||||
//int hw_btn_ins_0_type = hw_btn_ins_0[F("type")]; // 0
|
//int hw_btn_ins_0_type = hw_btn_ins_0[F("type")]; // 0
|
||||||
|
|
||||||
//int hw_ir_pin = hw[F("ir")][F("pin")]; // 4
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
CJSON(irEnabled, hw[F("ir")][F("type")]); // 0
|
int hw_ir_pin = hw[F("ir")][F("pin")]; // 4
|
||||||
|
if (pinManager.allocatePin(hw_ir_pin,false)) {
|
||||||
|
irPin = hw_ir_pin;
|
||||||
|
} else {
|
||||||
|
irPin = -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
CJSON(irEnabled, hw[F("ir")][F("type")]);
|
||||||
|
|
||||||
//int hw_relay_pin = hw[F("relay")][F("pin")]; // 12
|
int hw_relay_pin = hw[F("relay")][F("pin")];
|
||||||
//bool hw_relay_rev = hw[F("relay")][F("rev")]; // false
|
if (pinManager.allocatePin(hw_relay_pin,true)) {
|
||||||
|
rlyPin = hw_relay_pin;
|
||||||
|
pinMode(rlyPin, OUTPUT);
|
||||||
|
} else {
|
||||||
|
rlyPin = -1;
|
||||||
|
}
|
||||||
|
CJSON(rlyMde, hw[F("relay")][F("rev")]);
|
||||||
|
|
||||||
//int hw_status_pin = hw[F("status")][F("pin")]; // -1
|
//int hw_status_pin = hw[F("status")][F("pin")]; // -1
|
||||||
|
|
||||||
@ -404,70 +446,57 @@ void serializeConfig() {
|
|||||||
|
|
||||||
JsonArray hw_led_ins = hw_led.createNestedArray("ins");
|
JsonArray hw_led_ins = hw_led.createNestedArray("ins");
|
||||||
|
|
||||||
JsonObject hw_led_ins_0 = hw_led_ins.createNestedObject();
|
uint16_t start = 0;
|
||||||
hw_led_ins_0[F("en")] = true;
|
for (uint8_t s = 0; s < busses.getNumBusses(); s++) {
|
||||||
hw_led_ins_0[F("start")] = 0;
|
Bus *bus = busses.getBus(s);
|
||||||
hw_led_ins_0[F("len")] = ledCount;
|
if (!bus || bus->getLength()==0) break;
|
||||||
JsonArray hw_led_ins_0_pin = hw_led_ins_0.createNestedArray("pin");
|
JsonObject ins = hw_led_ins.createNestedObject();
|
||||||
hw_led_ins_0_pin.add(LEDPIN);
|
ins[F("en")] = true;
|
||||||
#ifdef DATAPIN
|
ins[F("start")] = bus->getStart();
|
||||||
hw_led_ins_0_pin.add(DATAPIN);
|
ins[F("len")] = bus->getLength();
|
||||||
#endif
|
JsonArray ins_pin = ins.createNestedArray("pin");
|
||||||
hw_led_ins_0[F("order")] = strip.getColorOrder();
|
uint8_t pins[5];
|
||||||
hw_led_ins_0[F("rev")] = false;
|
uint8_t nPins = bus->getPins(pins);
|
||||||
hw_led_ins_0[F("skip")] = skipFirstLed ? 1 : 0;
|
for (uint8_t i = 0; i < nPins; i++) ins_pin.add(pins[i]);
|
||||||
|
ins[F("order")] = bus->getColorOrder();
|
||||||
//this is very crude and temporary
|
ins[F("rev")] = bus->reversed;
|
||||||
byte ledType = TYPE_WS2812_RGB;
|
ins[F("skip")] = (skipFirstLed && s == 0) ? 1 : 0;
|
||||||
if (useRGBW) ledType = TYPE_SK6812_RGBW;
|
ins[F("type")] = bus->getType();
|
||||||
#ifdef USE_WS2801
|
}
|
||||||
ledType = TYPE_WS2801;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_APA102
|
|
||||||
ledType = TYPE_APA102;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_LPD8806
|
|
||||||
ledType = TYPE_LPD8806;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_P9813
|
|
||||||
ledType = TYPE_P9813;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_TM1814
|
|
||||||
ledType = TYPE_TM1814;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hw_led_ins_0[F("type")] = ledType;
|
|
||||||
|
|
||||||
JsonObject hw_btn = hw.createNestedObject("btn");
|
JsonObject hw_btn = hw.createNestedObject("btn");
|
||||||
|
|
||||||
JsonArray hw_btn_ins = hw_btn.createNestedArray("ins");
|
JsonArray hw_btn_ins = hw_btn.createNestedArray("ins");
|
||||||
|
|
||||||
#if defined(BTNPIN) && BTNPIN > -1
|
// button BTNPIN
|
||||||
JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject();
|
JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject();
|
||||||
hw_btn_ins_0[F("type")] = (buttonEnabled) ? BTN_TYPE_PUSH : BTN_TYPE_NONE;
|
hw_btn_ins_0[F("type")] = (buttonEnabled) ? BTN_TYPE_PUSH : BTN_TYPE_NONE;
|
||||||
|
|
||||||
JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
|
JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
|
||||||
hw_btn_ins_0_pin.add(BTNPIN);
|
hw_btn_ins_0_pin.add(btnPin);
|
||||||
|
|
||||||
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0.createNestedArray("macros");
|
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0.createNestedArray("macros");
|
||||||
hw_btn_ins_0_macros.add(macroButton);
|
hw_btn_ins_0_macros.add(macroButton);
|
||||||
hw_btn_ins_0_macros.add(macroLongPress);
|
hw_btn_ins_0_macros.add(macroLongPress);
|
||||||
hw_btn_ins_0_macros.add(macroDoublePress);
|
hw_btn_ins_0_macros.add(macroDoublePress);
|
||||||
|
|
||||||
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
|
if (irPin>=0) {
|
||||||
|
JsonObject hw_ir = hw.createNestedObject("ir");
|
||||||
|
hw_ir[F("pin")] = irPin;
|
||||||
|
hw_ir[F("type")] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled )
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(IRPIN) && IRPIN > -1
|
|
||||||
JsonObject hw_ir = hw.createNestedObject("ir");
|
|
||||||
hw_ir[F("pin")] = IRPIN;
|
|
||||||
hw_ir[F("type")] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(RLYPIN) && RLYPIN > -1
|
|
||||||
JsonObject hw_relay = hw.createNestedObject("relay");
|
JsonObject hw_relay = hw.createNestedObject("relay");
|
||||||
hw_relay[F("pin")] = RLYPIN;
|
hw_relay[F("pin")] = rlyPin;
|
||||||
hw_relay[F("rev")] = (RLYMDE) ? false : true;
|
hw_relay[F("rev")] = rlyMde;
|
||||||
JsonObject hw_status = hw.createNestedObject("status");
|
|
||||||
hw_status[F("pin")] = -1;
|
//JsonObject hw_status = hw.createNestedObject("status");
|
||||||
#endif
|
//hw_status[F("pin")] = -1;
|
||||||
|
|
||||||
|
JsonObject hw_aux = hw.createNestedObject("aux");
|
||||||
|
hw_aux[F("pin")] = auxPin;
|
||||||
|
|
||||||
JsonObject light = doc.createNestedObject("light");
|
JsonObject light = doc.createNestedObject("light");
|
||||||
light[F("scale-bri")] = briMultiplier;
|
light[F("scale-bri")] = briMultiplier;
|
||||||
|
@ -95,8 +95,8 @@
|
|||||||
#define TYPE_WS2812_RGB 22
|
#define TYPE_WS2812_RGB 22
|
||||||
#define TYPE_GS8608 23 //same driver as WS2812, but will require signal 2x per second (else displays test pattern)
|
#define TYPE_GS8608 23 //same driver as WS2812, but will require signal 2x per second (else displays test pattern)
|
||||||
#define TYPE_WS2811_400KHZ 24 //half-speed WS2812 protocol, used by very old WS2811 units
|
#define TYPE_WS2811_400KHZ 24 //half-speed WS2812 protocol, used by very old WS2811 units
|
||||||
#define TYPE_TM1814 25
|
|
||||||
#define TYPE_SK6812_RGBW 30
|
#define TYPE_SK6812_RGBW 30
|
||||||
|
#define TYPE_TM1814 31
|
||||||
//"Analog" types (PWM) (32-47)
|
//"Analog" types (PWM) (32-47)
|
||||||
#define TYPE_ONOFF 40 //binary output (relays etc.)
|
#define TYPE_ONOFF 40 //binary output (relays etc.)
|
||||||
#define TYPE_ANALOG_1CH 41 //single channel PWM. Uses value of brightest RGBW channel
|
#define TYPE_ANALOG_1CH 41 //single channel PWM. Uses value of brightest RGBW channel
|
||||||
@ -163,6 +163,9 @@
|
|||||||
#define ERR_FS_QUOTA 11 // The FS is full or the maximum file size is reached
|
#define ERR_FS_QUOTA 11 // The FS is full or the maximum file size is reached
|
||||||
#define ERR_FS_PLOAD 12 // It was attempted to load a preset that does not exist
|
#define ERR_FS_PLOAD 12 // It was attempted to load a preset that does not exist
|
||||||
#define ERR_FS_GENERAL 19 // A general unspecified filesystem error occured
|
#define ERR_FS_GENERAL 19 // A general unspecified filesystem error occured
|
||||||
|
#define ERR_OVERTEMP 30 // An attached temperature sensor has measured above threshold temperature (not implemented)
|
||||||
|
#define ERR_OVERCURRENT 31 // An attached current sensor has measured a current above the threshold (not implemented)
|
||||||
|
#define ERR_UNDERVOLT 32 // An attached voltmeter has measured a voltage below the threshold (not implemented)
|
||||||
|
|
||||||
//Timer mode types
|
//Timer mode types
|
||||||
#define NL_MODE_SET 0 //After nightlight time elapsed, set to target brightness
|
#define NL_MODE_SET 0 //After nightlight time elapsed, set to target brightness
|
||||||
@ -205,4 +208,9 @@
|
|||||||
#define JSON_BUFFER_SIZE 16384
|
#define JSON_BUFFER_SIZE 16384
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//this is merely a default now and can be changed at runtime
|
||||||
|
#ifndef LEDPIN
|
||||||
|
#define LEDPIN 2
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=500">
|
<meta name="viewport" content="width=500">
|
||||||
<title>LED Settings</title>
|
<title>LED Settings</title>
|
||||||
<script>
|
<script>
|
||||||
var d=document,laprev=55;
|
var d=document,laprev=55,maxST=1,bmax=5000,bquot=0; //maximum bytes for LED allocation: 5kB for 8266, 32kB for 32
|
||||||
function H()
|
function H()
|
||||||
{
|
{
|
||||||
window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings");
|
window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings");
|
||||||
@ -13,8 +13,29 @@
|
|||||||
function B()
|
function B()
|
||||||
{
|
{
|
||||||
window.open("/settings","_self");
|
window.open("/settings","_self");
|
||||||
}
|
}
|
||||||
function S(){GetV();setABL();}
|
function trySubmit() {
|
||||||
|
var LCs = d.getElementsByTagName("input");
|
||||||
|
for (i=0; i<LCs.length; i++) {
|
||||||
|
var nm = LCs[i].name.substring(0,2);
|
||||||
|
|
||||||
|
//check for pin conflicts
|
||||||
|
if (nm=="L0" || nm=="L1" || nm=="RL" || nm=="BT" || nm=="IR" || nm=="AX")
|
||||||
|
if (LCs[i].value!="" && LCs[i].value!="-1") {
|
||||||
|
if (LCs[i].value > 5 && LCs[i].value < 12) {alert("Sorry, pins 6-11 can not be used.");LCs[i].focus();return;}
|
||||||
|
if (d.um_p && d.um_p.some((e)=>e==parseInt(LCs[i].value,10))) {alert("Usermod pin conflict!");LCs[i].focus();return;}
|
||||||
|
for (j=i+1; j<LCs.length; j++)
|
||||||
|
{
|
||||||
|
var n2 = LCs[j].name.substring(0,2);
|
||||||
|
if (n2=="L0" || n2=="L1" || n2=="RL" || n2=="BT" || n2=="IR" || n2=="AX")
|
||||||
|
if (LCs[j].value!="" && LCs[i].value==LCs[j].value) {alert("Pin conflict!");LCs[i].focus();return;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bquot > 100) {var msg = "Too many LEDs for me to handle!"; if (bmax < 10000) msg += " Consider using an ESP32."; alert(msg); return;}
|
||||||
|
if (d.Sf.reportValidity()) d.Sf.submit();
|
||||||
|
}
|
||||||
|
function S(){GetV();setABL(); if (maxST>4) bmax=32000; d.getElementById('m1').innerHTML = bmax;}
|
||||||
function enABL()
|
function enABL()
|
||||||
{
|
{
|
||||||
var en = d.getElementById('able').checked;
|
var en = d.getElementById('able').checked;
|
||||||
@ -43,22 +64,95 @@
|
|||||||
default: d.getElementById('LAdis').style.display = 'inline';
|
default: d.getElementById('LAdis').style.display = 'inline';
|
||||||
}
|
}
|
||||||
UI();
|
UI();
|
||||||
|
}
|
||||||
|
//returns mem usage
|
||||||
|
function getMem(type, len, p0) {
|
||||||
|
//len = parseInt(len);
|
||||||
|
if (type < 32) {
|
||||||
|
if (bmax < 10000 && p0 ==3) { //8266 DMA uses 5x the mem
|
||||||
|
if (type > 29) return len*20; //RGBW
|
||||||
|
return len*15;
|
||||||
|
} else if (bmax > 10000) //ESP32 RMT uses double buffer?
|
||||||
|
{
|
||||||
|
if (type > 29) return len*8; //RGBW
|
||||||
|
return len*6;
|
||||||
|
}
|
||||||
|
if (type > 29) return len*4; //RGBW
|
||||||
|
return len*3;
|
||||||
|
}
|
||||||
|
if (type > 31 && type < 48) return 5;
|
||||||
|
if (type == 44 || type == 45) return len*4; //RGBW
|
||||||
|
return len*3;
|
||||||
}
|
}
|
||||||
function UI()
|
function UI()
|
||||||
{
|
{
|
||||||
var myC = d.querySelectorAll('.wc'),
|
var isRGBW = false, memu = 0;
|
||||||
l = myC.length;
|
|
||||||
for (i = 0; i < l; i++) {
|
|
||||||
myC[i].style.display = (d.getElementById('rgbw').checked) ? 'inline':'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
d.getElementById('ledwarning').style.display = (d.Sf.LC.value > 1000) ? 'inline':'none';
|
|
||||||
d.getElementById('ampwarning').style.display = (d.Sf.MA.value > 7200) ? 'inline':'none';
|
d.getElementById('ampwarning').style.display = (d.Sf.MA.value > 7200) ? 'inline':'none';
|
||||||
|
|
||||||
if (d.Sf.LA.value == 255) laprev = 12;
|
if (d.Sf.LA.value == 255) laprev = 12;
|
||||||
else if (d.Sf.LA.value > 0) laprev = d.Sf.LA.value;
|
else if (d.Sf.LA.value > 0) laprev = d.Sf.LA.value;
|
||||||
|
|
||||||
var val = Math.ceil((100 + d.Sf.LC.value * laprev)/500)/2;
|
var s = d.getElementsByTagName("select");
|
||||||
|
for (i=0; i<s.length; i++) {
|
||||||
|
if (s[i].name.substring(0,2)=="LT") {
|
||||||
|
n=s[i].name.substring(2);
|
||||||
|
var type = s[i].value;
|
||||||
|
d.getElementById("p0d"+n).innerHTML = (type > 49) ? "Data pin:" : (type >41) ? "Pins:" : "Pin:";
|
||||||
|
d.getElementById("p1d"+n).innerHTML = (type > 49) ? "Clk:" : "";
|
||||||
|
var LK = d.getElementsByName("L1"+n)[0];
|
||||||
|
|
||||||
|
memu += getMem(type, d.getElementsByName("LC"+n)[0].value, d.getElementsByName("L0"+n)[0].value);
|
||||||
|
|
||||||
|
for (p=1; p<5; p++) {
|
||||||
|
var LK = d.getElementsByName("L"+p+n)[0];
|
||||||
|
if (!LK) continue;
|
||||||
|
if ((type>49 && p==1) || (type>41 && type < 50 && (p+40 < type))) // TYPE_xxxx values from const.h
|
||||||
|
{
|
||||||
|
LK.style.display = "inline";
|
||||||
|
LK.required = true;
|
||||||
|
} else {
|
||||||
|
LK.style.display = "none";
|
||||||
|
LK.required = false;
|
||||||
|
LK.value="";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == 30 || type == 31 || type == 44 || type == 45) isRGBW = true;
|
||||||
|
d.getElementById("dig"+n).style.display = (type > 31 && type < 48) ? "none":"inline";
|
||||||
|
d.getElementById("psd"+n).innerHTML = (type > 31 && type < 48) ? "Index:":"Start:";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var myC = d.querySelectorAll('.wc'),
|
||||||
|
l = myC.length;
|
||||||
|
for (i = 0; i < l; i++) {
|
||||||
|
myC[i].style.display = (isRGBW) ? 'inline':'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.activeElement == d.getElementsByName("LC")[0]) {
|
||||||
|
var o = d.getElementsByClassName("iST");
|
||||||
|
var i = o.length;
|
||||||
|
if (i == 1) d.getElementsByName("LC0")[0].value = d.getElementsByName("LC")[0].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var LCs = d.getElementsByTagName("input");
|
||||||
|
var sLC = 0, maxLC = 0;
|
||||||
|
for (i=0; i<LCs.length; i++) {
|
||||||
|
var nm = LCs[i].name.substring(0,2);
|
||||||
|
if (nm=="LC" && LCs[i].name != "LC") {var c = parseInt(LCs[i].value,10); if (c) {sLC+=c; if (c>maxLC) maxLC = c;} continue;}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.getElementById('m0').innerHTML = memu;
|
||||||
|
bquot = memu / bmax * 100;
|
||||||
|
d.getElementById('dbar').style.background = `linear-gradient(90deg, ${bquot > 60 ? bquot > 90 ? "red":"orange":"#ccc"} 0 ${bquot}%%, #444 ${bquot}%% 100%%)`;
|
||||||
|
d.getElementById('ledwarning').style.display = (maxLC > 800 || bquot > 80) ? 'inline':'none';
|
||||||
|
//TODO add warning "Recommended pins on ESP8266 are 1 and 2 (3 only with low LED count)"
|
||||||
|
//TODO add overmemory warning
|
||||||
|
//TODO block disallowed pins 6-11
|
||||||
|
d.getElementById('wreason').innerHTML = (bquot > 80) ? "than 60%% of max. LED memory" : "800 LEDs per pin";
|
||||||
|
|
||||||
|
//var val = Math.ceil((100 + d.Sf.LC.value * laprev)/500)/2;
|
||||||
|
var val = Math.ceil((100 + sLC * laprev)/500)/2;
|
||||||
val = (val > 5) ? Math.ceil(val) : val;
|
val = (val > 5) ? Math.ceil(val) : val;
|
||||||
var s = "";
|
var s = "";
|
||||||
var is12V = (d.Sf.LAsel.value == 30);
|
var is12V = (d.Sf.LAsel.value == 30);
|
||||||
@ -72,18 +166,79 @@
|
|||||||
s += val;
|
s += val;
|
||||||
s += "A supply connected to LEDs";
|
s += "A supply connected to LEDs";
|
||||||
}
|
}
|
||||||
var val2 = Math.ceil((100 + d.Sf.LC.value * laprev)/1500)/2;
|
var val2 = Math.ceil((100 + sLC * laprev)/1500)/2;
|
||||||
val2 = (val2 > 5) ? Math.ceil(val2) : val2;
|
val2 = (val2 > 5) ? Math.ceil(val2) : val2;
|
||||||
var s2 = "(for most effects, ~";
|
var s2 = "(for most effects, ~";
|
||||||
s2 += val2;
|
s2 += val2;
|
||||||
s2 += "A is enough)<br>";
|
s2 += "A is enough)<br>";
|
||||||
d.getElementById('psu').innerHTML = s;
|
d.getElementById('psu').innerHTML = s;
|
||||||
d.getElementById('psu2').innerHTML = isWS2815 ? "" : s2;
|
d.getElementById('psu2').innerHTML = isWS2815 ? "" : s2;
|
||||||
}
|
}
|
||||||
|
function addLEDs(n)
|
||||||
|
{
|
||||||
|
if (n>1) {maxST=n; d.getElementById("+").style.display="inline"; return;}
|
||||||
|
|
||||||
|
var o = d.getElementsByClassName("iST");
|
||||||
|
var i = o.length;
|
||||||
|
|
||||||
|
if ((n==1 && i>=maxST) || (n==-1 && i==0)) return;
|
||||||
|
|
||||||
|
var f = d.getElementById("mLC");
|
||||||
|
if (n==1) {
|
||||||
|
var cn = `<div class="iST">
|
||||||
|
${i>0?'<hr style="width:260px">':''}
|
||||||
|
${i+1}:
|
||||||
|
<select name="LT${i}" onchange="UI()">
|
||||||
|
<option value="22">WS281x</option>
|
||||||
|
<option value="30">SK6812 RGBW</option>
|
||||||
|
<option value="31">TM1814</option>
|
||||||
|
<option value="24">400kHz</option>
|
||||||
|
<option value="50">WS2801</option>
|
||||||
|
<option value="51">APA102</option>
|
||||||
|
<option value="52">LPD8806</option>
|
||||||
|
<option value="53">P9813</option>
|
||||||
|
<option value="41">PWM White</option>
|
||||||
|
<option value="42">PWM WWCW</option>
|
||||||
|
<option value="43">PWM RGB</option>
|
||||||
|
<option value="44">PWM RGBW</option>
|
||||||
|
<option value="45">PWM RGBWC</option>
|
||||||
|
</select>
|
||||||
|
Color Order:
|
||||||
|
<select name="CO${i}">
|
||||||
|
<option value="0">GRB</option>
|
||||||
|
<option value="1">RGB</option>
|
||||||
|
<option value="2">BRG</option>
|
||||||
|
<option value="3">RBG</option>
|
||||||
|
<option value="4">BGR</option>
|
||||||
|
<option value="5">GBR</option>
|
||||||
|
</select><br>
|
||||||
|
<span id="p0d${i}">Pin:</span> <input type="number" name="L0${i}" min="0" max="40" required style="width:35px" oninput="UI()"/>
|
||||||
|
<span id="p1d${i}">Clock:</span> <input type="number" name="L1${i}" min="0" max="40" style="width:35px"/>
|
||||||
|
<span id="p2d${i}"></span><input type="number" name="L2${i}" min="0" max="40" style="width:35px"/>
|
||||||
|
<span id="p3d${i}"></span><input type="number" name="L3${i}" min="0" max="40" style="width:35px"/>
|
||||||
|
<span id="p4d${i}"></span><input type="number" name="L4${i}" min="0" max="40" style="width:35px"/>
|
||||||
|
<br>
|
||||||
|
<span id="psd${i}">Start:</span> <input type="number" name="LS${i}" min="0" max="8191" value="0" required />
|
||||||
|
<div id="dig${i}" style="display:inline">
|
||||||
|
Count: <input type="number" name="LC${i}" min="0" max="2048" value="1" required oninput="UI()" /><br>
|
||||||
|
Reverse: <input type="checkbox" name="CV${i}"></div><br>
|
||||||
|
</div>`;
|
||||||
|
f.insertAdjacentHTML("beforeend", cn);
|
||||||
|
}
|
||||||
|
if (n==-1) {
|
||||||
|
o[--i].remove();--i;
|
||||||
|
}
|
||||||
|
|
||||||
|
d.getElementById("+").style.display = (i<maxST-1) ? "inline":"none";
|
||||||
|
d.getElementById("-").style.display = (i>0) ? "inline":"none";
|
||||||
|
|
||||||
|
UI();
|
||||||
|
}
|
||||||
function GetV()
|
function GetV()
|
||||||
{
|
{
|
||||||
//values injected by server while sending HTML
|
//values injected by server while sending HTML
|
||||||
}
|
//d.um_p=[];addLEDs(3);d.Sf.LC.value=250;addLEDs(1);d.Sf.L00.value=2;d.Sf.L10.value=0;d.Sf.LC0.value=250;d.Sf.LT0.value=22;d.Sf.CO0.value=0;d.Sf.LS0.value=0;d.Sf.LS0.checked=0;d.Sf.MA.value=5400;d.Sf.LA.value=55;d.getElementsByClassName("pow")[0].innerHTML="350mA";d.Sf.CA.value=40;d.Sf.AW.value=3;d.Sf.BO.checked=0;d.Sf.BP.value=3;d.Sf.GB.checked=0;d.Sf.GC.checked=1;d.Sf.TF.checked=1;d.Sf.TD.value=700;d.Sf.PF.checked=0;d.Sf.BF.value=64;d.Sf.TB.value=0;d.Sf.TL.value=60;d.Sf.TW.value=1;d.Sf.PB.selectedIndex=0;d.Sf.RV.checked=0;d.Sf.SL.checked=0;d.Sf.RL.value=12;d.Sf.RM.checked=0;d.Sf.BT.value=-1;d.Sf.IR.value=-1;d.Sf.AX.value=-1;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
@import url("style.css");
|
@import url("style.css");
|
||||||
@ -92,62 +247,51 @@
|
|||||||
<body onload="S()">
|
<body onload="S()">
|
||||||
<form id="form_s" name="Sf" method="post">
|
<form id="form_s" name="Sf" method="post">
|
||||||
<div class="helpB"><button type="button" onclick="H()">?</button></div>
|
<div class="helpB"><button type="button" onclick="H()">?</button></div>
|
||||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
<button type="button" onclick="B()">Back</button><button type="button" onclick="trySubmit()">Save</button><hr>
|
||||||
<h2>LED setup</h2>
|
<h2>LED & Hardware setup</h2>
|
||||||
LED count: <input name="LC" type="number" min="1" max="1500" oninput="UI()" required><br>
|
Total LED count: <input name="LC" type="number" min="1" max="8192" oninput="UI()" required><br>
|
||||||
<div id="ledwarning" style="color: orange; display: none;">
|
<i>Recommended power supply for brightest white:</i><br>
|
||||||
⚠ You might run into stability or lag issues.<br>
|
<b><span id="psu">?</span></b><br>
|
||||||
Use less than 1000 LEDs per ESP for the best experience!<br>
|
<span id="psu2"><br></span>
|
||||||
</div>
|
<br>
|
||||||
<i>Recommended power supply for brightest white:</i><br>
|
Enable automatic brightness limiter: <input type="checkbox" name="ABen" onchange="enABL()" id="able"><br>
|
||||||
<b><span id="psu">?</span></b><br>
|
<div id="abl">
|
||||||
<span id="psu2"><br></span>
|
Maximum Current: <input name="MA" type="number" min="250" max="65000" oninput="UI()" required> mA<br>
|
||||||
<br>
|
<div id="ampwarning" style="color: orange; display: none;">
|
||||||
Enable automatic brightness limiter: <input type="checkbox" name="ABen" onchange="enABL()" id="able"><br>
|
⚠ Your power supply provides high current.<br>
|
||||||
<div id="abl">
|
To improve the safety of your setup,<br>
|
||||||
Maximum Current: <input name="MA" type="number" min="250" max="65000" oninput="UI()" required> mA<br>
|
please use thick cables,<br>
|
||||||
<div id="ampwarning" style="color: orange; display: none;">
|
multiple power injection points and a fuse!<br>
|
||||||
⚠ Your power supply provides high current.<br>
|
|
||||||
To improve the safety of your setup,<br>
|
|
||||||
please use thick cables,<br>
|
|
||||||
multiple power injection points and a fuse!<br>
|
|
||||||
</div>
|
|
||||||
<i>Automatically limits brightness to stay close to the limit.<br>
|
|
||||||
Keep at <1A if powering LEDs directly from the ESP 5V pin!<br>
|
|
||||||
If you are using an external power supply, enter its rating.<br>
|
|
||||||
(Current estimated usage: <span class="pow">unknown</span>)</i><br><br>
|
|
||||||
LED voltage (Max. current for a single LED):<br>
|
|
||||||
<select name="LAsel" onchange="enLA()">
|
|
||||||
<option value="55" selected>5V default (55mA)</option>
|
|
||||||
<option value="35">5V efficient (35mA)</option>
|
|
||||||
<option value="30">12V (30mA)</option>
|
|
||||||
<option value="255">WS2815 (12mA)</option>
|
|
||||||
<option value="50">Custom</option>
|
|
||||||
</select><br>
|
|
||||||
<span id="LAdis" style="display: none;">Custom max. current per LED: <input name="LA" type="number" min="0" max="255" id="la" oninput="UI()" required> mA<br></span>
|
|
||||||
<i>Keep at default if you are unsure about your type of LEDs.</i><br>
|
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<i>Automatically limits brightness to stay close to the limit.<br>
|
||||||
LEDs are 4-channel type (RGBW): <input type="checkbox" name="EW" onchange=UI() id="rgbw"><br>
|
Keep at <1A if powering LEDs directly from the ESP 5V pin!<br>
|
||||||
<span class="wc">
|
If you are using an external power supply, enter its rating.<br>
|
||||||
Auto-calculate white channel from RGB:<br>
|
(Current estimated usage: <span class="pow">unknown</span>)</i><br><br>
|
||||||
<select name=AW>
|
LED voltage (Max. current for a single LED):<br>
|
||||||
<option value=0>None</option>
|
<select name="LAsel" onchange="enLA()">
|
||||||
<option value=1>Brighter</option>
|
<option value="55" selected>5V default (55mA)</option>
|
||||||
<option value=2>Accurate</option>
|
<option value="35">5V efficient (35mA)</option>
|
||||||
<option value=3>Dual</option>
|
<option value="30">12V (30mA)</option>
|
||||||
<option value=4>Legacy</option>
|
<option value="255">WS2815 (12mA)</option>
|
||||||
</select>
|
<option value="50">Custom</option>
|
||||||
<br></span>
|
</select><br>
|
||||||
Color order:
|
<span id="LAdis" style="display: none;">Custom max. current per LED: <input name="LA" type="number" min="0" max="255" id="la" oninput="UI()" required> mA<br></span>
|
||||||
<select name="CO">
|
<i>Keep at default if you are unsure about your type of LEDs.</i><br>
|
||||||
<option value=0>GRB</option>
|
</div>
|
||||||
<option value=1>RGB</option>
|
<h3>Hardware setup</h3>
|
||||||
<option value=2>BRG</option>
|
<div id="mLC">LED outputs:</div>
|
||||||
<option value=3>RBG</option>
|
<button type="button" id="+" onclick="addLEDs(1)" style="display:none;border-radius:20px;height:36px;">+</button>
|
||||||
<option value=4>BGR</option>
|
<button type="button" id="-" onclick="addLEDs(-1)" style="display:none;border-radius:20px;width:36px;height:36px;">-</button><br>
|
||||||
<option value=5>GBR</option>
|
LED Memory Usage: <span id="m0">0</span> / <span id="m1">?</span> B<br>
|
||||||
</select>
|
<div id="dbar" style="display:inline-block; width: 100px; height: 10px; border-radius: 20px;"></div><br>
|
||||||
|
<div id="ledwarning" style="color: orange; display: none;">
|
||||||
|
⚠ You might run into stability or lag issues.<br>
|
||||||
|
Use less than <span id="wreason">800 LEDs per pin</span> for the best experience!<br>
|
||||||
|
</div><br>
|
||||||
|
Relay pin: <input type="number" min="-1" max="40" name="RL" onchange="UI()"> Active high <input type="checkbox" name="RM"><br>
|
||||||
|
Button pin: <input type="number" min="-1" max="40" name="BT" onchange="UI()"><br>
|
||||||
|
IR pin: <input type="number" min="-1" max="40" name="IR" onchange="UI()"><br>
|
||||||
|
AUX pin: <input type="number" min="-1" max="40" name="AX" onchange="UI()">
|
||||||
<h3>Defaults</h3>
|
<h3>Defaults</h3>
|
||||||
Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br>
|
Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br>
|
||||||
Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br><br>
|
Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br><br>
|
||||||
@ -171,7 +315,7 @@
|
|||||||
<option value="2">Fade Color</option>
|
<option value="2">Fade Color</option>
|
||||||
<option value="3">Sunrise</option>
|
<option value="3">Sunrise</option>
|
||||||
</select>
|
</select>
|
||||||
<h3>Advanced</h3>
|
<h3>Advanced</h3>
|
||||||
Palette blending:
|
Palette blending:
|
||||||
<select name="PB">
|
<select name="PB">
|
||||||
<option value="0">Linear (wrap if moving)</option>
|
<option value="0">Linear (wrap if moving)</option>
|
||||||
@ -180,8 +324,18 @@
|
|||||||
<option value="3">None (not recommended)</option>
|
<option value="3">None (not recommended)</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
Reverse LED order (rotate 180): <input type="checkbox" name="RV"><br>
|
Reverse LED order (rotate 180): <input type="checkbox" name="RV"><br>
|
||||||
Skip first LED: <input type="checkbox" name="SL"><hr>
|
Skip first LED: <input type="checkbox" name="SL"><br>
|
||||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
|
<span class="wc">
|
||||||
|
Auto-calculate white channel from RGB:<br>
|
||||||
|
<select name="AW">
|
||||||
|
<option value=0>None</option>
|
||||||
|
<option value=1>Brighter</option>
|
||||||
|
<option value=2>Accurate</option>
|
||||||
|
<option value=3>Dual</option>
|
||||||
|
<option value=4>Legacy</option>
|
||||||
|
</select>
|
||||||
|
<br></span><hr>
|
||||||
|
<button type="button" onclick="B()">Back</button><button type="button" onclick="trySubmit()">Save</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
File diff suppressed because one or more lines are too long
1345
wled00/html_ui.h
1345
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -488,7 +488,7 @@ void initIR()
|
|||||||
{
|
{
|
||||||
if (irEnabled > 0)
|
if (irEnabled > 0)
|
||||||
{
|
{
|
||||||
irrecv = new IRrecv(IRPIN);
|
irrecv = new IRrecv(irPin);
|
||||||
irrecv->enableIRIn();
|
irrecv->enableIRIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
103
wled00/set.cpp
103
wled00/set.cpp
@ -75,18 +75,90 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
//LED SETTINGS
|
//LED SETTINGS
|
||||||
if (subPage == 2)
|
if (subPage == 2)
|
||||||
{
|
{
|
||||||
int t = request->arg(F("LC")).toInt();
|
int t = 0;
|
||||||
|
|
||||||
|
if (rlyPin>=0 && pinManager.isPinAllocated(rlyPin)) pinManager.deallocatePin(rlyPin);
|
||||||
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
|
if (irPin>=0 && pinManager.isPinAllocated(irPin)) pinManager.deallocatePin(irPin);
|
||||||
|
#endif
|
||||||
|
if (btnPin>=0 && pinManager.isPinAllocated(btnPin)) pinManager.deallocatePin(btnPin);
|
||||||
|
//TODO remove all busses, but not in this system call
|
||||||
|
//busses->removeAll();
|
||||||
|
|
||||||
|
uint8_t colorOrder, type;
|
||||||
|
uint16_t length, start;
|
||||||
|
uint8_t pins[2] = {255, 255};
|
||||||
|
|
||||||
|
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
|
||||||
|
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
|
||||||
|
char lk[4] = "L1"; lk[2] = 48+s; lk[3] = 0; //strip clock pin. 255 for none
|
||||||
|
char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length
|
||||||
|
char co[4] = "CO"; co[2] = 48+s; co[3] = 0; //strip color order
|
||||||
|
char lt[4] = "LT"; lt[2] = 48+s; lt[3] = 0; //strip type
|
||||||
|
char ls[4] = "LS"; ls[2] = 48+s; ls[3] = 0; //strip start LED
|
||||||
|
char cv[4] = "CV"; cv[2] = 48+s; cv[3] = 0; //strip reverse
|
||||||
|
if (!request->hasArg(lp)) {
|
||||||
|
DEBUG_PRINTLN("No data."); break;
|
||||||
|
}
|
||||||
|
pins[0] = request->arg(lp).toInt();
|
||||||
|
if (request->hasArg(lk)) {
|
||||||
|
pins[1] = (request->arg(lk).length() > 0) ? request->arg(lk).toInt() : 255;
|
||||||
|
}
|
||||||
|
type = request->arg(lt).toInt();
|
||||||
|
|
||||||
|
if (request->hasArg(lc) && request->arg(lc).toInt() > 0) {
|
||||||
|
length = request->arg(lc).toInt();
|
||||||
|
} else {
|
||||||
|
break; // no parameter
|
||||||
|
}
|
||||||
|
colorOrder = request->arg(co).toInt();
|
||||||
|
start = (request->hasArg(ls)) ? request->arg(ls).toInt() : 0;
|
||||||
|
|
||||||
|
if (busConfigs[s] != nullptr) delete busConfigs[s];
|
||||||
|
busConfigs[s] = new BusConfig(type, pins, start, length, colorOrder, request->hasArg(cv));
|
||||||
|
}
|
||||||
|
|
||||||
|
ledCount = request->arg(F("LC")).toInt();
|
||||||
if (t > 0 && t <= MAX_LEDS) ledCount = t;
|
if (t > 0 && t <= MAX_LEDS) ledCount = t;
|
||||||
#ifdef ESP8266
|
//DMA method uses too much ram, TODO: limit!
|
||||||
#if LEDPIN == 3
|
|
||||||
if (ledCount > MAX_LEDS_DMA) ledCount = MAX_LEDS_DMA; //DMA method uses too much ram
|
// upate other pins
|
||||||
#endif
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
|
int hw_ir_pin = request->arg(F("IR")).toInt();
|
||||||
|
if (pinManager.isPinOk(hw_ir_pin) && pinManager.allocatePin(hw_ir_pin,false)) {
|
||||||
|
irPin = hw_ir_pin;
|
||||||
|
} else {
|
||||||
|
irPin = -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int hw_rly_pin = request->arg(F("RL")).toInt();
|
||||||
|
if (pinManager.allocatePin(hw_rly_pin,true)) {
|
||||||
|
rlyPin = hw_rly_pin;
|
||||||
|
} else {
|
||||||
|
rlyPin = -1;
|
||||||
|
}
|
||||||
|
rlyMde = (bool)request->hasArg(F("RM"));
|
||||||
|
|
||||||
|
int hw_btn_pin = request->arg(F("BT")).toInt();
|
||||||
|
if (pinManager.allocatePin(hw_btn_pin,false)) {
|
||||||
|
btnPin = hw_btn_pin;
|
||||||
|
pinMode(btnPin, INPUT_PULLUP);
|
||||||
|
} else {
|
||||||
|
btnPin = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hw_aux_pin = request->arg(F("AX")).toInt();
|
||||||
|
if (pinManager.allocatePin(hw_aux_pin,true)) {
|
||||||
|
auxPin = hw_aux_pin;
|
||||||
|
} else {
|
||||||
|
auxPin = -1;
|
||||||
|
}
|
||||||
|
|
||||||
strip.ablMilliampsMax = request->arg(F("MA")).toInt();
|
strip.ablMilliampsMax = request->arg(F("MA")).toInt();
|
||||||
strip.milliampsPerLed = request->arg(F("LA")).toInt();
|
strip.milliampsPerLed = request->arg(F("LA")).toInt();
|
||||||
|
|
||||||
useRGBW = request->hasArg(F("EW"));
|
useRGBW = request->hasArg(F("EW"));
|
||||||
strip.setColorOrder(request->arg(F("CO")).toInt());
|
|
||||||
strip.rgbwMode = request->arg(F("AW")).toInt();
|
strip.rgbwMode = request->arg(F("AW")).toInt();
|
||||||
|
|
||||||
briS = request->arg(F("CA")).toInt();
|
briS = request->arg(F("CA")).toInt();
|
||||||
@ -328,10 +400,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
DMXFixtureMap[i] = t;
|
DMXFixtureMap[i] = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (subPage != 6 || !doReboot) serializeConfig(); //do not save if factory reset
|
|
||||||
if (subPage == 2) doInitStrip = true;
|
if (subPage != 2 && (subPage != 6 || !doReboot)) serializeConfig(); //do not save if factory reset or LED settings (which are saved after LED re-init)
|
||||||
if (subPage == 4) alexaInit();
|
if (subPage == 4) alexaInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,15 +715,15 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
|||||||
}
|
}
|
||||||
if (nightlightMode > NL_MODE_SUN) nightlightMode = NL_MODE_SUN;
|
if (nightlightMode > NL_MODE_SUN) nightlightMode = NL_MODE_SUN;
|
||||||
|
|
||||||
#if AUXPIN >= 0
|
|
||||||
//toggle general purpose output
|
//toggle general purpose output
|
||||||
pos = req.indexOf(F("AX="));
|
if (auxPin>=0) {
|
||||||
if (pos > 0) {
|
pos = req.indexOf(F("AX="));
|
||||||
auxTime = getNumVal(&req, pos);
|
if (pos > 0) {
|
||||||
auxActive = true;
|
auxTime = getNumVal(&req, pos);
|
||||||
if (auxTime == 0) auxActive = false;
|
auxActive = true;
|
||||||
|
if (auxTime == 0) auxActive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
pos = req.indexOf(F("TT="));
|
pos = req.indexOf(F("TT="));
|
||||||
if (pos > 0) transitionDelay = getNumVal(&req, pos);
|
if (pos > 0) transitionDelay = getNumVal(&req, pos);
|
||||||
|
@ -195,9 +195,17 @@ void WLED::loop()
|
|||||||
handleHue();
|
handleHue();
|
||||||
handleBlynk();
|
handleBlynk();
|
||||||
|
|
||||||
if (doInitStrip) {
|
//LED settings have been saved, re-init busses
|
||||||
strip.init(useRGBW, ledCount, skipFirstLed);
|
if (busConfigs[0] != nullptr) {
|
||||||
doInitStrip = false;
|
busses.removeAll();
|
||||||
|
for (uint8_t i = 0; i < WLED_MAX_BUSSES; i++) {
|
||||||
|
if (busConfigs[i] == nullptr) break;
|
||||||
|
busses.add(*busConfigs[i]);
|
||||||
|
delete busConfigs[i]; busConfigs[i] = nullptr;
|
||||||
|
}
|
||||||
|
strip.finalizeInit(useRGBW, ledCount, skipFirstLed);
|
||||||
|
yield();
|
||||||
|
serializeConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
@ -285,8 +293,16 @@ void WLED::setup()
|
|||||||
updateFSInfo();
|
updateFSInfo();
|
||||||
deserializeConfig();
|
deserializeConfig();
|
||||||
|
|
||||||
#if STATUSLED && STATUSLED != LEDPIN
|
#if STATUSLED
|
||||||
pinMode(STATUSLED, OUTPUT);
|
bool lStatusLed = false;
|
||||||
|
for (uint8_t i=0; i<strip.numStrips; i++) {
|
||||||
|
if (strip.getStripPin(i)==STATUSLED) {
|
||||||
|
lStatusLed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!lStatusLed)
|
||||||
|
pinMode(STATUSLED, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//DEBUG_PRINTLN(F("Load EEPROM"));
|
//DEBUG_PRINTLN(F("Load EEPROM"));
|
||||||
@ -299,7 +315,8 @@ void WLED::setup()
|
|||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
|
|
||||||
Serial.println(F("Ada"));
|
// Serial.println(F("Ada"));
|
||||||
|
DEBUG_PRINTLN(F("Ada"));
|
||||||
|
|
||||||
// generate module IDs
|
// generate module IDs
|
||||||
escapedMac = WiFi.macAddress();
|
escapedMac = WiFi.macAddress();
|
||||||
@ -343,25 +360,14 @@ void WLED::setup()
|
|||||||
void WLED::beginStrip()
|
void WLED::beginStrip()
|
||||||
{
|
{
|
||||||
// Initialize NeoPixel Strip and button
|
// Initialize NeoPixel Strip and button
|
||||||
#ifdef ESP8266
|
|
||||||
#if LEDPIN == 3
|
|
||||||
if (ledCount > MAX_LEDS_DMA)
|
|
||||||
ledCount = MAX_LEDS_DMA; // DMA method uses too much ram
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ledCount > MAX_LEDS || ledCount == 0)
|
if (ledCount > MAX_LEDS || ledCount == 0)
|
||||||
ledCount = 30;
|
ledCount = 30;
|
||||||
|
|
||||||
strip.init(useRGBW, ledCount, skipFirstLed);
|
strip.finalizeInit(useRGBW, ledCount, skipFirstLed);
|
||||||
strip.setBrightness(0);
|
strip.setBrightness(0);
|
||||||
strip.setShowCallback(handleOverlayDraw);
|
strip.setShowCallback(handleOverlayDraw);
|
||||||
|
|
||||||
#if defined(BTNPIN) && BTNPIN > -1
|
|
||||||
pinManager.allocatePin(BTNPIN, false);
|
|
||||||
pinMode(BTNPIN, INPUT_PULLUP);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (bootPreset > 0) applyPreset(bootPreset);
|
if (bootPreset > 0) applyPreset(bootPreset);
|
||||||
if (turnOnAtBoot) {
|
if (turnOnAtBoot) {
|
||||||
if (briS > 0) bri = briS;
|
if (briS > 0) bri = briS;
|
||||||
@ -371,24 +377,13 @@ void WLED::beginStrip()
|
|||||||
}
|
}
|
||||||
colorUpdated(NOTIFIER_CALL_MODE_INIT);
|
colorUpdated(NOTIFIER_CALL_MODE_INIT);
|
||||||
|
|
||||||
// init relay pin
|
// init relay pin
|
||||||
#if RLYPIN >= 0
|
if (rlyPin>=0)
|
||||||
pinManager.allocatePin(RLYPIN);
|
digitalWrite(rlyPin, (rlyMde ? bri : !bri));
|
||||||
pinMode(RLYPIN, OUTPUT);
|
|
||||||
#if RLYMDE
|
|
||||||
digitalWrite(RLYPIN, bri);
|
|
||||||
#else
|
|
||||||
digitalWrite(RLYPIN, !bri);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// disable button if it is "pressed" unintentionally
|
// disable button if it is "pressed" unintentionally
|
||||||
#if (defined(BTNPIN) && BTNPIN > -1) || defined(TOUCHPIN)
|
if (btnPin>=0 && isButtonPressed())
|
||||||
if (isButtonPressed())
|
|
||||||
buttonEnabled = false;
|
buttonEnabled = false;
|
||||||
#else
|
|
||||||
buttonEnabled = false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WLED::initAP(bool resetAP)
|
void WLED::initAP(bool resetAP)
|
||||||
@ -419,7 +414,7 @@ void WLED::initAP(bool resetAP)
|
|||||||
udp2Connected = notifier2Udp.begin(udpPort2);
|
udp2Connected = notifier2Udp.begin(udpPort2);
|
||||||
}
|
}
|
||||||
e131.begin(false, e131Port, e131Universe, E131_MAX_UNIVERSE_COUNT);
|
e131.begin(false, e131Port, e131Universe, E131_MAX_UNIVERSE_COUNT);
|
||||||
|
|
||||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
dnsServer.start(53, "*", WiFi.softAPIP());
|
dnsServer.start(53, "*", WiFi.softAPIP());
|
||||||
}
|
}
|
||||||
@ -483,7 +478,7 @@ void WLED::initConnection()
|
|||||||
// convert the "serverDescription" into a valid DNS hostname (alphanumeric)
|
// convert the "serverDescription" into a valid DNS hostname (alphanumeric)
|
||||||
char hostname[25] = "wled-";
|
char hostname[25] = "wled-";
|
||||||
prepareHostname(hostname);
|
prepareHostname(hostname);
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
WiFi.hostname(hostname);
|
WiFi.hostname(hostname);
|
||||||
#endif
|
#endif
|
||||||
@ -634,7 +629,13 @@ void WLED::handleConnection()
|
|||||||
|
|
||||||
void WLED::handleStatusLED()
|
void WLED::handleStatusLED()
|
||||||
{
|
{
|
||||||
#if STATUSLED && STATUSLED != LEDPIN
|
#if STATUSLED
|
||||||
|
for (uint8_t s=0; s<strip.numStrips; s++) {
|
||||||
|
if (strip.getStripPin(s)==STATUSLED) {
|
||||||
|
return; // pin used for strip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ledStatusType = WLED_CONNECTED ? 0 : 2;
|
ledStatusType = WLED_CONNECTED ? 0 : 2;
|
||||||
if (mqttEnabled && ledStatusType != 2) // Wi-Fi takes presendence over MQTT
|
if (mqttEnabled && ledStatusType != 2) // Wi-Fi takes presendence over MQTT
|
||||||
ledStatusType = WLED_MQTT_CONNECTED ? 0 : 4;
|
ledStatusType = WLED_MQTT_CONNECTED ? 0 : 4;
|
||||||
@ -650,7 +651,7 @@ void WLED::handleStatusLED()
|
|||||||
#else
|
#else
|
||||||
digitalWrite(STATUSLED, LOW);
|
digitalWrite(STATUSLED, LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,7 @@
|
|||||||
#include "ir_codes.h"
|
#include "ir_codes.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "pin_manager.h"
|
#include "pin_manager.h"
|
||||||
|
#include "bus_manager.h"
|
||||||
|
|
||||||
#ifndef CLIENT_SSID
|
#ifndef CLIENT_SSID
|
||||||
#define CLIENT_SSID DEFAULT_CLIENT_SSID
|
#define CLIENT_SSID DEFAULT_CLIENT_SSID
|
||||||
@ -131,7 +132,7 @@
|
|||||||
Comment out this error message to build regardless.
|
Comment out this error message to build regardless.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IRPIN < 0
|
#if !defined(IRPIN) || IRPIN < 0
|
||||||
#ifndef WLED_DISABLE_INFRARED
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
#define WLED_DISABLE_INFRARED
|
#define WLED_DISABLE_INFRARED
|
||||||
#endif
|
#endif
|
||||||
@ -184,13 +185,29 @@ WLED_GLOBAL char otaPass[33] _INIT(DEFAULT_OTA_PASS);
|
|||||||
|
|
||||||
// Hardware CONFIG (only changeble HERE, not at runtime)
|
// Hardware CONFIG (only changeble HERE, not at runtime)
|
||||||
// LED strip pin, button pin and IR pin changeable in NpbWrapper.h!
|
// LED strip pin, button pin and IR pin changeable in NpbWrapper.h!
|
||||||
|
#ifndef BTNPIN
|
||||||
|
WLED_GLOBAL int8_t btnPin _INIT(-1);
|
||||||
|
#else
|
||||||
|
WLED_GLOBAL int8_t btnPin _INIT(BTNPIN);
|
||||||
|
#endif
|
||||||
|
#ifndef RLYPIN
|
||||||
|
WLED_GLOBAL int8_t rlyPin _INIT(-1);
|
||||||
|
#else
|
||||||
|
WLED_GLOBAL int8_t rlyPin _INIT(RLYPIN);
|
||||||
|
#endif
|
||||||
|
#ifndef RLYMDE
|
||||||
|
WLED_GLOBAL bool rlyMde _INIT(1);
|
||||||
|
#else
|
||||||
|
WLED_GLOBAL bool rlyMde _INIT(RLYMDE);
|
||||||
|
#endif
|
||||||
|
#ifndef IRPIN
|
||||||
|
WLED_GLOBAL int8_t irPin _INIT(-1);
|
||||||
|
#else
|
||||||
|
WLED_GLOBAL int8_t irPin _INIT(IRPIN);
|
||||||
|
#endif
|
||||||
|
|
||||||
//WLED_GLOBAL byte presetToApply _INIT(0);
|
//WLED_GLOBAL byte presetToApply _INIT(0);
|
||||||
|
|
||||||
#if AUXPIN >= 0
|
|
||||||
WLED_GLOBAL byte auxDefaultState _INIT(0); // 0: input 1: high 2: low
|
|
||||||
WLED_GLOBAL byte auxTriggeredState _INIT(0); // 0: input 1: high 2: low
|
|
||||||
#endif
|
|
||||||
WLED_GLOBAL char ntpServerName[33] _INIT("0.wled.pool.ntp.org"); // NTP server to use
|
WLED_GLOBAL char ntpServerName[33] _INIT("0.wled.pool.ntp.org"); // NTP server to use
|
||||||
|
|
||||||
// WiFi CONFIG (all these can be changed via web UI, no need to set them here)
|
// WiFi CONFIG (all these can be changed via web UI, no need to set them here)
|
||||||
@ -463,12 +480,18 @@ WLED_GLOBAL long lastInterfaceUpdate _INIT(0);
|
|||||||
WLED_GLOBAL byte interfaceUpdateCallMode _INIT(NOTIFIER_CALL_MODE_INIT);
|
WLED_GLOBAL byte interfaceUpdateCallMode _INIT(NOTIFIER_CALL_MODE_INIT);
|
||||||
WLED_GLOBAL char mqttStatusTopic[40] _INIT(""); // this must be global because of async handlers
|
WLED_GLOBAL char mqttStatusTopic[40] _INIT(""); // this must be global because of async handlers
|
||||||
|
|
||||||
#if AUXPIN >= 0
|
// auxiliary debug pin
|
||||||
// auxiliary debug pin
|
#ifndef AUXPIN
|
||||||
WLED_GLOBAL byte auxTime _INIT(0);
|
WLED_GLOBAL int8_t auxPin _INIT(-1);
|
||||||
WLED_GLOBAL unsigned long auxStartTime _INIT(0);
|
#else
|
||||||
WLED_GLOBAL bool auxActive _INIT(false, auxActiveBefore _INIT(false);
|
WLED_GLOBAL int8_t auxPin _INIT(AUXPIN);
|
||||||
#endif
|
#endif
|
||||||
|
WLED_GLOBAL byte auxTime _INIT(0);
|
||||||
|
WLED_GLOBAL unsigned long auxStartTime _INIT(0);
|
||||||
|
WLED_GLOBAL bool auxActive _INIT(false);
|
||||||
|
WLED_GLOBAL bool auxActiveBefore _INIT(false);
|
||||||
|
WLED_GLOBAL byte auxDefaultState _INIT(0); // 0: input 1: high 2: low
|
||||||
|
WLED_GLOBAL byte auxTriggeredState _INIT(0); // 0: input 1: high 2: low
|
||||||
|
|
||||||
// alexa udp
|
// alexa udp
|
||||||
WLED_GLOBAL String escapedMac;
|
WLED_GLOBAL String escapedMac;
|
||||||
@ -527,14 +550,15 @@ WLED_GLOBAL ESPAsyncE131 e131 _INIT_N(((handleE131Packet)));
|
|||||||
WLED_GLOBAL bool e131NewData _INIT(false);
|
WLED_GLOBAL bool e131NewData _INIT(false);
|
||||||
|
|
||||||
// led fx library object
|
// led fx library object
|
||||||
|
WLED_GLOBAL BusManager busses _INIT(BusManager());
|
||||||
WLED_GLOBAL WS2812FX strip _INIT(WS2812FX());
|
WLED_GLOBAL WS2812FX strip _INIT(WS2812FX());
|
||||||
WLED_GLOBAL bool doInitStrip _INIT(false);
|
WLED_GLOBAL BusConfig* busConfigs[WLED_MAX_BUSSES]; //temporary, to remember values from network callback until after
|
||||||
|
|
||||||
// Usermod manager
|
// Usermod manager
|
||||||
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
||||||
|
|
||||||
// Status LED
|
// Status LED
|
||||||
#if STATUSLED && STATUSLED != LEDPIN
|
#if STATUSLED
|
||||||
WLED_GLOBAL unsigned long ledStatusLastMillis _INIT(0);
|
WLED_GLOBAL unsigned long ledStatusLastMillis _INIT(0);
|
||||||
WLED_GLOBAL unsigned short ledStatusType _INIT(0); // current status type - corresponds to number of blinks per second
|
WLED_GLOBAL unsigned short ledStatusType _INIT(0); // current status type - corresponds to number of blinks per second
|
||||||
WLED_GLOBAL bool ledStatusState _INIT(0); // the current LED state
|
WLED_GLOBAL bool ledStatusState _INIT(0); // the current LED state
|
||||||
|
@ -254,7 +254,31 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 2) {
|
if (subPage == 2) {
|
||||||
oappend(SET_F("d.Sf.LC.max="));
|
char nS[3];
|
||||||
|
|
||||||
|
// add usermod pins as d.um_p array (TODO: usermod config shouldn't use state. instead we should load "um" object from cfg.json)
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
JsonObject mods = doc.createNestedObject(F("mods"));
|
||||||
|
usermods.addToJsonState(mods);
|
||||||
|
if (!mods.isNull()) {
|
||||||
|
uint8_t i=0;
|
||||||
|
oappend(SET_F("d.um_p=["));
|
||||||
|
for (JsonPair kv : mods) {
|
||||||
|
if (strncmp_P(kv.key().c_str(),PSTR("pin_"),4) == 0) {
|
||||||
|
if (i++) oappend(SET_F(","));
|
||||||
|
oappend(itoa((int)kv.value(),nS,10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oappend(SET_F("];"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(WLED_MAX_BUSSES) && WLED_MAX_BUSSES>1
|
||||||
|
oappend(SET_F("addLEDs("));
|
||||||
|
oappend(itoa(WLED_MAX_BUSSES,nS,10));
|
||||||
|
oappend(SET_F(");"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
oappend(SET_F("d.Sf.LC.max=")); //TODO Formula for max LEDs on ESP8266 depending on types. 500 DMA or 1500 UART (about 4kB mem usage)
|
||||||
#if defined(ESP8266) && LEDPIN == 3
|
#if defined(ESP8266) && LEDPIN == 3
|
||||||
oappendi(MAX_LEDS_DMA);
|
oappendi(MAX_LEDS_DMA);
|
||||||
#else
|
#else
|
||||||
@ -263,6 +287,27 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
oappend(";");
|
oappend(";");
|
||||||
|
|
||||||
sappend('v',SET_F("LC"),ledCount);
|
sappend('v',SET_F("LC"),ledCount);
|
||||||
|
|
||||||
|
for (uint8_t s=0; s < busses.getNumBusses(); s++){
|
||||||
|
Bus* bus = busses.getBus(s);
|
||||||
|
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
|
||||||
|
char lk[4] = "L1"; lk[2] = 48+s; lk[3] = 0; //strip clock pin. 255 for none
|
||||||
|
char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length
|
||||||
|
char co[4] = "CO"; co[2] = 48+s; co[3] = 0; //strip color order
|
||||||
|
char lt[4] = "LT"; lt[2] = 48+s; lt[3] = 0; //strip type
|
||||||
|
char ls[4] = "LS"; ls[2] = 48+s; ls[3] = 0; //strip start LED
|
||||||
|
char cv[4] = "CV"; cv[2] = 48+s; cv[3] = 0; //strip reverse
|
||||||
|
oappend(SET_F("addLEDs(1);"));
|
||||||
|
uint8_t pins[5];
|
||||||
|
uint8_t nPins = bus->getPins(pins);
|
||||||
|
sappend('v', lp, pins[0]);
|
||||||
|
if (pinManager.isPinOk(pins[1])) sappend('v', lk, pins[1]);
|
||||||
|
sappend('v', lc, bus->getLength());
|
||||||
|
sappend('v',lt,bus->getType());
|
||||||
|
sappend('v',co,bus->getColorOrder());
|
||||||
|
sappend('v',ls,bus->getStart());
|
||||||
|
sappend('c',cv,bus->reversed);
|
||||||
|
}
|
||||||
sappend('v',SET_F("MA"),strip.ablMilliampsMax);
|
sappend('v',SET_F("MA"),strip.ablMilliampsMax);
|
||||||
sappend('v',SET_F("LA"),strip.milliampsPerLed);
|
sappend('v',SET_F("LA"),strip.milliampsPerLed);
|
||||||
if (strip.currentMilliamps)
|
if (strip.currentMilliamps)
|
||||||
@ -274,8 +319,8 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sappend('v',SET_F("CA"),briS);
|
sappend('v',SET_F("CA"),briS);
|
||||||
sappend('c',SET_F("EW"),useRGBW);
|
//sappend('c',SET_F("EW"),useRGBW);
|
||||||
sappend('i',SET_F("CO"),strip.getColorOrder());
|
//sappend('i',SET_F("CO"),strip.getColorOrder());
|
||||||
sappend('v',SET_F("AW"),strip.rgbwMode);
|
sappend('v',SET_F("AW"),strip.rgbwMode);
|
||||||
|
|
||||||
sappend('c',SET_F("BO"),turnOnAtBoot);
|
sappend('c',SET_F("BO"),turnOnAtBoot);
|
||||||
@ -293,6 +338,11 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
sappend('i',SET_F("PB"),strip.paletteBlend);
|
sappend('i',SET_F("PB"),strip.paletteBlend);
|
||||||
sappend('c',SET_F("RV"),strip.reverseMode);
|
sappend('c',SET_F("RV"),strip.reverseMode);
|
||||||
sappend('c',SET_F("SL"),skipFirstLed);
|
sappend('c',SET_F("SL"),skipFirstLed);
|
||||||
|
sappend('v',SET_F("RL"),rlyPin);
|
||||||
|
sappend('c',SET_F("RM"),rlyMde);
|
||||||
|
sappend('v',SET_F("BT"),btnPin);
|
||||||
|
sappend('v',SET_F("IR"),irPin);
|
||||||
|
sappend('v',SET_F("AX"),auxPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 3)
|
if (subPage == 3)
|
||||||
|
Loading…
Reference in New Issue
Block a user