diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-12-15 18:32:45 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-12-15 18:32:45 +1000 |
commit | 17b921204cfaf09d31c16daff00c69360883c83e (patch) | |
tree | 40d9ba808a68fa72cd8a48d7a1feceab0c5a04dd /drivers | |
parent | 3936c630612c9aff74f3bc21984e486f81d3f7da (diff) | |
parent | 262db6484498ec31baa8b9888aadb48e4f4984f3 (diff) | |
download | uGFX-17b921204cfaf09d31c16daff00c69360883c83e.tar.gz uGFX-17b921204cfaf09d31c16daff00c69360883c83e.tar.bz2 uGFX-17b921204cfaf09d31c16daff00c69360883c83e.zip |
Split SSD1306 spi board example into 2 files.
Revert chibios 3.x use of bool as a base type for bool_t. back to char
bool is available on c++ compilers only!!!!
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c | 29 | ||||
-rw-r--r-- | drivers/gdisp/SSD1306/gdisp_lld_config.h | 3 |
2 files changed, 25 insertions, 7 deletions
diff --git a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c index abea8365..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,16 +137,32 @@ 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 + +#if GDISP_HARDWARE_CLEARS + 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; + memset(RAM(g), fill, bytes); + g->flags |= GDISP_FLG_NEEDFLUSH; } #endif @@ -168,8 +185,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = GDISP_SCREEN_HEIGHT-1 - g->p.y; break; case GDISP_ROTATE_270: - x = GDISP_SCREEN_HEIGHT-1 - g->p.y; - x = g->p.x; + x = GDISP_SCREEN_WIDTH-1 - g->p.y; + y = g->p.x; break; } if (gdispColor2Native(g->p.color) != Black) @@ -199,7 +216,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = GDISP_SCREEN_HEIGHT-1 - g->p.y; break; case GDISP_ROTATE_270: - x = GDISP_SCREEN_HEIGHT-1 - g->p.y; + x = GDISP_SCREEN_WIDTH-1 - g->p.y; y = g->p.x; break; } diff --git a/drivers/gdisp/SSD1306/gdisp_lld_config.h b/drivers/gdisp/SSD1306/gdisp_lld_config.h index 2b805e86..9c502157 100644 --- a/drivers/gdisp/SSD1306/gdisp_lld_config.h +++ b/drivers/gdisp/SSD1306/gdisp_lld_config.h @@ -17,7 +17,8 @@ #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
#define GDISP_HARDWARE_DRAWPIXEL TRUE
#define GDISP_HARDWARE_PIXELREAD TRUE
-#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_CLEARS TRUE
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
|