Skip to content

Commit

Permalink
Minor changes to reduce bss size.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMueller2003 committed Jan 17, 2025
1 parent 6dca638 commit 5878a44
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 83 deletions.
5 changes: 3 additions & 2 deletions include/ESPixelStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ extern void RequestReboot(uint32_t LoopDelay, bool SkipDisable = false);
extern bool RebootInProgress();

/// Core configuration structure
typedef struct {
struct config_t
{
// Device
String id;
uint32_t BlankDelay = uint32_t(5);
} config_t;
};

String serializeCore (bool pretty = false);
void deserializeCoreHandler (JsonDocument& jsonDoc);
Expand Down
23 changes: 0 additions & 23 deletions include/WebMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,7 @@ class c_WebMgr
void GetInputOptions ();
void GetOutputOptions ();

#ifdef BOARD_HAS_PSRAM

struct SpiRamAllocator
{
void *allocate(uint32_t size)
{
return ps_malloc(size);
}

void deallocate(void *pointer)
{
free(pointer);
}

void *reallocate(void *ptr, uint32_t new_size)
{
return ps_realloc(ptr, new_size);
}
};

using WebJsonDocument = BasicJsonDocument<SpiRamAllocator>;
#else
using WebJsonDocument = JsonDocument;
#endif // def BOARD_HAS_PSRAM

WebJsonDocument *WebJsonDoc = nullptr;
size_t GetFseqFileListChunk(uint8_t *buffer, size_t maxlen, size_t index);
Expand Down
4 changes: 2 additions & 2 deletions include/input/InputArtnet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class c_InputArtnet : public c_InputCommon
/// from sketch globals
uint16_t channel_count = 0; ///< Number of channels. Derived from output module configuration.

typedef struct
struct Universe_t
{
uint32_t DestinationOffset;
uint32_t BytesToCopy;
Expand All @@ -53,7 +53,7 @@ class c_InputArtnet : public c_InputCommon
uint8_t SequenceNumber;
uint32_t num_packets;

} Universe_t;
};
Universe_t UniverseArray[MAX_NUM_UNIVERSES];

void SetUpArtnet ();
Expand Down
22 changes: 11 additions & 11 deletions include/input/InputDDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,36 +64,36 @@ class c_InputDDP : public c_InputCommon
#define IsStorage(f) (DDP_FLAGS1_STORAGE == ((f) & DDP_FLAGS1_STORAGE))
#define IsTime(f) (DDP_FLAGS1_TIME == ((f) & DDP_FLAGS1_TIME))

typedef struct __attribute__ ((packed))
struct __attribute__ ((packed)) DDP_Header_t
{
byte flags1;
byte flags2;
byte type;
byte id;
uint32_t channelOffset;
uint16_t dataLen;
} DDP_Header_t;
};

typedef struct __attribute__ ((packed))
struct __attribute__ ((packed)) DDP_packet_t
{
DDP_Header_t header; // header may or may not be time code
byte data[DDP_MAX_DATALEN];
} DDP_packet_t;
};

typedef struct __attribute__ ((packed))
struct __attribute__ ((packed)) DDP_TimeCode_packet_t
{
DDP_Header_t header; // header may or may not be time code
uint32_t TimeCode;
byte data[DDP_MAX_DATALEN - sizeof(TimeCode)];
} DDP_TimeCode_packet_t;
};

typedef struct __attribute__ ((packed))
struct __attribute__ ((packed)) DDP_stats_t
{
uint32_t packetsReceived;
uint64_t bytesReceived;
uint32_t errors;
} DDP_stats_t;
String lastError;
};
String lastError;

AsyncUDP * udp = nullptr; // UDP
uint8_t lastReceivedSequenceNumber = 0;
Expand All @@ -114,13 +114,13 @@ class c_InputDDP : public c_InputCommon
BufferIsBeingProcessed,
};

