From 9dd53a17223e07dde9ea5f25143ace7296edbe7f Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 24 Apr 2016 23:50:56 +0200 Subject: [PATCH] display_ssd1306.c: support monospaced fonts. Monospaced fonts require a bit less space, right now it saves a nice 110 bytes binary size. Actually, the distinction between monospaced and proportional fonts was in font.h already, so not supporting them was a bug. But so far we have no monospaced font, so nobody noticed. --- display_ssd1306.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/display_ssd1306.c b/display_ssd1306.c index 97f5553..8a9ff35 100644 --- a/display_ssd1306.c +++ b/display_ssd1306.c @@ -97,8 +97,12 @@ void display_text_P(uint8_t line, uint8_t column, PGM_P message) { index -= 0x20; // Send the character bitmap. - for (i = 0; i < pgm_read_byte(&font[index].columns); i++) { - displaybus_write(pgm_read_byte(&font[index].data[i]), 0); + #ifdef FONT_IS_PROPORTIONAL + for (i = 0; i < pgm_read_byte(&font[index].columns); i++) { + #else + for (i = 0; i < FONT_COLUMNS; i++) { + #endif + displaybus_write(pgm_read_byte(&font[index].data[i]), 0); } // Send space between characters. for (i = 0; i < FONT_SYMBOL_SPACE; i++) {