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