Save some tiny amounts of RAM
- use `-D WLED_SAVE_RAM`
This commit is contained in:
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);
|
||||
|
||||
Reference in New Issue
Block a user