WLED/wled00/um_manager.cpp
Kevin Dorff 8e71c3ae17
Rotary Encoder, Four Line Display, and Auto Save Usermods (#1722)
* Ability to lookup Usermod by id so Usermods can use other Usermods.

* Rotary Encoder UI using two Usermods

* Updates. More to come, probably.

* Updated rotary usermod to honor USE_FOUR_LINE_DISPLAY if you want to use four line display. It should be truly optional, now.

* minor logic improvement to showing the current time in clock mode.

* improved 24 hour display foratting and ability to use the FourLineDisplayUsermod without the RotaryEncoderUIUsermod (option disable sleep and clock modes).

* Improved ordering of defines in the FourLineDisplayUsermod to put options people might need to change together toward the top.

* relocate plugins. add mention of the Wire requirement.

* usermod filenames changed, updating comment in const.h

* fix usermod locations.

* fix usermods_list to include changed folder.

* Improved for both usermods: install, config, and docs. Included sample platform_override.ini.

* Updated name of SDA and SCL defines for config of display

* update docs.

* Wrong year. Fixed.

* Fix youtube link, improve config of sleep/clock when the rotary usermod isn't installed.

* Minor fixes to four line display. Addition of Auto Save v2 usermod.

* Allow config for auto-save to set the preset number to use. Load preset at startup (so brightness is set correctly).

* Updated docs for Auto Save.

* Updated docs for Auto Save.

Co-authored-by: Kevin Dorff <kevin@macbookpro-kevin-wifi.local>
2021-02-09 17:15:43 +01:00

37 lines
1.4 KiB
C++

#include "wled.h"
/*
* Registration and management utility for v2 usermods
*/
//Usermod Manager internals
void UsermodManager::loop() { for (byte i = 0; i < numMods; i++) ums[i]->loop(); }
void UsermodManager::setup() { for (byte i = 0; i < numMods; i++) ums[i]->setup(); }
void UsermodManager::connected() { for (byte i = 0; i < numMods; i++) ums[i]->connected(); }
void UsermodManager::addToJsonState(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToJsonState(obj); }
void UsermodManager::addToJsonInfo(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToJsonInfo(obj); }
void UsermodManager::readFromJsonState(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->readFromJsonState(obj); }
void UsermodManager::addToConfig(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToConfig(obj); }
void UsermodManager::readFromConfig(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->readFromConfig(obj); }
/*
* Enables usermods to lookup another Usermod.
*/
Usermod* UsermodManager::lookup(uint16_t mod_id) {
for (byte i = 0; i < numMods; i++) {
if (ums[i]->getId() == mod_id) {
return ums[i];
}
}
return nullptr;
}
bool UsermodManager::add(Usermod* um)
{
if (numMods >= WLED_MAX_USERMODS || um == nullptr) return false;
ums[numMods] = um;
numMods++;
}
byte UsermodManager::getModCount() {return numMods;}