diff options
author | ergosys <ergosys@gmail.com> | 2014-12-12 15:27:37 -0800 |
---|---|---|
committer | ergosys <ergosys@gmail.com> | 2014-12-12 16:21:09 -0800 |
commit | bdfafbcf9f7d247b85699818cd2a959178a24b64 (patch) | |
tree | 5d873ee42463b00d0f8e5c01f868d6410b929ae0 /drivers/gdisp/SSD1306 | |
parent | cb115186c5269f6463a1a4b422e7a0b9e9f5c6b7 (diff) | |
download | uGFX-bdfafbcf9f7d247b85699818cd2a959178a24b64.tar.gz uGFX-bdfafbcf9f7d247b85699818cd2a959178a24b64.tar.bz2 uGFX-bdfafbcf9f7d247b85699818cd2a959178a24b64.zip |
slightly faster flush and clear
Diffstat (limited to 'drivers/gdisp/SSD1306')
-rw-r--r-- | drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c index 9670d2d0..2386c2d4 100644 --- a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c +++ b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c @@ -14,6 +14,7 @@ #include "src/gdisp/driver.h" #include "board_SSD1306.h" +#include <string.h> // for memset /*===========================================================================*/ /* Driver local definitions. */ @@ -136,17 +137,22 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_FLUSH LLDSPEC void gdisp_lld_flush(GDisplay *g) { - unsigned i; + uint8_t * ram; + unsigned pages; // Don't flush if we don't need it. if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; + ram = RAM(g); + pages = GDISP_SCREEN_HEIGHT/8; acquire_bus(g); write_cmd(g, SSD1306_SETSTARTLINE | 0); - for(i=0; i < GDISP_SCREEN_HEIGHT/8 * SSD1306_PAGE_WIDTH; i+=SSD1306_PAGE_WIDTH) - write_data(g, RAM(g)+i, SSD1306_PAGE_WIDTH); + while (pages--) { + write_data(g, ram, SSD1306_PAGE_WIDTH); + ram += SSD1306_PAGE_WIDTH; + } release_bus(g); } #endif @@ -155,9 +161,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { LLDSPEC void gdisp_lld_clear(GDisplay *g) { uint8_t fill = (g->p.color == Black) ? 0 : 0xff; int bytes = GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT/8; - int off; - for (off = 0; off < bytes; off++) - RAM(g)[off] = fill; + memset(RAM(g), fill, bytes); + g->flags |= GDISP_FLG_NEEDFLUSH; } #endif |