Skip to content

Commit

Permalink
Merge pull request #759 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Updates to merge the saved and current config in the UI.
  • Loading branch information
forkineye authored Apr 15, 2024
2 parents b65d9a2 + 8062550 commit 8e2b68b
Show file tree
Hide file tree
Showing 20 changed files with 621 additions and 183 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ jobs:
chip: "esp32"
- target: "esp3deuxquatro_dmx"
chip: "esp32"
- target: "esp32_quinled_uno_espsv3"
chip: "esp32"
#
- target: "esp32_tetra2go"
chip: "esp32"
# KR Lights
- target: "esp32_kr_lights_msm"
chip: "esp32"

runs-on: ubuntu-latest
steps:
Expand Down
32 changes: 32 additions & 0 deletions .scripts/CopyTargets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,43 @@ def PrepareDestinationDirectory(DirRoot, DirPath):
DST_BIN = DST_DIR + PIOENV + "-app.bin"
DST_PART = DST_DIR + PIOENV + "-partitions.bin"
DST_BOOT = DST_DIR + PIOENV + "-bootloader.bin"
DST_MERG = DST_DIR + PIOENV + "-merged.bin"
DST_FS = DST_DIR + PIOENV + "-littlefs.bin"

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

OS_NAME = platform.system().lower()
FS_BLD_PATH = "./dist/bin/"

if OS_NAME == "windows" :
FS_BLD_PATH += "win32/mklittlefs.exe"
elif OS_NAME == "linux" :
FS_BLD_PATH += "linux64/mklittlefs"
elif OS_NAME == "linux64" :
FS_BLD_PATH += "linux64/mklittlefs"
elif OS_NAME == "darwin" :
FS_BLD_PATH += "macos/mklittlefs"
else:
print("ERROR: Could not determine OS type. Got: " + str (OS_NAME))
exit(-1)

def merge_bin():
# create a file system image
FS_BLD_CMD = FS_BLD_PATH + " -b 4096 -p 256 -s 0x50000 -c ./ESPixelStick/data " + DST_FS
MERGE_CMD = "./dist/bin/esptool/esptool.exe" + " --chip " + BOARD_MCU + " merge_bin " + " -o " + DST_MERG + " --flash_mode dio" + " --flash_freq 80m" + " --flash_size 4MB" + " 0x0000 " + DST_BOOT + " 0x8000 " + DST_PART + " 0xe000 " + DST_DIR + "boot_app0.bin" + " 0x10000 " + DST_BIN + " 0x003b0000 " + DST_FS + ""

if OS_NAME == "windows" :
FS_BLD_CMD = FS_BLD_CMD.replace("/", "\\")
MERGE_CMD = MERGE_CMD.replace("/", "\\")

print("FS_BLD_CMD: " + FS_BLD_CMD)
os.system(FS_BLD_CMD)
print("MERGE_CMD: " + MERGE_CMD)
os.system(MERGE_CMD)

def after_build(source, target, env):

DstPath = os.path.join("", DST_DIR)
Expand Down Expand Up @@ -105,5 +136,6 @@ def after_build(source, target, env):
# print("Copy SRC_BL_DIR: " + SRC_BL_DIR)
print("Copy: " + SRC_BL_DIR)
shutil.copyfile(SRC_BL_DIR, DST_BOOT)
# merge_bin()

env.AddPostAction("buildprog", after_build)
12 changes: 6 additions & 6 deletions ESP32_partitions.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1D0000,
app1, app, ota_1, 0x1E0000,0x1D0000,
spiffs, data, spiffs, 0x3B0000,0x50000,
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x009000, 0x005000,
otadata, data, ota, 0x00e000, 0x002000,
app0, app, ota_0, 0x010000, 0x1D0000,
app1, app, ota_1, 0x1E0000, 0x1D0000,
spiffs, data, spiffs, 0x3B0000, 0x050000,
21 changes: 0 additions & 21 deletions ESPixelStick/ESPixelStick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ bool ResetWiFi = false;
bool IsBooting = true; // Configuration initialization flag
time_t ConfigLoadNeeded = NO_CONFIG_NEEDED;
bool ConfigSaveNeeded = false;
bool RestoredConfig = false;

uint32_t DiscardedRxData = 0;
const String RestoredConfigFileName = "/RestoredConfig.json";

