Preset 16 working

This commit is contained in:
cschwinne 2019-12-03 14:15:12 +01:00
parent 89a54e31f1
commit 334783f89a
6 changed files with 33 additions and 11 deletions

View File

@ -839,10 +839,10 @@ uint8_t WS2812FX::gamma8(uint8_t b)
uint32_t WS2812FX::gamma32(uint32_t color) uint32_t WS2812FX::gamma32(uint32_t color)
{ {
if (!gammaCorrectCol) return color; if (!gammaCorrectCol) return color;
uint8_t w = (color >> 24) & 0xFF; uint8_t w = (color >> 24);
uint8_t r = (color >> 16) & 0xFF; uint8_t r = (color >> 16);
uint8_t g = (color >> 8) & 0xFF; uint8_t g = (color >> 8);
uint8_t b = color & 0xFF; uint8_t b = color;
w = gammaT[w]; w = gammaT[w];
r = gammaT[r]; r = gammaT[r];
g = gammaT[g]; g = gammaT[g];

View File

@ -97,7 +97,7 @@
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 1912013 #define VERSION 1912033
char versionString[] = "0.8.7-dev"; char versionString[] = "0.8.7-dev";
@ -431,6 +431,7 @@ AsyncClient* hueClient = NULL;
AsyncMqttClient* mqtt = NULL; AsyncMqttClient* mqtt = NULL;
//function prototypes //function prototypes
void colorFromUint32(uint32_t,bool=false);
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte); void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
void handleE131Packet(e131_packet_t*, IPAddress); void handleE131Packet(e131_packet_t*, IPAddress);

View File

@ -565,6 +565,7 @@ bool applyPreset(byte index, bool loadBri = true, bool loadCol = true, bool load
uint16_t i = 380 + index*20; uint16_t i = 380 + index*20;
if (index < 16) { if (index < 16) {
if (EEPROM.read(i) != 1) return false; if (EEPROM.read(i) != 1) return false;
strip.applyToAllSelected = true;
if (loadBri) bri = EEPROM.read(i+1); if (loadBri) bri = EEPROM.read(i+1);
if (loadCol) if (loadCol)
{ {
@ -583,9 +584,11 @@ bool applyPreset(byte index, bool loadBri = true, bool loadCol = true, bool load
} }
} else { } else {
if (EEPROM.read(i) != 2) return false; if (EEPROM.read(i) != 2) return false;
strip.applyToAllSelected = false;
if (loadBri) bri = EEPROM.read(i+1); if (loadBri) bri = EEPROM.read(i+1);
WS2812FX::Segment* seg = strip.getSegments(); WS2812FX::Segment* seg = strip.getSegments();
memcpy(seg, EEPROM.getDataPtr() +i+2, 240); memcpy(seg, EEPROM.getDataPtr() +i+2, 240);
setValuesFromMainSeg();
} }
currentPreset = index; currentPreset = index;
isPreset = true; isPreset = true;
@ -619,6 +622,7 @@ void savePreset(byte index)
} }
commit(); commit();
savedToPresets();
currentPreset = index; currentPreset = index;
isPreset = true; isPreset = true;
} }

View File

@ -1,6 +1,16 @@
/* /*
* LED methods * LED methods
*/ */
void setValuesFromMainSeg()
{
WS2812FX::Segment& seg = strip.getSegment(strip.getMainSegmentId());
colorFromUint32(seg.colors[0]);
colorFromUint32(seg.colors[1], true);
effectCurrent = seg.mode;
effectSpeed = seg.speed;
effectIntensity = seg.intensity;
effectPalette = seg.palette;
}
void toggleOnOff() void toggleOnOff()
{ {

View File

@ -2,12 +2,19 @@
* Color conversion methods * Color conversion methods
*/ */
void colorFromUint32(uint32_t in) void colorFromUint32(uint32_t in, bool secondary)
{ {
col[3] = in >> 24 & 0xFF; if (secondary) {
col[0] = in >> 16 & 0xFF; colSec[3] = in >> 24 & 0xFF;
col[1] = in >> 8 & 0xFF; colSec[0] = in >> 16 & 0xFF;
col[2] = in & 0xFF; colSec[1] = in >> 8 & 0xFF;
colSec[2] = in & 0xFF;
} else {
col[3] = in >> 24 & 0xFF;
col[0] = in >> 16 & 0xFF;
col[1] = in >> 8 & 0xFF;
col[2] = in & 0xFF;
}
} }
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb

View File

@ -268,7 +268,7 @@ void serializeInfo(JsonObject root)
#ifndef WLED_DISABLE_HUESYNC #ifndef WLED_DISABLE_HUESYNC
os += 0x04; os += 0x04;
#endif #endif
#ifndef WLED_DISABLE_MOBILE_UI #ifdef WLED_ENABLE_ADALIGHT
os += 0x02; os += 0x02;
#endif #endif
#ifndef WLED_DISABLE_OTA #ifndef WLED_DISABLE_OTA