Clean up global variables namespace, save a few 100 bytes of flash (#5368)

* reduce scope of some variables to "static"

these are not used anywhere else. Making them static avoid name conflicts, cleans up the global scope and in some cases allows for better  optimization by the compiler.

* remove unused reference ``tz``from analog clock usermod

* side-catch: remove two "local var shadows global var" warnings

* reduce scope of functions declared globally, but not used anywhere else
Safe to make static
* declared in fcn_declare.h, only used locally in one file
* not declared in fcn_declare.h, only used locally

* HUB75 small optimization
make bit array functions "static inline"
-> better for optimization, saves some bytes because the compiler does not need to preserve a non-inline function copy for external references.

* a few more static functions
as suggested by the rabbit.
This commit is contained in:
Frank Möhle
2026-02-11 22:24:06 +01:00
committed by GitHub
parent ce31d802d5
commit f830ea498c
19 changed files with 87 additions and 65 deletions

View File

@@ -1,5 +1,8 @@
#include "wled.h"
// forward declarations
static void sendBytes();
/*
* Adalight and TPM2 handler
*/
@@ -19,9 +22,9 @@ enum class AdaState {
TPM2_Header_CountLo,
};
uint16_t currentBaud = 1152; //default baudrate 115200 (divided by 100)
bool continuousSendLED = false;
uint32_t lastUpdate = 0;
static uint16_t currentBaud = 1152; //default baudrate 115200 (divided by 100)
static bool continuousSendLED = false;
static uint32_t lastUpdate = 0;
void updateBaudRate(uint32_t rate){
unsigned rate100 = rate/100;
@@ -37,7 +40,7 @@ void updateBaudRate(uint32_t rate){
}
// RGB LED data return as JSON array. Slow, but easy to use on the other end.
void sendJSON(){
static inline void sendJSON(){
if (serialCanTX) {
unsigned used = strip.getLengthTotal();
Serial.write('[');
@@ -50,7 +53,7 @@ void sendJSON(){
}
// RGB LED data returned as bytes in TPM2 format. Faster, and slightly less easy to use on the other end.
void sendBytes(){
static void sendBytes(){
if (serialCanTX) {
Serial.write(0xC9); Serial.write(0xDA);
unsigned used = strip.getLengthTotal();