/////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -173,17 +171,6 @@ void setup()
// TestHeap(uint32_t(10));
// DEBUG_V("");
FileMgr.Begin();
#ifdef SUPPORT_CONFIG_MERGE
if(FileMgr.FlashFileExists (RestoredConfigFileName))
{
// DEBUG_V("Setting Restored Config flag to true");
RestoredConfig = true;
}
else
{
// DEBUG_V("Setting Restored Config flag to false");
}
#endif // def SUPPORT_CONFIG_MERGE
// Load configuration from the File System and set Hostname
// TestHeap(uint32_t(15));
// DEBUG_V(String("LoadConfig Heap: ") + String(ESP.getFreeHeap()));
Expand Down Expand Up @@ -231,14 +218,6 @@ void setup()
// Done with initialization
IsBooting = false;

if(RestoredConfig)
{
// DEBUG_V("Delete Restored Config Flag file");
FileMgr.DeleteFlashFile(RestoredConfigFileName);
ConfigSaveNeeded = true;
RestoredConfig = false;
}

// DEBUG_END;

} // setup
Expand Down
1 change: 0 additions & 1 deletion ESPixelStick/src/ESPixelStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ bool setFromJSON (T& OutValue, J& Json, N Name)

extern config_t config;
extern bool ConfigSaveNeeded;
extern bool RestoredConfig;

extern const uint8_t CurrentConfigVersion;
#define LOAD_CONFIG_DELAY 4
Expand Down
4 changes: 4 additions & 0 deletions ESPixelStick/src/GPIO_Defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ typedef enum
# include "platformDefinitions/GPIO_Defs_ESP8266_ESPS_V3.hpp"
#elif defined (BOARD_ESPS_ESP3DEUXQUATRO_DMX)
# include "platformDefinitions/GPIO_Defs_ESP32_ESP3DEUXQuattro_DMX.hpp"
#elif defined (BOARD_ESP32_TETRA2GO)
# include "platformDefinitions/GPIO_Defs_ESP32_Tetra2go.hpp"
#elif defined (BOARD_ESP32_KR_LIGHTS_MSM)
# include "platformDefinitions/GPIO_Defs_ESP32_kr_lights_msm.hpp"
#elif defined (ARDUINO_ARCH_ESP32)
# include "platformDefinitions/GPIO_Defs_ESP32_generic.hpp"
#elif defined (ARDUINO_ARCH_ESP8266)
Expand Down
8 changes: 1 addition & 7 deletions ESPixelStick/src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,6 @@ void c_WebMgr::init ()
OutputMgr.ScheduleLoadConfig();
request->send (200, CN_textSLASHplain, String(F("XFER Complete")));
}
else if(UploadFileName.equals(F("RestoredConfig.json")))
{
DEBUG_V("Received RestoredConfig message");
request->send (200, CN_textSLASHplain, String(F("XFER Complete")));
RequestReboot(700000);
}
else
{
logcon(String(F("Unexpected Config File Name: ")) + UploadFileName);
Expand Down Expand Up @@ -742,7 +736,7 @@ void c_WebMgr::FirmwareUpload (AsyncWebServerRequest* request,
if (efupdate.hasError ())
{
logcon (String(CN_stars) + F (" UPDATE ERROR: ") + String (efupdate.getError ()));
DEBUG_V ("efupdate.hasError");
// DEBUG_V ("efupdate.hasError");
request->send (200, CN_textSLASHplain, (String (F ("Update Error: ")) + String (efupdate.getError ()).c_str()));
break;
}
Expand Down
1 change: 1 addition & 0 deletions ESPixelStick/src/input/InputFPPRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void c_InputFPPRemote::StopPlaying ()
while (!pInputFPPRemotePlayItem->IsIdle ())
{
pInputFPPRemotePlayItem->Poll ();
// DEBUG_V();
pInputFPPRemotePlayItem->Stop ();
}

Expand Down
9 changes: 6 additions & 3 deletions ESPixelStick/src/input/InputFPPRemotePlayFileFsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ IRAM_ATTR void fsm_PlayFile_state_PlayingFile::TimerPoll ()
// xDEBUG_V (String ("TotalNumberOfFramesInSequence: ") + String (p_Parent->TotalNumberOfFramesInSequence));
// xDEBUG_V (String (" CurrentFrame: ") + String (CurrentFrame));

// logcon (F ("File Playback Failed to read enough data"));
// DEBUG_V (F ("File Playback Failed to read enough data"));
p_Parent->Stop ();
}
}
Expand Down Expand Up @@ -347,6 +347,7 @@ void fsm_PlayFile_state_PlayingFile::Init (c_InputFPPRemotePlayFile* Parent)
// DEBUG_V (String ("RemainingPlayCount: ") + p_Parent->RemainingPlayCount);
if (0 == p_Parent->RemainingPlayCount)
{
// DEBUG_V();
p_Parent->Stop ();
break;
}
Expand Down Expand Up @@ -386,8 +387,9 @@ void fsm_PlayFile_state_PlayingFile::Start (String& FileName, float ElapsedSecon
// DEBUG_V (String (" LastPlayedFrameId: ") + String (p_Parent->LastPlayedFrameId));
// DEBUG_V (String ("TotalNumberOfFramesInSequence: ") + String (p_Parent->TotalNumberOfFramesInSequence));
// DEBUG_V (String ("RemainingPlayCount: ") + p_Parent->RemainingPlayCount);

// DEBUG_V();
p_Parent->Stop ();
// DEBUG_V();
p_Parent->Start (FileName, ElapsedSeconds, PlayCount);

// DEBUG_END;
Expand Down Expand Up @@ -427,6 +429,7 @@ bool fsm_PlayFile_state_PlayingFile::Sync (String& FileName, float ElapsedSecond
{
// DEBUG_V ("Sync: Filename change");
p_Parent->Stop ();
// DEBUG_V();
p_Parent->Start (FileName, ElapsedSeconds, 1);
break;
}
Expand Down Expand Up @@ -551,7 +554,7 @@ void fsm_PlayFile_state_Stopping::Stop (void)
{
// DEBUG_START;
// DEBUG_V("fsm_PlayFile_state_Stopping::Stop");

// DEBUG_V("Not actually doing anything");
// DEBUG_END;

} // fsm_PlayFile_state_Stopping::Stop
Expand Down
5 changes: 3 additions & 2 deletions ESPixelStick/src/input/InputFPPRemotePlayListFsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void fsm_PlayList_state_Idle::GetStatus (JsonObject& jsonStatus)
//-----------------------------------------------------------------------------
bool fsm_PlayList_state_PlayingFile::Poll ()
{
// DEBUG_START;
// xDEBUG_START;

bool Response = pInputFPPRemotePlayList->pInputFPPRemotePlayItem->Poll ();

Expand All @@ -165,7 +165,7 @@ bool fsm_PlayList_state_PlayingFile::Poll ()
pInputFPPRemotePlayList->Stop ();
}

// DEBUG_END;
// xDEBUG_END;
return Response;

} // fsm_PlayList_state_PlayingFile::Poll
Expand Down Expand Up @@ -315,6 +315,7 @@ bool fsm_PlayList_state_Paused::Poll ()

if (pInputFPPRemotePlayList->PauseDelayTimer.IsExpired())
{
// DEBUG_V();
pInputFPPRemotePlayList->Stop();
}

Expand Down
25 changes: 4 additions & 21 deletions ESPixelStick/src/input/InputMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,11 @@ void c_InputMgr::Begin (uint32_t BufferSize)
}
HasBeenInitialized = true;

