From 6dbb576acad95e580f2d7c599b50a80d3dbd2e73 Mon Sep 17 00:00:00 2001 From: Manuel Reimer Date: Sun, 25 Mar 2018 14:12:48 +0200 Subject: st7565r-reel: Reduced memory usage of LCD buffer --- glcddrivers/st7565r-reel.c | 22 ++++++++-------------- glcddrivers/st7565r-reel.h | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/glcddrivers/st7565r-reel.c b/glcddrivers/st7565r-reel.c index 7a00703..a97b9cf 100644 --- a/glcddrivers/st7565r-reel.c +++ b/glcddrivers/st7565r-reel.c @@ -61,19 +61,19 @@ cDriverST7565RReel::~cDriverST7565RReel() int cDriverST7565RReel::Init(void) { width = config->width; - if (width < 0) + if (width <= 0) width = 128; height = config->height; - if (height < 0) + if (height <= 0) height = 64; // setup lcd array - LCD = new uint32_t *[width]; + LCD = new unsigned char *[width / 8]; if (LCD) { - for (int x = 0; x < width; x++) + for (int x = 0; x < width / 8; x++) { - LCD[x] = new uint32_t[height]; + LCD[x] = new unsigned char[height]; } } @@ -101,7 +101,7 @@ int cDriverST7565RReel::DeInit(void) // free lcd array if (LCD) { - for (int x = 0; x < width; x++) + for (int x = 0; x < width / 8; x++) { delete[] LCD[x]; } @@ -152,14 +152,8 @@ int cDriverST7565RReel::CheckSetup(void) void cDriverST7565RReel::Clear(void) { - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - LCD[x][y] = GRAPHLCD_White; - } - } -// syslog(LOG_INFO, "Clear.\n"); + for (int x = 0; x < width / 8; x++) + memset(LCD[x], 0, height); } void cDriverST7565RReel::SetPixel(int x, int y, uint32_t data) diff --git a/glcddrivers/st7565r-reel.h b/glcddrivers/st7565r-reel.h index 346f6d9..71b5089 100644 --- a/glcddrivers/st7565r-reel.h +++ b/glcddrivers/st7565r-reel.h @@ -43,7 +43,7 @@ class cDriverST7565RReel : public cDriver { private: cSerialPort* port; - uint32_t ** LCD; + unsigned char ** LCD; int CheckSetup(void); void display_cmd(unsigned char cmd); void display_data(unsigned char *data, unsigned char l); -- cgit v1.2.3