mirror of
https://github.com/wled/WLED.git
synced 2025-04-23 22:37:18 +00:00
Save some tiny amounts of RAM
- use `-D WLED_SAVE_RAM`
This commit is contained in:
parent
8688777ae1
commit
8d00e4d31d
@ -720,6 +720,9 @@ class WS2812FX { // 96 bytes
|
||||
#ifndef WLED_DISABLE_2D
|
||||
panels(1),
|
||||
#endif
|
||||
autoSegments(false),
|
||||
correctWB(false),
|
||||
cctFromRgb(false),
|
||||
// semi-private (just obscured) used in effect functions through macros
|
||||
_colors_t{0,0,0},
|
||||
_virtualSegmentLength(0),
|
||||
@ -908,6 +911,12 @@ class WS2812FX { // 96 bytes
|
||||
void loadCustomPalettes(void); // loads custom palettes from JSON
|
||||
std::vector<CRGBPalette16> customPalettes; // TODO: move custom palettes out of WS2812FX class
|
||||
|
||||
struct {
|
||||
bool autoSegments : 1;
|
||||
bool correctWB : 1;
|
||||
bool cctFromRgb : 1;
|
||||
};
|
||||
|
||||
// using public variables to reduce code size increase due to inline function getSegment() (with bounds checking)
|
||||
// and color transitions
|
||||
uint32_t _colors_t[3]; // color used for effect (includes transition)
|
||||
|
@ -1028,9 +1028,9 @@ void Segment::refreshLightCapabilities() {
|
||||
if (bus->getStart() + bus->getLength() <= segStartIdx) continue;
|
||||
|
||||
//uint8_t type = bus->getType();
|
||||
if (bus->hasRGB() || (cctFromRgb && bus->hasCCT())) capabilities |= SEG_CAPABILITY_RGB;
|
||||
if (!cctFromRgb && bus->hasCCT()) capabilities |= SEG_CAPABILITY_CCT;
|
||||
if (correctWB && (bus->hasRGB() || bus->hasCCT())) capabilities |= SEG_CAPABILITY_CCT; //white balance correction (CCT slider)
|
||||
if (bus->hasRGB() || (strip.cctFromRgb && bus->hasCCT())) capabilities |= SEG_CAPABILITY_RGB;
|
||||
if (!strip.cctFromRgb && bus->hasCCT()) capabilities |= SEG_CAPABILITY_CCT;
|
||||
if (strip.correctWB && (bus->hasRGB() || bus->hasCCT())) capabilities |= SEG_CAPABILITY_CCT; //white balance correction (CCT slider)
|
||||
if (bus->hasWhite()) {
|
||||
unsigned aWM = Bus::getGlobalAWMode() == AW_GLOBAL_DISABLED ? bus->getAutoWhiteMode() : Bus::getGlobalAWMode();
|
||||
bool whiteSlider = (aWM == RGBW_MODE_DUAL || aWM == RGBW_MODE_MANUAL_ONLY); // white slider allowed
|
||||
|
@ -20,17 +20,19 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
|
||||
//long vid = doc[F("vid")]; // 2010020
|
||||
|
||||
#ifdef WLED_USE_ETHERNET
|
||||
#ifdef WLED_USE_ETHERNET
|
||||
JsonObject ethernet = doc[F("eth")];
|
||||
CJSON(ethernetType, ethernet["type"]);
|
||||
// NOTE: Ethernet configuration takes priority over other use of pins
|
||||
WLED::instance().initEthernet();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
JsonObject id = doc["id"];
|
||||
getStringFromJson(cmDNS, id[F("mdns")], 33);
|
||||
getStringFromJson(serverDescription, id[F("name")], 33);
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
getStringFromJson(alexaInvocationName, id[F("inv")], 33);
|
||||
#endif
|
||||
CJSON(simplifiedUI, id[F("sui")]);
|
||||
|
||||
JsonObject nw = doc["nw"];
|
||||
@ -109,8 +111,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
uint16_t ablMilliampsMax = hw_led[F("maxpwr")] | BusManager::ablMilliampsMax();
|
||||
BusManager::setMilliampsMax(ablMilliampsMax);
|
||||
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | AW_GLOBAL_DISABLED);
|
||||
CJSON(correctWB, hw_led["cct"]);
|
||||
CJSON(cctFromRgb, hw_led[F("cr")]);
|
||||
CJSON(strip.correctWB, hw_led["cct"]);
|
||||
CJSON(strip.cctFromRgb, hw_led[F("cr")]);
|
||||
CJSON(cctICused, hw_led[F("ic")]);
|
||||
CJSON(strip.cctBlending, hw_led[F("cb")]);
|
||||
Bus::setCCTBlend(strip.cctBlending);
|
||||
@ -431,7 +433,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
JsonObject light = doc[F("light")];
|
||||
CJSON(briMultiplier, light[F("scale-bri")]);
|
||||
CJSON(strip.paletteBlend, light[F("pal-mode")]);
|
||||
CJSON(autoSegments, light[F("aseg")]);
|
||||
CJSON(strip.autoSegments, light[F("aseg")]);
|
||||
|
||||
CJSON(gammaCorrectVal, light["gc"]["val"]); // default 2.8
|
||||
float light_gc_bri = light["gc"]["bri"];
|
||||
@ -530,12 +532,12 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
CJSON(arlsDisableGammaCorrection, if_live[F("no-gc")]); // false
|
||||
CJSON(arlsOffset, if_live[F("offset")]); // 0
|
||||
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
CJSON(alexaEnabled, interfaces["va"][F("alexa")]); // false
|
||||
|
||||
CJSON(macroAlexaOn, interfaces["va"]["macros"][0]);
|
||||
CJSON(macroAlexaOff, interfaces["va"]["macros"][1]);
|
||||
|
||||
CJSON(alexaNumPresets, interfaces["va"]["p"]);
|
||||
#endif
|
||||
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
JsonObject if_mqtt = interfaces["mqtt"];
|
||||
@ -739,7 +741,9 @@ void serializeConfig() {
|
||||
JsonObject id = root.createNestedObject("id");
|
||||
id[F("mdns")] = cmDNS;
|
||||
id[F("name")] = serverDescription;
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
id[F("inv")] = alexaInvocationName;
|
||||
#endif
|
||||
id[F("sui")] = simplifiedUI;
|
||||
|
||||
JsonObject nw = root.createNestedObject("nw");
|
||||
@ -818,8 +822,8 @@ void serializeConfig() {
|
||||
hw_led[F("total")] = strip.getLengthTotal(); //provided for compatibility on downgrade and per-output ABL
|
||||
hw_led[F("maxpwr")] = BusManager::ablMilliampsMax();
|
||||
hw_led[F("ledma")] = 0; // no longer used
|
||||
hw_led["cct"] = correctWB;
|
||||
hw_led[F("cr")] = cctFromRgb;
|
||||
hw_led["cct"] = strip.correctWB;
|
||||
hw_led[F("cr")] = strip.cctFromRgb;
|
||||
hw_led[F("ic")] = cctICused;
|
||||
hw_led[F("cb")] = strip.cctBlending;
|
||||
hw_led["fps"] = strip.getTargetFps();
|
||||
@ -931,7 +935,7 @@ void serializeConfig() {
|
||||
JsonObject light = root.createNestedObject(F("light"));
|
||||
light[F("scale-bri")] = briMultiplier;
|
||||
light[F("pal-mode")] = strip.paletteBlend;
|
||||
light[F("aseg")] = autoSegments;
|
||||
light[F("aseg")] = strip.autoSegments;
|
||||
|
||||
JsonObject light_gc = light.createNestedObject("gc");
|
||||
light_gc["bri"] = (gammaCorrectBri) ? gammaCorrectVal : 1.0f; // keep compatibility
|
||||
|
@ -56,9 +56,9 @@ void handleDDPPacket(e131_packet_t* p) {
|
||||
//E1.31 and Art-Net protocol support
|
||||
void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
|
||||
unsigned uni = 0, dmxChannels = 0;
|
||||
int uni = 0, dmxChannels = 0;
|
||||
uint8_t* e131_data = nullptr;
|
||||
unsigned seq = 0, mde = REALTIME_MODE_E131;
|
||||
int seq = 0, mde = REALTIME_MODE_E131;
|
||||
|
||||
if (protocol == P_ARTNET)
|
||||
{
|
||||
@ -179,7 +179,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
if (uni != e131Universe || availDMXLen < 2) return;
|
||||
|
||||
// limit max. selectable preset to 250, even though DMX max. val is 255
|
||||
unsigned dmxValPreset = (e131_data[dataOffset+1] > 250 ? 250 : e131_data[dataOffset+1]);
|
||||
int dmxValPreset = (e131_data[dataOffset+1] > 250 ? 250 : e131_data[dataOffset+1]);
|
||||
|
||||
// only apply preset if value changed
|
||||
if (dmxValPreset != 0 && dmxValPreset != currentPreset &&
|
||||
@ -254,7 +254,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
// Set segment opacity or global brightness
|
||||
if (isSegmentMode) {
|
||||
if (e131_data[dataOffset] != seg.opacity) seg.setOpacity(e131_data[dataOffset]);
|
||||
} else if ( id == strip.getSegmentsNum()-1 ) {
|
||||
} else if ( id == strip.getSegmentsNum()-1U ) {
|
||||
if (bri != e131_data[dataOffset]) {
|
||||
bri = e131_data[dataOffset];
|
||||
strip.setBrightness(bri, true);
|
||||
|
@ -37,14 +37,14 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
Segment prev = seg; //make a backup so we can tell if something changed (calling copy constructor)
|
||||
//DEBUG_PRINTF_P(PSTR("-- Duplicate segment: %p (%p)\n"), &prev, prev.data);
|
||||
|
||||
unsigned start = elem["start"] | seg.start;
|
||||
int start = elem["start"] | seg.start;
|
||||
if (stop < 0) {
|
||||
int len = elem["len"];
|
||||
stop = (len > 0) ? start + len : seg.stop;
|
||||
}
|
||||
// 2D segments
|
||||
unsigned startY = elem["startY"] | seg.startY;
|
||||
unsigned stopY = elem["stopY"] | seg.stopY;
|
||||
int startY = elem["startY"] | seg.startY;
|
||||
int stopY = elem["stopY"] | seg.stopY;
|
||||
|
||||
//repeat, multiplies segment until all LEDs are used, or max segments reached
|
||||
bool repeat = elem["rpt"] | false;
|
||||
@ -105,7 +105,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
uint8_t set = elem[F("set")] | seg.set;
|
||||
seg.set = constrain(set, 0, 3);
|
||||
|
||||
unsigned len = 1;
|
||||
int len = 1;
|
||||
if (stop > start) len = stop - start;
|
||||
int offset = elem[F("of")] | INT32_MAX;
|
||||
if (offset != INT32_MAX) {
|
||||
|
@ -130,9 +130,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
unsigned ablMilliampsMax = request->arg(F("MA")).toInt();
|
||||
BusManager::setMilliampsMax(ablMilliampsMax);
|
||||
|
||||
autoSegments = request->hasArg(F("MS"));
|
||||
correctWB = request->hasArg(F("CCT"));
|
||||
cctFromRgb = request->hasArg(F("CR"));
|
||||
strip.autoSegments = request->hasArg(F("MS"));
|
||||
strip.correctWB = request->hasArg(F("CCT"));
|
||||
strip.cctFromRgb = request->hasArg(F("CR"));
|
||||
cctICused = request->hasArg(F("IC"));
|
||||
strip.cctBlending = request->arg(F("CB")).toInt();
|
||||
Bus::setCCTBlend(strip.cctBlending);
|
||||
@ -421,10 +421,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
t = request->arg(F("WO")).toInt();
|
||||
if (t >= -255 && t <= 255) arlsOffset = t;
|
||||
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
alexaEnabled = request->hasArg(F("AL"));
|
||||
strlcpy(alexaInvocationName, request->arg(F("AI")).c_str(), 33);
|
||||
t = request->arg(F("AP")).toInt();
|
||||
if (t >= 0 && t <= 9) alexaNumPresets = t;
|
||||
#endif
|
||||
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
mqttEnabled = request->hasArg(F("MQ"));
|
||||
|
180
wled00/wled.h
180
wled00/wled.h
@ -321,19 +321,53 @@ WLED_GLOBAL bool rlyOpenDrain _INIT(RLYODRAIN);
|
||||
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)
|
||||
WLED_GLOBAL uint8_t selectedWiFi _INIT(0);
|
||||
WLED_GLOBAL std::vector<WiFiConfig> multiWiFi;
|
||||
WLED_GLOBAL IPAddress dnsAddress _INIT_N((( 8, 8, 8, 8))); // Google's DNS
|
||||
WLED_GLOBAL char cmDNS[33] _INIT(MDNS_NAME); // mDNS address (*.local, replaced by wledXXXXXX if default is used)
|
||||
WLED_GLOBAL char apSSID[33] _INIT(""); // AP off by default (unless setup)
|
||||
#ifdef WLED_SAVE_RAM
|
||||
typedef class WiFiOptions {
|
||||
public:
|
||||
struct {
|
||||
uint8_t selectedWiFi : 4; // max 16 SSIDs
|
||||
uint8_t apChannel : 4;
|
||||
bool apHide : 1;
|
||||
uint8_t apBehavior : 3;
|
||||
bool noWifiSleep : 1;
|
||||
bool force802_3g : 1;
|
||||
};
|
||||
WiFiOptions(uint8_t s, uint8_t c, bool h, uint8_t b, bool sl, bool g) {
|
||||
selectedWiFi = s;
|
||||
apChannel = c;
|
||||
apHide = h;
|
||||
apBehavior = b;
|
||||
noWifiSleep = sl;
|
||||
force802_3g = g;
|
||||
}
|
||||
} __attribute__ ((aligned(1), packed)) wifi_options_t;
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
WLED_GLOBAL wifi_options_t wifiOpt _INIT_N(({0, 1, false, AP_BEHAVIOR_BOOT_NO_CONN, true, false}));
|
||||
#else
|
||||
WLED_GLOBAL wifi_options_t wifiOpt _INIT_N(({0, 1, false, AP_BEHAVIOR_BOOT_NO_CONN, false, false}));
|
||||
#endif
|
||||
#define selectedWiFi wifiOpt.selectedWiFi
|
||||
#define apChannel wifiOpt.apChannel
|
||||
#define apHide wifiOpt.apHide
|
||||
#define apBehavior wifiOpt.apBehavior
|
||||
#define noWifiSleep wifiOpt.noWifiSleep
|
||||
#define force802_3g wifiOpt.force802_3g
|
||||
#else
|
||||
WLED_GLOBAL uint8_t selectedWiFi _INIT(0);
|
||||
WLED_GLOBAL byte apChannel _INIT(1); // 2.4GHz WiFi AP channel (1-13)
|
||||
WLED_GLOBAL byte apHide _INIT(0); // hidden AP SSID
|
||||
WLED_GLOBAL byte apBehavior _INIT(AP_BEHAVIOR_BOOT_NO_CONN); // access point opens when no connection after boot by default
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
WLED_GLOBAL bool noWifiSleep _INIT(true); // disabling modem sleep modes will increase heat output and power usage, but may help with connection issues
|
||||
#else
|
||||
#else
|
||||
WLED_GLOBAL bool noWifiSleep _INIT(false);
|
||||
#endif
|
||||
#endif
|
||||
WLED_GLOBAL bool force802_3g _INIT(false);
|
||||
#endif // WLED_SAVE_RAM
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#if defined(LOLIN_WIFI_FIX) && (defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32S3))
|
||||
WLED_GLOBAL uint8_t txPower _INIT(WIFI_POWER_8_5dBm);
|
||||
@ -341,7 +375,6 @@ WLED_GLOBAL uint8_t txPower _INIT(WIFI_POWER_8_5dBm);
|
||||
WLED_GLOBAL uint8_t txPower _INIT(WIFI_POWER_19_5dBm);
|
||||
#endif
|
||||
#endif
|
||||
WLED_GLOBAL bool force802_3g _INIT(false);
|
||||
#define WLED_WIFI_CONFIGURED (strlen(multiWiFi[0].clientSSID) >= 1 && strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) != 0)
|
||||
|
||||
#ifdef WLED_USE_ETHERNET
|
||||
@ -359,14 +392,11 @@ WLED_GLOBAL byte bootPreset _INIT(0); // save preset to load
|
||||
//if true, a segment per bus will be created on boot and LED settings save
|
||||
//if false, only one segment spanning the total LEDs is created,
|
||||
//but not on LED settings save if there is more than one segment currently
|
||||
WLED_GLOBAL bool autoSegments _INIT(false);
|
||||
#ifdef ESP8266
|
||||
WLED_GLOBAL bool useGlobalLedBuffer _INIT(false); // double buffering disabled on ESP8266
|
||||
#else
|
||||
WLED_GLOBAL bool useGlobalLedBuffer _INIT(true); // double buffering enabled on ESP32
|
||||
#endif
|
||||
WLED_GLOBAL bool correctWB _INIT(false); // CCT color correction of RGB color
|
||||
WLED_GLOBAL bool cctFromRgb _INIT(false); // CCT is calculated from RGB instead of using seg.cct
|
||||
#ifdef WLED_USE_IC_CCT
|
||||
WLED_GLOBAL bool cctICused _INIT(true); // CCT IC used (Athom 15W bulbs)
|
||||
#else
|
||||
@ -378,7 +408,6 @@ WLED_GLOBAL float gammaCorrectVal _INIT(2.8f); // gamma correction value
|
||||
|
||||
WLED_GLOBAL byte col[] _INIT_N(({ 255, 160, 0, 0 })); // current RGB(W) primary color. col[] should be updated if you want to change the color.
|
||||
WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) secondary color
|
||||
WLED_GLOBAL byte briS _INIT(128); // default brightness
|
||||
|
||||
WLED_GLOBAL byte nightlightTargetBri _INIT(0); // brightness after nightlight is over
|
||||
WLED_GLOBAL byte nightlightDelayMins _INIT(60);
|
||||
@ -406,30 +435,14 @@ WLED_GLOBAL byte irEnabled _INIT(IRTYPE); // Infrared receiver
|
||||
#endif
|
||||
WLED_GLOBAL bool irApplyToAllSelected _INIT(true); //apply IR or ESP-NOW to all selected segments
|
||||
|
||||
WLED_GLOBAL uint16_t udpPort _INIT(21324); // WLED notifier default port
|
||||
WLED_GLOBAL uint16_t udpPort2 _INIT(65506); // WLED notifier supplemental port
|
||||
WLED_GLOBAL uint16_t udpRgbPort _INIT(19446); // Hyperion port
|
||||
|
||||
WLED_GLOBAL uint8_t syncGroups _INIT(0x01); // sync groups this instance syncs (bit mapped)
|
||||
WLED_GLOBAL uint8_t receiveGroups _INIT(0x01); // sync receive groups this instance belongs to (bit mapped)
|
||||
WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications
|
||||
WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color
|
||||
WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup
|
||||
WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options
|
||||
WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segment bounds (start, stop, offset)
|
||||
WLED_GLOBAL bool notifyDirect _INIT(false); // send notification if change via UI or HTTP API
|
||||
WLED_GLOBAL bool notifyButton _INIT(false); // send if updated by button or infrared remote
|
||||
WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa
|
||||
WLED_GLOBAL bool notifyHue _INIT(true); // send notification if Hue light changes
|
||||
WLED_GLOBAL uint8_t udpNumRetries _INIT(0); // Number of times a UDP sync message is retransmitted. Increase to increase reliability
|
||||
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
WLED_GLOBAL bool alexaEnabled _INIT(false); // enable device discovery by Amazon Echo
|
||||
WLED_GLOBAL char alexaInvocationName[33] _INIT("Light"); // speech control name of device. Choose something voice-to-text can understand
|
||||
WLED_GLOBAL byte alexaNumPresets _INIT(0); // number of presets to expose to Alexa, starting from preset 1, up to 9
|
||||
#endif
|
||||
|
||||
WLED_GLOBAL uint16_t realtimeTimeoutMs _INIT(2500); // ms timeout of realtime mode before returning to normal mode
|
||||
WLED_GLOBAL int arlsOffset _INIT(0); // realtime LED offset
|
||||
WLED_GLOBAL bool receiveDirect _INIT(true); // receive UDP/Hyperion realtime
|
||||
WLED_GLOBAL bool arlsDisableGammaCorrection _INIT(true); // activate if gamma correction is handled by the source
|
||||
WLED_GLOBAL bool arlsForceMaxBri _INIT(false); // enable to force max brightness if source has very dark colors that would be black
|
||||
|
||||
@ -587,6 +600,7 @@ WLED_GLOBAL byte colNlT[] _INIT_N(({ 0, 0, 0, 0 })); // current nightligh
|
||||
// brightness
|
||||
WLED_GLOBAL unsigned long lastOnTime _INIT(0);
|
||||
WLED_GLOBAL bool offMode _INIT(!turnOnAtBoot);
|
||||
WLED_GLOBAL byte briS _INIT(128); // default brightness
|
||||
WLED_GLOBAL byte bri _INIT(briS); // global brightness (set)
|
||||
WLED_GLOBAL byte briOld _INIT(0); // global brightness while in transition loop (previous iteration)
|
||||
WLED_GLOBAL byte briT _INIT(0); // global brightness during transition
|
||||
@ -610,6 +624,77 @@ WLED_GLOBAL bool sendNotificationsRT _INIT(false); // master notifica
|
||||
WLED_GLOBAL unsigned long notificationSentTime _INIT(0);
|
||||
WLED_GLOBAL byte notificationSentCallMode _INIT(CALL_MODE_INIT);
|
||||
WLED_GLOBAL uint8_t notificationCount _INIT(0);
|
||||
WLED_GLOBAL uint8_t syncGroups _INIT(0x01); // sync send groups this instance syncs to (bit mapped)
|
||||
WLED_GLOBAL uint8_t receiveGroups _INIT(0x01); // sync receive groups this instance belongs to (bit mapped)
|
||||
#ifdef WLED_SAVE_RAM
|
||||
// this will save us 8 bytes of RAM while increasing code by ~400 bytes
|
||||
typedef class Receive {
|
||||
public:
|
||||
union {
|
||||
uint8_t Options;
|
||||
struct {
|
||||
bool Brightness : 1;
|
||||
bool Color : 1;
|
||||
bool Effects : 1;
|
||||
bool SegmentOptions : 1;
|
||||
bool SegmentBounds : 1;
|
||||
bool Direct : 1;
|
||||
uint8_t reserved : 2;
|
||||
};
|
||||
};
|
||||
Receive(int i) { Options = i; }
|
||||
Receive(bool b, bool c, bool e, bool sO, bool sB) {
|
||||
Brightness = b;
|
||||
Color = c;
|
||||
Effects = e;
|
||||
SegmentOptions = sO;
|
||||
SegmentBounds = sB;
|
||||
};
|
||||
} __attribute__ ((aligned(1), packed)) receive_notification_t;
|
||||
typedef class Send {
|
||||
public:
|
||||
union {
|
||||
uint8_t Options;
|
||||
struct {
|
||||
bool Direct : 1;
|
||||
bool Button : 1;
|
||||
bool Alexa : 1;
|
||||
bool Hue : 1;
|
||||
uint8_t reserved : 4;
|
||||
};
|
||||
};
|
||||
Send(int o) { Options = o; }
|
||||
Send(bool d, bool b, bool a, bool h) {
|
||||
Direct = d;
|
||||
Button = b;
|
||||
Alexa = a;
|
||||
Hue = h;
|
||||
}
|
||||
} __attribute__ ((aligned(1), packed)) send_notification_t;
|
||||
WLED_GLOBAL receive_notification_t receiveN _INIT(0b00100111);
|
||||
WLED_GLOBAL send_notification_t notifyG _INIT(0b00001111);
|
||||
#define receiveNotificationBrightness receiveN.Brightness
|
||||
#define receiveNotificationColor receiveN.Color
|
||||
#define receiveNotificationEffects receiveN.Effects
|
||||
#define receiveSegmentOptions receiveN.SegmentOptions
|
||||
#define receiveSegmentBounds receiveN.SegmentBounds
|
||||
#define receiveDirect receiveN.Direct
|
||||
#define notifyDirect notifyG.Direct
|
||||
#define notifyButton notifyG.Button
|
||||
#define notifyAlexa notifyG.Alexa
|
||||
#define notifyHue notifyG.Hue
|
||||
#else
|
||||
WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications
|
||||
WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color
|
||||
WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup
|
||||
WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options
|
||||
WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segment bounds (start, stop, offset)
|
||||
WLED_GLOBAL bool receiveDirect _INIT(true); // receive UDP/Hyperion realtime
|
||||
WLED_GLOBAL bool notifyDirect _INIT(false); // send notification if change via UI or HTTP API
|
||||
WLED_GLOBAL bool notifyButton _INIT(false); // send if updated by button or infrared remote
|
||||
WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa
|
||||
WLED_GLOBAL bool notifyHue _INIT(true); // send notification if Hue light changes
|
||||
#endif
|
||||
|
||||
// effects
|
||||
WLED_GLOBAL byte effectCurrent _INIT(0);
|
||||
@ -619,7 +704,46 @@ WLED_GLOBAL byte effectPalette _INIT(0);
|
||||
WLED_GLOBAL bool stateChanged _INIT(false);
|
||||
|
||||
// network
|
||||
WLED_GLOBAL bool udpConnected _INIT(false), udp2Connected _INIT(false), udpRgbConnected _INIT(false);
|
||||
#ifdef WLED_SAVE_RAM
|
||||
// this will save us 2 bytes of RAM while increasing code by ~400 bytes
|
||||
typedef class Udp {
|
||||
public:
|
||||
uint16_t Port;
|
||||
uint16_t Port2;
|
||||
uint16_t RgbPort;
|
||||
struct {
|
||||
uint8_t NumRetries : 5;
|
||||
bool Connected : 1;
|
||||
bool Connected2 : 1;
|
||||
bool RgbConnected : 1;
|
||||
};
|
||||
Udp(int p1, int p2, int p3, int r, bool c1, bool c2, bool c3) {
|
||||
Port = p1;
|
||||
Port2 = p2;
|
||||
RgbPort = p3;
|
||||
NumRetries = r;
|
||||
Connected = c1;
|
||||
Connected2 = c2;
|
||||
RgbConnected = c3;
|
||||
}
|
||||
} __attribute__ ((aligned(1), packed)) udp_port_t;
|
||||
WLED_GLOBAL udp_port_t udp _INIT_N(({21234, 65506, 19446, 0, false, false, false}));
|
||||
#define udpPort udp.Port
|
||||
#define udpPort2 udp.Port2
|
||||
#define udpRgbPort udp.RgbPort
|
||||
#define udpNumRetries udp.NumRetries
|
||||
#define udpConnected udp.Connected
|
||||
#define udp2Connected udp.Connected2
|
||||
#define udpRgbConnected udp.RgbConnected
|
||||
#else
|
||||
WLED_GLOBAL uint16_t udpPort _INIT(21324); // WLED notifier default port
|
||||
WLED_GLOBAL uint16_t udpPort2 _INIT(65506); // WLED notifier supplemental port
|
||||
WLED_GLOBAL uint16_t udpRgbPort _INIT(19446); // Hyperion port
|
||||
WLED_GLOBAL uint8_t udpNumRetries _INIT(0); // Number of times a UDP sync message is retransmitted. Increase to increase reliability
|
||||
WLED_GLOBAL bool udpConnected _INIT(false);
|
||||
WLED_GLOBAL bool udp2Connected _INIT(false);
|
||||
WLED_GLOBAL bool udpRgbConnected _INIT(false);
|
||||
#endif
|
||||
|
||||
// ui style
|
||||
WLED_GLOBAL bool showWelcomePage _INIT(false);
|
||||
|
@ -361,10 +361,10 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
oappend(itoa(WLED_MAX_ANALOG_CHANNELS,nS,10));
|
||||
oappend(SET_F(");"));
|
||||
|
||||
sappend('c',SET_F("MS"),autoSegments);
|
||||
sappend('c',SET_F("CCT"),correctWB);
|
||||
sappend('c',SET_F("MS"),strip.autoSegments);
|
||||
sappend('c',SET_F("CCT"),strip.correctWB);
|
||||
sappend('c',SET_F("IC"),cctICused);
|
||||
sappend('c',SET_F("CR"),cctFromRgb);
|
||||
sappend('c',SET_F("CR"),strip.cctFromRgb);
|
||||
sappend('v',SET_F("CB"),strip.cctBlending);
|
||||
sappend('v',SET_F("FR"),strip.getTargetFps());
|
||||
sappend('v',SET_F("AW"),Bus::getGlobalAWMode());
|
||||
@ -533,11 +533,12 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
sappend('c',SET_F("FB"),arlsForceMaxBri);
|
||||
sappend('c',SET_F("RG"),arlsDisableGammaCorrection);
|
||||
sappend('v',SET_F("WO"),arlsOffset);
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
sappend('c',SET_F("AL"),alexaEnabled);
|
||||
sappends('s',SET_F("AI"),alexaInvocationName);
|
||||
sappend('c',SET_F("SA"),notifyAlexa);
|
||||
sappend('v',SET_F("AP"),alexaNumPresets);
|
||||
#ifdef WLED_DISABLE_ALEXA
|
||||
#elese
|
||||
oappend(SET_F("toggle('Alexa');")); // hide Alexa settings
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user