From d7525456752e182b2e20ae0f38ed022f881eec9e Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 10 Jan 2026 13:12:33 +0100 Subject: framebuffer, pixelfont: use HAVE_PROGMEM rather than hardcoding arch checks --- include/lib/pixelfont/pixeloperator.h | 2 +- include/lib/pixelfont/pixeloperator_mirrored.h | 2 +- include/lib/pixelfont/terminus16.h | 2 +- include/lib/pixelfont/terminus24.h | 2 +- src/arch/arduino-nano/Makefile.inc | 1 + src/arch/atmega2560/Makefile.inc | 1 + src/object/framebuffer.cc | 6 +++--- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/lib/pixelfont/pixeloperator.h b/include/lib/pixelfont/pixeloperator.h index 30f5154..dc1c7d2 100644 --- a/include/lib/pixelfont/pixeloperator.h +++ b/include/lib/pixelfont/pixeloperator.h @@ -9,7 +9,7 @@ * SPDX-License-Identifier: CC0-1.0 */ -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM #include #define GLYPH_ATTR PROGMEM #else diff --git a/include/lib/pixelfont/pixeloperator_mirrored.h b/include/lib/pixelfont/pixeloperator_mirrored.h index 149015c..817d843 100644 --- a/include/lib/pixelfont/pixeloperator_mirrored.h +++ b/include/lib/pixelfont/pixeloperator_mirrored.h @@ -9,7 +9,7 @@ * SPDX-License-Identifier: CC0-1.0 */ -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM #include #define GLYPH_ATTR PROGMEM #else diff --git a/include/lib/pixelfont/terminus16.h b/include/lib/pixelfont/terminus16.h index e63fba8..d84a328 100644 --- a/include/lib/pixelfont/terminus16.h +++ b/include/lib/pixelfont/terminus16.h @@ -8,7 +8,7 @@ * SPDX-License-Identifier: OFL-1.1 */ -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM #include #define GLYPH_ATTR PROGMEM #else diff --git a/include/lib/pixelfont/terminus24.h b/include/lib/pixelfont/terminus24.h index cd4a785..3a285e1 100644 --- a/include/lib/pixelfont/terminus24.h +++ b/include/lib/pixelfont/terminus24.h @@ -8,7 +8,7 @@ * SPDX-License-Identifier: OFL-1.1 */ -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM #include #define GLYPH_ATTR PROGMEM #else diff --git a/src/arch/arduino-nano/Makefile.inc b/src/arch/arduino-nano/Makefile.inc index 2313d18..f6fb416 100644 --- a/src/arch/arduino-nano/Makefile.inc +++ b/src/arch/arduino-nano/Makefile.inc @@ -22,6 +22,7 @@ cpu_freq ?= 16000000 COMMON_FLAGS += -Werror=overflow COMMON_FLAGS += -mmcu=${MCU} -DMULTIPASS_ARCH_arduino_nano COMMON_FLAGS += -DF_CPU=${cpu_freq}UL +COMMON_FLAGS += -DHAVE_PROGMEM ifeq (${stack_usage}, ) COMMON_FLAGS += -flto diff --git a/src/arch/atmega2560/Makefile.inc b/src/arch/atmega2560/Makefile.inc index 6d82a1c..a8cfb42 100644 --- a/src/arch/atmega2560/Makefile.inc +++ b/src/arch/atmega2560/Makefile.inc @@ -17,6 +17,7 @@ cpu_freq ?= 16000000 COMMON_FLAGS += -Werror=overflow COMMON_FLAGS += -mmcu=${MCU} -DMULTIPASS_ARCH_atmega2560 COMMON_FLAGS += -DF_CPU=${cpu_freq}UL +COMMON_FLAGS += -DHAVE_PROGMEM ifeq (${stack_usage}, ) COMMON_FLAGS += -flto diff --git a/src/object/framebuffer.cc b/src/object/framebuffer.cc index e7b914d..a3848ef 100644 --- a/src/object/framebuffer.cc +++ b/src/object/framebuffer.cc @@ -1,6 +1,6 @@ #include "object/framebuffer.h" -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM #include #endif @@ -119,7 +119,7 @@ void Framebuffer::put(char c) if ((c < 32) || (c > 126)) { c = '?'; } -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM uint8_t *glyph_addr = (uint8_t *)pgm_read_ptr(&font[c - 32]); const unsigned char glyph_w = pgm_read_byte(&glyph_addr[0]); #else @@ -136,7 +136,7 @@ void Framebuffer::put(char c) for (unsigned char i = 0; i < glyph_w; i++) { unsigned char x = i / fontSize; unsigned char y = i % fontSize; -#ifdef MULTIPASS_ARCH_arduino_nano +#ifdef HAVE_PROGMEM data[(height/8) * (fontX + x) + fontY/8 + y] = pgm_read_byte(&glyph_addr[i+1]); #else data[(height/8) * (fontX + x) + fontY/8 + y] = glyph[i+1]; -- cgit v1.2.3