typedef struct
struct PacketBuffer_t
{
PacketBufferStatus_t PacketBufferStatus = PacketBufferStatus_t::BufferIsAvailable;
DDP_packet_t Packet;
IPAddress ResponseAddress;
uint16_t ResponsePort;
} PacketBuffer_t;
} ;

PacketBuffer_t PacketBuffer;

Expand Down
9 changes: 4 additions & 5 deletions include/input/InputE131.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ class c_InputE131 : public c_InputCommon
/// from sketch globals
uint16_t channel_count = 0; ///< Number of channels. Derived from output module configuration.

typedef struct
struct Universe_t
{
uint32_t DestinationOffset;
uint32_t BytesToCopy;
uint32_t SourceDataOffset;
uint8_t SequenceNumber;
uint32_t SequenceErrorCounter;

} Universe_t;
uint8_t SequenceNumber;
uint32_t SequenceErrorCounter;
};
Universe_t UniverseArray[MAX_NUM_UNIVERSES];

void validateConfiguration ();
Expand Down
14 changes: 7 additions & 7 deletions include/input/InputEffectEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class c_InputEffectEngine : public c_InputCommon

typedef uint16_t (c_InputEffectEngine::* EffectFunc)(void);

typedef struct EffectDescriptor_s
struct EffectDescriptor_t
{
String name;
EffectFunc func;
Expand All @@ -74,19 +74,19 @@ class c_InputEffectEngine : public c_InputCommon
bool hasAllLeds;
bool hasWhiteChannel;
String wsTCode;
} EffectDescriptor_t;
};

typedef struct MQTTConfiguration_s
struct MQTTConfiguration_t
{
String effect;
bool mirror;
bool allLeds;
uint8_t brightness;
bool whiteChannel;
CRGB color;
} MQTTConfiguration_s;
};

