summaryrefslogtreecommitdiff
path: root/glcddrivers
diff options
context:
space:
mode:
Diffstat (limited to 'glcddrivers')
-rw-r--r--glcddrivers/dm140gink.c10
-rw-r--r--glcddrivers/dm140gink.h2
-rw-r--r--glcddrivers/driver.c22
-rw-r--r--glcddrivers/driver.h69
-rw-r--r--glcddrivers/framebuffer.c4
-rw-r--r--glcddrivers/framebuffer.h2
-rw-r--r--glcddrivers/g15daemon.c6
-rw-r--r--glcddrivers/g15daemon.h2
-rw-r--r--glcddrivers/gu126x64D-K610A4.c6
-rw-r--r--glcddrivers/gu126x64D-K610A4.h2
-rw-r--r--glcddrivers/gu140x32f.c4
-rw-r--r--glcddrivers/gu140x32f.h2
-rw-r--r--glcddrivers/gu256x64-372.c8
-rw-r--r--glcddrivers/gu256x64-372.h2
-rw-r--r--glcddrivers/gu256x64-3900.c4
-rw-r--r--glcddrivers/gu256x64-3900.h2
-rw-r--r--glcddrivers/image.c36
-rw-r--r--glcddrivers/image.h9
-rw-r--r--glcddrivers/noritake800.c4
-rw-r--r--glcddrivers/noritake800.h2
-rw-r--r--glcddrivers/serdisp.c280
-rw-r--r--glcddrivers/serdisp.h64
22 files changed, 410 insertions, 132 deletions
diff --git a/glcddrivers/dm140gink.c b/glcddrivers/dm140gink.c
index c7efdba..87e29c2 100644
--- a/glcddrivers/dm140gink.c
+++ b/glcddrivers/dm140gink.c
@@ -92,7 +92,7 @@ int cDriverDM140GINK::SendReport(const char *cbuf, size_t size)
//**************************************************************
if((err = ioctl(fd, HIDIOCSUSAGE, &uref)) < 0)
{
- syslog(LOG_INFO, "%s: Error with sending the USAGE ioctl %d,0x%02X;size:%d\n", config->name.c_str(), i, (int)buf[i],size);
+ syslog(LOG_INFO, "%s: Error with sending the USAGE ioctl %d,0x%02X;size:%d\n", config->name.c_str(), (int)i, (int)buf[i], (int)size);
return err;
}
uref.usage_code = 0xffa10006; //unused?
@@ -130,8 +130,8 @@ int cDriverDM140GINK::Init()
if (height <= 0)
height = 16;
- vendor = 0x040b;
- product = 0x7001;
+ signed short vendor = 0x040b;
+ signed short product = 0x7001;
for (unsigned int i = 0; i < config->options.size(); i++)
{
@@ -254,7 +254,7 @@ int cDriverDM140GINK::CheckSetup()
return 0;
}
-void cDriverDM140GINK::SetPixel(int x, int y)
+void cDriverDM140GINK::SetPixel(int x, int y, uint32_t data)
{
if (x >= width || y >= height)
return;
@@ -282,7 +282,7 @@ void cDriverDM140GINK::Set8Pixels(int x, int y, unsigned char data)
for (int n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/dm140gink.h b/glcddrivers/dm140gink.h
index 526263a..8686ad9 100644
--- a/glcddrivers/dm140gink.h
+++ b/glcddrivers/dm140gink.h
@@ -38,7 +38,7 @@ private:
int SendReport(const char *buf, size_t size);
int CheckSetup();
- void SetPixel(int x, int y);
+ void SetPixel(int x, int y, uint32_t data);
public:
cDriverDM140GINK(cDriverConfig * config);
diff --git a/glcddrivers/driver.c b/glcddrivers/driver.c
index b1b6286..056f8bc 100644
--- a/glcddrivers/driver.c
+++ b/glcddrivers/driver.c
@@ -9,7 +9,8 @@
* 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>
*/
#include "common.h"
@@ -19,13 +20,18 @@
namespace GLCD
{
+cSimpleTouchEvent::cSimpleTouchEvent() : x(0), y(0), touch(0)
+{
+}
+
cDriver::cDriver()
: width(0),
height(0)
{
}
-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 +40,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 +62,7 @@ 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]);
}
}
- }
+*/
}
} // end of namespace
diff --git a/glcddrivers/driver.h b/glcddrivers/driver.h
index 1d82eaa..babb71a 100644
--- a/glcddrivers/driver.h
+++ b/glcddrivers/driver.h
@@ -9,22 +9,43 @@
* 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>
*/
#ifndef _GLCDDRIVERS_DRIVER_H_
#define _GLCDDRIVERS_DRIVER_H_
#include <stdint.h>
+#include "../glcdgraphics/bitmap.h"
+
+// for strcasecmp
+#include <strings.h>
namespace GLCD
{
+class cGLCDEvent {
+public:
+ virtual ~cGLCDEvent() {}
+};
+
+class cSimpleTouchEvent : public cGLCDEvent {
+public:
+ int x;
+ int y;
+ int touch;
+ cSimpleTouchEvent();
+};
+
+
class cDriver
{
protected:
int width;
int height;
+
+ virtual bool GetDriverFeature (const std::string & Feature, int & value) { return false; }
public:
cDriver();
virtual ~cDriver() {}
@@ -36,11 +57,55 @@ public:
virtual int DeInit() { return 0; }
virtual void Clear() {}
+ virtual void SetPixel(int x, int y, uint32_t data) {}
virtual void Set8Pixels(int x, int y, unsigned char data) {}
- virtual void SetScreen(const unsigned char * data, int width, int height, int lineSize);
+// virtual void SetScreen(const unsigned char * data, int width, int height, int lineSize);
+ virtual void SetScreen(const uint32_t *data, int width, int height);
virtual void Refresh(bool refreshAll = false) {}
virtual void SetBrightness(unsigned int percent) {}
+
+ virtual GLCD::cColor GetBackgroundColor(void) { return GLCD::cColor(GLCD::cColor::White); }
+
+ virtual bool SetFeature (const std::string & Feature, int value) { return false; }
+
+ GLCD::cColor GetForegroundColor(void) {
+ return GLCD::cColor(GetBackgroundColor()).Invert();
+ }
+
+ // not to be overridden, override GetDriverFeature() instead
+ // the following feature names (case insensitive!) are guaranteed to give results:
+ // 'depth' colour depth, default: 1
+ // 'ismonochrome' is lcd a monochrome display?, default: true (1)
+ // the following feature names are pre-defined but default to false (0)
+ // 'isgreyscale', 'isgrayscale' is lcd a greyscale display?
+ // 'iscolour', 'iscolor' is lcd a colour display?
+ // 'touch', 'touchscreen' is a touchscreen supported and available?
+ bool GetFeature (const std::string & Feature, int & value) {
+ if (GetDriverFeature(Feature, value)) {
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "depth") == 0) {
+ value = 1;
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "ismonochrome") == 0) {
+ value = 1; // true == 1, false == 0
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "isgreyscale") == 0 || strcasecmp(Feature.c_str(), "isgrayscale") == 0) {
+ value = 0; // true == 1, false == 0
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "iscolour") == 0 || strcasecmp(Feature.c_str(), "iscolor") == 0) {
+ value = 0; // true == 1, false == 0
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "touch") == 0 || strcasecmp(Feature.c_str(), "touchscreen") == 0) {
+ value = 0; // true == 1, false == 0
+ return true;
+ }
+ value = 0;
+ return false;
+ }
+
+ virtual cGLCDEvent * GetEvent(void) { return NULL; }
+
};
} // end of namespace
diff --git a/glcddrivers/framebuffer.c b/glcddrivers/framebuffer.c
index ef96cde..10ed9fd 100644
--- a/glcddrivers/framebuffer.c
+++ b/glcddrivers/framebuffer.c
@@ -150,7 +150,7 @@ int cDriverFramebuffer::CheckSetup()
return 0;
}
-void cDriverFramebuffer::SetPixel(int x, int y)
+void cDriverFramebuffer::SetPixel(int x, int y, uint32_t data)
{
int location;
int outcol;
@@ -239,7 +239,7 @@ void cDriverFramebuffer::Set8Pixels(int x, int y, unsigned char data)
for (n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/framebuffer.h b/glcddrivers/framebuffer.h
index 79d1d77..12e307c 100644
--- a/glcddrivers/framebuffer.h
+++ b/glcddrivers/framebuffer.h
@@ -37,7 +37,7 @@ private:
int zoom;
int CheckSetup();
- void SetPixel(int x, int y);
+ void SetPixel(int x, int y, uint32_t data);
public:
cDriverFramebuffer(cDriverConfig * config);
diff --git a/glcddrivers/g15daemon.c b/glcddrivers/g15daemon.c
index 91f08c9..28c5569 100644
--- a/glcddrivers/g15daemon.c
+++ b/glcddrivers/g15daemon.c
@@ -33,7 +33,7 @@
#define G15_HEIGHT 43
-static int g15_send(int sock, char *buf, int len)
+static int g15_send(int sock, const char *buf, int len)
{
int total = 0;
int retval = 0;
@@ -180,7 +180,7 @@ int cDriverG15daemon::CheckSetup()
return 0;
}
-void cDriverG15daemon::SetPixel(int x, int y)
+void cDriverG15daemon::SetPixel(int x, int y, uint32_t data)
{
if (x >= width || y >= height)
return;
@@ -208,7 +208,7 @@ void cDriverG15daemon::Set8Pixels(int x, int y, unsigned char data)
for (n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/g15daemon.h b/glcddrivers/g15daemon.h
index c91ef17..33e3381 100644
--- a/glcddrivers/g15daemon.h
+++ b/glcddrivers/g15daemon.h
@@ -30,7 +30,7 @@ private:
int zoom;
int CheckSetup();
- void SetPixel(int x, int y);
+ void SetPixel(int x, int y, uint32_t data);
public:
cDriverG15daemon(cDriverConfig * config);
diff --git a/glcddrivers/gu126x64D-K610A4.c b/glcddrivers/gu126x64D-K610A4.c
index 711e672..049b79f 100644
--- a/glcddrivers/gu126x64D-K610A4.c
+++ b/glcddrivers/gu126x64D-K610A4.c
@@ -417,7 +417,7 @@ int cDriverGU126X64D_K610A4::write(unsigned char data)
} // cDriverGU126X64D_K610A4::write()
//-----------------------------------------------------------------------------
-void cDriverGU126X64D_K610A4::setPixel(int x, int y)
+void cDriverGU126X64D_K610A4::setPixel(int x, int y, uint32_t data)
{
if (!myDrawMem ) return;
if (x >= width || x < 0) return;
@@ -444,7 +444,7 @@ void cDriverGU126X64D_K610A4::Set8Pixels(int x, int y, unsigned char data)
{
if ((data & (0x80 >> n)) != 0) // if bit is set
{
- setPixel(x + n, y);
+ setPixel(x + n, y, GLCD::cColor::White);
} // if
} // for
} // cDriverGU126X64D_K610A4::Set8Pixels()
@@ -796,7 +796,7 @@ int cDriverGU126X64D_K610A4::cmdWriteText(const char *theText)
if (isLogEnabled(LL_VFD_CMD))
{
- syslog(LOG_INFO, "-%2dB: WRITE_TEXT : '%s'", strlen(theText), theText);
+ syslog(LOG_INFO, "-%2dB: WRITE_TEXT : '%s'", (int)strlen(theText), theText);
} // if
for (const char *p = theText; *p != '\0'; ++p)
diff --git a/glcddrivers/gu126x64D-K610A4.h b/glcddrivers/gu126x64D-K610A4.h
index 3d6c29c..439da94 100644
--- a/glcddrivers/gu126x64D-K610A4.h
+++ b/glcddrivers/gu126x64D-K610A4.h
@@ -68,7 +68,7 @@ public:
, FONT_FIX_BIG
};
- void setPixel (int x, int y);
+ void setPixel (int x, int y, uint32_t data);
int cmdReset ();
int cmdPower (bool fOn);
diff --git a/glcddrivers/gu140x32f.c b/glcddrivers/gu140x32f.c
index c3990a3..865d133 100644
--- a/glcddrivers/gu140x32f.c
+++ b/glcddrivers/gu140x32f.c
@@ -326,7 +326,7 @@ void cDriverGU140X32F::Write(unsigned char nFlags, unsigned char bData, unsigned
nSleepDeInit();
}
-void cDriverGU140X32F::SetPixel(int x, int y)
+void cDriverGU140X32F::SetPixel(int x, int y, uint32_t data)
{
unsigned char c;
int n;
@@ -361,7 +361,7 @@ void cDriverGU140X32F::Set8Pixels(int x, int y, unsigned char data)
for (n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/gu140x32f.h b/glcddrivers/gu140x32f.h
index c0b87f2..4e0d1e8 100644
--- a/glcddrivers/gu140x32f.h
+++ b/glcddrivers/gu140x32f.h
@@ -51,7 +51,7 @@ class cDriverGU140X32F : public cDriver
protected:
void ClearVFDMem();
- void SetPixel(int x, int y);
+ void SetPixel(int x, int y, uint32_t data);
void Write(unsigned char nFlags, unsigned char bData, unsigned int nMicroSecBusyTime);
public:
diff --git a/glcddrivers/gu256x64-372.c b/glcddrivers/gu256x64-372.c
index 57ec981..41f5881 100644
--- a/glcddrivers/gu256x64-372.c
+++ b/glcddrivers/gu256x64-372.c
@@ -131,7 +131,7 @@ int cDriverGU256X64_372::Init()
RDLO = kStandardRDLO;
CDHI = kStandardCDHI;
CDLO = kStandardCDLO;
- syslog(LOG_DEBUG, "%s: using standard wiring\n");
+ syslog(LOG_DEBUG, "%s: using standard wiring\n", config->name.c_str());
}
else if (config->options[i].value == kWiringWindows)
{
@@ -141,7 +141,7 @@ int cDriverGU256X64_372::Init()
RDLO = kWindowsRDLO;
CDHI = kWindowsCDHI;
CDLO = kWindowsCDLO;
- syslog(LOG_DEBUG, "%s: using windows wiring\n");
+ syslog(LOG_DEBUG, "%s: using windows wiring\n", config->name.c_str());
}
else
{
@@ -345,7 +345,7 @@ void cDriverGU256X64_372::GU256X64Data(unsigned char data)
nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
}
-void cDriverGU256X64_372::SetPixel(int x, int y)
+void cDriverGU256X64_372::SetPixel(int x, int y, uint32_t data)
{
unsigned char c;
@@ -378,7 +378,7 @@ void cDriverGU256X64_372::Set8Pixels(int x, int y, unsigned char data)
for (n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/gu256x64-372.h b/glcddrivers/gu256x64-372.h
index 7d92561..db63bcb 100644
--- a/glcddrivers/gu256x64-372.h
+++ b/glcddrivers/gu256x64-372.h
@@ -57,7 +57,7 @@ class cDriverGU256X64_372 : public cDriver
protected:
void ClearVFDMem();
- void SetPixel(int x, int y);
+ void SetPixel(int x, int y, uint32_t data);
void GU256X64Cmd(unsigned char data);
void GU256X64Data(unsigned char data);
diff --git a/glcddrivers/gu256x64-3900.c b/glcddrivers/gu256x64-3900.c
index d9279dc..938c01f 100644
--- a/glcddrivers/gu256x64-3900.c
+++ b/glcddrivers/gu256x64-3900.c
@@ -503,7 +503,7 @@ void cDriverGU256X64_3900::Write(unsigned char data)
WriteParallel(data);
}
-void cDriverGU256X64_3900::SetPixel(int x, int y)
+void cDriverGU256X64_3900::SetPixel(int x, int y, uint32_t data)
{
unsigned char c;
@@ -536,7 +536,7 @@ void cDriverGU256X64_3900::Set8Pixels(int x, int y, unsigned char data)
for (n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/gu256x64-3900.h b/glcddrivers/gu256x64-3900.h
index 2201417..163bcef 100644
--- a/glcddrivers/gu256x64-3900.h
+++ b/glcddrivers/gu256x64-3900.h
@@ -59,7 +59,7 @@ class cDriverGU256X64_3900 : public cDriver
protected:
void ClearVFDMem();
- void SetPixel(int x, int y);
+ void SetPixel(int x, int y, uint32_t data);
int InitSerialPort();
int InitParallelPort();
void InitNormalDisplay();
diff --git a/glcddrivers/image.c b/glcddrivers/image.c
index 9c71006..94623c4 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>
@@ -50,12 +52,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;
@@ -121,6 +124,29 @@ void cDriverImage::Set8Pixels(int x, int y, unsigned char data)
}
}
+void cDriverImage::SetPixel(int x, int y, uint32_t data)
+{
+ if (x >= width || y >= height)
+ return;
+
+ if ((data | 0xFF000000) != cColor::Black) {
+ data = cColor::White;
+ }
+
+ if (!config->upsideDown)
+ {
+ // normal orientation
+ newLCD[y * x] |= data;
+ }
+ else
+ {
+ // upside down orientation
+ x = width - 1 - x;
+ y = height - 1 - y;
+ newLCD[y * x] |= ReverseBits(data);
+ }
+}
+
void cDriverImage::Refresh(bool refreshAll)
{
int i;
diff --git a/glcddrivers/image.h b/glcddrivers/image.h
index 3e39e3f..75a2f33 100644
--- a/glcddrivers/image.h
+++ b/glcddrivers/image.h
@@ -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
*/
#ifndef _GLCDDRIVERS_IMAGE_H_
@@ -24,8 +26,8 @@ class cDriverConfig;
class cDriverImage : public cDriver
{
private:
- unsigned char * newLCD;
- unsigned char * oldLCD;
+ uint32_t * newLCD;
+ uint32_t * oldLCD;
cDriverConfig * config;
cDriverConfig * oldConfig;
int lineSize;
@@ -41,6 +43,7 @@ public:
virtual int DeInit();
virtual void Clear();
+ virtual void SetPixel(int x, int y, uint32_t data);
virtual void Set8Pixels(int x, int y, unsigned char data);
virtual void Refresh(bool refreshAll = false);
};
diff --git a/glcddrivers/noritake800.c b/glcddrivers/noritake800.c
index 5a386a5..971bf5e 100644
--- a/glcddrivers/noritake800.c
+++ b/glcddrivers/noritake800.c
@@ -404,7 +404,7 @@ void cDriverNoritake800::N800Data(unsigned char data)
m_pport->WriteControl(LPT_CTL_HI_DIR | m_pWiringMaskCache[0x00]);
}
-void cDriverNoritake800::SetPixel(int x, int y)
+void cDriverNoritake800::SetPixel(int x, int y, uint32_t data)
{
unsigned char c;
@@ -437,7 +437,7 @@ void cDriverNoritake800::Set8Pixels(int x, int y, unsigned char data)
for (n = 0; n < 8; ++n)
{
if (data & (0x80 >> n)) // if bit is set
- SetPixel(x + n, y);
+ SetPixel(x + n, y, GLCD::cColor::White);
}
}
diff --git a/glcddrivers/noritake800.h b/glcddrivers/noritake800.h
index cb2dfb0..e275afe 100644
--- a/glcddrivers/noritake800.h
+++ b/glcddrivers/noritake800.h
@@ -80,7 +80,7 @@ public:
virtual int DeInit();
virtual void Clear();
- virtual void SetPixel(int x, int y);
+ virtual void SetPixel(int x, int y, uint32_t data);
virtual void Set8Pixels(int x, int y, unsigned char data);
virtual void Refresh(bool refreshAll = false);
diff --git a/glcddrivers/serdisp.c b/glcddrivers/serdisp.c
index 7521105..5676bb3 100644
--- a/glcddrivers/serdisp.c
+++ b/glcddrivers/serdisp.c
@@ -7,7 +7,7 @@
* This file is released under the GNU General Public License. Refer
* to the COPYING file distributed with this package.
*
- * (c) 2003-2010 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
+ * (c) 2003-2011 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
*/
#include <stdio.h>
@@ -19,6 +19,9 @@
#include "config.h"
#include "serdisp.h"
+// for memcpy
+#include <string.h>
+
#define SERDISP_VERSION(a,b) ((long)(((a) << 8) + (b)))
#define SERDISP_VERSION_GET_MAJOR(_c) ((int)( (_c) >> 8 ))
#define SERDISP_VERSION_GET_MINOR(_c) ((int)( (_c) & 0xFF ))
@@ -32,15 +35,25 @@
#define SD_COL_BLACK 0xFF000000
#define SD_COL_WHITE 0xFFFFFFFF
+// taken from serdisp_gpevents.h
+#define SDGPT_SIMPLETOUCH 0x10 /* simple touch screen event, type: SDGP_evpkt_simpletouch_t */
+
namespace GLCD
{
+static void wrapEventListener(void* dd, SDGP_event_t* recylce);
+
+static int simpleTouchX=0, simpleTouchY=0, simpleTouchT=0;
+static bool simpleTouchChanged=false;
+
+
cDriverSerDisp::cDriverSerDisp(cDriverConfig * config)
: config(config)
{
oldConfig = new cDriverConfig(*config);
dd = (void *) NULL;
+ simpleTouchChanged = false;
}
cDriverSerDisp::~cDriverSerDisp(void)
@@ -83,95 +96,57 @@ int cDriverSerDisp::Init(void)
fp_serdisp_getversioncode = (long int (*)()) dlsym(sdhnd, "serdisp_getversioncode");
if (dlerror()) { // no serdisp_getversioncode() -> version of serdisplib is < 1.95
- syslog(LOG_DEBUG, "%s: INFO: symbol serdisp_getversioncode unknown: autodetecting pre 1.95 serdisplib version (cDriver::Init)\n",
- config->name.c_str());
-
- fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
- if (dlerror()) { // no SDCONN_open() -> version of serdisplib is < 1.93
- serdisp_version = SERDISP_VERSION(1,92);
- syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version <= 1.92 (cDriver::Init)\n", config->name.c_str());
-
- fp_PP_open = (void*(*)(const char*))dlsym(sdhnd, "PP_open");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "PP_open", errmsg);
- return -1;
- }
- fp_PP_close = (void*(*)(void*))dlsym(sdhnd, "PP_close");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "PP_close", errmsg);
- return -1;
- }
- } else {
- serdisp_version = SERDISP_VERSION(1,94); // no serdisp_getversioncode, but SDCONN_open: 1.93 or 1.94
- syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version 1.93 or 1.94 (cDriver::Init)\n", config->name.c_str());
-
- fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_quit", errmsg);
- return -1;
- }
- }
+ syslog(LOG_ERR, "%s: error: serdisplib version >= 1.95 required\n", config->name.c_str());
+ return -1;
+ }
- fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setpixel");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_setpixel", errmsg);
- return -1;
- }
- fg_colour = 1; /* set foreground to 'pixel on' */
+ serdisp_version = fp_serdisp_getversioncode();
+ syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n",
+ config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version));
- } else { // serdisp version >= 1.95
- serdisp_version = fp_serdisp_getversioncode();
- syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n",
- config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version));
+ fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
+ if ( (errmsg = dlerror()) != NULL ) { // should not happen
+ syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
+ config->name.c_str(), "SDCONN_open", errmsg);
+ return -1;
+ }
+ fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
+ if ( (errmsg = dlerror()) != NULL ) { // should not happen
+ syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
+ config->name.c_str(), "serdisp_quit", errmsg);
+ return -1;
+ }
+ fp_serdisp_setcolour = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour");
+ if ( (errmsg = dlerror()) != NULL ) { // should not happen
+ syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
+ config->name.c_str(), "serdisp_setcolour", errmsg);
+ return -1;
+ }
+ fg_colour = SD_COL_BLACK; /* set foreground colour to black */
+
+ if (serdisp_version >= SERDISP_VERSION(1,96) ) {
+ supports_options = 1;
- fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
+ fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption");
if ( (errmsg = dlerror()) != NULL ) { // should not happen
syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "SDCONN_open", errmsg);
+ config->name.c_str(), "serdisp_isoption", errmsg);
return -1;
}
- fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
+ fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption");
if ( (errmsg = dlerror()) != NULL ) { // should not happen
syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_quit", errmsg);
+ config->name.c_str(), "serdisp_setoption", errmsg);
return -1;
}
- fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour");
+ fp_serdisp_getoption = (long int (*)(void*, const char*, int*)) dlsym(sdhnd, "serdisp_getoption");
if ( (errmsg = dlerror()) != NULL ) { // should not happen
syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_setcolour", errmsg);
+ config->name.c_str(), "serdisp_getoption", errmsg);
return -1;
}
- fg_colour = SD_COL_BLACK; /* set foreground colour to black */
-
- if (serdisp_version >= SERDISP_VERSION(1,96) ) {
- supports_options = 1;
-
- fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_isoption", errmsg);
- return -1;
- }
- fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_setoption", errmsg);
- return -1;
- }
- fp_serdisp_getoption = (long int (*)(void*, const char*, int*)) dlsym(sdhnd, "serdisp_getoption");
- if ( (errmsg = dlerror()) != NULL ) { // should not happen
- syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
- config->name.c_str(), "serdisp_getoption", errmsg);
- return -1;
- }
- } /* >= 1.96 */
- }
+ } /* >= 1.96 */
// load other symbols that will be required
fp_serdisp_init = (void*(*)(void*, const char*, const char*)) dlsym(sdhnd, "serdisp_init");
@@ -230,6 +205,22 @@ int cDriverSerDisp::Init(void)
return -1;
}
+ fp_serdisp_getcolours = (int (*)(void*)) dlsym(sdhnd, "serdisp_getcolours");
+ if ( (errmsg = dlerror()) != NULL ) { // should not happen
+ syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
+ config->name.c_str(), "serdisp_getcolours", errmsg);
+ return -1;
+ }
+
+ // don't care if the following functions are not available
+ fp_serdisp_getdepth = (int (*)(void*)) dlsym(sdhnd, "serdisp_getdepth");
+
+ fp_SDGPI_search = (uint8_t (*)(void*, const char*)) dlsym(sdhnd, "SDGPI_search");
+ fp_SDGPI_isenabled = (int (*)(void*, uint8_t)) dlsym(sdhnd, "SDGPI_isenabled");
+ fp_SDGPI_enable = (int (*)(void*, uint8_t, int)) dlsym(sdhnd, "SDGPI_enable");
+ fp_SDEVLP_add_listener = (int (*)(void*, uint8_t, fp_eventlistener_t)) dlsym(sdhnd, "SDEVLP_add_listener");
+
+
// done loading all required symbols
// setting up the display
@@ -341,7 +332,8 @@ int cDriverSerDisp::Init(void)
fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
} else {
/* standard options */
- fp_serdisp_setoption(dd, "ROTATE", config->upsideDown);
+ if (config->upsideDown)
+ fp_serdisp_setoption(dd, "ROTATE", config->upsideDown);
fp_serdisp_setoption(dd, "CONTRAST", config->contrast);
fp_serdisp_setoption(dd, "BACKLIGHT", config->backlight);
fp_serdisp_setoption(dd, "INVERT", config->invert);
@@ -433,6 +425,7 @@ int cDriverSerDisp::CheckSetup()
update = true;
}
+#if 0
/* driver dependend options */
if ( supports_options ) {
for (unsigned int i = 0; i < config->options.size(); i++) {
@@ -447,7 +440,7 @@ int cDriverSerDisp::CheckSetup()
}
}
}
-
+#endif
if (update)
return 1;
@@ -462,7 +455,7 @@ void cDriverSerDisp::Clear(void)
int x,y;
for (y = 0; y < fp_serdisp_getheight(dd); y++)
for (x = 0; x < fp_serdisp_getwidth(dd); x++)
- fp_serdisp_setpixcol(dd, x, y, bg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
+ fp_serdisp_setcolour(dd, x, y, bg_colour);
}
}
@@ -475,13 +468,50 @@ void cDriverSerDisp::Set8Pixels(int x, int y, unsigned char data) {
for (i = 0; i < 8; i++) {
pixel = data & (1 << i);
- if (pixel)
- fp_serdisp_setpixcol(dd, start + i, y, fg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
- else if (!pixel && bg_colour != -1) /* if bg_colour is set: use it if pixel is not set */
- fp_serdisp_setpixcol(dd, start + i, y, bg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
+ if (pixel) {
+ SetPixel(start + i, y, fg_colour);
+ } else if (!pixel && bg_colour != -1) { /* if bg_colour is set: use it if pixel is not set */
+ SetPixel(start + i, y, bg_colour);
+ }
}
}
+void cDriverSerDisp::SetPixel(int x, int y, uint32_t data)
+{
+ fp_serdisp_setcolour(dd, x, y, data);
+}
+
+#if 0
+// temporarily overwrite SetScreen() until problem with 'to Clear() or not to Clear()' is solved
+void cDriverSerDisp::SetScreen(const unsigned char * data, int wid, int hgt, int lineSize)
+{
+ int x, y;
+
+ if (wid > width)
+ wid = width;
+ if (hgt > height)
+ hgt = height;
+
+ //Clear();
+ if (data)
+ {
+ for (y = 0; y < hgt; y++)
+ {
+ for (x = 0; x < (wid / 8); x++)
+ {
+ Set8Pixels(x * 8, y, data[y * lineSize + x]);
+ }
+ if (width % 8)
+ {
+ Set8Pixels((wid / 8) * 8, y, data[y * lineSize + wid / 8] & bitmaskl[wid % 8 - 1]);
+ }
+ }
+ } else {
+ Clear();
+ }
+}
+#endif
+
void cDriverSerDisp::Refresh(bool refreshAll)
{
if (CheckSetup() == 1)
@@ -494,9 +524,93 @@ void cDriverSerDisp::Refresh(bool refreshAll)
}
void cDriverSerDisp::SetBrightness(unsigned int percent)
-{
+{
if ( supports_options && (fp_serdisp_isoption(dd, "BRIGHTNESS") == 1) ) /* if == 1: option is existing AND r/w */
- fp_serdisp_setoption(dd, "BRIGHTNESS", (long)percent);
+ fp_serdisp_setoption(dd, "BRIGHTNESS", (long)percent);
+}
+
+GLCD::cColor cDriverSerDisp::GetBackgroundColor(void) {
+ if ( supports_options && fp_serdisp_isoption(dd, "SELFEMITTING") && (fp_serdisp_getoption(dd, "SELFEMITTING", 0)) ) {
+ return GLCD::cColor::Black;
+ }
+ return GLCD::cColor::White;
+}
+
+
+bool cDriverSerDisp::SetFeature (const std::string & Feature, int value)
+{
+ if (strcasecmp(Feature.c_str(), "TOUCHSCREEN") == 0 || strcasecmp(Feature.c_str(), "TOUCH") == 0) {
+ if (fp_SDGPI_search && fp_SDGPI_isenabled && fp_SDGPI_enable) {
+ uint8_t gpid = fp_SDGPI_search(dd, Feature.c_str());
+ if (gpid == 0xFF)
+ return false;
+
+ int ena = fp_SDGPI_isenabled(dd, gpid);
+ bool enable = (value == 1) ? true : false;
+ if (ena == enable) { // already enabled or disabled
+ return true;
+ } else {
+ bool rc = (fp_SDGPI_enable(dd, gpid, ((enable) ? 1 : 0)) >= 0) ? true : false;
+
+ if (enable && rc && fp_SDEVLP_add_listener) {
+ fp_SDEVLP_add_listener(dd, gpid, wrapEventListener);
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool cDriverSerDisp::GetDriverFeature (const std::string & Feature, int & value) {
+ if (dd) {
+ if (strcasecmp(Feature.c_str(), "depth") == 0) {
+ value = fp_serdisp_getdepth(dd);
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "ismonochrome") == 0) {
+ value = (fp_serdisp_getdepth(dd) == 1) ? 1 : 0;
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "isgreyscale") == 0 || strcasecmp(Feature.c_str(), "isgrayscale") == 0) {
+ value = (fp_serdisp_getdepth(dd) > 1 && fp_serdisp_getdepth(dd) < 8) ? 1 : 0;
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "iscolour") == 0 || strcasecmp(Feature.c_str(), "iscolor") == 0) {
+ value = (fp_serdisp_getdepth(dd) >= 8) ? 1 : 0;
+ return true;
+ } else if (strcasecmp(Feature.c_str(), "touch") == 0 || strcasecmp(Feature.c_str(), "touchscreen") == 0) {
+ if (fp_SDGPI_search && fp_SDGPI_isenabled) {
+ uint8_t gpid = fp_SDGPI_search(dd, Feature.c_str());
+ value = (gpid != 0xFF && fp_SDGPI_isenabled(dd, gpid)) ? 1 : 0;
+ }
+ return true;
+ }
+ }
+ value = 0;
+ return false;
+}
+
+cGLCDEvent * cDriverSerDisp::GetEvent(void) {
+ if (GLCD::simpleTouchChanged == false)
+ return NULL;
+
+ cSimpleTouchEvent * ev = new cSimpleTouchEvent();
+
+ ev->x = simpleTouchX;
+ ev->y = simpleTouchY;
+ ev->touch = simpleTouchT;
+ simpleTouchChanged = false;
+ return ev;
+}
+
+static void wrapEventListener(void* dd, SDGP_event_t* event) {
+ if (!event) return;
+ if (event->type == SDGPT_SIMPLETOUCH) {
+ SDGP_evpkt_simpletouch_t simpletouch;
+ memcpy(&simpletouch, &event->data, sizeof(SDGP_evpkt_simpletouch_t));
+ simpleTouchChanged = true;
+ simpleTouchX = simpletouch.norm_x;
+ simpleTouchY = simpletouch.norm_y;
+ simpleTouchT = simpletouch.norm_touch;
+ }
}
} // end of namespace
diff --git a/glcddrivers/serdisp.h b/glcddrivers/serdisp.h
index c84874e..99ca09b 100644
--- a/glcddrivers/serdisp.h
+++ b/glcddrivers/serdisp.h
@@ -7,18 +7,52 @@
* This file is released under the GNU General Public License. Refer
* to the COPYING file distributed with this package.
*
- * (c) 2003-2010 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
+ * (c) 2003-2011 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
*/
#ifndef _GLCDDRIVERS_SERDISP_H_
#define _GLCDDRIVERS_SERDISP_H_
#include "driver.h"
-
+#include <sys/time.h>
namespace GLCD
{
+/* event-type for GPIs, GPOs, and data exchange messages. min. size: 16 byte, max size: 12 + 64) */
+typedef struct SDGP_event_s { /* 16 to 78 bytes */
+ /* byte 0 */
+ uint8_t type; /* one of SDGPT_* */
+ uint8_t cmdid; /* command-ID (one of SD_CMD_*) */
+ uint8_t devid; /* device ID, 0 == local */
+ uint8_t subid; /* gp-ID or page-ID */
+ /* byte 4 */
+ struct timeval timestamp; /* timestamp (8 bytes) */
+ /* byte 12 */
+ union {
+ int32_t value; /* if single value event: value */
+ struct { /* if streaming event or package: */
+ uint16_t length; /* length of stream if known or 0 if some stop tag is used */
+ uint8_t word_size; /* stream elements are bytes/chars (0 or 1), shorts (2), or longs (4) */
+ uint8_t _reserved; /* reserved for later use */
+ };
+ uint8_t data[64]; /* if data-package type: max. 64 byte payload */
+ };
+} SDGP_event_t;
+
+/* event-payload-type for simple touchscreen events (no multitouch or similar) */
+typedef struct SDGP_evpkt_simpletouch_s { /* 16 bytes */
+ /* 12 bytes */
+ int16_t raw_x; /* raw coordinate X */
+ int16_t raw_y; /* raw coordinate Y */
+ int16_t raw_touch; /* raw touch value */
+ int16_t norm_x; /* normalised coordinate X (norm_x <= dd->width) */
+ int16_t norm_y; /* normalised coordinate Y (norm_y <= dd->height) */
+ int16_t norm_touch; /* normalised touch value */
+} SDGP_evpkt_simpletouch_t;
+
+typedef void (*fp_eventlistener_t) (void* dd, SDGP_event_t* recylce);
+
class cDriverConfig;
class cDriverSerDisp : public cDriver
@@ -49,18 +83,29 @@ private:
void (*fp_serdisp_rewrite) (void* dd);
void (*fp_serdisp_update) (void* dd);
void (*fp_serdisp_clearbuffer) (void* dd);
- void (*fp_serdisp_setpixcol) (void* dd, int x, int y, long colour); // serdisp_setpixel or serdisp_setcolour
+ void (*fp_serdisp_setcolour) (void* dd, int x, int y, long colour);
int (*fp_serdisp_feature) (void* dd, int feature, int value);
int (*fp_serdisp_isoption) (void* dd, const char* optionname);
void (*fp_serdisp_setoption) (void* dd, const char* optionname, long value);
long (*fp_serdisp_getoption) (void* dd, const char* optionname, int* typesize);
int (*fp_serdisp_getwidth) (void* dd);
int (*fp_serdisp_getheight) (void* dd);
+ int (*fp_serdisp_getcolours) (void* dd);
+ int (*fp_serdisp_getdepth) (void* dd);
void (*fp_serdisp_quit) (void* dd);
void (*fp_serdisp_close) (void* dd);
+ uint8_t (*fp_SDGPI_search) (void* dd, const char* gpname);
+ int (*fp_SDGPI_isenabled) (void* dd, uint8_t gpid);
+ int (*fp_SDGPI_enable) (void* dd, uint8_t gpid, int enable);
+ int (*fp_SDEVLP_add_listener) (void* dd, uint8_t gpid, fp_eventlistener_t eventlistener );
int CheckSetup();
+ void eventListener (void* dd, SDGP_event_t* recycle);
+
+protected:
+ virtual bool GetDriverFeature (const std::string & Feature, int & value);
+
public:
cDriverSerDisp(cDriverConfig * config);
@@ -70,11 +115,22 @@ public:
virtual int DeInit();
virtual void Clear();
+ virtual void SetPixel(int x, int y, uint32_t data);
virtual void Set8Pixels(int x, int y, unsigned char data);
+#if 0
+ virtual void SetScreen(const unsigned char * data, int width, int height, int lineSize);
+#endif
virtual void Refresh(bool refreshAll = false);
virtual void SetBrightness(unsigned int percent);
+
+ virtual GLCD::cColor GetBackgroundColor(void);
+
+ virtual bool SetFeature (const std::string & Feature, int value);
+
+ virtual cGLCDEvent * GetEvent(void);
+
};
+} // end of namespace
#endif
-} // end of namespace