Implemented enums for cloud
This commit is contained in:
@ -2,9 +2,9 @@
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <buttonsinterface.h>
|
||||
#include <cpptypesafeenum.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbytypesafeenum.h"
|
||||
#include "bobbybuttons.h"
|
||||
|
||||
#define BobbyQuickActionsValues(x) \
|
||||
@ -18,7 +18,7 @@
|
||||
x(HUPE) \
|
||||
x(COMPRESSOR_TOGGLE)
|
||||
|
||||
DECLARE_TYPESAFE_ENUM(BobbyQuickActions, : uint8_t, BobbyQuickActionsValues)
|
||||
DECLARE_BOBBYTYPESAFE_ENUM(BobbyQuickActions, : uint8_t, BobbyQuickActionsValues)
|
||||
|
||||
namespace quickactions {
|
||||
|
||||
|
@ -148,8 +148,6 @@ toArduinoJson(std::string_view key, T value, T defaultValue, JsonObject &object)
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, sntp_sync_mode_t> ||
|
||||
std::is_same_v<T, espchrono::DayLightSavingMode> ||
|
||||
std::is_same_v<T, OtaAnimationModes> ||
|
||||
std::is_same_v<T, LedstripAnimation> ||
|
||||
std::is_same_v<T, HandbremseMode> ||
|
||||
@ -158,6 +156,24 @@ typename std::enable_if<
|
||||
std::is_same_v<T, BatteryCellType>
|
||||
, void>::type
|
||||
toArduinoJson(std::string_view key, T value, T defaultValue, JsonObject &object)
|
||||
{
|
||||
object["n"] = key;
|
||||
object["v"] = std::to_underlying(value);
|
||||
object["d"] = std::to_underlying(defaultValue);
|
||||
|
||||
JsonArray enumObject = object.createNestedArray("e");
|
||||
|
||||
iterateEnum<T>::iterate([&](T enum_value, const auto &string_value){
|
||||
enumObject.add(toString(enum_value));
|
||||
});
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, sntp_sync_mode_t> ||
|
||||
std::is_same_v<T, espchrono::DayLightSavingMode>
|
||||
, void>::type
|
||||
toArduinoJson(std::string_view key, T value, T defaultValue, JsonObject &object)
|
||||
{
|
||||
object["n"] = key;
|
||||
object["v"] = std::to_underlying(value);
|
||||
|
Reference in New Issue
Block a user