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