summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReelfan <37248793+Reelfan@users.noreply.github.com>2018-03-18 10:48:47 +0100
committerManuel Reimer <manuel.reimer@gmx.de>2018-03-18 10:50:59 +0100
commit6bb3061934726f626d9179137e10f6ec0a1534d0 (patch)
treebab3ecaf30e1b566dbf95f3ad365665fc2b4631b
parent57a396cc74df2538ec40fed26b36d01af8a9b132 (diff)
downloadgraphlcd-base-6bb3061934726f626d9179137e10f6ec0a1534d0.tar.gz
graphlcd-base-6bb3061934726f626d9179137e10f6ec0a1534d0.tar.bz2
Add st7565r-reel driver
-rw-r--r--HISTORY3
-rw-r--r--README1
-rw-r--r--docs/DRIVER.st7565r-reel38
-rw-r--r--glcddrivers/Makefile2
-rw-r--r--glcddrivers/drivers.c4
-rw-r--r--glcddrivers/drivers.h1
-rw-r--r--glcddrivers/st7565r-reel.c342
-rw-r--r--glcddrivers/st7565r-reel.h69
-rw-r--r--graphlcd.conf9
9 files changed, 468 insertions, 1 deletions
diff --git a/HISTORY b/HISTORY
index 0d4251d..3482aec 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,6 +1,9 @@
GraphLCD base package Revision History
--------------------------------------
+2018-03-16:
+- New driver "st7565r-reel"
+
2018-03-02:
- New driver "usbserlcd". With this driver it is possible to diy an USB LCD.
See also: https://github.com/M-Reimer/usbserlcd/
diff --git a/README b/README
index 99b6d6c..00197ee 100644
--- a/README
+++ b/README
@@ -27,6 +27,7 @@ based on the graphlcd plugin for the Video Disc Recorder
futaba dm140 driver by Stephan Skrodzki (skrodzki AT stevekist.de)
futaba md166 driver by Andreas Brachold <vdr07 AT deltab de>
usbserlcd driver by Manuel Reimer <manuel.reimer AT gmx.de>
+ st7565r-reel driver by Georg Acher, BayCom GmbH based on simlcd.c by Carsten Siebholz, ported by Ufuk Altinkaynak
Project's homepage: https://projects.vdr-developer.org/projects/graphlcd-base
GIT repo: https://projects.vdr-developer.org/git/graphlcd-base.git
diff --git a/docs/DRIVER.st7565r-reel b/docs/DRIVER.st7565r-reel
new file mode 100644
index 0000000..ac08014
--- /dev/null
+++ b/docs/DRIVER.st7565r-reel
@@ -0,0 +1,38 @@
+---------------------------------------------------------------------
+GraphLCD driver library
+
+The ST7565R-REEL driver
+---------------------------------------------------------------------
+
+Description
+-----------
+The ST7565R-REEL driver supports the Reelbox Frontpanel LCD Displays.
+Connection is Serial
+
+
+Configuration Parameters
+------------------------
+The ST7565R-REEL driver supports the following parameters in config
+file:
+
+Device
+ In a Reelbox enviroment the serial port was linked to /dev/frontpanel
+ Connected to "normal pc" use serial port for example /dev/ttyS0
+
+Width
+ Sets the horizontal size of the display. If this parameter is not
+ given, a default value of 128 pixels is used.
+
+Height
+ Sets the vertical size of the display. If this parameter is not
+ given, a default value of 64 pixels is used.
+
+Brightness
+ Sets the brightness of your display's backlight.
+ Possible values: 0 <= x <= 100)
+ Default value: 100
+
+Contrast
+ Sets the contrast of your display's.
+ Possible values: 0 <= x <= 100)
+ Default value: 100
diff --git a/glcddrivers/Makefile b/glcddrivers/Makefile
index 2e5b64c..155ce98 100644
--- a/glcddrivers/Makefile
+++ b/glcddrivers/Makefile
@@ -14,7 +14,7 @@ BASENAME = libglcddrivers.so
LIBNAME = $(BASENAME).$(VERMAJOR).$(VERMINOR).$(VERMICRO)
-OBJS = common.o config.o driver.o drivers.o port.o simlcd.o framebuffer.o gu140x32f.o gu256x64-372.o gu256x64-3900.o hd61830.o ks0108.o image.o sed1330.o sed1520.o t6963c.o noritake800.o serdisp.o avrctl.o g15daemon.o network.o gu126x64D-K610A4.o dm140gink.o usbserlcd.o
+OBJS = common.o config.o driver.o drivers.o port.o simlcd.o framebuffer.o gu140x32f.o gu256x64-372.o gu256x64-3900.o hd61830.o ks0108.o image.o sed1330.o sed1520.o t6963c.o noritake800.o serdisp.o avrctl.o g15daemon.o network.o gu126x64D-K610A4.o dm140gink.o usbserlcd.o st7565r-reel.o
HEADERS = config.h driver.h drivers.h
diff --git a/glcddrivers/drivers.c b/glcddrivers/drivers.c
index ca1c30b..61fee82 100644
--- a/glcddrivers/drivers.c
+++ b/glcddrivers/drivers.c
@@ -31,6 +31,7 @@
#include "serdisp.h"
#include "g15daemon.h"
#include "usbserlcd.h"
+#include "st7565r-reel.h"
#ifdef HAVE_LIBHID
#include "futabaMDM166A.h"
#endif
@@ -72,6 +73,7 @@ tDriver drivers[] =
{"gu126x64D-K610A4", kDriverGU126X64D_K610A4},
{"dm140gink", kDriverDM140GINK},
{"usbserlcd", kDriverUSBserLCD},
+ {"st7565r-reel", kDriverST7565RReel},
#ifdef HAVE_LIBHID
{"futabaMDM166A", kDriverFutabaMDM166A},
#endif
@@ -148,6 +150,8 @@ cDriver * CreateDriver(int driverID, cDriverConfig * config)
return new cDriverDM140GINK(config);
case kDriverUSBserLCD:
return new cDriverUSBserLCD(config);
+ case kDriverST7565RReel:
+ return new cDriverST7565RReel(config);
#ifdef HAVE_LIBHID
case kDriverFutabaMDM166A:
return new cDriverFutabaMDM166A(config);
diff --git a/glcddrivers/drivers.h b/glcddrivers/drivers.h
index 99d9f82..cae3091 100644
--- a/glcddrivers/drivers.h
+++ b/glcddrivers/drivers.h
@@ -57,6 +57,7 @@ enum eDriver
kDriverILI9341 = 22,
#endif
kDriverUSBserLCD = 23,
+ kDriverST7565RReel = 24,
kDriverSerDisp = 100,
kDriverG15daemon = 200
};
diff --git a/glcddrivers/st7565r-reel.c b/glcddrivers/st7565r-reel.c
new file mode 100644
index 0000000..1890a7a
--- /dev/null
+++ b/glcddrivers/st7565r-reel.c
@@ -0,0 +1,342 @@
+/**
+ * GraphLCD driver library
+ *
+ * st7565-reel.c - Plugin for ST7565 display on Reelbox
+ * driven by an AVR on the front panel
+ *
+ * (c) 2004 Georg Acher, BayCom GmbH, http://www.baycom.de
+ * based on simlcd.c by Carsten Siebholz
+ **/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; *
+ * if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ * *
+ ***************************************************************************/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <syslog.h>
+#include <termios.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <inttypes.h>
+
+#include "common.h"
+#include "config.h"
+
+#include "st7565r-reel.h"
+#include "port.h"
+
+
+namespace GLCD
+{
+
+cDriverST7565RReel::cDriverST7565RReel(cDriverConfig * config) : cDriver(config)
+{
+}
+
+
+int cDriverST7565RReel::Init(void)
+{
+ width = config->width;
+ if (width < 0)
+ width = 128;
+ height = config->height;
+ if (height < 0)
+ height = 64;
+
+ for (unsigned int i = 0; i < config->options.size(); i++)
+ {
+ if (config->options[i].name == "")
+ {
+ }
+ }
+
+ // setup lcd array
+ LCD = new uint32_t *[width];
+ if (LCD)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ LCD[x] = new uint32_t[height];
+ }
+ }
+
+ int bdflag=B115200;
+ struct termios tty;
+ fd = open(config->device.c_str(), O_RDWR|O_NONBLOCK|O_NOCTTY);
+ fcntl(fd,F_SETFL,0);
+
+ tcgetattr(fd, &tty);
+ tty.c_iflag = IGNBRK | IGNPAR;
+ tty.c_oflag = 0;
+ tty.c_lflag = 0;
+ tty.c_line = 0;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 1;
+ tty.c_cflag = CS8|CREAD|HUPCL;
+ cfsetispeed(&tty,bdflag);
+ cfsetospeed(&tty,bdflag);
+ tcsetattr(fd, TCSAFLUSH, &tty);
+
+ *oldConfig = *config;
+ set_displaymode(0);
+ set_clock();
+ // clear display
+ Clear();
+
+ syslog(LOG_INFO, "%s: ST7565R initialized.\n", config->name.c_str());
+ return 0;
+}
+
+int cDriverST7565RReel::DeInit(void)
+{
+ // free lcd array
+
+ if (fd>0)
+ {
+// clear_display();
+// set_displaymode(1); // Clock
+// syslog(LOG_INFO, "deint.\n");
+ close(fd);
+ }
+
+ // free lcd array
+ if (LCD)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ delete[] LCD[x];
+ }
+ delete[] LCD;
+ }
+
+ return 0;
+}
+
+
+int cDriverST7565RReel::CheckSetup(void)
+{
+ if (config->device != oldConfig->device ||
+ config->width != oldConfig->width ||
+ config->height != oldConfig->height)
+ {
+ DeInit();
+ Init();
+ return 0;
+ }
+ if (config->brightness != oldConfig->brightness)
+ {
+ oldConfig->brightness = config->brightness;
+ SetBrightness(config->brightness);
+ usleep(500000);
+ }
+ if (config->contrast != oldConfig->contrast)
+ {
+ oldConfig->contrast = config->contrast;
+ SetContrast(config->contrast);
+ }
+ if (config->upsideDown != oldConfig->upsideDown ||
+ config->invert != oldConfig->invert)
+ {
+ oldConfig->upsideDown = config->upsideDown;
+ oldConfig->invert = config->invert;
+ return 1;
+ }
+ return 0;
+}
+
+
+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");
+
+}
+
+void cDriverST7565RReel::SetPixel(int x, int y, uint32_t data)
+/*{
+ if (x > width || y > height)
+ return;
+ if (config->upsideDown)
+ {
+ // upside down orientation
+ x = width - 1 - x;
+ y = height - 1 - y;
+ }
+// syslog(LOG_INFO, "setpixel.\n");
+ LCD[x][y] = data;*/
+{
+ if (x >= width || y >= height)
+ return;
+
+ 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)
+ LCD[x / 8][y] |= (1 << pos);
+ else
+ LCD[x / 8][y] &= ( 0xFF ^ (1 << pos) );
+}
+
+void cDriverST7565RReel::Refresh(bool refreshAll)
+{
+ int x,y,xx,yy;
+ int i;
+ unsigned char c;
+ int rx;
+ int invert;
+
+ CheckSetup();
+ if (!LCD)
+ return;
+ invert=(config->invert != 0) ? 0xff : 0x00;
+ if (fd>=0)
+ {
+ for (y = 0; y < (height); y+=8)
+ {
+ display_cmd( 0xb0+((y/8)&15));
+ for (x = 0; x < width / 8; x+=4)
+ {
+ unsigned char d[32]={0};
+
+ for(yy=0;yy<8;yy++)
+ {
+ for (xx=0;xx<4;xx++)
+ {
+ c = (LCD[x+xx][y+yy])^invert;
+
+ for (i = 0; i < 8; i++)
+ {
+ d[i+xx*8]>>=1;
+ if (c & 0x80)
+ d[i+xx*8]|=0x80;
+ c<<=1;
+ }
+ }
+ }
+ rx=4+x*8;
+// printf("X %i, y%i\n",rx,y);
+
+ display_cmd( 0x10+((rx>>4)&15));
+ display_cmd( 0x00+(rx&15));
+ display_data( d,32);
+ }
+ }
+ }
+// syslog(LOG_INFO, "refresh.\n");
+}
+void cDriverST7565RReel::Set8Pixels(int x, int y, unsigned char data)
+{
+ if (!LCD)
+ return;
+
+ clip(x, 0, width - 1);
+ clip(y, 0, height - 1);
+
+ if (1) // !config->upsideDown)
+ {
+ // normal orientation
+// syslog(LOG_INFO, "%s: set8pixel normal.\n");
+ LCD[x / 8][y] = LCD[x / 8][y] | data;
+ }
+ else
+ {
+ // upside down orientation
+ x = width - 1 - x;
+ y = height - 1 - y;
+// syslog(LOG_INFO, "%s: set8pixel flip.\n", LCD);
+ LCD[x /8][y] = LCD[x / 8][y] | ReverseBits(data);
+ }
+}
+
+void cDriverST7565RReel::display_cmd( unsigned char cmd)
+{
+ unsigned char buf[]={0xa5, 0x05, 3, 0, cmd};
+ write(fd,buf,5);
+// syslog(LOG_INFO, "%s: display cmd.\n", cmd);
+}
+
+void cDriverST7565RReel::display_data( unsigned char *data, int l)
+{
+ unsigned char buf[64]={0xa5,0x05,l+2,+1};
+ memcpy(buf+4,data,l);
+ write(fd,buf,l+4);
+// syslog(LOG_INFO, "%s: display data.\n", data);
+}
+void cDriverST7565RReel::set_displaymode(int m)
+{
+ char buf[]={0xa5,0x09,m};
+ write(fd,buf,3);
+// syslog(LOG_INFO, "displaymode.\n");
+}
+
+void cDriverST7565RReel::set_clock(void)
+{
+ time_t t;
+ struct tm tm;
+ t=time(0);
+ localtime_r(&t,&tm);
+ {
+ char buf[]={0xa5,0x7,tm.tm_hour,tm.tm_min,tm.tm_sec,
+ t>>24,t>>16,t>>8,t};
+ write(fd,buf,9);
+ }
+// syslog(LOG_INFO, "set_clock cmd.\n");
+}
+
+void cDriverST7565RReel::clear_display(void)
+{
+ char buf[]={0xa5,0x04};
+ write(fd,buf,2);
+// syslog(LOG_INFO, "clear_display cmd.\n");
+}
+
+void cDriverST7565RReel::SetBrightness(unsigned int percent)
+{
+ char buf[]={0xa5,0x02, 0x00, 0x00};
+ int n=static_cast<int>(percent*2.5);
+ if (n>255)
+ n=255;
+ buf[2]=(char)(n);
+ write(fd,buf,4);
+}
+
+void cDriverST7565RReel::SetContrast(unsigned int val)
+{
+ char buf[]={0xa5,0x03, 0x00, 0x00};
+ buf[2]=(char)(val*25);
+ write(fd,buf,4);
+}
+
+
+}
diff --git a/glcddrivers/st7565r-reel.h b/glcddrivers/st7565r-reel.h
new file mode 100644
index 0000000..b1e6cd5
--- /dev/null
+++ b/glcddrivers/st7565r-reel.h
@@ -0,0 +1,69 @@
+/**
+ * GraphLCD driver library
+ *
+ * st7565-reel.h - Plugin for ST7565 display on Reelbox
+ * driven by an AVR on the front panel
+ *
+ * (c) 2004 Georg Acher, BayCom GmbH, http://www.baycom.de
+ * based on simlcd by Carsten Siebholz
+ **/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; *
+ * if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ * *
+ ***************************************************************************/
+
+#ifndef _LIBGRAPHLCD_ST7565_H_
+#define _LIBGRAPHLCD_ST7565_H_
+
+#include "driver.h"
+#include "unistd.h"
+
+namespace GLCD
+{
+
+class cDriverConfig;
+
+class cDriverST7565RReel : public cDriver
+{
+private:
+ int fd;
+ uint32_t ** LCD;
+ int CheckSetup(void);
+ void display_cmd(unsigned char cmd);
+ void display_data(unsigned char *data, int l);
+ void set_displaymode(int m);
+ void set_clock(void);
+ void clear_display(void);
+
+public:
+ cDriverST7565RReel(cDriverConfig * config);
+
+ virtual int Init();
+ 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);
+ virtual void SetBrightness(unsigned int percent);
+ virtual void SetContrast(unsigned int percent);
+};
+
+}
+
+#endif
diff --git a/graphlcd.conf b/graphlcd.conf
index ad9a573..becdd54 100644
--- a/graphlcd.conf
+++ b/graphlcd.conf
@@ -725,3 +725,12 @@ Backlight=yes
Driver=usbserlcd
Device=/dev/ttyUSB0
RefreshDisplay=0
+
+[st7565r-reel]
+# st7565r driver
+# This is a driver module for the ST7565R based Reelbox frontpanel LCD
+# Default size: 128 x 64
+Driver=st7565r-reel
+Device=/dev/ttyS0
+Brightness=100
+Contrast=80