Skip to content

Commit

Permalink
Merge branch 'martin'
Browse files Browse the repository at this point in the history
  • Loading branch information
forkineye committed Nov 27, 2024
2 parents efb8049 + 3b3af8b commit cde75f2
Show file tree
Hide file tree
Showing 76 changed files with 989 additions and 566 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,18 @@ jobs:
# M5Stack Atom
- target: "m5stack_atom"
chip: "esp32"
#
- target: "esp3deuxquatro_dmx"
chip: "esp32"
#
- target: "esp32_quinled_uno_espsv3"
chip: "esp32"
#
- target: "esp32_tetra2go"
chip: "esp32"
#
- target: "esp32_octa2go"
chip: "esp32"
# KR Lights
- target: "esp32_kr_lights_msm"
chip: "esp32"
Expand Down
22 changes: 12 additions & 10 deletions ESPixelStick/ESPixelStick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ void setup()

// TestHeap(uint32_t(10));
// DEBUG_V("");
#ifdef ARDUINO_ARCH_ESP32
logcon(String("CPU Frequency: ") + String(getCpuFrequencyMhz()) + "MHz");
logcon(String("APB Frequency: ") + String(getApbFrequency() / 1000000) + "MHz");
#endif // def ARDUINO_ARCH_ESP32

FileMgr.Begin();
// Load configuration from the File System and set Hostname
// TestHeap(uint32_t(15));
Expand Down Expand Up @@ -253,13 +258,13 @@ bool validateConfig()
bool dsDevice(JsonObject & json)
{
// DEBUG_START;
// extern void PrettyPrint (JsonObject & jsonStuff, String Name);
// PrettyPrint (json, "dsDevice");

bool ConfigChanged = false;
JsonObject JsonDeviceConfig = json[CN_device];
if (JsonDeviceConfig)
{
// PrettyPrint(JsonDeviceConfig, "device");

//TODO: Add configuration upgrade handling - cfgver moved to root level
ConfigChanged |= setFromJSON (config.id, JsonDeviceConfig, CN_id);
Expand Down Expand Up @@ -298,7 +303,6 @@ bool deserializeCore (JsonObject & json)

bool DataHasBeenAccepted = false;

// extern void PrettyPrint (JsonObject & jsonStuff, String Name);
// PrettyPrint (json, "Main Config");
JsonObject SystemConfig = json[CN_system];
JsonObject InitConfig = json[CN_init];
Expand Down Expand Up @@ -352,21 +356,18 @@ bool deserializeCore (JsonObject & json)
// DEBUG_V("Checking to see if the config is from the web flash tool");

// is this a config from the web flash tool?
if (DeviceConfig.containsKey("requiresConfigSave"))
{
// DEBUG_V("Forcing a save config due to missing GPIO settings");
ConfigSaveNeeded = true;
}
// DEBUG_V("Forcing a save config due to missing GPIO settings");
ConfigSaveNeeded = DeviceConfig["requiresConfigSave"].is<bool>();

dsDevice(DeviceConfig);
// DEBUG_V("");
FileMgr.SetConfig(DeviceConfig);
// DEBUG_V("");
ConfigSaveNeeded |= NetworkMgr.SetConfig(DeviceConfig);
// DEBUG_V("");
#ifdef SUPPORT_SENSOR_DS18B20
#ifdef SUPPORT_SENSOR_DS18B20
ConfigSaveNeeded |= SensorDS18B20.SetConfig(DeviceConfig);
#endif // def SUPPORT_SENSOR_DS18B20
#endif // def SUPPORT_SENSOR_DS18B20
// DEBUG_V("");
DataHasBeenAccepted = true;

Expand All @@ -381,7 +382,6 @@ void deserializeCoreHandler (JsonDocument & jsonDoc)
{
// DEBUG_START;

// extern void PrettyPrint(JsonDocument & jsonStuff, String Name);
// PrettyPrint(jsonDoc, "deserializeCoreHandler");

JsonObject json = jsonDoc.as<JsonObject>();
Expand Down Expand Up @@ -448,6 +448,8 @@ void GetConfig (JsonObject & json)
device[CN_id] = config.id;
device[CN_blanktime] = config.BlankDelay;

// PrettyPrint(device, "device");

FileMgr.GetConfig (device);

NetworkMgr.GetConfig (json);
Expand Down
5 changes: 5 additions & 0 deletions ESPixelStick/src/ConstNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const CN_PROGMEM char CN_ip [] = "ip";
const CN_PROGMEM char CN_input [] = "input";
const CN_PROGMEM char CN_input_config [] = "input_config";
const CN_PROGMEM char CN_last_clientIP [] = "last_clientIP";
const CN_PROGMEM char CN_long [] = "long";
const CN_PROGMEM char CN_lwt [] = "lwt";
const CN_PROGMEM char CN_mac [] = "mac";
const CN_PROGMEM char CN_MarqueeGroups [] = "MarqueeGroups";
Expand All @@ -142,6 +143,8 @@ const CN_PROGMEM char CN_netmask [] = "netmask";
const CN_PROGMEM char CN_network [] = "network";
const CN_PROGMEM char CN_num_chan [] = "num_chan";
const CN_PROGMEM char CN_num_packets [] = "num_packets";
const CN_PROGMEM char CN_off [] = "off";
const CN_PROGMEM char CN_on [] = "on";
const CN_PROGMEM char CN_output [] = "output";
const CN_PROGMEM char CN_output_config [] = "output_config";
const CN_PROGMEM char CN_OutputSpi [] = "OutputSpi";
Expand All @@ -153,6 +156,7 @@ const CN_PROGMEM char CN_Paused [] = "Paused";
const CN_PROGMEM char CN_pixel_count [] = "pixel_count";
const CN_PROGMEM char CN_Platform [] = "Platform";
const CN_PROGMEM char CN_play [] = "play";
const CN_PROGMEM char CN_playcount [] = "playcount";
const CN_PROGMEM char CN_playFseq [] = "playFseq";
const CN_PROGMEM char CN_playlist [] = "playlist";
const CN_PROGMEM char CN_plussigns [] = "+++++";
Expand All @@ -172,6 +176,7 @@ const CN_PROGMEM char CN_reverse [] = "reverse";
const CN_PROGMEM char CN_RMT [] = "RMT";
const CN_PROGMEM char CN_rssi [] = "rssi";
const CN_PROGMEM char CN_sca [] = "sca";
const CN_PROGMEM char CN_sdspeed [] = "sdspeed";
const CN_PROGMEM char CN_seconds_elapsed [] = "seconds_elapsed";
const CN_PROGMEM char CN_seconds_played [] = "seconds_played";
const CN_PROGMEM char CN_seconds_remaining [] = "seconds_remaining";
Expand Down
5 changes: 5 additions & 0 deletions ESPixelStick/src/ConstNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ extern const CN_PROGMEM char CN_ip [];
extern const CN_PROGMEM char CN_input [];
extern const CN_PROGMEM char CN_input_config [];
extern const CN_PROGMEM char CN_last_clientIP [];
extern const CN_PROGMEM char CN_long [];
extern const CN_PROGMEM char CN_lwt [];
extern const CN_PROGMEM char CN_mac [];
extern const CN_PROGMEM char CN_MarqueeGroups [];
Expand All @@ -151,6 +152,8 @@ extern const CN_PROGMEM char CN_netmask [];
extern const CN_PROGMEM char CN_network [];
extern const CN_PROGMEM char CN_num_chan [];
extern const CN_PROGMEM char CN_num_packets [];
extern const CN_PROGMEM char CN_off [];
extern const CN_PROGMEM char CN_on [];
extern const CN_PROGMEM char CN_output [];
extern const CN_PROGMEM char CN_output_config [];
extern const CN_PROGMEM char CN_OutputSpi [];
Expand All @@ -162,6 +165,7 @@ extern const CN_PROGMEM char CN_Paused [];
extern const CN_PROGMEM char CN_pixel_count [];
extern const CN_PROGMEM char CN_Platform [];
extern const CN_PROGMEM char CN_play [];
extern const CN_PROGMEM char CN_playcount [];
extern const CN_PROGMEM char CN_playFseq [];
extern const CN_PROGMEM char CN_playlist [];
extern const CN_PROGMEM char CN_plussigns [];
Expand All @@ -181,6 +185,7 @@ extern const CN_PROGMEM char CN_reverse [];
extern const CN_PROGMEM char CN_RMT [];
extern const CN_PROGMEM char CN_rssi [];
extern const CN_PROGMEM char CN_sca [];
extern const CN_PROGMEM char CN_sdspeed [];
extern const CN_PROGMEM char CN_seconds_elapsed [];
extern const CN_PROGMEM char CN_seconds_played [];
extern const CN_PROGMEM char CN_seconds_remaining [];
Expand Down
34 changes: 23 additions & 11 deletions ESPixelStick/src/ESPixelStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern bool RebootInProgress();
typedef struct {
// Device
String id;
time_t BlankDelay = time_t(5);
uint32_t BlankDelay = uint32_t(5);
} config_t;

String serializeCore (bool pretty = false);
Expand All @@ -83,30 +83,39 @@ extern const String ConfigFileName;
extern void FeedWDT ();
extern uint32_t DiscardedRxData;

template <typename J, typename N>
bool setFromJSON (float & OutValue, J& Json, N Name)
extern void PrettyPrint (JsonObject& jsonStuff, String Name);
extern void PrettyPrint (JsonArray& jsonStuff, String Name);
extern void PrettyPrint(JsonDocument &jsonStuff, String Name);

template <typename T, typename N>
bool setFromJSON (T& OutValue, JsonObject & Json, N Name)
{
bool HasBeenModified = false;

if (true == Json.containsKey (Name))
if (Json[Name].template is<T>())
{
float temp = Json[Name];
if (fabs (temp - OutValue) > 0.000005F)
T temp = Json[Name];
if (temp != OutValue)
{
OutValue = temp;
HasBeenModified = true;
}
}
else
{
DEBUG_V(String("Could not find field '") + Name + "' in the json record");
PrettyPrint (Json, Name);
}

return HasBeenModified;
};

template <typename T, typename J, typename N>
bool setFromJSON (T& OutValue, J& Json, N Name)
template <typename T, typename N>
bool setFromJSON (T& OutValue, JsonVariant & Json, N Name)
{
bool HasBeenModified = false;

if (true == Json.containsKey (Name))
if (Json[Name].template is<T>())
{
T temp = Json[Name];
if (temp != OutValue)
Expand All @@ -115,12 +124,15 @@ bool setFromJSON (T& OutValue, J& Json, N Name)
HasBeenModified = true;
}
}
else
{
DEBUG_V(String("Could not find field '") + Name + "' in the json record");
PrettyPrint (Json, Name);
}

return HasBeenModified;
};



#define logcon(msg) \
{ \
String DN; \
Expand Down
Loading

0 comments on commit cde75f2

Please sign in to comment.