diff options
Diffstat (limited to 'glcddrivers/driver.c')
-rw-r--r-- | glcddrivers/driver.c | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/glcddrivers/driver.c b/glcddrivers/driver.c index b1b6286..ea13eaf 100644 --- a/glcddrivers/driver.c +++ b/glcddrivers/driver.c @@ -9,23 +9,47 @@ * 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-2013 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #include "common.h" #include "driver.h" - +#include "config.h" namespace GLCD { -cDriver::cDriver() +cTouchEvent::cTouchEvent() : x(0), y(0), touch(0) +{ +} + +cDriver::cDriver(cDriverConfig * config) : width(0), - height(0) + height(0), + config(config) +{ + fgcol = GetDefaultForegroundColor(); + bgcol = GetDefaultBackgroundColor(); + oldConfig = new cDriverConfig(*config); +} + +cDriver::~cDriver(void) { + delete oldConfig; +} + +const std::string cDriver::ConfigName() { + return (config) ? config->name : ""; +} + +const std::string cDriver::DriverName() { + return (config) ? config->driver : ""; } -void cDriver::SetScreen(const unsigned char * data, int wid, int hgt, int lineSize) + +//void cDriver::SetScreen(const unsigned char * data, int wid, int hgt, int lineSize) +void cDriver::SetScreen(const uint32_t * data, int wid, int hgt) { int x, y; @@ -34,11 +58,19 @@ void cDriver::SetScreen(const unsigned char * data, int wid, int hgt, int lineSi if (hgt > height) hgt = height; - Clear(); + //Clear(); if (data) { for (y = 0; y < hgt; y++) { + for (x = 0; x < wid; x++) + { +// printf("%s:%s(%d) - %03d * %03d (linesize %02d), %08x\n", __FILE__, __FUNCTION__, __LINE__, x, y, lineSize, data[y * lineSize + x]); + SetPixel(x, y, data[y * wid + x]); + } + } + } +/* for (x = 0; x < (wid / 8); x++) { Set8Pixels(x * 8, y, data[y * lineSize + x]); @@ -48,7 +80,24 @@ void cDriver::SetScreen(const unsigned char * data, int wid, int hgt, int lineSi Set8Pixels((wid / 8) * 8, y, data[y * lineSize + wid / 8] & bitmaskl[wid % 8 - 1]); } } +*/ +} + +void cDriver::Set8Pixels(int x, int y, unsigned char data) +{ + int n; + // calling GetForegroundColor() and GetBackgroundColor() is slow in some situations. + // will be replaced through setting object-wide (incl. derived objs) class members + uint32_t fg = GetForegroundColor(); + uint32_t bg = GetBackgroundColor(); + + // guarante that x starts at a position divisible by 8 + x &= 0xFFF8; + + for (n = 0; n < 8; ++n) { + SetPixel(x + n, y, (data & (0x80 >> n)) ? fg : bg); } } + } // end of namespace |