Skip to content

Commit

Permalink
Merge pull request #804 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Stabilize xLights data transfers
  • Loading branch information
forkineye authored Dec 9, 2024
2 parents dc000a3 + 55a18fb commit 6cb3da8
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 165 deletions.
38 changes: 20 additions & 18 deletions include/FileMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,22 @@ class c_FileMgr

bool SdCardIsInstalled () { return SdCardInstalled; }
FileId CreateSdFileHandle ();
void DeleteSdFile (const String & FileName);
void SaveSdFile (const String & FileName, String & FileData);
void SaveSdFile (const String & FileName, JsonVariant & FileData);
bool OpenSdFile (const String & FileName, FileMode Mode, FileId & FileHandle, int FileListIndex = -1);
size_t ReadSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToRead);
size_t ReadSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToRead, size_t StartingPosition);
bool ReadSdFile (const String & FileName, String & FileData);
bool ReadSdFile (const String & FileName, JsonDocument & FileData);
size_t WriteSdFileBuf (const FileId & FileHandle, byte * FileData, size_t NumBytesToWrite);
size_t WriteSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToWrite);
size_t WriteSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToWrite, size_t StartingPosition);
void CloseSdFile (FileId & FileHandle);
void GetListOfSdFiles (std::vector<String> & Response);
uint64_t GetSdFileSize (const String & FileName);
uint64_t GetSdFileSize (const FileId & FileHandle);
void BuildFseqList ();
void ResumeSdFile (const FileId & FileHandle);
void PauseSdFile (const FileId & FileHandle);
void DeleteSdFile (const String & FileName, bool LockStatus = false);
void SaveSdFile (const String & FileName, String & FileData, bool LockStatus = false);
void SaveSdFile (const String & FileName, JsonVariant & FileData, bool LockStatus = false);
bool OpenSdFile (const String & FileName, FileMode Mode, FileId & FileHandle, int FileListIndex, bool LockStatus = false);
size_t ReadSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToRead, bool LockStatus = false);
size_t ReadSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToRead, size_t StartingPosition, bool LockStatus = false);
bool ReadSdFile (const String & FileName, String & FileData, bool LockStatus = false);
bool ReadSdFile (const String & FileName, JsonDocument & FileData, bool LockStatus = false);
size_t WriteSdFileBuf (const FileId & FileHandle, byte * FileData, size_t NumBytesToWrite, bool LockStatus = false);
size_t WriteSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToWrite, bool LockStatus = false);
size_t WriteSdFile (const FileId & FileHandle, byte * FileData, size_t NumBytesToWrite, size_t StartingPosition, bool LockStatus = false);
void CloseSdFile (FileId & FileHandle, bool LockStatus = false);
void GetListOfSdFiles (std::vector<String> & Response, bool LockStatus = false);
uint64_t GetSdFileSize (const String & FileName, bool LockStatus = false);
uint64_t GetSdFileSize (const FileId & FileHandle, bool LockStatus = false);
void BuildFseqList (bool LockStatus = false);

void GetDriverName (String& Name) { Name = "FileMgr"; }
void NetworkStateChanged (bool NewState);
Expand All @@ -115,6 +113,8 @@ class c_FileMgr
void SetSpiIoPins ();
void SetSdSpeed ();
void ResetSdCard ();
void LockSd(bool ExistingLockStatus);
void UnLockSd(bool ExistingLockStatus);

# define SD_CARD_CLK_MHZ SD_SCK_MHZ(37) // 50 MHz SPI clock
#ifndef MaxSdTransSpeedMHz
Expand Down Expand Up @@ -240,6 +240,8 @@ public: struct __attribute__((__packed__, aligned(4))) CSD {
uint32_t LastFileSent = 0;
uint32_t expectedIndex = 0;

bool SdAccessSemaphore = false;

protected:

}; // c_FileMgr
Expand Down
14 changes: 9 additions & 5 deletions include/output/OutputWS2811.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputWS2811.h - WS2811 driver code for ESPixelStick
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2015, 2022 Shelby Merrick
* Copyright (c) 2015, 2024 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -52,10 +52,14 @@ class c_OutputWS2811 : public c_OutputPixel
#define WS2811_PIXEL_NS_BIT_TOTAL ( (1.0 / WS2811_PIXEL_DATA_RATE) * NanoSecondsInASecond)
#ifdef ARDUINO_ARCH_ESP32
// values have been adjusted to work with seed pixels.
#define WS2811_PIXEL_NS_BIT_0_HIGH 312.0 // = 312 on logic analyzer 220ns - 380ns per datasheet
#define WS2811_PIXEL_NS_BIT_0_LOW 945.0 // = 937 on logic analyzer 580ns - 1.6us per datasheet
#define WS2811_PIXEL_NS_BIT_1_HIGH 975.0 // = 937 on logic analyzer 580ns - 1.6us per datasheet
#define WS2811_PIXEL_NS_BIT_1_LOW 300.0 // = 312 on logic analyzer 220ns - 380ns per datasheet
// #define WS2811_PIXEL_NS_BIT_0_HIGH 312.0 // = 312 on logic analyzer 220ns - 380ns per datasheet
// #define WS2811_PIXEL_NS_BIT_0_LOW 945.0 // = 937 on logic analyzer 580ns - 1.6us per datasheet
// #define WS2811_PIXEL_NS_BIT_1_HIGH 975.0 // = 937 on logic analyzer 580ns - 1.6us per datasheet
// #define WS2811_PIXEL_NS_BIT_1_LOW 300.0 // = 312 on logic analyzer 220ns - 380ns per datasheet
#define WS2811_PIXEL_NS_BIT_0_HIGH 300.0 // 220ns - 380ns per datasheet
#define WS2811_PIXEL_NS_BIT_0_LOW (WS2811_PIXEL_NS_BIT_TOTAL - WS2811_PIXEL_NS_BIT_0_HIGH)
#define WS2811_PIXEL_NS_BIT_1_HIGH WS2811_PIXEL_NS_BIT_0_LOW
#define WS2811_PIXEL_NS_BIT_1_LOW WS2811_PIXEL_NS_BIT_0_HIGH
#else
#define WS2811_PIXEL_NS_BIT_0_HIGH 312.0 // 220ns - 380ns per datasheet
#define WS2811_PIXEL_NS_BIT_0_LOW (WS2811_PIXEL_NS_BIT_TOTAL - WS2811_PIXEL_NS_BIT_0_HIGH)
Expand Down
2 changes: 2 additions & 0 deletions include/service/FPPDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class c_FPPDiscovery
struct SystemDebugStats_t
{
uint32_t ProcessFPPJson = 0;
uint32_t ProcessFPPDJson = 0;
uint32_t CmdGetFPPstatus = 0;
uint32_t CmdGetSysInfoJSON = 0;
uint32_t CmdGetHostname = 0;
Expand All @@ -114,6 +115,7 @@ SystemDebugStats_t SystemDebugStats;
void begin ();

void ProcessFPPJson (AsyncWebServerRequest* request);
void ProcessFPPDJson (AsyncWebServerRequest* request);
void ProcessGET (AsyncWebServerRequest* request);
void ProcessPOST (AsyncWebServerRequest* request);
void ProcessFile (AsyncWebServerRequest* request, String filename, uint32_t index, uint8_t* data, uint32_t len, bool final, uint32_t contentLength = 0);
Expand Down
Loading

0 comments on commit 6cb3da8

Please sign in to comment.