From ae8e284d417c42bfb3764941aa57263fe47db2ee Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Tue, 21 Mar 2017 14:57:41 -0400 Subject: [PATCH] optimize drawChar (-126 bytes) --- src/Arduboy2.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index ff5ac46..b2cbf8a 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -1159,7 +1159,9 @@ size_t Arduboy2::write(uint8_t c) void Arduboy2::drawChar (int16_t x, int16_t y, unsigned char c, uint8_t color, uint8_t bg, uint8_t size) { + uint8_t line; bool draw_background = bg != color; + uint8_t *bitmap = font + c*5; if ((x >= WIDTH) || // Clip right (y >= HEIGHT) || // Clip bottom @@ -1170,17 +1172,12 @@ void Arduboy2::drawChar return; } - for (int8_t i=0; i<6; i++ ) + for (uint8_t i=0; i<6; i++ ) { - uint8_t line; - if (i == 5) - { + line = pgm_read_byte(bitmap++); + if (i == 5) { line = 0x0; } - else - { - line = pgm_read_byte(font+(c*5)+i); - } for (int8_t j = 0; j<8; j++) {