Skip to content

Commit

Permalink
Merge pull request #535 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Fixes to make the system more stable and easier to maintain.
  • Loading branch information
forkineye committed Jun 1, 2022
2 parents b18521d + 08d5daa commit a8eb537
Show file tree
Hide file tree
Showing 24 changed files with 453 additions and 403 deletions.
26 changes: 22 additions & 4 deletions .scripts/CopyTargets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import os
Import("env")

f = open("./MyEnv.txt", "a")
f.write(env.Dump())
f.close()

def PrepareDestinationDirectory(DirRoot, DirPath):
# os.system("ls -al ./")
Expand Down Expand Up @@ -38,7 +41,9 @@ def PrepareDestinationDirectory(DirRoot, DirPath):
SRC_DIR = BUILD_DIR + "/" + PIOENV + "/"
SRC_BIN = SRC_DIR + PROGNAME + ".bin"
SRC_PART = SRC_DIR + "partitions.bin"
SRC_DBG = SRC_DIR + PROGNAME + ".elf"
SRC_ELF = SRC_DIR + PROGNAME + ".elf"
SRC_MAP = SRC_DIR + PROGNAME + ".map"
SRC_MAP2 = "./" + PROGNAME + ".map"

# print("SRC_BIN " + SRC_BIN)

Expand All @@ -50,7 +55,8 @@ def PrepareDestinationDirectory(DirRoot, DirPath):

DBG_ROOT = "./debug/"
DBG_DIR = DBG_ROOT + BOARD_MCU + "/"
DST_DBG = DBG_DIR + PIOENV + ".elf"
DST_ELF = DBG_DIR + PIOENV + ".elf"
DST_MAP = DBG_DIR + PIOENV + ".map"

def after_build(source, target, env):

Expand All @@ -63,11 +69,23 @@ def after_build(source, target, env):

DbgPath = os.path.join("", DBG_DIR)
PrepareDestinationDirectory(DBG_ROOT, DbgPath)
print("Copy from: '" + SRC_DBG + "' to '" + DST_DBG + "'")
shutil.copyfile(SRC_DBG, DST_DBG)
print("Copy from: '" + SRC_ELF + "' to '" + DST_ELF + "'")
shutil.copyfile(SRC_ELF, DST_ELF)
# print("Listing dir: " + DbgPath)
# os.system("ls -al " + DbgPath + "/")

if(os.path.exists(SRC_MAP)):
print("Copy from: '" + SRC_MAP + "' to '" + DST_MAP + "'")
shutil.move(SRC_MAP, DST_MAP)
# print("Listing dir: " + DbgPath)
# os.system("ls -al " + DbgPath + "/")

if(os.path.exists(SRC_MAP2)):
print("Copy from: '" + SRC_MAP2 + "' to '" + DST_MAP + "'")
shutil.move(SRC_MAP2, DST_MAP)
# print("Listing dir: " + DbgPath)
# os.system("ls -al " + DbgPath + "/")

if("FLASH_EXTRA_IMAGES" in env):
FLASH_EXTRA_IMAGES = env['FLASH_EXTRA_IMAGES']
# print('FLASH_EXTRA_IMAGES: ')
Expand Down
24 changes: 21 additions & 3 deletions ESPixelStick/ESPixelStick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ RF_PRE_INIT() {
}
#endif

void TestHeap(uint32_t Id)
{
DEBUG_V(String("Test ID: ") + String(Id));
DEBUG_V(String("Allocate JSON document. Size = ") + String(20 * 1024));
DEBUG_V(String("Heap Before: ") + ESP.getFreeHeap());
{
DynamicJsonDocument jsonDoc(20 * 1024);
}
DEBUG_V(String(" Heap After: ") + ESP.getFreeHeap());
}

/// Arduino Setup
/** Arduino based setup code that is executed at startup. */
void setup()
Expand Down Expand Up @@ -141,23 +152,29 @@ void setup()
logcon (ESP.getSdkVersion ());
#endif

// DEBUG_V ("");
FileMgr.Begin ();
// TestHeap(uint32_t(10));
// DEBUG_V("");
FileMgr.Begin();

// Load configuration from the File System and set Hostname
// TestHeap(uint32_t(15));
loadConfig();

// TestHeap(uint32_t(20));
// DEBUG_V(String("InputMgr Heap: ") + String(ESP.getFreeHeap()));
// connect the input processing to the output processing.
InputMgr.Begin (0);

// TestHeap(uint32_t(30));
// DEBUG_V(String("OutputMgr Heap: ") + String(ESP.getFreeHeap()));
// Set up the output manager to start sending data to the serial ports
OutputMgr.Begin();

// TestHeap(uint32_t(40));
// DEBUG_V(String("NetworkMgr Heap: ") + String(ESP.getFreeHeap()));
NetworkMgr.Begin();

