Merge pull request #40 from Aircoookie/master

Update
This commit is contained in:
srg74 2020-02-24 21:21:20 -05:00 committed by GitHub
commit ad2c7ee363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 125 additions and 107 deletions

View File

@ -12,7 +12,7 @@ A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control
### Features:
- WS2812FX library integrated for over 100 special effects
- FastLED noise effects and palettes
- FastLED noise effects and 50 palettes
- Modern UI with color, effect and segment controls
- Segments to set different effects and colors to parts of the LEDs
- Settings page - configuration over network

View File

@ -591,6 +591,7 @@ class WS2812FX {
uint8_t _brightness;
static uint16_t _usedSegmentData;
void load_gradient_palette(uint8_t);
void handle_palette(void);
void fill(uint32_t);

View File

@ -324,7 +324,7 @@ uint8_t WS2812FX::getModeCount()
uint8_t WS2812FX::getPaletteCount()
{
return 13 + gGradientPaletteCount;
return 13 + GRADIENT_PALETTE_COUNT;
}
//TODO transitions
@ -707,6 +707,15 @@ CRGB WS2812FX::col_to_crgb(uint32_t color)
}
void WS2812FX::load_gradient_palette(uint8_t index)
{
byte i = constrain(index, 0, GRADIENT_PALETTE_COUNT -1);
byte tcp[72]; //support gradient palettes with up to 18 entries
memcpy_P(tcp, (byte*)pgm_read_dword(&(gGradientPalettes[i])), 72);
targetPalette.loadDynamicGradientPalette(tcp);
}
/*
* FastLED palette modes helper function. Limitation: Due to memory reasons, multiple active segments with FastLED will disable the Palette transitions
*/
@ -724,13 +733,13 @@ void WS2812FX::handle_palette(void)
case 0: {//default palette. Differs depending on effect
switch (SEGMENT.mode)
{
case FX_MODE_FIRE_2012 : targetPalette = gGradientPalettes[22]; break;//heat palette
case FX_MODE_COLORWAVES : targetPalette = gGradientPalettes[13]; break;//landscape 33
case FX_MODE_FIRE_2012 : load_gradient_palette(22); break;//heat palette
case FX_MODE_COLORWAVES : load_gradient_palette(13); break;//landscape 33
case FX_MODE_FILLNOISE8 : targetPalette = OceanColors_p; break;
case FX_MODE_NOISE16_1 : targetPalette = gGradientPalettes[17]; break;//Drywet
case FX_MODE_NOISE16_2 : targetPalette = gGradientPalettes[30]; break;//Blue cyan yellow
case FX_MODE_NOISE16_3 : targetPalette = gGradientPalettes[22]; break;//heat palette
case FX_MODE_NOISE16_4 : targetPalette = gGradientPalettes[13]; break;//landscape 33
case FX_MODE_NOISE16_1 : load_gradient_palette(17); break;//Drywet
case FX_MODE_NOISE16_2 : load_gradient_palette(30); break;//Blue cyan yellow
case FX_MODE_NOISE16_3 : load_gradient_palette(22); break;//heat palette
case FX_MODE_NOISE16_4 : load_gradient_palette(13); break;//landscape 33
//case FX_MODE_GLITTER : targetPalette = RainbowColors_p; break;
default: targetPalette = PartyColors_p; break;//palette, bpm
@ -787,7 +796,7 @@ void WS2812FX::handle_palette(void)
case 12: //Rainbow stripe colors
targetPalette = RainbowStripeColors_p; break;
default: //progmem palettes
targetPalette = gGradientPalettes[constrain(SEGMENT.palette -13, 0, gGradientPaletteCount -1)];
load_gradient_palette(SEGMENT.palette -13);
}
if (singleSegmentMode && paletteFade) //only blend if just one segment uses FastLED mode

View File

@ -61,4 +61,13 @@
#define TYPE_ANALOG_4CH 9 //analog RGBW
#define TYPE_ANALOG_5CH 10 //analog RGB + WW + CW
//Hue error codes
#define HUE_ERROR_INACTIVE 0
#define HUE_ERROR_UNAUTHORIZED 1
#define HUE_ERROR_LIGHTID 3
#define HUE_ERROR_PUSHLINK 101
#define HUE_ERROR_JSON_PARSING 250
#define HUE_ERROR_TIMEOUT 251
#define HUE_ERROR_ACTIVE 255
#endif

View File

@ -335,7 +335,7 @@ Hue Bridge IP:<br>
<input name="H3" type="number" min="0" max="255" ><br>
<b>Press the pushlink button on the bridge, after that save this page!</b><br>
(when first connecting)<br>
Hue status: <span class="hms"> Internal ESP Error! </span><hr>
Hue status: <span class="hms"> Disabled in this build </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>

View File

@ -13,7 +13,9 @@
#ifndef PalettesWLED_h
#define PalettesWLED_h
DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
#define GRADIENT_PALETTE_COUNT 38
const byte ib_jul01_gp[] PROGMEM = {
0, 194, 1, 1,
94, 1, 29, 18,
132, 57,131, 28,
@ -24,7 +26,7 @@ DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
const byte es_vintage_57_gp[] PROGMEM = {
0, 2, 1, 1,
53, 18, 1, 0,
104, 69, 29, 1,
@ -37,7 +39,7 @@ DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
const byte es_vintage_01_gp[] PROGMEM = {
0, 4, 1, 1,
51, 16, 0, 1,
76, 97,104, 3,
@ -53,7 +55,7 @@ DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
const byte es_rivendell_15_gp[] PROGMEM = {
0, 1, 14, 5,
101, 16, 36, 14,
165, 56, 68, 30,
@ -67,7 +69,7 @@ DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
// Size: 36 bytes of program space.
// Edited to be brighter
DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
const byte rgi_15_gp[] PROGMEM = {
0, 4, 1, 70,
31, 55, 1, 30,
63, 255, 4, 7,
@ -84,7 +86,7 @@ DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 8 bytes of program space.
DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
const byte retro2_16_gp[] PROGMEM = {
0, 188,135, 1,
255, 46, 7, 1};
@ -94,7 +96,7 @@ DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
const byte Analogous_1_gp[] PROGMEM = {
0, 3, 0,255,
63, 23, 0,255,
127, 67, 0,255,
@ -107,7 +109,7 @@ DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
const byte es_pinksplash_08_gp[] PROGMEM = {
0, 126, 11,255,
127, 197, 1, 22,
175, 210,157,172,
@ -120,7 +122,7 @@ DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
const byte es_ocean_breeze_036_gp[] PROGMEM = {
0, 1, 6, 7,
89, 1, 99,111,
153, 144,209,255,
@ -132,7 +134,7 @@ DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 88 bytes of program space.
DEFINE_GRADIENT_PALETTE( departure_gp ) {
const byte departure_gp[] PROGMEM = {
0, 8, 3, 0,
42, 23, 7, 0,
63, 75, 38, 6,
@ -152,7 +154,7 @@ DEFINE_GRADIENT_PALETTE( departure_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
const byte es_landscape_64_gp[] PROGMEM = {
0, 0, 0, 0,
37, 2, 25, 1,
76, 15,115, 5,
@ -169,7 +171,7 @@ DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
const byte es_landscape_33_gp[] PROGMEM = {
0, 1, 5, 0,
19, 32, 23, 1,
38, 161, 55, 1,
@ -183,7 +185,7 @@ DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
const byte rainbowsherbet_gp[] PROGMEM = {
0, 255, 33, 4,
43, 255, 68, 25,
86, 255, 7, 25,
@ -198,7 +200,7 @@ DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
const byte gr65_hult_gp[] PROGMEM = {
0, 247,176,247,
48, 255,136,255,
89, 220, 29,226,
@ -212,7 +214,7 @@ DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
const byte gr64_hult_gp[] PROGMEM = {
0, 1,124,109,
66, 1, 93, 79,
104, 52, 65, 1,
@ -228,7 +230,7 @@ DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
const byte GMT_drywet_gp[] PROGMEM = {
0, 47, 30, 2,
42, 213,147, 24,
84, 103,219, 52,
@ -243,7 +245,7 @@ DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE( ib15_gp ) {
const byte ib15_gp[] PROGMEM = {
0, 113, 91,147,
72, 157, 88, 78,
89, 208, 85, 33,
@ -257,7 +259,7 @@ DEFINE_GRADIENT_PALETTE( ib15_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( Tertiary_01_gp ) {
const byte Tertiary_01_gp[] PROGMEM = {
0, 0, 1,255,
63, 3, 68, 45,
127, 23,255, 0,
@ -270,7 +272,7 @@ DEFINE_GRADIENT_PALETTE( Tertiary_01_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.
DEFINE_GRADIENT_PALETTE( lava_gp ) {
const byte lava_gp[] PROGMEM = {
0, 0, 0, 0,
46, 18, 0, 0,
96, 113, 0, 0,
@ -291,7 +293,7 @@ DEFINE_GRADIENT_PALETTE( lava_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( fierce_ice_gp ) {
const byte fierce_ice_gp[] PROGMEM = {
0, 0, 0, 0,
59, 0, 9, 45,
119, 0, 38,255,
@ -306,7 +308,7 @@ DEFINE_GRADIENT_PALETTE( fierce_ice_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
const byte Colorfull_gp[] PROGMEM = {
0, 10, 85, 5,
25, 29,109, 18,
60, 59,138, 42,
@ -325,7 +327,7 @@ DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
const byte Pink_Purple_gp[] PROGMEM = {
0, 19, 2, 39,
25, 26, 4, 45,
51, 33, 6, 52,
@ -344,7 +346,7 @@ DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
const byte Sunset_Real_gp[] PROGMEM = {
0, 120, 0, 0,
22, 179, 22, 0,
51, 255,104, 0,
@ -359,7 +361,7 @@ DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE( Sunset_Yellow_gp ) {
const byte Sunset_Yellow_gp[] PROGMEM = {
0, 10, 62,123,
36, 56,130,103,
87, 153,225, 85,
@ -378,7 +380,7 @@ DEFINE_GRADIENT_PALETTE( Sunset_Yellow_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 60 bytes of program space.
DEFINE_GRADIENT_PALETTE( Beech_gp ) {
const byte Beech_gp[] PROGMEM = {
0, 255,252,214,
12, 255,252,214,
22, 255,252,214,
@ -401,7 +403,7 @@ DEFINE_GRADIENT_PALETTE( Beech_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE( Another_Sunset_gp ) {
const byte Another_Sunset_gp[] PROGMEM = {
0, 110, 49, 11,
29, 55, 34, 10,
68, 22, 22, 9,
@ -420,7 +422,7 @@ DEFINE_GRADIENT_PALETTE( Another_Sunset_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
const byte es_autumn_19_gp[] PROGMEM = {
0, 26, 1, 1,
51, 67, 4, 1,
84, 118, 14, 1,
@ -441,7 +443,7 @@ DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
const byte BlacK_Blue_Magenta_White_gp[] PROGMEM = {
0, 0, 0, 0,
42, 0, 0, 45,
84, 0, 0,255,
@ -456,7 +458,7 @@ DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
const byte BlacK_Magenta_Red_gp[] PROGMEM = {
0, 0, 0, 0,
63, 42, 0, 45,
127, 255, 0,255,
@ -469,7 +471,7 @@ DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
const byte BlacK_Red_Magenta_Yellow_gp[] PROGMEM = {
0, 0, 0, 0,
42, 42, 0, 0,
84, 255, 0, 0,
@ -484,7 +486,7 @@ DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
const byte Blue_Cyan_Yellow_gp[] PROGMEM = {
0, 0, 0,255,
63, 0, 55,255,
127, 0,255,255,
@ -494,7 +496,7 @@ DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
//Custom palette by Aircoookie
DEFINE_GRADIENT_PALETTE( Orange_Teal_gp ) {
const byte Orange_Teal_gp[] PROGMEM = {
0, 0,150, 92,
55, 0,150, 92,
200, 255, 72, 0,
@ -502,7 +504,7 @@ DEFINE_GRADIENT_PALETTE( Orange_Teal_gp ) {
//Custom palette by Aircoookie
DEFINE_GRADIENT_PALETTE( Tiamat_gp ) {
const byte Tiamat_gp[] PROGMEM = {
0, 1, 2, 14, //gc
33, 2, 5, 35, //gc from 47, 61,126
100, 13,135, 92, //gc from 88,242,247
@ -517,7 +519,7 @@ DEFINE_GRADIENT_PALETTE( Tiamat_gp ) {
//Custom palette by Aircoookie
DEFINE_GRADIENT_PALETTE( April_Night_gp ) {
const byte April_Night_gp[] PROGMEM = {
0, 1, 5, 45, //deep blue
10, 1, 5, 45,
25, 5,169,175, //light blue
@ -536,7 +538,7 @@ DEFINE_GRADIENT_PALETTE( April_Night_gp ) {
244, 1, 5, 45,
255, 1, 5, 45};
DEFINE_GRADIENT_PALETTE( Orangery_gp ) {
const byte Orangery_gp[] PROGMEM = {
0, 255, 95, 23,
30, 255, 82, 0,
60, 223, 13, 8,
@ -548,7 +550,7 @@ DEFINE_GRADIENT_PALETTE( Orangery_gp ) {
255, 213, 37, 4};
//inspired by Mark Kriegsman https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
DEFINE_GRADIENT_PALETTE( C9_gp ) {
const byte C9_gp[] PROGMEM = {
0, 184, 4, 0, //red
60, 184, 4, 0,
65, 144, 44, 2, //amber
@ -558,14 +560,14 @@ DEFINE_GRADIENT_PALETTE( C9_gp ) {
195, 7, 7, 88, //blue
255, 7, 7, 88};
DEFINE_GRADIENT_PALETTE( Sakura_gp ) {
const byte Sakura_gp[] PROGMEM = {
0, 196, 19, 10,
65, 255, 69, 45,
130, 223, 45, 72,
195, 255, 82,103,
255, 223, 13, 17};
DEFINE_GRADIENT_PALETTE( Aurora_gp ) {
const byte Aurora_gp[] PROGMEM = {
0, 1, 5, 45, //deep blue
64, 0,200, 23,
128, 0,255, 0, //green
@ -578,13 +580,7 @@ DEFINE_GRADIENT_PALETTE( Aurora_gp ) {
// This will let us programmatically choose one based on
// a number, rather than having to activate each explicitly
// by name every time.
// Since it is const, this array could also be moved
// into PROGMEM to save SRAM, but for simplicity of illustration
// we'll keep it in a regular SRAM array.
//
// This list of color palettes acts as a "playlist"; you can
// add or delete, or re-arrange as you wish.
const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
const byte* const gGradientPalettes[] PROGMEM = {
Sunset_Real_gp, //13-00 Sunset
es_rivendell_15_gp, //14-01 Rivendell
es_ocean_breeze_036_gp, //15-02 Breeze
@ -625,9 +621,4 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
Aurora_gp, //50-37 Aurora
};
// Count of how many cpt-city gradients are defined:
const uint8_t gGradientPaletteCount =
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
#endif

View File

@ -119,7 +119,7 @@
#endif
//version code in format yymmddb (b = daily build)
#define VERSION 2002243
#define VERSION 2002252
char versionString[] = "0.9.1";
@ -350,7 +350,7 @@ bool udpConnected = false, udpRgbConnected = false;
bool showWelcomePage = false;
//hue
char hueError[25] = "Inactive";
byte hueError = HUE_ERROR_INACTIVE;
//uint16_t hueFailCount = 0;
float hueXLast = 0, hueYLast = 0;
uint16_t hueHueLast = 0, hueCtLast = 0;
@ -430,7 +430,7 @@ IPAddress ntpServerIP;
uint16_t ntpLocalPort = 2390;
#define NTP_PACKET_SIZE 48
//maximum number of LEDs - MAX_LEDS is comming from the JSON response getting too big, MAX_LEDS_DMA will become a timing issue
//maximum number of LEDs - MAX_LEDS is coming from the JSON response getting too big, MAX_LEDS_DMA will become a timing issue
#define MAX_LEDS 1500
#define MAX_LEDS_DMA 500

View File

@ -9,7 +9,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
obuf = (dest == nullptr)? sbuf:dest;
olen = 0;
oappend("<?xml version=\"1.0\" ?><vs><ac>");
oappend((const char*)F("<?xml version=\"1.0\" ?><vs><ac>"));
oappendi((nightlightActive && nightlightFade) ? briT : bri);
oappend("</ac>");
@ -65,7 +65,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
{
mesg += "E1.31 mode ";
mesg += DMXMode;
mesg += " at DMX Address ";
mesg += F(" at DMX Address ");
mesg += DMXAddress;
mesg += " from ";
mesg += realtimeIP[0];
@ -85,7 +85,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
mesg += realtimeIP[i];
}
} else if (realtimeMode == REALTIME_MODE_ADALIGHT) {
mesg += "USB Adalight";
mesg += F("USB Adalight");
} else { //generic
mesg += "data";
}
@ -137,11 +137,11 @@ char* URL_response(AsyncWebServerRequest *request)
obuf = sbuf;
olen = 0;
oappend("<html><body><a href=\"");
oappend((const char*)F("<html><body><a href=\""));
oappend(s2buf);
oappend("\" target=\"_blank\">");
oappend((const char*)F("\" target=\"_blank\">"));
oappend(s2buf);
oappend("</a></body></html>");
oappend((const char*)F("</a></body></html>"));
if (request != nullptr) request->send(200, "text/html", obuf);
}
@ -355,9 +355,7 @@ void getSettingsJS(byte subPage, char* dest)
sappends('s',"MG",mqttGroupTopic);
#endif
#ifdef WLED_DISABLE_HUESYNC
sappends('m',"(\"hms\")[0]","Unsupported in build");
#else
#ifndef WLED_DISABLE_HUESYNC
sappend('v',"H0",hueIP[0]);
sappend('v',"H1",hueIP[1]);
sappend('v',"H2",hueIP[2]);
@ -368,7 +366,20 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',"HO",hueApplyOnOff);
sappend('c',"HB",hueApplyBri);
sappend('c',"HC",hueApplyColor);
sappends('m',"(\"hms\")[0]",hueError);
char hueErrorString[25];
switch (hueError)
{
case HUE_ERROR_INACTIVE : strcpy(hueErrorString,(char*)F("Inactive")); break;
case HUE_ERROR_ACTIVE : strcpy(hueErrorString,(char*)F("Active")); break;
case HUE_ERROR_UNAUTHORIZED : strcpy(hueErrorString,(char*)F("Unauthorized")); break;
case HUE_ERROR_LIGHTID : strcpy(hueErrorString,(char*)F("Invalid light ID")); break;
case HUE_ERROR_PUSHLINK : strcpy(hueErrorString,(char*)F("Link button not pressed")); break;
case HUE_ERROR_JSON_PARSING : strcpy(hueErrorString,(char*)F("JSON parsing error")); break;
case HUE_ERROR_TIMEOUT : strcpy(hueErrorString,(char*)F("Timeout")); break;
default: sprintf(hueErrorString,"Bridge Error %i",hueError);
}
sappends('m',"(\"hms\")[0]",hueErrorString);
#endif
}

View File

@ -23,7 +23,7 @@ void handleHue()
reconnectHue();
} else {
hueClient->close();
if (hueError[0] == 'A') strcpy(hueError,"Inactive");
if (hueError == HUE_ERROR_ACTIVE) hueError = HUE_ERROR_INACTIVE;
}
}
@ -44,7 +44,7 @@ void reconnectHue()
void onHueError(void* arg, AsyncClient* client, int8_t error)
{
DEBUG_PRINTLN("Hue err");
strcpy(hueError,"Request timeout");
hueError = HUE_ERROR_TIMEOUT;
}
void onHueConnect(void* arg, AsyncClient* client)
@ -59,15 +59,15 @@ void sendHuePoll()
String req = "";
if (hueAuthRequired)
{
req += "POST /api HTTP/1.1\r\nHost: ";
req += F("POST /api HTTP/1.1\r\nHost: ");
req += hueIP.toString();
req += "\r\nContent-Length: 25\r\n\r\n{\"devicetype\":\"wled#esp\"}";
req += F("\r\nContent-Length: 25\r\n\r\n{\"devicetype\":\"wled#esp\"}");
} else
{
req += "GET /api/";
req += hueApiKey;
req += "/lights/" + String(huePollLightId);
req += " HTTP/1.1\r\nHost: ";
req += F(" HTTP/1.1\r\nHost: ");
req += hueIP.toString();
req += "\r\n\r\n";
}
@ -93,21 +93,18 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len)
auto error = deserializeJson(root, str);
if (error)
{
strcpy(hueError,"JSON parsing error"); return;
hueError = HUE_ERROR_JSON_PARSING; return;
}
int hueErrorCode = root[0]["error"]["type"];
if (hueErrorCode)//hue bridge returned error
{
hueError = hueErrorCode;
switch (hueErrorCode)
{
case 1: strcpy(hueError,"Unauthorized"); hueAuthRequired = true; break;
case 3: strcpy(hueError,"Invalid light ID"); huePollingEnabled = false; break;
case 101: strcpy(hueError,"Link button not pressed"); hueAuthRequired = true; break;
default:
char coerr[18];
sprintf(coerr,"Bridge Error %i",hueErrorCode);
strcpy(hueError,coerr);
case 1: hueAuthRequired = true; break; //Unauthorized user
case 3: huePollingEnabled = false; break; //Invalid light ID
case 101: hueAuthRequired = true; break; //link button not presset
}
return;
}
@ -133,7 +130,7 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len)
auto error = deserializeJson(root, str);
if (error)
{
strcpy(hueError,"JSON parsing error"); return;
hueError = HUE_ERROR_JSON_PARSING; return;
}
float hueX=0, hueY=0;
@ -173,7 +170,7 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len)
hueBri = 0;
}
strcpy(hueError,"Active");
hueError = HUE_ERROR_ACTIVE;
//apply vals
if (hueBri != hueBriLast)

View File

@ -62,44 +62,44 @@ void initServer()
});
server.on("/reset", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 200,"Rebooting now...","Please wait ~10 seconds...",129);
serveMessage(request, 200,"Rebooting now...",F("Please wait ~10 seconds..."),129);
doReboot = true;
});
server.on("/settings/wifi", HTTP_POST, [](AsyncWebServerRequest *request){
if (!(wifiLock && otaLock)) handleSettingsSet(request, 1);
serveMessage(request, 200,"WiFi settings saved.","Please connect to the new IP (if changed)",129);
serveMessage(request, 200,F("WiFi settings saved."),F("Please connect to the new IP (if changed)"),129);
forceReconnect = true;
});
server.on("/settings/leds", HTTP_POST, [](AsyncWebServerRequest *request){
handleSettingsSet(request, 2);
serveMessage(request, 200,"LED settings saved.","Redirecting...",1);
serveMessage(request, 200,F("LED settings saved."),"Redirecting...",1);
});
server.on("/settings/ui", HTTP_POST, [](AsyncWebServerRequest *request){
handleSettingsSet(request, 3);
serveMessage(request, 200,"UI settings saved.","Redirecting...",1);
serveMessage(request, 200,F("UI settings saved."),"Redirecting...",1);
});
server.on("/settings/dmx", HTTP_POST, [](AsyncWebServerRequest *request){
handleSettingsSet(request, 7);
serveMessage(request, 200,"UI settings saved.","Redirecting...",1);
serveMessage(request, 200,F("UI settings saved."),"Redirecting...",1);
});
server.on("/settings/sync", HTTP_POST, [](AsyncWebServerRequest *request){
handleSettingsSet(request, 4);
serveMessage(request, 200,"Sync settings saved.","Redirecting...",1);
serveMessage(request, 200,F("Sync settings saved."),"Redirecting...",1);
});
server.on("/settings/time", HTTP_POST, [](AsyncWebServerRequest *request){
handleSettingsSet(request, 5);
serveMessage(request, 200,"Time settings saved.","Redirecting...",1);
serveMessage(request, 200,F("Time settings saved."),"Redirecting...",1);
});
server.on("/settings/sec", HTTP_POST, [](AsyncWebServerRequest *request){
handleSettingsSet(request, 6);
if (!doReboot) serveMessage(request, 200,"Security settings saved.","Rebooting, please wait ~10 seconds...",129);
if (!doReboot) serveMessage(request, 200,F("Security settings saved."),F("Rebooting, please wait ~10 seconds..."),129);
doReboot = true;
});
@ -148,7 +148,7 @@ void initServer()
});
server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254);
serveMessage(request, 418, F("418. I'm a teapot."), F("(Tangible Embedded Advanced Project Of Twinkling)"), 254);
});
//if OTA is allowed
@ -161,7 +161,7 @@ void initServer()
#endif
#else
server.on("/edit", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 501, "Not implemented", "The SPIFFS editor is disabled in this build.", 254);
serveMessage(request, 501, "Not implemented", F("The SPIFFS editor is disabled in this build."), 254);
});
#endif
//init ota page
@ -173,9 +173,9 @@ void initServer()
server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){
if (Update.hasError())
{
serveMessage(request, 500, "Failed updating firmware!", "Please check your file and retry!", 254); return;
serveMessage(request, 500, F("Failed updating firmware!"), F("Please check your file and retry!"), 254); return;
}
serveMessage(request, 200, "Successfully updated firmware!", "Please wait while the module reboots...", 131);
serveMessage(request, 200, F("Successfully updated firmware!"), F("Please wait while the module reboots..."), 131);
doReboot = true;
},[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
if(!index){
@ -197,7 +197,7 @@ void initServer()
#else
server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 501, "Not implemented", "OTA updates are disabled in this build.", 254);
serveMessage(request, 501, "Not implemented", F("OTA updates are disabled in this build."), 254);
});
#endif
} else
@ -217,7 +217,7 @@ void initServer()
});
#else
server.on("/dmxmap", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 501, "Not implemented", "DMX support is not enabled in this build.", 254);
serveMessage(request, 501, "Not implemented", F("DMX support is not enabled in this build."), 254);
});
#endif
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
@ -292,10 +292,10 @@ String msgProcessor(const String& var)
messageBody += "<script>setTimeout(RP," + String((optt-120)*1000) + ")</script>";
} else if (optt == 253)
{
messageBody += "<br><br><form action=/settings><button class=\"bt\" type=submit>Back</button></form>"; //button to settings
messageBody += F("<br><br><form action=/settings><button class=\"bt\" type=submit>Back</button></form>"); //button to settings
} else if (optt == 254)
{
messageBody += "<br><br><button type=\"button\" class=\"bt\" onclick=\"B()\">Back</button>";
messageBody += F("<br><br><button type=\"button\" class=\"bt\" onclick=\"B()\">Back</button>");
}
return messageBody;
}
@ -324,7 +324,7 @@ String settingsProcessor(const String& var)
#ifdef WLED_ENABLE_DMX
if (var == "DMXMENU") {
return String("<form action=/settings/dmx><button type=submit>DMX Output</button></form>");
return String(F("<form action=/settings/dmx><button type=submit>DMX Output</button></form>"));
}
#endif

View File

@ -343,7 +343,7 @@ void serveJson(AsyncWebServerRequest* request)
return;
}
else if (url.length() > 6) { //not just /json
request->send( 501, "application/json", "{\"error\":\"Not implemented\"}");
request->send( 501, "application/json", F("{\"error\":\"Not implemented\"}"));
return;
}