slightly faster flush and clear
This commit is contained in:
parent
cb115186c5
commit
bdfafbcf9f
1 changed files with 11 additions and 6 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include "src/gdisp/driver.h"
|
#include "src/gdisp/driver.h"
|
||||||
|
|
||||||
#include "board_SSD1306.h"
|
#include "board_SSD1306.h"
|
||||||
|
#include <string.h> // for memset
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local definitions. */
|
/* Driver local definitions. */
|
||||||
|
@ -136,17 +137,22 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||||
|
|
||||||
#if GDISP_HARDWARE_FLUSH
|
#if GDISP_HARDWARE_FLUSH
|
||||||
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
||||||
unsigned i;
|
uint8_t * ram;
|
||||||
|
unsigned pages;
|
||||||
|
|
||||||
// Don't flush if we don't need it.
|
// Don't flush if we don't need it.
|
||||||
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
|
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
|
||||||
return;
|
return;
|
||||||
|
ram = RAM(g);
|
||||||
|
pages = GDISP_SCREEN_HEIGHT/8;
|
||||||
|
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
write_cmd(g, SSD1306_SETSTARTLINE | 0);
|
write_cmd(g, SSD1306_SETSTARTLINE | 0);
|
||||||
|
|
||||||
for(i=0; i < GDISP_SCREEN_HEIGHT/8 * SSD1306_PAGE_WIDTH; i+=SSD1306_PAGE_WIDTH)
|
while (pages--) {
|
||||||
write_data(g, RAM(g)+i, SSD1306_PAGE_WIDTH);
|
write_data(g, ram, SSD1306_PAGE_WIDTH);
|
||||||
|
ram += SSD1306_PAGE_WIDTH;
|
||||||
|
}
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -155,9 +161,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||||
LLDSPEC void gdisp_lld_clear(GDisplay *g) {
|
LLDSPEC void gdisp_lld_clear(GDisplay *g) {
|
||||||
uint8_t fill = (g->p.color == Black) ? 0 : 0xff;
|
uint8_t fill = (g->p.color == Black) ? 0 : 0xff;
|
||||||
int bytes = GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT/8;
|
int bytes = GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT/8;
|
||||||
int off;
|
memset(RAM(g), fill, bytes);
|
||||||
for (off = 0; off < bytes; off++)
|
g->flags |= GDISP_FLG_NEEDFLUSH;
|
||||||
RAM(g)[off] = fill;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue