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

@@ -82,12 +82,12 @@
//#define MAX_FREQ_LOG10 3.71f
// effect utility functions
uint8_t sin_gap(uint16_t in) {
static uint8_t sin_gap(uint16_t in) {
if (in & 0x100) return 0;
return sin8_t(in + 192); // correct phase shift of sine so that it starts and stops at 0
}
uint16_t triwave16(uint16_t in) {
static uint16_t triwave16(uint16_t in) {
if (in < 0x8000) return in *2;
return 0xFFFF - (in - 0x8000)*2;
}
@@ -99,7 +99,7 @@ uint16_t triwave16(uint16_t in) {
* @param attdec attack & decay, max. pulsewidth / 2
* @returns signed waveform value
*/
int8_t tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec) {
static int8_t tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec) {
int8_t a = 127;
if (x > 127) {
a = -127;