mirror of
https://github.com/wled/WLED.git
synced 2025-04-19 12:27:17 +00:00
Override identifier
This commit is contained in:
parent
3f21b4aa7d
commit
45dc5e236d
@ -87,7 +87,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* readFromConfig() is called prior to setup()
|
||||
* You can use it to initialize variables, sensors or similar.
|
||||
*/
|
||||
void setup() {
|
||||
void setup() override {
|
||||
// do your set-up here
|
||||
//Serial.println("Hello from my usermod!");
|
||||
initDone = true;
|
||||
@ -98,7 +98,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* connected() is called every time the WiFi is (re)connected
|
||||
* Use it to initialize network interfaces
|
||||
*/
|
||||
void connected() {
|
||||
void connected() override {
|
||||
//Serial.println("Connected to WiFi!");
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* 2. Try to avoid using the delay() function. NEVER use delays longer than 10 milliseconds.
|
||||
* Instead, use a timer check as shown here.
|
||||
*/
|
||||
void loop() {
|
||||
void loop() override {
|
||||
// if usermod is disabled or called during strip updating just exit
|
||||
// NOTE: on very long strips strip.isUpdating() may always return true so update accordingly
|
||||
if (!enabled || strip.isUpdating()) return;
|
||||
@ -131,7 +131,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
||||
* Below it is shown how this could be used for e.g. a light sensor
|
||||
*/
|
||||
void addToJsonInfo(JsonObject& root)
|
||||
void addToJsonInfo(JsonObject& root) override
|
||||
{
|
||||
// if "u" object does not exist yet wee need to create it
|
||||
JsonObject user = root["u"];
|
||||
@ -156,7 +156,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void addToJsonState(JsonObject& root)
|
||||
void addToJsonState(JsonObject& root) override
|
||||
{
|
||||
if (!initDone || !enabled) return; // prevent crash on boot applyPreset()
|
||||
|
||||
@ -171,7 +171,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject& root)
|
||||
void readFromJsonState(JsonObject& root) override
|
||||
{
|
||||
if (!initDone) return; // prevent crash on boot applyPreset()
|
||||
|
||||
@ -220,7 +220,7 @@ class MyExampleUsermod : public Usermod {
|
||||
*
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root)
|
||||
void addToConfig(JsonObject& root) override
|
||||
{
|
||||
JsonObject top = root.createNestedObject(FPSTR(_name));
|
||||
top[FPSTR(_enabled)] = enabled;
|
||||
@ -253,7 +253,7 @@ class MyExampleUsermod : public Usermod {
|
||||
*
|
||||
* This function is guaranteed to be called on boot, but could also be called every time settings are updated
|
||||
*/
|
||||
bool readFromConfig(JsonObject& root)
|
||||
bool readFromConfig(JsonObject& root) override
|
||||
{
|
||||
// default settings values could be set here (or below using the 3-argument getJsonValue()) instead of in the class definition or constructor
|
||||
// setting them inside readFromConfig() is slightly more robust, handling the rare but plausible use case of single value being missing after boot (e.g. if the cfg.json was manually edited and a value was removed)
|
||||
@ -285,7 +285,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* it may add additional metadata for certain entry fields (adding drop down is possible)
|
||||
* be careful not to add too much as oappend() buffer is limited to 3k
|
||||
*/
|
||||
void appendConfigData()
|
||||
void appendConfigData() override
|
||||
{
|
||||
oappend(SET_F("addInfo('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F(":great")); oappend(SET_F("',1,'<i>(this is a great config value)</i>');"));
|
||||
oappend(SET_F("addInfo('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F(":testString")); oappend(SET_F("',1,'enter any string you want');"));
|
||||
@ -300,7 +300,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* Use this to blank out some LEDs or set them to a different color regardless of the set effect mode.
|
||||
* Commonly used for custom clocks (Cronixie, 7 segment)
|
||||
*/
|
||||
void handleOverlayDraw()
|
||||
void handleOverlayDraw() override
|
||||
{
|
||||
//strip.setPixelColor(0, RGBW32(0,0,0,0)) // set the first pixel to black
|
||||
}
|
||||
@ -311,7 +311,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* will prevent button working in a default way.
|
||||
* Replicating button.cpp
|
||||
*/
|
||||
bool handleButton(uint8_t b) {
|
||||
bool handleButton(uint8_t b) override {
|
||||
yield();
|
||||
// ignore certain button types as they may have other consequences
|
||||
if (!enabled
|
||||
@ -334,7 +334,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* handling of MQTT message
|
||||
* topic only contains stripped topic (part after /wled/MAC)
|
||||
*/
|
||||
bool onMqttMessage(char* topic, char* payload) {
|
||||
bool onMqttMessage(char* topic, char* payload) override {
|
||||
// check if we received a command
|
||||
//if (strlen(topic) == 8 && strncmp_P(topic, PSTR("/command"), 8) == 0) {
|
||||
// String action = payload;
|
||||
@ -355,7 +355,7 @@ class MyExampleUsermod : public Usermod {
|
||||
/**
|
||||
* onMqttConnect() is called when MQTT connection is established
|
||||
*/
|
||||
void onMqttConnect(bool sessionPresent) {
|
||||
void onMqttConnect(bool sessionPresent) override {
|
||||
// do any MQTT related initialisation here
|
||||
//publishMqtt("I am alive!");
|
||||
}
|
||||
@ -366,7 +366,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* onStateChanged() is used to detect WLED state change
|
||||
* @mode parameter is CALL_MODE_... parameter used for notifications
|
||||
*/
|
||||
void onStateChange(uint8_t mode) {
|
||||
void onStateChange(uint8_t mode) override {
|
||||
// do something if WLED state changed (color, brightness, effect, preset, etc)
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ class MyExampleUsermod : public Usermod {
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId()
|
||||
uint16_t getId() override
|
||||
{
|
||||
return USERMOD_ID_EXAMPLE;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
* setup() is called once at boot. WiFi is not yet connected at this point.
|
||||
* You can use it to initialize variables, sensors or similar.
|
||||
*/
|
||||
void setup();
|
||||
void setup() override;
|
||||
|
||||
/**
|
||||
* connected() is called every time the WiFi is (re)connected
|
||||
@ -128,24 +128,24 @@ public:
|
||||
/**
|
||||
* onMqttConnect() is called when MQTT connection is established
|
||||
*/
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
void onMqttConnect(bool sessionPresent) override;
|
||||
|
||||
/**
|
||||
* loop() is called continuously. Here you can check for events, read sensors, etc.
|
||||
*/
|
||||
void loop();
|
||||
void loop() override;
|
||||
|
||||
/**
|
||||
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
|
||||
*
|
||||
* Add PIR sensor state and switch off timer duration to jsoninfo
|
||||
*/
|
||||
void addToJsonInfo(JsonObject &root);
|
||||
void addToJsonInfo(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* onStateChanged() is used to detect WLED state change
|
||||
*/
|
||||
void onStateChange(uint8_t mode);
|
||||
void onStateChange(uint8_t mode) override;
|
||||
|
||||
/**
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
@ -157,17 +157,17 @@ public:
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject &root);
|
||||
void readFromJsonState(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* provide the changeable values
|
||||
*/
|
||||
void addToConfig(JsonObject &root);
|
||||
void addToConfig(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* provide UI information and allow extending UI options
|
||||
*/
|
||||
void appendConfigData();
|
||||
void appendConfigData() override;
|
||||
|
||||
/**
|
||||
* restore the changeable values
|
||||
@ -175,13 +175,13 @@ public:
|
||||
*
|
||||
* The function should return true if configuration was successfully loaded or false if there was no configuration.
|
||||
*/
|
||||
bool readFromConfig(JsonObject &root);
|
||||
bool readFromConfig(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId() { return USERMOD_ID_PIRSWITCH; }
|
||||
uint16_t getId() override { return USERMOD_ID_PIRSWITCH; }
|
||||
};
|
||||
|
||||
// strings to reduce flash memory usage (used more than twice)
|
||||
|
@ -188,7 +188,7 @@ class PWMFanUsermod : public Usermod {
|
||||
|
||||
// gets called once at boot. Do all initialization that doesn't depend on
|
||||
// network here
|
||||
void setup() {
|
||||
void setup() override {
|
||||
#ifdef USERMOD_DALLASTEMPERATURE
|
||||
// This Usermod requires Temperature usermod
|
||||
tempUM = (UsermodTemperature*) usermods.lookup(USERMOD_ID_TEMPERATURE);
|
||||
@ -203,12 +203,12 @@ class PWMFanUsermod : public Usermod {
|
||||
|
||||
// gets called every time WiFi is (re-)connected. Initialize own network
|
||||
// interfaces here
|
||||
void connected() {}
|
||||
void connected() override {}
|
||||
|
||||
/*
|
||||
* Da loop.
|
||||
*/
|
||||
void loop() {
|
||||
void loop() override {
|
||||
if (!enabled || strip.isUpdating()) return;
|
||||
|
||||
unsigned long now = millis();
|
||||
@ -223,7 +223,7 @@ class PWMFanUsermod : public Usermod {
|
||||
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
||||
* Below it is shown how this could be used for e.g. a light sensor
|
||||
*/
|
||||
void addToJsonInfo(JsonObject& root) {
|
||||
void addToJsonInfo(JsonObject& root) override {
|
||||
JsonObject user = root["u"];
|
||||
if (user.isNull()) user = root.createNestedObject("u");
|
||||
|
||||
@ -272,7 +272,7 @@ class PWMFanUsermod : public Usermod {
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject& root) {
|
||||
void readFromJsonState(JsonObject& root) override {
|
||||
if (!initDone) return; // prevent crash on boot applyPreset()
|
||||
JsonObject usermod = root[FPSTR(_name)];
|
||||
if (!usermod.isNull()) {
|
||||
@ -305,7 +305,7 @@ class PWMFanUsermod : public Usermod {
|
||||
*
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root) {
|
||||
void addToConfig(JsonObject& root) override {
|
||||
JsonObject top = root.createNestedObject(FPSTR(_name)); // usermodname
|
||||
top[FPSTR(_enabled)] = enabled;
|
||||
top[FPSTR(_pwmPin)] = pwmPin;
|
||||
@ -328,7 +328,7 @@ class PWMFanUsermod : public Usermod {
|
||||
*
|
||||
* The function should return true if configuration was successfully loaded or false if there was no configuration.
|
||||
*/
|
||||
bool readFromConfig(JsonObject& root) {
|
||||
bool readFromConfig(JsonObject& root) override {
|
||||
int8_t newTachoPin = tachoPin;
|
||||
int8_t newPwmPin = pwmPin;
|
||||
|
||||
@ -380,7 +380,7 @@ class PWMFanUsermod : public Usermod {
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId() {
|
||||
uint16_t getId() override {
|
||||
return USERMOD_ID_PWM_FAN;
|
||||
}
|
||||
};
|
||||
|
@ -132,7 +132,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* setup() is called once at boot. WiFi is not yet connected at this point.
|
||||
* You can use it to initialize variables, sensors or similar.
|
||||
*/
|
||||
void setup()
|
||||
void setup() override
|
||||
{
|
||||
PinManagerPinType spiPins[] = { { spi_mosi, true }, { spi_miso, false}, { spi_sclk, true } };
|
||||
if (!pinManager.allocateMultiplePins(spiPins, 3, PinOwner::HW_SPI)) { enabled = false; return; }
|
||||
@ -162,7 +162,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* connected() is called every time the WiFi is (re)connected
|
||||
* Use it to initialize network interfaces
|
||||
*/
|
||||
void connected() {
|
||||
void connected() override {
|
||||
//Serial.println("Connected to WiFi!");
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* 2. Try to avoid using the delay() function. NEVER use delays longer than 10 milliseconds.
|
||||
* Instead, use a timer check as shown here.
|
||||
*/
|
||||
void loop() {
|
||||
void loop() override {
|
||||
char buff[LINE_BUFFER_SIZE];
|
||||
|
||||
// Check if we time interval for redrawing passes.
|
||||
@ -316,7 +316,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
||||
* Below it is shown how this could be used for e.g. a light sensor
|
||||
*/
|
||||
void addToJsonInfo(JsonObject& root)
|
||||
void addToJsonInfo(JsonObject& root) override
|
||||
{
|
||||
JsonObject user = root["u"];
|
||||
if (user.isNull()) user = root.createNestedObject("u");
|
||||
@ -330,7 +330,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void addToJsonState(JsonObject& root)
|
||||
void addToJsonState(JsonObject& root) override
|
||||
{
|
||||
//root["user0"] = userVar0;
|
||||
}
|
||||
@ -340,7 +340,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject& root)
|
||||
void readFromJsonState(JsonObject& root) override
|
||||
{
|
||||
//userVar0 = root["user0"] | userVar0; //if "user0" key exists in JSON, update, else keep old value
|
||||
//if (root["bri"] == 255) Serial.println(F("Don't burn down your garage!"));
|
||||
@ -361,7 +361,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
*
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root)
|
||||
void addToConfig(JsonObject& root) override
|
||||
{
|
||||
JsonObject top = root.createNestedObject("ST7789");
|
||||
JsonArray pins = top.createNestedArray("pin");
|
||||
@ -373,7 +373,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
}
|
||||
|
||||
|
||||
void appendConfigData() {
|
||||
void appendConfigData() override {
|
||||
oappend(SET_F("addInfo('ST7789:pin[]',0,'','SPI CS');"));
|
||||
oappend(SET_F("addInfo('ST7789:pin[]',1,'','SPI DC');"));
|
||||
oappend(SET_F("addInfo('ST7789:pin[]',2,'','SPI RST');"));
|
||||
@ -388,7 +388,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup.
|
||||
* If you don't know what that is, don't fret. It most likely doesn't affect your use case :)
|
||||
*/
|
||||
bool readFromConfig(JsonObject& root)
|
||||
bool readFromConfig(JsonObject& root) override
|
||||
{
|
||||
//JsonObject top = root["top"];
|
||||
//userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot)
|
||||
@ -400,7 +400,7 @@ class St7789DisplayUsermod : public Usermod {
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId()
|
||||
uint16_t getId() override
|
||||
{
|
||||
return USERMOD_ID_ST7789_DISPLAY;
|
||||
}
|
||||
|
@ -76,26 +76,26 @@ class UsermodTemperature : public Usermod {
|
||||
inline float getTemperatureF() { return temperature * 1.8f + 32.0f; }
|
||||
float getTemperature();
|
||||
const char *getTemperatureUnit();
|
||||
uint16_t getId() { return USERMOD_ID_TEMPERATURE; }
|
||||
uint16_t getId() override { return USERMOD_ID_TEMPERATURE; }
|
||||
|
||||
void setup();
|
||||
void loop();
|
||||
//void connected();
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
//void connected() override;
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
void onMqttConnect(bool sessionPresent) override;
|
||||
#endif
|
||||
//void onUpdateBegin(bool init);
|
||||
//void onUpdateBegin(bool init) override;
|
||||
|
||||
//bool handleButton(uint8_t b);
|
||||
//void handleOverlayDraw();
|
||||
//bool handleButton(uint8_t b) override;
|
||||
//void handleOverlayDraw() override;
|
||||
|
||||
void addToJsonInfo(JsonObject& root);
|
||||
//void addToJsonState(JsonObject &root);
|
||||
//void readFromJsonState(JsonObject &root);
|
||||
void addToConfig(JsonObject &root);
|
||||
bool readFromConfig(JsonObject &root);
|
||||
void addToJsonInfo(JsonObject& root) override;
|
||||
//void addToJsonState(JsonObject &root) override;
|
||||
//void readFromJsonState(JsonObject &root) override;
|
||||
void addToConfig(JsonObject &root) override;
|
||||
bool readFromConfig(JsonObject &root) override;
|
||||
|
||||
void appendConfigData();
|
||||
void appendConfigData() override;
|
||||
};
|
||||
|
||||
//Dallas sensor quick (& dirty) reading. Credit to - Author: Peter Scargill, August 17th, 2013
|
||||
|
@ -1094,7 +1094,7 @@ class AudioReactive : public Usermod {
|
||||
* You can use it to initialize variables, sensors or similar.
|
||||
* It is called *AFTER* readFromConfig()
|
||||
*/
|
||||
void setup()
|
||||
void setup() override
|
||||
{
|
||||
disableSoundProcessing = true; // just to be sure
|
||||
if (!initDone) {
|
||||
@ -1217,7 +1217,7 @@ class AudioReactive : public Usermod {
|
||||
* connected() is called every time the WiFi is (re)connected
|
||||
* Use it to initialize network interfaces
|
||||
*/
|
||||
void connected()
|
||||
void connected() override
|
||||
{
|
||||
if (udpSyncConnected) { // clean-up: if open, close old UDP sync connection
|
||||
udpSyncConnected = false;
|
||||
@ -1244,7 +1244,7 @@ class AudioReactive : public Usermod {
|
||||
* 2. Try to avoid using the delay() function. NEVER use delays longer than 10 milliseconds.
|
||||
* Instead, use a timer check as shown here.
|
||||
*/
|
||||
void loop()
|
||||
void loop() override
|
||||
{
|
||||
static unsigned long lastUMRun = millis();
|
||||
|
||||
@ -1375,7 +1375,7 @@ class AudioReactive : public Usermod {
|
||||
}
|
||||
|
||||
|
||||
bool getUMData(um_data_t **data)
|
||||
bool getUMData(um_data_t **data) override
|
||||
{
|
||||
if (!data || !enabled) return false; // no pointer provided by caller or not enabled -> exit
|
||||
*data = um_data;
|
||||
@ -1383,7 +1383,7 @@ class AudioReactive : public Usermod {
|
||||
}
|
||||
|
||||
|
||||
void onUpdateBegin(bool init)
|
||||
void onUpdateBegin(bool init) override
|
||||
{
|
||||
#ifdef WLED_DEBUG
|
||||
fftTime = sampleTime = 0;
|
||||
@ -1438,7 +1438,7 @@ class AudioReactive : public Usermod {
|
||||
* handleButton() can be used to override default button behaviour. Returning true
|
||||
* will prevent button working in a default way.
|
||||
*/
|
||||
bool handleButton(uint8_t b) {
|
||||
bool handleButton(uint8_t b) override {
|
||||
yield();
|
||||
// crude way of determining if audio input is analog
|
||||
// better would be for AudioSource to implement getType()
|
||||
@ -1461,7 +1461,7 @@ class AudioReactive : public Usermod {
|
||||
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
||||
* Below it is shown how this could be used for e.g. a light sensor
|
||||
*/
|
||||
void addToJsonInfo(JsonObject& root)
|
||||
void addToJsonInfo(JsonObject& root) override
|
||||
{
|
||||
char myStringBuffer[16]; // buffer for snprintf()
|
||||
JsonObject user = root["u"];
|
||||
@ -1600,7 +1600,7 @@ class AudioReactive : public Usermod {
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void addToJsonState(JsonObject& root)
|
||||
void addToJsonState(JsonObject& root) override
|
||||
{
|
||||
if (!initDone) return; // prevent crash on boot applyPreset()
|
||||
JsonObject usermod = root[FPSTR(_name)];
|
||||
@ -1615,7 +1615,7 @@ class AudioReactive : public Usermod {
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject& root)
|
||||
void readFromJsonState(JsonObject& root) override
|
||||
{
|
||||
if (!initDone) return; // prevent crash on boot applyPreset()
|
||||
bool prevEnabled = enabled;
|
||||
@ -1640,7 +1640,7 @@ class AudioReactive : public Usermod {
|
||||
}
|
||||
}
|
||||
|
||||
void onStateChange(uint8_t callMode) {
|
||||
void onStateChange(uint8_t callMode) override {
|
||||
if (initDone && enabled && addPalettes && palettes==0 && strip.customPalettes.size()<10) {
|
||||
// if palettes were removed during JSON call re-add them
|
||||
createAudioPalettes();
|
||||
@ -1682,7 +1682,7 @@ class AudioReactive : public Usermod {
|
||||
*
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root)
|
||||
void addToConfig(JsonObject& root) override
|
||||
{
|
||||
JsonObject top = root.createNestedObject(FPSTR(_name));
|
||||
top[FPSTR(_enabled)] = enabled;
|
||||
@ -1735,7 +1735,7 @@ class AudioReactive : public Usermod {
|
||||
*
|
||||
* This function is guaranteed to be called on boot, but could also be called every time settings are updated
|
||||
*/
|
||||
bool readFromConfig(JsonObject& root)
|
||||
bool readFromConfig(JsonObject& root) override
|
||||
{
|
||||
JsonObject top = root[FPSTR(_name)];
|
||||
bool configComplete = !top.isNull();
|
||||
@ -1786,7 +1786,7 @@ class AudioReactive : public Usermod {
|
||||
}
|
||||
|
||||
|
||||
void appendConfigData()
|
||||
void appendConfigData() override
|
||||
{
|
||||
oappend(SET_F("dd=addDropdown('AudioReactive','digitalmic:type');"));
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
@ -1841,7 +1841,7 @@ class AudioReactive : public Usermod {
|
||||
* Use this to blank out some LEDs or set them to a different color regardless of the set effect mode.
|
||||
* Commonly used for custom clocks (Cronixie, 7 segment)
|
||||
*/
|
||||
//void handleOverlayDraw()
|
||||
//void handleOverlayDraw() override
|
||||
//{
|
||||
//strip.setPixelColor(0, RGBW32(0,0,0,0)) // set the first pixel to black
|
||||
//}
|
||||
@ -1851,7 +1851,7 @@ class AudioReactive : public Usermod {
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId()
|
||||
uint16_t getId() override
|
||||
{
|
||||
return USERMOD_ID_AUDIOREACTIVE;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class BobLightUsermod : public Usermod {
|
||||
|
||||
public:
|
||||
|
||||
void setup() {
|
||||
void setup() override {
|
||||
uint16_t totalLights = bottom + left + top + right;
|
||||
if ( totalLights > strip.getLengthTotal() ) {
|
||||
DEBUG_PRINTLN(F("BobLight: Too many lights."));
|
||||
@ -202,14 +202,14 @@ class BobLightUsermod : public Usermod {
|
||||
initDone = true;
|
||||
}
|
||||
|
||||
void connected() {
|
||||
void connected() override {
|
||||
// we can only start server when WiFi is connected
|
||||
if (!bob) bob = new WiFiServer(bobPort, 1);
|
||||
bob->begin();
|
||||
bob->setNoDelay(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
void loop() override {
|
||||
if (!enabled || strip.isUpdating()) return;
|
||||
if (millis() - lastTime > 10) {
|
||||
lastTime = millis();
|
||||
@ -225,7 +225,7 @@ class BobLightUsermod : public Usermod {
|
||||
* topic only contains stripped topic (part after /wled/MAC)
|
||||
* topic should look like: /swipe with amessage of [up|down]
|
||||
*/
|
||||
bool onMqttMessage(char* topic, char* payload) {
|
||||
bool onMqttMessage(char* topic, char* payload) override {
|
||||
//if (strlen(topic) == 6 && strncmp_P(topic, PSTR("/subtopic"), 6) == 0) {
|
||||
// String action = payload;
|
||||
// if (action == "on") {
|
||||
@ -242,7 +242,7 @@ class BobLightUsermod : public Usermod {
|
||||
/**
|
||||
* subscribe to MQTT topic for controlling usermod
|
||||
*/
|
||||
void onMqttConnect(bool sessionPresent) {
|
||||
void onMqttConnect(bool sessionPresent) override {
|
||||
//char subuf[64];
|
||||
//if (mqttDeviceTopic[0] != 0) {
|
||||
// strcpy(subuf, mqttDeviceTopic);
|
||||
@ -252,7 +252,7 @@ class BobLightUsermod : public Usermod {
|
||||
}
|
||||
#endif
|
||||
|
||||
void addToJsonInfo(JsonObject& root)
|
||||
void addToJsonInfo(JsonObject& root) override
|
||||
{
|
||||
JsonObject user = root["u"];
|
||||
if (user.isNull()) user = root.createNestedObject("u");
|
||||
@ -273,7 +273,7 @@ class BobLightUsermod : public Usermod {
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void addToJsonState(JsonObject& root)
|
||||
void addToJsonState(JsonObject& root) override
|
||||
{
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ class BobLightUsermod : public Usermod {
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject& root) {
|
||||
void readFromJsonState(JsonObject& root) override {
|
||||
if (!initDone) return; // prevent crash on boot applyPreset()
|
||||
bool en = enabled;
|
||||
JsonObject um = root[FPSTR(_name)];
|
||||
@ -304,7 +304,7 @@ class BobLightUsermod : public Usermod {
|
||||
}
|
||||
}
|
||||
|
||||
void appendConfigData() {
|
||||
void appendConfigData() override {
|
||||
//oappend(SET_F("dd=addDropdown('usermod','selectfield');"));
|
||||
//oappend(SET_F("addOption(dd,'1st value',0);"));
|
||||
//oappend(SET_F("addOption(dd,'2nd value',1);"));
|
||||
@ -315,7 +315,7 @@ class BobLightUsermod : public Usermod {
|
||||
oappend(SET_F("addInfo('BobLight:pct',1,'Depth of scan [%]');")); // 0 is field type, 1 is actual field
|
||||
}
|
||||
|
||||
void addToConfig(JsonObject& root) {
|
||||
void addToConfig(JsonObject& root) override {
|
||||
JsonObject umData = root.createNestedObject(FPSTR(_name));
|
||||
umData[FPSTR(_enabled)] = enabled;
|
||||
umData[F("port")] = bobPort;
|
||||
@ -326,7 +326,7 @@ class BobLightUsermod : public Usermod {
|
||||
umData[F("pct")] = pct;
|
||||
}
|
||||
|
||||
bool readFromConfig(JsonObject& root) {
|
||||
bool readFromConfig(JsonObject& root) override {
|
||||
JsonObject umData = root[FPSTR(_name)];
|
||||
bool configComplete = !umData.isNull();
|
||||
|
||||
@ -355,11 +355,11 @@ class BobLightUsermod : public Usermod {
|
||||
* Use this to blank out some LEDs or set them to a different color regardless of the set effect mode.
|
||||
* Commonly used for custom clocks (Cronixie, 7 segment)
|
||||
*/
|
||||
void handleOverlayDraw() {
|
||||
void handleOverlayDraw() override {
|
||||
//strip.setPixelColor(0, RGBW32(0,0,0,0)) // set the first pixel to black
|
||||
}
|
||||
|
||||
uint16_t getId() { return USERMOD_ID_BOBLIGHT; }
|
||||
uint16_t getId() override { return USERMOD_ID_BOBLIGHT; }
|
||||
|
||||
};
|
||||
|
||||
|
@ -143,7 +143,7 @@ class MultiRelay : public Usermod {
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
inline uint16_t getId() { return USERMOD_ID_MULTI_RELAY; }
|
||||
inline uint16_t getId() override { return USERMOD_ID_MULTI_RELAY; }
|
||||
|
||||
/**
|
||||
* switch relay on/off
|
||||
@ -161,22 +161,22 @@ class MultiRelay : public Usermod {
|
||||
* setup() is called once at boot. WiFi is not yet connected at this point.
|
||||
* You can use it to initialize variables, sensors or similar.
|
||||
*/
|
||||
void setup();
|
||||
void setup() override;
|
||||
|
||||
/**
|
||||
* connected() is called every time the WiFi is (re)connected
|
||||
* Use it to initialize network interfaces
|
||||
*/
|
||||
inline void connected() { InitHtmlAPIHandle(); }
|
||||
inline void connected() override { InitHtmlAPIHandle(); }
|
||||
|
||||
/**
|
||||
* loop() is called continuously. Here you can check for events, read sensors, etc.
|
||||
*/
|
||||
void loop();
|
||||
void loop() override;
|
||||
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
bool onMqttMessage(char* topic, char* payload);
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
bool onMqttMessage(char* topic, char* payload) override;
|
||||
void onMqttConnect(bool sessionPresent) override;
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -184,31 +184,31 @@ class MultiRelay : public Usermod {
|
||||
* will prevent button working in a default way.
|
||||
* Replicating button.cpp
|
||||
*/
|
||||
bool handleButton(uint8_t b);
|
||||
bool handleButton(uint8_t b) override;
|
||||
|
||||
/**
|
||||
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
|
||||
*/
|
||||
void addToJsonInfo(JsonObject &root);
|
||||
void addToJsonInfo(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void addToJsonState(JsonObject &root);
|
||||
void addToJsonState(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject &root);
|
||||
void readFromJsonState(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* provide the changeable values
|
||||
*/
|
||||
void addToConfig(JsonObject &root);
|
||||
void addToConfig(JsonObject &root) override;
|
||||
|
||||
void appendConfigData();
|
||||
void appendConfigData() override;
|
||||
|
||||
/**
|
||||
* restore the changeable values
|
||||
@ -216,7 +216,7 @@ class MultiRelay : public Usermod {
|
||||
*
|
||||
* The function should return true if configuration was successfully loaded or false if there was no configuration.
|
||||
*/
|
||||
bool readFromConfig(JsonObject &root);
|
||||
bool readFromConfig(JsonObject &root) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -211,16 +211,16 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
|
||||
// gets called once at boot. Do all initialization that doesn't depend on
|
||||
// network here
|
||||
void setup();
|
||||
void setup() override;
|
||||
|
||||
// gets called every time WiFi is (re-)connected. Initialize own network
|
||||
// interfaces here
|
||||
void connected();
|
||||
void connected() override;
|
||||
|
||||
/**
|
||||
* Da loop.
|
||||
*/
|
||||
void loop();
|
||||
void loop() override;
|
||||
|
||||
//function to update lastredraw
|
||||
inline void updateRedrawTime() { lastRedraw = millis(); }
|
||||
@ -287,28 +287,28 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
*/
|
||||
bool handleButton(uint8_t b);
|
||||
|
||||
void onUpdateBegin(bool init);
|
||||
void onUpdateBegin(bool init) override;
|
||||
|
||||
/*
|
||||
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
|
||||
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
||||
* Below it is shown how this could be used for e.g. a light sensor
|
||||
*/
|
||||
//void addToJsonInfo(JsonObject& root);
|
||||
//void addToJsonInfo(JsonObject& root) override;
|
||||
|
||||
/*
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
//void addToJsonState(JsonObject& root);
|
||||
//void addToJsonState(JsonObject& root) override;
|
||||
|
||||
/*
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
//void readFromJsonState(JsonObject& root);
|
||||
//void readFromJsonState(JsonObject& root) override;
|
||||
|
||||
void appendConfigData();
|
||||
void appendConfigData() override;
|
||||
|
||||
/*
|
||||
* addToConfig() can be used to add custom persistent settings to the cfg.json file in the "um" (usermod) object.
|
||||
@ -324,7 +324,7 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
*
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root);
|
||||
void addToConfig(JsonObject& root) override;
|
||||
|
||||
/*
|
||||
* readFromConfig() can be used to read back the custom settings you added with addToConfig().
|
||||
@ -334,13 +334,13 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
* but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup.
|
||||
* If you don't know what that is, don't fret. It most likely doesn't affect your use case :)
|
||||
*/
|
||||
bool readFromConfig(JsonObject& root);
|
||||
bool readFromConfig(JsonObject& root) override;
|
||||
|
||||
/*
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId() {
|
||||
uint16_t getId() override {
|
||||
return USERMOD_ID_FOUR_LINE_DISP;
|
||||
}
|
||||
};
|
||||
|
@ -285,7 +285,7 @@ class RotaryEncoderUIUsermod : public Usermod {
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
* This could be used in the future for the system to determine whether your usermod is installed.
|
||||
*/
|
||||
uint16_t getId() { return USERMOD_ID_ROTARY_ENC_UI; }
|
||||
uint16_t getId() override { return USERMOD_ID_ROTARY_ENC_UI; }
|
||||
/**
|
||||
* Enable/Disable the usermod
|
||||
*/
|
||||
@ -300,7 +300,7 @@ class RotaryEncoderUIUsermod : public Usermod {
|
||||
* setup() is called once at boot. WiFi is not yet connected at this point.
|
||||
* You can use it to initialize variables, sensors or similar.
|
||||
*/
|
||||
void setup();
|
||||
void setup() override;
|
||||
|
||||
/**
|
||||
* connected() is called every time the WiFi is (re)connected
|
||||
@ -311,11 +311,11 @@ class RotaryEncoderUIUsermod : public Usermod {
|
||||
/**
|
||||
* loop() is called continuously. Here you can check for events, read sensors, etc.
|
||||
*/
|
||||
void loop();
|
||||
void loop() override;
|
||||
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
//bool onMqttMessage(char* topic, char* payload);
|
||||
//void onMqttConnect(bool sessionPresent);
|
||||
//bool onMqttMessage(char* topic, char* payload) override;
|
||||
//void onMqttConnect(bool sessionPresent) override;
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -323,31 +323,31 @@ class RotaryEncoderUIUsermod : public Usermod {
|
||||
* will prevent button working in a default way.
|
||||
* Replicating button.cpp
|
||||
*/
|
||||
//bool handleButton(uint8_t b);
|
||||
//bool handleButton(uint8_t b) override;
|
||||
|
||||
/**
|
||||
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
|
||||
*/
|
||||
//void addToJsonInfo(JsonObject &root);
|
||||
//void addToJsonInfo(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
//void addToJsonState(JsonObject &root);
|
||||
//void addToJsonState(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
//void readFromJsonState(JsonObject &root);
|
||||
//void readFromJsonState(JsonObject &root) override;
|
||||
|
||||
/**
|
||||
* provide the changeable values
|
||||
*/
|
||||
void addToConfig(JsonObject &root);
|
||||
void addToConfig(JsonObject &root) override;
|
||||
|
||||
void appendConfigData();
|
||||
void appendConfigData() override;
|
||||
|
||||
/**
|
||||
* restore the changeable values
|
||||
@ -355,7 +355,7 @@ class RotaryEncoderUIUsermod : public Usermod {
|
||||
*
|
||||
* The function should return true if configuration was successfully loaded or false if there was no configuration.
|
||||
*/
|
||||
bool readFromConfig(JsonObject &root);
|
||||
bool readFromConfig(JsonObject &root) override;
|
||||
|
||||
// custom methods
|
||||
void displayNetworkInfo();
|
||||
|
@ -129,10 +129,9 @@ class Bus {
|
||||
virtual void setPixelColor(uint16_t pix, uint32_t c) = 0;
|
||||
virtual uint32_t getPixelColor(uint16_t pix) { return 0; }
|
||||
virtual void setBrightness(uint8_t b) { _bri = b; };
|
||||
virtual void cleanup() = 0;
|
||||
virtual uint8_t getPins(uint8_t* pinArray) { return 0; }
|
||||
virtual uint16_t getLength() { return _len; }
|
||||
virtual void setColorOrder() {}
|
||||
virtual void setColorOrder(uint8_t co) {}
|
||||
virtual uint8_t getColorOrder() { return COL_ORDER_RGB; }
|
||||
virtual uint8_t skippedLeds() { return 0; }
|
||||
virtual uint16_t getFrequency() { return 0U; }
|
||||
@ -207,21 +206,21 @@ class BusDigital : public Bus {
|
||||
BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com);
|
||||
~BusDigital() { cleanup(); }
|
||||
|
||||
void show();
|
||||
bool canShow();
|
||||
void setBrightness(uint8_t b);
|
||||
void setStatusPixel(uint32_t c);
|
||||
void setPixelColor(uint16_t pix, uint32_t c);
|
||||
void setColorOrder(uint8_t colorOrder);
|
||||
uint32_t getPixelColor(uint16_t pix);
|
||||
uint8_t getColorOrder() { return _colorOrder; }
|
||||
uint8_t getPins(uint8_t* pinArray);
|
||||
uint8_t skippedLeds() { return _skip; }
|
||||
uint16_t getFrequency() { return _frequencykHz; }
|
||||
void show() override;
|
||||
bool canShow() override;
|
||||
void setBrightness(uint8_t b) override;
|
||||
void setStatusPixel(uint32_t c) override;
|
||||
void setPixelColor(uint16_t pix, uint32_t c) override;
|
||||
void setColorOrder(uint8_t colorOrder) override;
|
||||
uint32_t getPixelColor(uint16_t pix) override;
|
||||
uint8_t getColorOrder() override { return _colorOrder; }
|
||||
uint8_t getPins(uint8_t* pinArray) override;
|
||||
uint8_t skippedLeds() override { return _skip; }
|
||||
uint16_t getFrequency() override { return _frequencykHz; }
|
||||
uint8_t estimateCurrentAndLimitBri();
|
||||
uint16_t getLEDCurrent() { return _milliAmpsPerLed; }
|
||||
uint16_t getUsedCurrent() { return _milliAmpsTotal; }
|
||||
uint16_t getMaxCurrent() { return _milliAmpsMax; }
|
||||
uint16_t getLEDCurrent() override { return _milliAmpsPerLed; }
|
||||
uint16_t getUsedCurrent() override { return _milliAmpsTotal; }
|
||||
uint16_t getMaxCurrent() override { return _milliAmpsMax; }
|
||||
void reinit();
|
||||
void cleanup();
|
||||
|
||||
@ -256,11 +255,11 @@ class BusPwm : public Bus {
|
||||
BusPwm(BusConfig &bc);
|
||||
~BusPwm() { cleanup(); }
|
||||
|
||||
void setPixelColor(uint16_t pix, uint32_t c);
|
||||
uint32_t getPixelColor(uint16_t pix); //does no index check
|
||||
uint8_t getPins(uint8_t* pinArray);
|
||||
uint16_t getFrequency() { return _frequency; }
|
||||
void show();
|
||||
void setPixelColor(uint16_t pix, uint32_t c) override;
|
||||
uint32_t getPixelColor(uint16_t pix) override; //does no index check
|
||||
uint8_t getPins(uint8_t* pinArray) override;
|
||||
uint16_t getFrequency() override { return _frequency; }
|
||||
void show() override;
|
||||
void cleanup() { deallocatePins(); }
|
||||
|
||||
private:
|
||||
@ -297,13 +296,13 @@ class BusNetwork : public Bus {
|
||||
BusNetwork(BusConfig &bc);
|
||||
~BusNetwork() { cleanup(); }
|
||||
|
||||
bool hasRGB() { return true; }
|
||||
bool hasWhite() { return _rgbw; }
|
||||
bool canShow() { return !_broadcastLock; } // this should be a return value from UDP routine if it is still sending data out
|
||||
void setPixelColor(uint16_t pix, uint32_t c);
|
||||
uint32_t getPixelColor(uint16_t pix);
|
||||
uint8_t getPins(uint8_t* pinArray);
|
||||
void show();
|
||||
bool hasRGB() override { return true; }
|
||||
bool hasWhite() override { return _rgbw; }
|
||||
bool canShow() override { return !_broadcastLock; } // this should be a return value from UDP routine if it is still sending data out
|
||||
void setPixelColor(uint16_t pix, uint32_t c) override;
|
||||
uint32_t getPixelColor(uint16_t pix) override;
|
||||
uint8_t getPins(uint8_t* pinArray) override;
|
||||
void show() override;
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user