// TestHeap(uint32_t(50));
// DEBUG_V(String("WebMgr Heap: ") + String(ESP.getFreeHeap()));
// Configure and start the web server
WebMgr.Begin(&config);
Expand Down Expand Up @@ -299,6 +316,7 @@ bool deserializeCore (JsonObject & json)
}

dsDevice(DeviceConfig);
// DEBUG_V("");
FileMgr.SetConfig(DeviceConfig);
// DEBUG_V("");
ConfigSaveNeeded |= NetworkMgr.SetConfig(DeviceConfig);
Expand Down Expand Up @@ -359,7 +377,7 @@ void loadConfig()

ConfigSaveNeeded |= !validateConfig ();

// DEBUG_START;
// DEBUG_END;
} // loadConfig

void DeleteConfig ()
Expand Down
22 changes: 0 additions & 22 deletions ESPixelStick/secrets.h

This file was deleted.

2 changes: 2 additions & 0 deletions ESPixelStick/src/ConstNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const CN_PROGMEM char CN_current_sequence [] = "current_sequence";
const CN_PROGMEM char CN_data_pin [] = "data_pin";
const CN_PROGMEM char CN_device [] = "device";
const CN_PROGMEM char CN_dhcp [] = "dhcp";
const CN_PROGMEM char CN_Dotfseq [] = ".fseq";
const CN_PROGMEM char CN_Dotpl [] = ".pl";
const CN_PROGMEM char CN_duration [] = "duration";
const CN_PROGMEM char CN_effect [] = "effect";
const CN_PROGMEM char CN_effect_list [] = "effect_list";
Expand Down
2 changes: 2 additions & 0 deletions ESPixelStick/src/ConstNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ extern const CN_PROGMEM char CN_current_sequence[];
extern const CN_PROGMEM char CN_data_pin[];
extern const CN_PROGMEM char CN_device [];
extern const CN_PROGMEM char CN_dhcp[];
extern const CN_PROGMEM char CN_Dotfseq[];
extern const CN_PROGMEM char CN_Dotpl[];
extern const CN_PROGMEM char CN_duration[];
extern const CN_PROGMEM char CN_effect[];
extern const CN_PROGMEM char CN_effect_list[];
Expand Down
21 changes: 16 additions & 5 deletions ESPixelStick/src/FileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void c_FileMgr::SetSpiIoPins ()
// DEBUG_V (String (" cs_pin: ") + String (cs_pin));

SPI.begin (clk_pin, miso_pin, mosi_pin, cs_pin);

// DEBUG_V();
# ifdef USE_MISO_PULLUP
// DEBUG_V("USE_MISO_PULLUP");
// on some hardware MISO is missing a required pull-up resistor, use internal pull-up.
Expand All @@ -188,11 +188,13 @@ void c_FileMgr::SetSpiIoPins ()
# endif // ! ARDUINO_ARCH_ESP32
#endif // !def SUPPORT_SD_MMC
{
logcon (String (F ("No SD card installed")));
// DEBUG_V();
logcon(String(F("No SD card installed")));
SdCardInstalled = false;
}
else
{
// DEBUG_V();
SdCardInstalled = true;
DescribeSdCardToUser ();
}
Expand Down Expand Up @@ -270,6 +272,8 @@ void c_FileMgr::listDir (fs::FS& fs, String dirname, uint8_t levels)
//-----------------------------------------------------------------------------
bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler Handler)
{
// DEBUG_START;

bool retval = false;

do // once
Expand All @@ -286,7 +290,9 @@ bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler H
}
logcon(RawFileData);
*/
// DEBUG_V();
fs::File file = LittleFS.open (FileName.c_str (), "r");
// DEBUG_V();
if (!file)
{
if (!IsBooting) {
Expand All @@ -295,10 +301,12 @@ bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler H
break;
}

// DEBUG_V ("Convert File to JSON document");
size_t JsonDocSize = file.size () * 3;
DynamicJsonDocument jsonDoc (JsonDocSize);
// DEBUG_V(String("Allocate JSON document. Size = ") + String(JsonDocSize));
// DEBUG_V(String("Heap: ") + ESP.getFreeHeap());
DynamicJsonDocument jsonDoc(JsonDocSize);

// DEBUG_V ("Convert File to JSON document");
DeserializationError error = deserializeJson (jsonDoc, file);
file.close ();

Expand All @@ -319,12 +327,15 @@ bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler H
// extern void PrettyPrint(DynamicJsonDocument & jsonStuff, String Name);
// PrettyPrint(jsonDoc, CfgFileMessagePrefix);

// DEBUG_V ("");
// DEBUG_V ();
jsonDoc.garbageCollect ();

logcon (CfgFileMessagePrefix + String (F ("loaded.")));

// DEBUG_V ();
Handler (jsonDoc);

// DEBUG_V();
retval = true;

} while (false);
Expand Down
Loading

0 comments on commit a8eb537

Please sign in to comment.