if(RestoredConfig)
{
logcon("Merging Restored Input Config File");
CreateNewConfig();
}

// load up the configuration from the saved file. This also starts the drivers
LoadConfig ();

// CreateNewConfig();

// DEBUG_END;

} // begin
Expand Down Expand Up @@ -262,20 +258,7 @@ void c_InputMgr::CreateNewConfig ()
DynamicJsonDocument JsonConfigDoc(IM_JSON_SIZE);
// DEBUG_V("");

// do we create a clean config or do we merge from a restored config?
if(RestoredConfig)
{
DEBUG_V("Merge a Restored Input Config");
// read the existing file and add to it as needed
FileMgr.ReadFlashFile(ConfigFileName, JsonConfigDoc);
}

if(!JsonConfigDoc.containsKey(CN_input_config))
{
DEBUG_V("Add missing input config fields");
JsonConfigDoc.createNestedObject(CN_input_config);
}
JsonObject JsonConfig = JsonConfigDoc[CN_input_config];
JsonObject JsonConfig = JsonConfigDoc.createNestedObject(CN_input_config);
// DEBUG_V("");

JsonConfig[CN_cfgver] = CurrentConfigVersion;
Expand Down Expand Up @@ -849,7 +832,7 @@ bool c_InputMgr::ProcessJsonConfig (JsonObject & jsonConfig)
// DEBUG_V ("");
if(!FindJsonChannelConfig(jsonConfig, e_InputChannelIds(ChannelIndex), InputChannelConfig))
{
DEBUG_V("Did not find the desired channel configuration");
// DEBUG_V("Did not find the desired channel configuration");
continue;
}
// set a default value for channel type
Expand Down
Loading

0 comments on commit 8e2b68b

Please sign in to comment.