Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes for large configs. #640

Merged
merged 8 commits into from
Jul 7, 2023
16 changes: 15 additions & 1 deletion ESPixelStick/src/FileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler H
// DEBUG_V();
if (!file)
{
if (!IsBooting) {
if (!IsBooting)
{
logcon (String (CN_stars) + CfgFileMessagePrefix + String (F (" Could not open file for reading ")) + CN_stars);
}
break;
Expand All @@ -336,6 +337,19 @@ bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler H
// DEBUG_V(String("Allocate JSON document. Size = ") + String(JsonDocSize));
// DEBUG_V(String("Heap: ") + ESP.getFreeHeap());
DynamicJsonDocument jsonDoc(JsonDocSize);
// DEBUG_V(String("jsonDoc.capacity: ") + String(jsonDoc.capacity()));

// did we get enough memory?
if(jsonDoc.capacity() < JsonDocSize)
{
logcon (String(CN_stars) + CfgFileMessagePrefix + String (F ("Could Not Allocate enough memory to process config ")) + CN_stars);

// DEBUG_V(String("Allocate JSON document. Size = ") + String(JsonDocSize));
// DEBUG_V(String("Heap: ") + ESP.getFreeHeap());
// DEBUG_V(String("jsonDoc.capacity: ") + String(jsonDoc.capacity()));
file.close ();
break;
}

// DEBUG_V ("Convert File to JSON document");
DeserializationError error = deserializeJson (jsonDoc, file);
Expand Down
16 changes: 10 additions & 6 deletions ESPixelStick/src/input/InputMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,17 @@ void c_InputMgr::LoadConfig ()
// DEBUG_V ("");
}))
{
if (!IsBooting) {
logcon (CN_stars + String (F (" Error loading Input Manager Config File ")) + CN_stars);
if (IsBooting)
{
// create a config file with default values
// DEBUG_V ("");
CreateNewConfig ();
}
else
{
logcon (CN_stars + String (F (" Error loading Input Manager Config File. Rebooting ")) + CN_stars);
reboot = true;
}

// create a config file with default values
// DEBUG_V ("");
CreateNewConfig ();
}

// DEBUG_END;
Expand Down
18 changes: 12 additions & 6 deletions ESPixelStick/src/output/OutputMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,15 @@ void c_OutputMgr::InstantiateNewOutputChannel(DriverInfo_t & CurrentOutputChanne
} // end there is an existing driver

// DEBUG_V ();

// get the new data and UART info
CurrentOutputChannelDriver.GpioPin = OutputChannelIdToGpioAndPort[CurrentOutputChannelDriver.DriverId].GpioPin;
CurrentOutputChannelDriver.PortType = OutputChannelIdToGpioAndPort[CurrentOutputChannelDriver.DriverId].PortType;
CurrentOutputChannelDriver.PortId = OutputChannelIdToGpioAndPort[CurrentOutputChannelDriver.DriverId].PortId;

// give the other tasks a chance to run
delay(100);

// DEBUG_V (String("DriverId: ") + String(CurrentOutputChannelDriver.DriverId));
// DEBUG_V (String(" GpioPin: ") + String(CurrentOutputChannelDriver.PortId));
// DEBUG_V (String("PortType: ") + String(CurrentOutputChannelDriver.PortType));
Expand Down Expand Up @@ -1016,14 +1019,17 @@ void c_OutputMgr::LoadConfig ()
// DEBUG_V ();
}))
{
if (!IsBooting)
if (IsBooting)
{
// on boot, create a config file with default values
// DEBUG_V ();
CreateNewConfig ();
}
else
{
logcon(CN_stars + String(MN_15) + CN_stars);
reboot = true;
}

// create a config file with default values
// DEBUG_V ();
CreateNewConfig ();
}

