mirror of
https://github.com/wled/WLED.git
synced 2025-07-19 00:36:36 +00:00
UsermodManager: Make into namespace
Namespaces are the C++ language construct for grouping global functions.
This commit is contained in:
parent
0a97e28aab
commit
95b4bde918
@ -326,36 +326,33 @@ class Usermod {
|
||||
template<typename T> static inline void oappend(const T& t) { oappend_shim->print(t); };
|
||||
};
|
||||
|
||||
class UsermodManager {
|
||||
private:
|
||||
static Usermod* ums[WLED_MAX_USERMODS];
|
||||
static byte numMods;
|
||||
namespace UsermodManager {
|
||||
extern byte numMods;
|
||||
|
||||
public:
|
||||
static void loop();
|
||||
static void handleOverlayDraw();
|
||||
static bool handleButton(uint8_t b);
|
||||
static bool getUMData(um_data_t **um_data, uint8_t mod_id = USERMOD_ID_RESERVED); // USERMOD_ID_RESERVED will poll all usermods
|
||||
static void setup();
|
||||
static void connected();
|
||||
static void appendConfigData(Print&);
|
||||
static void addToJsonState(JsonObject& obj);
|
||||
static void addToJsonInfo(JsonObject& obj);
|
||||
static void readFromJsonState(JsonObject& obj);
|
||||
static void addToConfig(JsonObject& obj);
|
||||
static bool readFromConfig(JsonObject& obj);
|
||||
void loop();
|
||||
void handleOverlayDraw();
|
||||
bool handleButton(uint8_t b);
|
||||
bool getUMData(um_data_t **um_data, uint8_t mod_id = USERMOD_ID_RESERVED); // USERMOD_ID_RESERVED will poll all usermods
|
||||
void setup();
|
||||
void connected();
|
||||
void appendConfigData(Print&);
|
||||
void addToJsonState(JsonObject& obj);
|
||||
void addToJsonInfo(JsonObject& obj);
|
||||
void readFromJsonState(JsonObject& obj);
|
||||
void addToConfig(JsonObject& obj);
|
||||
bool readFromConfig(JsonObject& obj);
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
static void onMqttConnect(bool sessionPresent);
|
||||
static bool onMqttMessage(char* topic, char* payload);
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
bool onMqttMessage(char* topic, char* payload);
|
||||
#endif
|
||||
#ifndef WLED_DISABLE_ESPNOW
|
||||
static bool onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len);
|
||||
bool onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len);
|
||||
#endif
|
||||
static void onUpdateBegin(bool);
|
||||
static void onStateChange(uint8_t);
|
||||
static bool add(Usermod* um);
|
||||
static Usermod* lookup(uint16_t mod_id);
|
||||
static inline byte getModCount() {return numMods;};
|
||||
void onUpdateBegin(bool);
|
||||
void onStateChange(uint8_t);
|
||||
bool add(Usermod* um);
|
||||
Usermod* lookup(uint16_t mod_id);
|
||||
inline byte getModCount() {return numMods;};
|
||||
};
|
||||
|
||||
//usermods_list.cpp
|
||||
|
@ -3,6 +3,9 @@
|
||||
* Registration and management utility for v2 usermods
|
||||
*/
|
||||
|
||||
static Usermod* ums[WLED_MAX_USERMODS] = {nullptr};
|
||||
byte UsermodManager::numMods = 0;
|
||||
|
||||
//Usermod Manager internals
|
||||
void UsermodManager::setup() { for (unsigned i = 0; i < numMods; i++) ums[i]->setup(); }
|
||||
void UsermodManager::connected() { for (unsigned i = 0; i < numMods; i++) ums[i]->connected(); }
|
||||
@ -69,8 +72,6 @@ bool UsermodManager::add(Usermod* um)
|
||||
return true;
|
||||
}
|
||||
|
||||
Usermod* UsermodManager::ums[WLED_MAX_USERMODS] = {nullptr};
|
||||
byte UsermodManager::numMods = 0;
|
||||
|
||||
/* Usermod v2 interface shim for oappend */
|
||||
Print* Usermod::oappend_shim = nullptr;
|
||||
|
@ -896,9 +896,6 @@ WLED_GLOBAL uint32_t ledMaps _INIT(0); // bitfield representation of available l
|
||||
WLED_GLOBAL uint16_t ledMaps _INIT(0); // bitfield representation of available ledmaps
|
||||
#endif
|
||||
|
||||
// Usermod manager
|
||||
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
||||
|
||||
// global I2C SDA pin (used for usermods)
|
||||
#ifndef I2CSDAPIN
|
||||
WLED_GLOBAL int8_t i2c_sda _INIT(-1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user