struct MarqueeGroup
struct MarqueeGroup_t
{
uint32_t NumPixelsInGroup;
CRGB Color;
Expand All @@ -97,9 +97,9 @@ class c_InputEffectEngine : public c_InputCommon
// functions to be provided by the derived class
void Begin (); ///< set up the operating environment based on the current config (or defaults)
bool SetConfig (JsonObject& jsonConfig); ///< Set a new config in the driver
void SetMqttConfig (MQTTConfiguration_s& mqttConfig); ///< Set a new config in the driver
void SetMqttConfig (MQTTConfiguration_t& mqttConfig); ///< Set a new config in the driver
void GetConfig (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetMqttConfig (MQTTConfiguration_s& mqttConfig); ///< Get the current config used by the driver
void GetMqttConfig (MQTTConfiguration_t& mqttConfig); ///< Get the current config used by the driver
void GetMqttEffectList (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject& jsonStatus);
void Process ();
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputMQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class c_InputMQTT : public c_InputCommon
c_InputFPPRemotePlayItem* pPlayFileEngine = nullptr;

// Keep track of last known effect configuration state
c_InputEffectEngine::MQTTConfiguration_s effectConfig;
c_InputEffectEngine::MQTTConfiguration_t effectConfig;

// from original config struct
String ip;
Expand Down
2 changes: 1 addition & 1 deletion include/network/WiFiDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class c_WiFiDriver
void Enable ();

private:
#define DEFAULT_SSID_NOT_SET "DEFAULT_SSID_NOT_SET"
#define DEFAULT_SSID_NOT_SET F("DEFAULT_SSID_NOT_SET")
int ValidateConfig ();

#ifdef ARDUINO_ARCH_ESP8266
Expand Down
18 changes: 6 additions & 12 deletions include/output/OutputMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,9 @@ class c_OutputMgr
};

#ifdef ARDUINO_ARCH_ESP8266
# define OM_MAX_NUM_CHANNELS (1200 * 3)
# define OM_MAX_CONFIG_SIZE ((uint32_t)(3 * 1024))
# define OM_MAX_NUM_CHANNELS (1200 * 3)
#else // ARDUINO_ARCH_ESP32
# define OM_MAX_CONFIG_SIZE ((uint32_t)(20 * 1024))
# ifdef BOARD_HAS_PSRAM
# define OM_MAX_NUM_CHANNELS (7000 * 3)
# else
# define OM_MAX_NUM_CHANNELS (3000 * 3)
# endif // !def BOARD_HAS_PSRAM
# define OM_MAX_NUM_CHANNELS (3000 * 3)
#endif // !def ARDUINO_ARCH_ESP32

enum OM_PortType_t
Expand Down Expand Up @@ -251,10 +245,10 @@ class c_OutputMgr

String ConfigFileName;

uint8_t OutputBuffer[OM_MAX_NUM_CHANNELS];
uint32_t UsedBufferSize = 0;
gpio_num_t ConsoleTxGpio = gpio_num_t::GPIO_NUM_1;
gpio_num_t ConsoleRxGpio = gpio_num_t::GPIO_NUM_3;
uint8_t OutputBuffer[OM_MAX_NUM_CHANNELS];
uint32_t UsedBufferSize = 0;
gpio_num_t ConsoleTxGpio = gpio_num_t::GPIO_NUM_1;
gpio_num_t ConsoleRxGpio = gpio_num_t::GPIO_NUM_3;
bool ConsoleUartIsActive = true;
#if defined(ARDUINO_ARCH_ESP32)
TaskHandle_t myTaskHandle = NULL;
Expand Down
4 changes: 2 additions & 2 deletions include/output/OutputRelay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ GNU General Public License for more details.
class c_OutputRelay : public c_OutputCommon
{
public:
typedef struct RelayChannel_s
struct RelayChannel_t
{
bool Enabled;
bool InvertOutput;
Expand All @@ -50,7 +50,7 @@ class c_OutputRelay : public c_OutputCommon
uint16_t PwmFrequency;
#endif // defined(ARDUINO_ARCH_ESP32)

} RelayChannel_t;
};

// These functions are inherited from c_OutputCommon
c_OutputRelay (c_OutputMgr::e_OutputChannelIds OutputChannelId,
Expand Down
4 changes: 2 additions & 2 deletions include/output/OutputServoPCA9685.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class c_OutputServoPCA9685 : public c_OutputCommon
#define SERVO_PCA9685_OUTPUT_MIN_PULSE_WIDTH 650
#define SERVO_PCA9685_OUTPUT_MAX_PULSE_WIDTH 2350

typedef struct ServoPCA9685Channel_s
struct ServoPCA9685Channel_t
{
uint8_t Id = -1;
bool Enabled = false;
Expand All @@ -41,7 +41,7 @@ class c_OutputServoPCA9685 : public c_OutputCommon
bool IsScaled = true;
uint8_t HomeValue = 0;

} ServoPCA9685Channel_t;
};

public:

Expand Down
7 changes: 3 additions & 4 deletions src/FileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ bool c_FileMgr::handleFileUpload (
CloseSdFile(fsUploadFileHandle, false);
DeleteSdFile (fsUploadFileName, false);
fsUploadFileHandle = INVALID_FILE_HANDLE;
delay(1000);
delay(100);
BuildFseqList(false, false);
expectedIndex = 0;
fsUploadFileName = emptyString;
Expand Down Expand Up @@ -2033,11 +2033,10 @@ bool c_FileMgr::handleFileUpload (
F(" Bytes out of ") + String(totalLen) +
F(" bytes. FileLen: ") + GetSdFileSize(filename, false));

delay(1000);
FeedWDT();

expectedIndex = 0;
delay(1000);

delay(100);
BuildFseqList(false, false);

// DEBUG_V(String("Expected: ") + String(totalLen));
Expand Down
8 changes: 4 additions & 4 deletions src/input/InputEffectEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static std::vector<c_InputEffectEngine::dCRGB> TransitionColorTable =
{100, 100, 55},
};

static std::vector<c_InputEffectEngine::MarqueeGroup> MarqueueGroupTable =
static std::vector<c_InputEffectEngine::MarqueeGroup_t> MarqueueGroupTable =
{
{5, {255, 0, 0}, 100, 100},
{5, {255, 255, 255}, 100, 0},
Expand Down Expand Up @@ -214,7 +214,7 @@ void c_InputEffectEngine::GetMqttEffectList (JsonObject& jsonConfig)
} // GetMqttEffectList

//-----------------------------------------------------------------------------
void c_InputEffectEngine::GetMqttConfig (MQTTConfiguration_s & mqttConfig)
void c_InputEffectEngine::GetMqttConfig (MQTTConfiguration_t & mqttConfig)
{
// DEBUG_START;

Expand Down Expand Up @@ -564,7 +564,7 @@ bool c_InputEffectEngine::SetConfig (ArduinoJson::JsonObject& jsonConfig)

for (auto _MarqueeGroup : MarqueeGroupArray)
{
MarqueeGroup NewGroup;
MarqueeGroup_t NewGroup;
JsonObject currentMarqueeGroup = _MarqueeGroup.as<JsonObject>();
// DEBUG_V ("");
JsonObject GroupColor = currentMarqueeGroup[(char*)CN_color];
Expand Down Expand Up @@ -602,7 +602,7 @@ bool c_InputEffectEngine::SetConfig (ArduinoJson::JsonObject& jsonConfig)
} // SetConfig

//-----------------------------------------------------------------------------
void c_InputEffectEngine::SetMqttConfig (MQTTConfiguration_s& mqttConfig)
void c_InputEffectEngine::SetMqttConfig (MQTTConfiguration_t& mqttConfig)
{
// DEBUG_START;
String effectName;
Expand Down
4 changes: 2 additions & 2 deletions src/input/InputMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
//-----------------------------------------------------------------------------
// Local Data definitions
//-----------------------------------------------------------------------------
typedef struct
struct InputTypeXlateMap_t
{
c_InputMgr::e_InputType id;
String name;
c_InputMgr::e_InputChannelIds ChannelId;
} InputTypeXlateMap_t;
};

static const InputTypeXlateMap_t InputTypeXlateMap[c_InputMgr::e_InputType::InputType_End] =
{
Expand Down
2 changes: 1 addition & 1 deletion src/network/WiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# define SECRETS_SSID DEFAULT_SSID_NOT_SET
#endif // SECRETS_SSID
#if !defined(SECRETS_PASS)
# define SECRETS_PASS "DEFAULT_PASSPHRASE_NOT_SET"
# define SECRETS_PASS F("DEFAULT_PASSPHRASE_NOT_SET")
#endif // SECRETS_PASS

/* Fallback configuration if config.json is empty or fails */
Expand Down
8 changes: 4 additions & 4 deletions src/output/OutputMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
//-----------------------------------------------------------------------------
// Local Data definitions
//-----------------------------------------------------------------------------
typedef struct
struct OutputTypeXlateMap_t
{
c_OutputMgr::e_OutputType id;
String name;
}OutputTypeXlateMap_t;
};

static const OutputTypeXlateMap_t OutputTypeXlateMap[c_OutputMgr::e_OutputType::OutputType_End] =
{
Expand Down Expand Up @@ -126,12 +126,12 @@ static const OutputTypeXlateMap_t OutputTypeXlateMap[c_OutputMgr::e_OutputType::
};

//-----------------------------------------------------------------------------
typedef struct
struct OutputChannelIdToGpioAndPortEntry_t
{
gpio_num_t GpioPin;
uart_port_t PortId;
c_OutputMgr::OM_PortType_t PortType;
} OutputChannelIdToGpioAndPortEntry_t;
};

//-----------------------------------------------------------------------------
static const OutputChannelIdToGpioAndPortEntry_t OutputChannelIdToGpioAndPort[] =
Expand Down

0 comments on commit 5878a44

Please sign in to comment.