// DEBUG_END;
Expand Down
45 changes: 27 additions & 18 deletions ESPixelStick/src/output/OutputRmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,11 @@ void c_OutputRmt::Begin (OutputRmtConfig_t config )
void c_OutputRmt::GetStatus (ArduinoJson::JsonObject& jsonStatus)
{
// //DEBUG_START;

jsonStatus[F("NumRmtSlotOverruns")] = NumRmtSlotOverruns;
#ifdef USE_RMT_DEBUG_COUNTERS
jsonStatus[F("OutputIsPaused")] = OutputIsPaused; JsonObject debugStatus = jsonStatus.createNestedObject("RMT Debug");
jsonStatus[F("OutputIsPaused")] = OutputIsPaused;
JsonObject debugStatus = jsonStatus.createNestedObject("RMT Debug");
debugStatus["RmtChannelId"] = OutputRmtConfig.RmtChannelId;
debugStatus["GPIO"] = OutputRmtConfig.DataPin;
debugStatus["conf0"] = String(RMT.conf_ch[OutputRmtConfig.RmtChannelId].conf0.val, HEX);
Expand Down Expand Up @@ -274,29 +275,37 @@ void c_OutputRmt::GetStatus (ArduinoJson::JsonObject& jsonStatus)
debugStatus["NumRmtSlotsPerIntensityValue"] = NumRmtSlotsPerIntensityValue;
debugStatus["RmtEntriesTransfered"] = RmtEntriesTransfered;
debugStatus["RmtXmtFills"] = RmtXmtFills;
debugStatus["ZeroBitValue"] = String (Intensity2Rmt[RmtDataBitIdType_t::RMT_DATA_BIT_ZERO_ID].val, HEX);
debugStatus["OneBitValue"] = String (Intensity2Rmt[RmtDataBitIdType_t::RMT_DATA_BIT_ONE_ID].val, HEX);

// #define IncludeBufferData
#ifdef IncludeBufferData
uint32_t index = 0;
for (auto CurrentCounter : BitTypeCounters)
{
debugStatus[String("RMT TYPE used Counter ") + String(index++)] = String(CurrentCounter);
uint32_t index = 0;
for (auto CurrentCounter : BitTypeCounters)
{
break;
debugStatus[String("RMT TYPE used Counter ") + String(index++)] = String(CurrentCounter);
}
}

index = 0;
uint32_t * CurrentPointer = (uint32_t*)const_cast<rmt_item32_t*>(&SendBuffer[0]);
for(index = 0; index < NUM_RMT_SLOTS; index++)
{
uint32_t data = CurrentPointer[index];
debugStatus[String("Buffer Data ") + String(index)] = String(data, HEX);
uint32_t index = 0;
uint32_t * CurrentPointer = (uint32_t*)const_cast<rmt_item32_t*>(&SendBuffer[0]);
// for(index = 0; index < NUM_RMT_SLOTS; index++)
for(index = 0; index < 2; index++)
{
uint32_t data = CurrentPointer[index];
debugStatus[String("Buffer Data ") + String(index)] = String(data, HEX);
}
}

index = 0;
CurrentPointer = (uint32_t*)const_cast<rmt_item32_t*>(&RMTMEM.chan[OutputRmtConfig.RmtChannelId].data32[0]);
for(index = 0; index < NUM_RMT_SLOTS; index++)
{
uint32_t data = CurrentPointer[index];
debugStatus[String("RMT Data ") + String(index)] = String(data, HEX);
uint32_t index = 0;
uint32_t * CurrentPointer = (uint32_t*)const_cast<rmt_item32_t*>(&RMTMEM.chan[OutputRmtConfig.RmtChannelId].data32[0]);
// for(index = 0; index < NUM_RMT_SLOTS; index++)
for(index = 0; index < 2; index++)
{
uint32_t data = CurrentPointer[index];
debugStatus[String("RMT Data ") + String(index)] = String(data, HEX);
}
}
#endif // def IncludeBufferData
#endif // def USE_RMT_DEBUG_COUNTERS
Expand Down
1 change: 1 addition & 0 deletions ESPixelStick/src/output/OutputRmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class c_OutputRmt

// #define USE_RMT_DEBUG_COUNTERS
#ifdef USE_RMT_DEBUG_COUNTERS
// #define IncludeBufferData
// debug counters
uint32_t DataCallbackCounter = 0;
uint32_t DataTaskcounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
// Output Manager
#define DEFAULT_RMT_0_GPIO gpio_num_t::GPIO_NUM_16 // Output 1
#define DEFAULT_RMT_1_GPIO gpio_num_t::GPIO_NUM_3 // Output 2
// #define DEFAULT_RMT_1_GPIO gpio_num_t::GPIO_NUM_27 // Output 2
#define DEFAULT_RMT_2_GPIO gpio_num_t::GPIO_NUM_1 // Output 3
// #define DEFAULT_RMT_2_GPIO gpio_num_t::GPIO_NUM_25 // Output 3
#define DEFAULT_RMT_3_GPIO gpio_num_t::GPIO_NUM_4 // Output 4

// AE+ extra 3 outputs (Level-shifted and 33R resistor)
Expand Down