summaryrefslogtreecommitdiff
path: root/glcddrivers/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'glcddrivers/image.c')
-rw-r--r--glcddrivers/image.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/glcddrivers/image.c b/glcddrivers/image.c
index a07ce54..a3d123f 100644
--- a/glcddrivers/image.c
+++ b/glcddrivers/image.c
@@ -7,7 +7,9 @@
* This file is released under the GNU General Public License. Refer
* to the COPYING file distributed with this package.
*
- * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net>
+ Andreas 'randy' Weinberger
*/
#include <stdio.h>
@@ -23,15 +25,13 @@ namespace GLCD
{
cDriverImage::cDriverImage(cDriverConfig * config)
-: config(config)
+: cDriver(config)
{
- oldConfig = new cDriverConfig(*config);
}
cDriverImage::~cDriverImage()
{
DeInit();
- delete oldConfig;
}
int cDriverImage::Init()
@@ -51,12 +51,13 @@ int cDriverImage::Init()
}
}
- newLCD = new unsigned char[lineSize * height];
+// newLCD = new unsigned char[lineSize * height];
+ newLCD = new uint32_t[width * height];
if (newLCD)
- memset(newLCD, 0, lineSize * height);
- oldLCD = new unsigned char[lineSize * height];
+ memset(newLCD, 0, width * height);
+ oldLCD = new uint32_t[width * height];
if (oldLCD)
- memset(oldLCD, 0, lineSize * height);
+ memset(oldLCD, 0, width * height);
counter = 0;
@@ -109,6 +110,7 @@ void cDriverImage::Clear()
memset(newLCD, 0, lineSize * height);
}
+#if 0
void cDriverImage::Set8Pixels(int x, int y, unsigned char data)
{
if (x >= width || y >= height)
@@ -127,6 +129,28 @@ void cDriverImage::Set8Pixels(int x, int y, unsigned char data)
newLCD[lineSize * y + x / 8] |= ReverseBits(data);
}
}
+#endif
+
+void cDriverImage::SetPixel(int x, int y, uint32_t data)
+{
+ if (x >= width || y >= height)
+ return;
+
+ int cols = (width + 7 ) >> 3;
+ int pos = x % 8;
+ if (config->upsideDown)
+ {
+ x = width - 1 - x;
+ y = height - 1 - y;
+ } else {
+ pos = 7 - pos; // reverse bit position
+ }
+
+ if (data == GRAPHLCD_White)
+ newLCD[y * cols + (x >> 3)] |= ( 1 << pos );
+ else
+ newLCD[y * cols + (x >> 3)] &= ( 0xFF ^ ( 1 << pos) );
+}
void cDriverImage::Refresh(bool refreshAll)
{