aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2014-08-20 00:39:52 +0200
committerJoel Bodenmann <joel@unormal.org>2014-08-20 00:39:52 +0200
commitbf164b4583983edc06d47c7694c698eb6b2dfb90 (patch)
treed4d292a121930dde6a3ed72164fe1fc1fe57c746
parent3b21507274aa4f98644382903ae529c1fc2c7bd4 (diff)
downloaduGFX-bf164b4583983edc06d47c7694c698eb6b2dfb90.tar.gz
uGFX-bf164b4583983edc06d47c7694c698eb6b2dfb90.tar.bz2
uGFX-bf164b4583983edc06d47c7694c698eb6b2dfb90.zip
added SPFD54124B driver by user shilow
-rw-r--r--docs/releases.txt1
-rw-r--r--drivers/gdisp/SPFD54124B/board_SPFD54124B_template.h56
-rw-r--r--drivers/gdisp/SPFD54124B/gdisp_lld.mk2
-rw-r--r--drivers/gdisp/SPFD54124B/gdisp_lld_SPFD54124B.c277
-rw-r--r--drivers/gdisp/SPFD54124B/gdisp_lld_config.h73
5 files changed, 409 insertions, 0 deletions
diff --git a/docs/releases.txt b/docs/releases.txt
index 8af1409b..3654dba0 100644
--- a/docs/releases.txt
+++ b/docs/releases.txt
@@ -25,6 +25,7 @@ FEATURE: Prevent mouse events going to obscured widgets
FEATURE: Add GFILE support for file lists
FEATURE: Add GFILE support for C strings as files
FEATURE: Add GFILE support for PetitFS
+FEATURE: Added SPFD54124B GDISP driver by user shilow
*** Release 2.1 ***
diff --git a/drivers/gdisp/SPFD54124B/board_SPFD54124B_template.h b/drivers/gdisp/SPFD54124B/board_SPFD54124B_template.h
new file mode 100644
index 00000000..a8acf718
--- /dev/null
+++ b/drivers/gdisp/SPFD54124B/board_SPFD54124B_template.h
@@ -0,0 +1,56 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+static inline void init_board(GDisplay *g)
+{
+ (void) g;
+}
+
+static inline void post_init_board(GDisplay *g)
+{
+ (void) g;
+}
+
+static inline void setpin_reset(GDisplay *g, bool_t state)
+{
+ (void) g;
+ (void) state;
+}
+
+static inline void set_backlight(GDisplay *g, uint8_t percent)
+{
+ (void) g;
+ (void) percent;
+}
+
+static inline void acquire_bus(GDisplay *g)
+{
+ (void) g;
+}
+
+static inline void release_bus(GDisplay *g)
+{
+ (void) g;
+}
+
+static inline void write_index(GDisplay *g, uint16_t index)
+{
+ (void) g;
+ (void) index;
+}
+
+static inline void write_data(GDisplay *g, uint16_t data)
+{
+ (void) g;
+ (void) data;
+}
+
+#endif /* _GDISP_LLD_BOARD_H */
+
diff --git a/drivers/gdisp/SPFD54124B/gdisp_lld.mk b/drivers/gdisp/SPFD54124B/gdisp_lld.mk
new file mode 100644
index 00000000..f5a34259
--- /dev/null
+++ b/drivers/gdisp/SPFD54124B/gdisp_lld.mk
@@ -0,0 +1,2 @@
+GFXINC += $(GFXLIB)/drivers/gdisp/SPFD54124B
+GFXSRC += $(GFXLIB)/drivers/gdisp/SPFD54124B/gdisp_lld_SPFD54124B.c
diff --git a/drivers/gdisp/SPFD54124B/gdisp_lld_SPFD54124B.c b/drivers/gdisp/SPFD54124B/gdisp_lld_SPFD54124B.c
new file mode 100644
index 00000000..9744f883
--- /dev/null
+++ b/drivers/gdisp/SPFD54124B/gdisp_lld_SPFD54124B.c
@@ -0,0 +1,277 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ *
+ * Driver for display from Nokia 1616 phone
+ * based on the work of axillent@gmail.com (http://radiokot.ru/articles/53/)
+ * adapted by shilow@ukr.net with the help of Federico Reds <fede.677387@hotmail.it>
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GDISP
+
+#if defined(GDISP_SCREEN_HEIGHT)
+#warning "GDISP: This low level driver does not support setting a screen size. It is being ignored."
+#undef GDISP_SCREEN_HEIGHT
+#endif
+#if defined(GDISP_SCREEN_WIDTH)
+#warning "GDISP: This low level driver does not support setting a screen size. It is being ignored."
+#undef GDISP_SCREEN_WIDTH
+#endif
+
+#include "drivers/gdisp/SPFD54124B/gdisp_lld_config.h"
+#include "src/gdisp/driver.h"
+
+#include "board_SPFD54124B.h"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+// Set parameters if they are not already set
+#ifndef GDISP_SCREEN_HEIGHT
+#define GDISP_SCREEN_HEIGHT 161
+#endif
+#ifndef GDISP_SCREEN_WIDTH
+#define GDISP_SCREEN_WIDTH 129
+#endif
+/* Offset in RAM of visible area */
+#ifndef GDISP_RAM_X_OFFSET
+#define GDISP_RAM_X_OFFSET 2
+#endif
+/* Offset in RAM of visible area */
+#ifndef GDISP_RAM_Y_OFFSET
+#define GDISP_RAM_Y_OFFSET 1
+#endif
+#ifndef GDISP_SLEEP_POS
+#define GDISP_SLEEP_POS ((GDISP_SCAN_LINES-GDISP_SLEEP_SIZE)/2 & ~3)
+#endif
+#ifndef GDISP_INITIAL_CONTRAST
+#define GDISP_INITIAL_CONTRAST 50
+#endif
+#ifndef GDISP_INITIAL_BACKLIGHT
+#define GDISP_INITIAL_BACKLIGHT 100
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+// Use the priv pointer itself to save our color. This save allocating ram for it
+// and works provided sizeof(uint16_t) <= sizeof(void *)
+#define savecolor(g) (*(uint16_t *)&g->priv)
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+// Some macros just to make reading the code easier
+#define delayms(ms) gfxSleepMilliseconds(ms)
+#define write_data2(g, d1, d2) { write_data(g, d1); write_data(g, d2); }
+#define write_data3(g, d1, d2, d3) { write_data(g, d1); write_data(g, d2); write_data(g, d3); }
+#define write_reg(g, cmd, d1) { write_index(g, cmd); write_data(g, d1); }
+#define write_reg2(g, cmd, d1, d2) { write_index(g, cmd); write_data2(g, d1, d2); }
+#define write_reg3(g, cmd, d1, d2, d3) { write_index(g, cmd); write_data3(g, d1, d2, d3); }
+
+static inline void set_viewport(GDisplay* g)
+{
+ write_reg2(g, SPFD54124B_CMD_CASET, GDISP_RAM_X_OFFSET+g->p.x, GDISP_RAM_X_OFFSET+g->p.x+g->p.cx-1); // Column address set
+ write_reg2(g, SPFD54124B_CMD_RASET, GDISP_RAM_Y_OFFSET+g->p.y, GDISP_RAM_Y_OFFSET+g->p.y+g->p.cy-1); // Page address set
+ write_index(g, SPFD54124B_CMD_RAMWR);
+}
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+const uint16_t lcd_init_list[] = {
+ SPFD54124B_CMD_SLPOUT,
+ SPFD54124B_CMD_COLMOD, SPFD54124B_SEND_DATA | SPFD54124B_CMD_COLMOD_MCU16bit,
+ SPFD54124B_CMD_DISPON,
+ SPFD54124B_CMD_INVOFF,
+ SPFD54124B_CMD_NORON
+};
+
+LLDSPEC bool_t gdisp_lld_init(GDisplay *g)
+{
+ // No private area for this controller
+ g->priv = 0;
+
+ // Initialise the board interface
+ init_board(g);
+
+ // Hardware reset
+ setpin_reset(g, TRUE);
+ delayms(100);
+ setpin_reset(g, FALSE);
+ delayms(100);
+
+ acquire_bus(g);
+
+ const uint16_t *list = &lcd_init_list[0];
+ uint8_t size = sizeof(lcd_init_list) / sizeof(lcd_init_list[0]);
+
+ while(size--) {
+ write_index(g, *list++);
+ }
+
+ // Finish Init
+ post_init_board(g);
+
+ release_bus(g);
+
+ // Turn on the back-light
+ set_backlight(g, GDISP_INITIAL_BACKLIGHT);
+
+ // Initialise the GDISP structure to match
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Orientation = GDISP_ROTATE_0;
+ g->g.Powermode = powerOn;
+ g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
+ g->g.Contrast = GDISP_INITIAL_CONTRAST;
+
+ return TRUE;
+}
+
+#if GDISP_HARDWARE_STREAM_WRITE
+LLDSPEC void gdisp_lld_write_start(GDisplay *g)
+{
+ acquire_bus(g);
+ set_viewport(g);
+}
+
+LLDSPEC void gdisp_lld_write_color(GDisplay *g)
+{
+ write_data(g, gdispColor2Native(g->p.color));
+}
+
+LLDSPEC void gdisp_lld_write_stop(GDisplay *g)
+{
+ release_bus(g);
+}
+#endif
+
+
+#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
+LLDSPEC void gdisp_lld_control(GDisplay *g)
+{
+ /* The hardware is capable of supporting...
+ * GDISP_CONTROL_POWER - supported
+ * GDISP_CONTROL_ORIENTATION - supported
+ * GDISP_CONTROL_BACKLIGHT - unsupported
+ * GDISP_CONTROL_CONTRAST - unsupported
+ */
+
+ switch(g->p.x) {
+ case GDISP_CONTROL_POWER:
+ if (g->g.Powermode == (powermode_t)g->p.ptr)
+ return;
+
+ switch((powermode_t)g->p.ptr) {
+ case powerOff:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_SLPIN);
+ release_bus(g);
+ break;
+
+ case powerOn:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_SLPOUT);
+ delayms(20);
+ write_index(g, SPFD54124B_CMD_NORON);
+ release_bus(g);
+ break;
+
+ case powerSleep:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_SLPOUT);
+ delayms(20);
+ release_bus(g);
+ break;
+
+ default:
+ return;
+ }
+
+ g->g.Powermode = (powermode_t)g->p.ptr;
+ return;
+
+ case GDISP_CONTROL_ORIENTATION:
+ if (g->g.Orientation == (orientation_t)g->p.ptr)
+ return;
+
+ switch((orientation_t)g->p.ptr) {
+ case GDISP_ROTATE_0:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_MADCTR);
+ write_index(g, 0x00);
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+
+ case GDISP_ROTATE_90:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_MADCTR);
+ write_index(g, 0xA0);
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+
+ case GDISP_ROTATE_180:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_MADCTR);
+ write_index(g, 0xC0);
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+
+ case GDISP_ROTATE_270:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_MADCTR);
+ write_index(g, 0x60);
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+
+ case GDISP_ROTATE_PORTRAIT:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_MADCTR);
+ write_index(g, 0x00);
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+
+ case GDISP_ROTATE_LANDSCAPE:
+ acquire_bus(g);
+ write_index(g, SPFD54124B_CMD_MADCTR);
+ write_index(g, 0xA0);
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+
+ default:
+ return;
+ }
+
+ g->g.Orientation = (orientation_t)g->p.ptr;
+
+ return;
+ }
+}
+#endif
+
+#endif /* GFX_USE_GDISP */
diff --git a/drivers/gdisp/SPFD54124B/gdisp_lld_config.h b/drivers/gdisp/SPFD54124B/gdisp_lld_config.h
new file mode 100644
index 00000000..52ac315b
--- /dev/null
+++ b/drivers/gdisp/SPFD54124B/gdisp_lld_config.h
@@ -0,0 +1,73 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+/*
+ * Driver for display from Nokia 1616 phone
+ * based on the work of axillent@gmail.com (http://radiokot.ru/articles/53/)
+ * adapted by shilow@ukr.net with the help of Federico Reds <fede.677387@hotmail.it>
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if GFX_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_STREAM_WRITE TRUE
+
+#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+
+#define SPFD54124B_SEND_CMD 0x00
+#define SPFD54124B_SEND_DATA 0x100
+
+#define SPFD54124B_CMD_NOP 0x00
+#define SPFD54124B_CMD_SLPIN 0x11
+#define SPFD54124B_CMD_SLPOUT 0x11
+#define SPFD54124B_CMD_NORON 0x13
+
+#define SPFD54124B_CMD_INVOFF 0x20
+#define SPFD54124B_CMD_DISPON 0x29
+#define SPFD54124B_CMD_CASET 0x2A
+#define SPFD54124B_CMD_RASET 0x2B
+#define SPFD54124B_CMD_RAMWR 0x2C
+#define SPFD54124B_CMD_RGBSET 0x2D
+#define SPFD54124B_CMD_PTLAR 0x30
+
+#define SPFD54124B_CMD_MADCTR 0x36
+#define SPFD54124B_CMD_VSCSAD 0x37
+#define SPFD54124B_CMD_COLMOD 0x3A
+
+// MCU interface 12bit
+#define SPFD54124B_CMD_COLMOD_MCU12bit 0x03
+// MCU interface 16bit
+#define SPFD54124B_CMD_COLMOD_MCU16bit 0x05
+// MCU interface 18bit
+#define SPFD54124B_CMD_COLMOD_MCU18bit 0x06
+// RGB interface 16bit
+#define SPFD54124B_CMD_COLMOD_RGB16bit 0x50
+// RGB interface 18bit
+#define SPFD54124B_CMD_COLMOD_RGB18bit 0x60
+
+// Row Address Order
+#define SPFD54124B_CMD_MADCTR_MY (1 << 7)
+// Column Address Order
+#define SPFD54124B_CMD_MADCTR_MX (1 << 6)
+// Row/Column Exchange
+#define SPFD54124B_CMD_MADCTR_MV (1 << 5)
+// Vertical Refresh Order
+#define SPFD54124B_CMD_MADCTR_ML (1 << 4)
+// RGB-BGR ORDER
+#define SPFD54124B_CMD_MADCTR_RGB (1 << 3)
+
+#endif /* GFX_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+