From e29396274d61e25928905405bc40d117d5e7e749 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 3 Nov 2021 21:55:55 +0100 Subject: store fonts in PROGMEM on AVR --- src/os/object/framebuffer.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/os/object/framebuffer.cc') diff --git a/src/os/object/framebuffer.cc b/src/os/object/framebuffer.cc index 7b3fe0d..f23cd84 100644 --- a/src/os/object/framebuffer.cc +++ b/src/os/object/framebuffer.cc @@ -1,5 +1,9 @@ #include "object/framebuffer.h" +#ifdef MULTIPASS_ARCH_arduino_nano +#include +#endif + #ifdef CONFIG_framebuffer_in_text_segment __attribute__ ((section(".text"))) #endif @@ -80,8 +84,13 @@ void Framebuffer::put(char c) if ((c < 32) || (c > 126)) { c = '?'; } +#ifdef MULTIPASS_ARCH_arduino_nano + uint8_t *glyph_addr = (uint8_t *)pgm_read_ptr(&font[c - 32]); + const unsigned char glyph_w = pgm_read_byte(&glyph_addr[0]); +#else glyph_t glyph = font[c - 32]; const unsigned char glyph_w = glyph[0]; +#endif if (fontX + glyph_w + 1 >= width) { put('\n'); @@ -90,7 +99,11 @@ void Framebuffer::put(char c) return; } for (unsigned char i = 0; i < glyph_w; i++) { +#ifdef MULTIPASS_ARCH_arduino_nano + data[(height/8) * (fontX + i) + fontY/8] = pgm_read_byte(&glyph_addr[i+1]); +#else data[(height/8) * (fontX + i) + fontY/8] = glyph[i+1]; +#endif } data[(height/8) * (fontX + glyph_w + 1) + fontY/8] = 0; fontX += glyph_w + 2; -- cgit v1.2.3