From f3870ce44130516ee7a898685c53ddf48d47d8cd Mon Sep 17 00:00:00 2001 From: "p.shamray" Date: Thu, 12 Jun 2014 11:05:53 +0300 Subject: first commit PCF8812 driver --- drivers/gdisp/PCF8812/PCF8812.h | 53 ++++++ drivers/gdisp/PCF8812/board_PCF8812_template.h | 43 +++++ drivers/gdisp/PCF8812/gdisp_lld.mk | 2 + drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 213 +++++++++++++++++++++++++ drivers/gdisp/PCF8812/gdisp_lld_config.h | 25 +++ 5 files changed, 336 insertions(+) create mode 100644 drivers/gdisp/PCF8812/PCF8812.h create mode 100644 drivers/gdisp/PCF8812/board_PCF8812_template.h create mode 100644 drivers/gdisp/PCF8812/gdisp_lld.mk create mode 100644 drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c create mode 100644 drivers/gdisp/PCF8812/gdisp_lld_config.h (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h new file mode 100644 index 00000000..6faec88a --- /dev/null +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -0,0 +1,53 @@ +/* + * 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 _PCF8812_H +#define _PCF8812_H + +#define PCF8812_SET_FUNC 0x20 // Function set +#define PCF8812_H 0x01 +#define PCF8812_V 0x02 +#define PCF8812_PD 0x04 + +#define PCF8812_DISPLAY 0x08 +#define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCF8812_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 + +#define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select + +#define PCF8812_SET_Y 0x04 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 + +// ========================================= + +#define PCF8812_TEMP_CONTROL 0x04 // set temperature coefficient (TCx) +#define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCF8812_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 + +#define PCF8812_SET_VMULT 0x08 // Set voltage multiplier factor +#define PCF8812_VMULT_MODE_0 0x00 // S1 = 0, S0 = 0 - 2 × voltage multiplier +#define PCF8812_VMULT_MODE_1 0x01 // S1 = 0, S0 = 1 - 3 × voltage multiplier +#define PCF8812_VMULT_MODE_2 0x02 // S1 = 1, S0 = 0 - 4 × voltage multiplier +#define PCF8812_VMULT_MODE_3 0x03 // S1 = 1, S0 = 1 - 5 × voltage multiplier + +#define PCF8812_SET_BIAS 0x10 // set bias system (BSx) +#define PCF8812_BIAS_MODE_7 0x00 // 1 to 100 +#define PCF8812_BIAS_MODE_6 0x01 // 1 to 80 +#define PCF8812_BIAS_MODE_5 0x02 // 1 to 65 +#define PCF8812_BIAS_MODE_4 0x03 // 1 to 48 +#define PCF8812_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCF8812_BIAS_MODE_2 0x05 // 1 to 24 +#define PCF8812_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCF8812_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 + +#define PCF8812_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 + +#endif /* _PCF8812_H */ diff --git a/drivers/gdisp/PCF8812/board_PCF8812_template.h b/drivers/gdisp/PCF8812/board_PCF8812_template.h new file mode 100644 index 00000000..08ec130d --- /dev/null +++ b/drivers/gdisp/PCF8812/board_PCF8812_template.h @@ -0,0 +1,43 @@ +/* + * 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 acquire_bus(GDisplay *g) { + (void) g; +} + +static inline void release_bus(GDisplay *g) { + (void) g; +} + +static inline void write_cmd(GDisplay *g, uint8_t cmd) { + (void) g; + (void) cmd; +} + +static inline void write_data(GDisplay *g, uint8_t* data, uint16_t length) { + (void) g; + (void) data; + (void) length; +} + +#endif /* _GDISP_LLD_BOARD_H */ diff --git a/drivers/gdisp/PCF8812/gdisp_lld.mk b/drivers/gdisp/PCF8812/gdisp_lld.mk new file mode 100644 index 00000000..f2394eaf --- /dev/null +++ b/drivers/gdisp/PCF8812/gdisp_lld.mk @@ -0,0 +1,2 @@ +GFXINC += $(GFXLIB)/drivers/gdisp/PCF8812 +GFXSRC += $(GFXLIB)/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c new file mode 100644 index 00000000..083f6d50 --- /dev/null +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -0,0 +1,213 @@ +/* + * 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 + */ + +#include "gfx.h" + +#if GFX_USE_GDISP + +#define GDISP_DRIVER_VMT GDISPVMT_PCF8812 +#include "drivers/gdisp/PCF8812/gdisp_lld_config.h" +#include "src/gdisp/driver.h" + +#include "board_PCF8812.h" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 65 +#endif +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 102 +#endif +#ifndef GDISP_INITIAL_CONTRAST + #define GDISP_INITIAL_CONTRAST 51 +#endif +#ifndef GDISP_INITIAL_BACKLIGHT + #define GDISP_INITIAL_BACKLIGHT 100 +#endif + +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) + +#include "drivers/gdisp/PCF8812/PCF8812.h" + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +// Some common routines and macros +#define RAM(g) ((uint8_t *)g->priv) + +#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH) +#define xybit(y) (1<<((y)&7)) + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* + * As this controller can't update on a pixel boundary we need to maintain the + * the entire display surface in memory so that we can do the necessary bit + * operations. Fortunately it is a small display in monochrome. + * 65 * 102 / 8 = 829 bytes. + */ + +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { + // The private area is the display surface. + g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)); + + // Initialise the board interface + init_board(g); + + // Hardware reset + setpin_reset(g, TRUE); + gfxSleepMilliseconds(100); + setpin_reset(g, FALSE); + gfxSleepMilliseconds(100); + + acquire_bus(g); + + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_TEMP_CONTROL | PCF8812_TEMP_MODE_1); + write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_cmd(g, PCF8812_SET_VOP | 0xFF); + write_cmd(g, PCF8812_SET_FUNC); + write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + + + + unsigned int i; + for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); ++i) + { + RAM(g)[i] &= 0x00; + write_data(g, (uint8_t*)0x00, 1); + } + + // Finish Init + post_init_board(g); + + // Release the bus + release_bus(g); + + /* Initialise the GDISP structure */ + 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_FLUSH + LLDSPEC void gdisp_lld_flush(GDisplay *g) { + + // Don't flush if we don't need it. + if (!(g->flags & GDISP_FLG_NEEDFLUSH)) + return; + + unsigned int i; + + acquire_bus(g); + for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i += GDISP_SCREEN_WIDTH) { + write_data(g, RAM(g) + i, GDISP_SCREEN_WIDTH); + } + release_bus(g); + } +#endif + +#if GDISP_HARDWARE_DRAWPIXEL + LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { + coord_t x, y; + + switch(g->g.Orientation) { + default: + case GDISP_ROTATE_0: + x = g->p.x; + y = g->p.y; + break; + case GDISP_ROTATE_90: + x = g->p.y; + y = GDISP_SCREEN_HEIGHT-1 - g->p.x; + break; + case GDISP_ROTATE_180: + x = GDISP_SCREEN_WIDTH-1 - g->p.x; + y = GDISP_SCREEN_HEIGHT-1 - g->p.y; + break; + case GDISP_ROTATE_270: + x = GDISP_SCREEN_HEIGHT-1 - g->p.y; + y = g->p.x; + break; + } + if (gdispColor2Native(g->p.color) == Black) + RAM(g)[xyaddr(x, y)] |= xybit(y); + else + RAM(g)[xyaddr(x, y)] &= ~xybit(y); + g->flags |= GDISP_FLG_NEEDFLUSH; + } +#endif + +#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + 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: + case powerSleep: + case powerDeepSleep: + acquire_bus(g); + write_cmd(g, PCF8812_DISPLAY_OFF); + release_bus(g); + break; + case powerOn: + acquire_bus(g); + write_cmd(g, PCF8812_DISPLAY_ON); + 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) { + /* Rotation is handled by the drawing routines */ + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + g->g.Height = GDISP_SCREEN_WIDTH; + g->g.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_CONTRAST: + if ((unsigned)g->p.ptr > 100) + g->p.ptr = (void *)100; + acquire_bus(g); + release_bus(g); + g->g.Contrast = (unsigned)g->p.ptr; + return; + } + } +#endif // GDISP_NEED_CONTROL + +#endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCF8812/gdisp_lld_config.h b/drivers/gdisp/PCF8812/gdisp_lld_config.h new file mode 100644 index 00000000..f95fc178 --- /dev/null +++ b/drivers/gdisp/PCF8812/gdisp_lld_config.h @@ -0,0 +1,25 @@ +/* + * 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_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing +#define GDISP_HARDWARE_DRAWPIXEL TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ -- cgit v1.2.3 From a38fd71311c212e06d6b4435737833784fa868ed Mon Sep 17 00:00:00 2001 From: pashamray Date: Fri, 13 Jun 2014 12:05:41 +0000 Subject: =?UTF-8?q?gdisp=5Flld=5FPCF8812.c=20=D0=BE=D1=82=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=BE=D0=BD=D0=BB=D0=B0=D0=B9=D0=BD=20=D0=BD=D0=B0=20Bitbucket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 083f6d50..b0475fae 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -115,8 +115,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; acquire_bus(g); - for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i += GDISP_SCREEN_WIDTH) { - write_data(g, RAM(g) + i, GDISP_SCREEN_WIDTH); + for (i = 0; i < 9; ++i) { + write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); } release_bus(g); } -- cgit v1.2.3 From 8e13c10f392396022a4b2ae04b5ccd8cb795f17e Mon Sep 17 00:00:00 2001 From: pashamray Date: Wed, 18 Jun 2014 21:43:14 +0300 Subject: remove not use code --- drivers/gdisp/PCF8812/PCF8812.h | 4 +- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 91 +++++++------------------------ drivers/gdisp/PCF8812/gdisp_lld_config.h | 3 +- 3 files changed, 23 insertions(+), 75 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h index 6faec88a..95e7c217 100644 --- a/drivers/gdisp/PCF8812/PCF8812.h +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -21,12 +21,12 @@ #define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select -#define PCF8812_SET_Y 0x04 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCF8812_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 #define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 // ========================================= -#define PCF8812_TEMP_CONTROL 0x04 // set temperature coefficient (TCx) +#define PCF8812_SET_TEMP 0x04 // set temperature coefficient (TCx) #define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 #define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 #define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index b0475fae..88fc2aea 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -32,7 +32,7 @@ #define GDISP_INITIAL_BACKLIGHT 100 #endif -#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCF8812/PCF8812.h" @@ -43,8 +43,10 @@ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH) -#define xybit(y) (1<<((y)&7)) +unsigned char RAM[(GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)]; + +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) +#define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ /* Driver exported functions. */ @@ -72,19 +74,19 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); - write_cmd(g, PCF8812_TEMP_CONTROL | PCF8812_TEMP_MODE_1); - write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_cmd(g, PCF8812_SET_VOP | 0xFF); + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); + write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_cmd(g, PCF8812_SET_VOP | 0xFF); write_cmd(g, PCF8812_SET_FUNC); - write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); - + write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_cmd(g, PCF8812_SET_X); // X = 0 + write_cmd(g, PCF8812_SET_Y); // Y = 0 unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); ++i) + for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i++) { - RAM(g)[i] &= 0x00; write_data(g, (uint8_t*)0x00, 1); } @@ -115,8 +117,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; acquire_bus(g); - for (i = 0; i < 9; ++i) { - write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); + + //write_cmd(g, PCF8812_SET_X); + //write_cmd(g, PCF8812_SET_Y); + + for (i = 0; i < 9; i++) { + write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); } release_bus(g); } @@ -145,7 +151,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (gdispColor2Native(g->p.color) == Black) + if (gdispColor2Native(g->p.color) != Black) RAM(g)[xyaddr(x, y)] |= xybit(y); else RAM(g)[xyaddr(x, y)] &= ~xybit(y); @@ -153,61 +159,4 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif -#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL - LLDSPEC void gdisp_lld_control(GDisplay *g) { - 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: - case powerSleep: - case powerDeepSleep: - acquire_bus(g); - write_cmd(g, PCF8812_DISPLAY_OFF); - release_bus(g); - break; - case powerOn: - acquire_bus(g); - write_cmd(g, PCF8812_DISPLAY_ON); - 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) { - /* Rotation is handled by the drawing routines */ - case GDISP_ROTATE_0: - case GDISP_ROTATE_180: - g->g.Height = GDISP_SCREEN_HEIGHT; - g->g.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - case GDISP_ROTATE_270: - g->g.Height = GDISP_SCREEN_WIDTH; - g->g.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - g->g.Orientation = (orientation_t)g->p.ptr; - return; - - case GDISP_CONTROL_CONTRAST: - if ((unsigned)g->p.ptr > 100) - g->p.ptr = (void *)100; - acquire_bus(g); - release_bus(g); - g->g.Contrast = (unsigned)g->p.ptr; - return; - } - } -#endif // GDISP_NEED_CONTROL - #endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCF8812/gdisp_lld_config.h b/drivers/gdisp/PCF8812/gdisp_lld_config.h index f95fc178..598f71af 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_config.h +++ b/drivers/gdisp/PCF8812/gdisp_lld_config.h @@ -16,9 +16,8 @@ #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_DRAWPIXEL TRUE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO #endif /* GFX_USE_GDISP */ -- cgit v1.2.3 From 5c421b09f72c679e2052a65a58fa4314b8acf9d0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Jul 2014 15:05:12 +0300 Subject: edit --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 88fc2aea..d280fd21 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -43,8 +43,6 @@ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -unsigned char RAM[(GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)]; - #define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) #define xybit(y) (1 << ((y) & 7)) @@ -61,7 +59,7 @@ unsigned char RAM[(GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)]; LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // The private area is the display surface. - g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)); + g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8))); // Initialise the board interface init_board(g); @@ -85,13 +83,14 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i++) + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { - write_data(g, (uint8_t*)0x00, 1); + RAM(g)[i] = 0x00; + write_data(g, 0x00, 1); } - // Finish Init - post_init_board(g); + // Finish Init + post_init_board(g); // Release the bus release_bus(g); @@ -114,15 +113,17 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; - unsigned int i; - acquire_bus(g); - //write_cmd(g, PCF8812_SET_X); - //write_cmd(g, PCF8812_SET_Y); + write_cmd(g, PCF8812_SET_X); + write_cmd(g, PCF8812_SET_Y); + + unsigned char x, y; - for (i = 0; i < 9; i++) { - write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); + for (y = 0; y < (GDISP_SCREEN_HEIGHT / 8); y++) { + for(x = 0; x < GDISP_SCREEN_WIDTH; x++) { + write_data(g, RAM(g) + xyaddr(x, y), 1); + } } release_bus(g); } @@ -151,7 +152,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (gdispColor2Native(g->p.color) != Black) + if (gdispColor2Native(g->p.color) == Black) RAM(g)[xyaddr(x, y)] |= xybit(y); else RAM(g)[xyaddr(x, y)] &= ~xybit(y); -- cgit v1.2.3 From fd17106f99338e91485f8bbdee5af727ac07f2d7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Jul 2014 00:19:39 +0300 Subject: work --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index d280fd21..668d8ffd 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -83,9 +83,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) - { - RAM(g)[i] = 0x00; + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { write_data(g, 0x00, 1); } @@ -110,21 +108,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { LLDSPEC void gdisp_lld_flush(GDisplay *g) { // Don't flush if we don't need it. - if (!(g->flags & GDISP_FLG_NEEDFLUSH)) + if (!(g->flags & GDISP_FLG_NEEDFLUSH)) { return; + } acquire_bus(g); write_cmd(g, PCF8812_SET_X); write_cmd(g, PCF8812_SET_Y); - unsigned char x, y; + unsigned int i; - for (y = 0; y < (GDISP_SCREEN_HEIGHT / 8); y++) { - for(x = 0; x < GDISP_SCREEN_WIDTH; x++) { - write_data(g, RAM(g) + xyaddr(x, y), 1); - } + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { + write_data(g, RAM(g)[i], 1); } + release_bus(g); } #endif @@ -152,10 +150,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (gdispColor2Native(g->p.color) == Black) + + if (gdispColor2Native(g->p.color) != Black) { RAM(g)[xyaddr(x, y)] |= xybit(y); - else + } else { RAM(g)[xyaddr(x, y)] &= ~xybit(y); + } + g->flags |= GDISP_FLG_NEEDFLUSH; } #endif -- cgit v1.2.3 From d8d47f804e245b48afbc0058aa3731c58934dfda Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Jul 2014 18:13:49 +0300 Subject: work driver pcf8812 --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 35 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 668d8ffd..87d5d6d9 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -9,7 +9,7 @@ #if GFX_USE_GDISP -#define GDISP_DRIVER_VMT GDISPVMT_PCF8812 +#define GDISP_DRIVER_VMT GDISPVMT_PCF8812 #include "drivers/gdisp/PCF8812/gdisp_lld_config.h" #include "src/gdisp/driver.h" @@ -20,10 +20,10 @@ /*===========================================================================*/ #ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 65 + #define GDISP_SCREEN_HEIGHT 65 #endif #ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 102 + #define GDISP_SCREEN_WIDTH 102 #endif #ifndef GDISP_INITIAL_CONTRAST #define GDISP_INITIAL_CONTRAST 51 @@ -41,7 +41,7 @@ /*===========================================================================*/ // Some common routines and macros -#define RAM(g) ((uint8_t *)g->priv) +#define RAM(g) ((uint8_t *)g->priv) #define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) #define xybit(y) (1 << ((y) & 7)) @@ -54,7 +54,7 @@ * As this controller can't update on a pixel boundary we need to maintain the * the entire display surface in memory so that we can do the necessary bit * operations. Fortunately it is a small display in monochrome. - * 65 * 102 / 8 = 829 bytes. + * 102 * 65 / 8 = 828,75 bytes. */ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { @@ -72,18 +72,18 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); - write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); - write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_cmd(g, PCF8812_SET_VOP | 0xFF); + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); + write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_cmd(g, PCF8812_SET_VOP | 0xFF); write_cmd(g, PCF8812_SET_FUNC); - write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); write_cmd(g, PCF8812_SET_X); // X = 0 write_cmd(g, PCF8812_SET_Y); // Y = 0 - unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { + + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { write_data(g, 0x00, 1); } @@ -93,6 +93,9 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // Release the bus release_bus(g); + /* Turn on the back-light */ + set_backlight(g, GDISP_INITIAL_BACKLIGHT); + /* Initialise the GDISP structure */ g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; @@ -114,12 +117,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_X); - write_cmd(g, PCF8812_SET_Y); + write_cmd(g, PCF8812_SET_X); // X = 0 + write_cmd(g, PCF8812_SET_Y); // Y = 0 unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { write_data(g, RAM(g)[i], 1); } @@ -129,7 +132,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { - coord_t x, y; + coord_t x, y; switch(g->g.Orientation) { default: -- cgit v1.2.3 From 71892bf7616cfd3289e728b9034f286681dfccab Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 13:57:28 +0300 Subject: fixed height bug and add actual display size 96*65 pixels --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 254 ++++++++++++++++++++++++------ drivers/gdisp/PCF8812/gdisp_lld_config.h | 6 +- 2 files changed, 208 insertions(+), 52 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 87d5d6d9..cf4518b4 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -12,39 +12,37 @@ #define GDISP_DRIVER_VMT GDISPVMT_PCF8812 #include "drivers/gdisp/PCF8812/gdisp_lld_config.h" #include "src/gdisp/driver.h" - #include "board_PCF8812.h" /*===========================================================================*/ /* Driver local definitions. */ /*===========================================================================*/ -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 65 -#endif -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 102 -#endif -#ifndef GDISP_INITIAL_CONTRAST - #define GDISP_INITIAL_CONTRAST 51 -#endif -#ifndef GDISP_INITIAL_BACKLIGHT - #define GDISP_INITIAL_BACKLIGHT 100 -#endif +#define GDISP_MATRIX_HEIGHT 72 +#define GDISP_MATRIX_WIDTH 102 + +#define GDISP_SCREEN_HEIGHT 65 +#define GDISP_SCREEN_WIDTH 96 + +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCF8812/PCF8812.h" /*===========================================================================*/ -/* Driver local functions. */ +/* Driver local routines . */ /*===========================================================================*/ // Some common routines and macros -#define RAM(g) ((uint8_t *)g->priv) +#define RAM(g) ((uint8_t *)g->priv) + +//#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) +//#define xybit(y) (1 << ((y) & 7)) -#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) -#define xybit(y) (1 << ((y) & 7)) +#define xyaddr(x, y) ((((y) / 8) * GDISP_MATRIX_WIDTH) + (x)) +#define xybit(y) (1 << ((y) % 8)) /*===========================================================================*/ /* Driver exported functions. */ @@ -54,12 +52,17 @@ * As this controller can't update on a pixel boundary we need to maintain the * the entire display surface in memory so that we can do the necessary bit * operations. Fortunately it is a small display in monochrome. - * 102 * 65 / 8 = 828,75 bytes. + * Matrix 102 * 65 / 8 = 828,75 bytes. + * Display 96 * 65 / 8 = 780 */ +#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) +#define GDISP_MATRIX_BYTES ((GDISP_MATRIX_WIDTH * GDISP_MATRIX_HEIGHT) / 8) // real height 65 pixels, this fix 65 / 8 != 9 + LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // The private area is the display surface. - g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8))); + if (!(g->priv = gfxAlloc(GDISP_MATRIX_BYTES))) + gfxHalt("GDISP PCF8812: Failed to allocate private memory"); // Initialise the board interface init_board(g); @@ -72,18 +75,18 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); - write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); - write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_cmd(g, PCF8812_SET_VOP | 0xFF); - write_cmd(g, PCF8812_SET_FUNC); - write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); - write_cmd(g, PCF8812_SET_X); // X = 0 - write_cmd(g, PCF8812_SET_Y); // Y = 0 + write_index(g, PCF8812_SET_FUNC | PCF8812_H); + write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); + write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_index(g, PCF8812_SET_VOP | 0x00); + write_index(g, PCF8812_SET_FUNC); + write_index(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_index(g, PCF8812_SET_X); // X = 0 + write_index(g, PCF8812_SET_Y); // Y = 0 - unsigned int i; + coord_t i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { + for (i = 0; i < GDISP_MATRIX_BYTES; i++) { write_data(g, 0x00, 1); } @@ -117,12 +120,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_X); // X = 0 - write_cmd(g, PCF8812_SET_Y); // Y = 0 + write_index(g, PCF8812_SET_X | 0); // X = 0 + write_index(g, PCF8812_SET_Y | 0); // Y = 0 - unsigned int i; + coord_t i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { + for (i = 0; i < GDISP_MATRIX_BYTES; i++) { write_data(g, RAM(g)[i], 1); } @@ -133,26 +136,31 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { coord_t x, y; - - switch(g->g.Orientation) { - default: - case GDISP_ROTATE_0: + + #if GDISP_NEED_CONTROL + switch(g->g.Orientation) { + default: + case GDISP_ROTATE_0: + x = g->p.x; + y = g->p.y; + break; + case GDISP_ROTATE_90: + x = g->p.y; + y = g->g.Height - g->p.x-1; + break; + case GDISP_ROTATE_180: + x = g->g.Width - g->p.x-1; + y = g->g.Height - g->p.y-1; + break; + case GDISP_ROTATE_270: + x = g->g.Height - g->p.y-1; + y = g->p.x; + break; + } + #else x = g->p.x; y = g->p.y; - break; - case GDISP_ROTATE_90: - x = g->p.y; - y = GDISP_SCREEN_HEIGHT-1 - g->p.x; - break; - case GDISP_ROTATE_180: - x = GDISP_SCREEN_WIDTH-1 - g->p.x; - y = GDISP_SCREEN_HEIGHT-1 - g->p.y; - break; - case GDISP_ROTATE_270: - x = GDISP_SCREEN_HEIGHT-1 - g->p.y; - y = g->p.x; - break; - } + #endif if (gdispColor2Native(g->p.color) != Black) { RAM(g)[xyaddr(x, y)] |= xybit(y); @@ -164,4 +172,148 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif +/* +#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + 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); + + release_bus(g); + break; + case powerOn: + acquire_bus(g); + + release_bus(g); + break; + case powerSleep: + acquire_bus(g); + + 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); + + release_bus(g); + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + acquire_bus(g); + + release_bus(g); + g->g.Height = GDISP_SCREEN_WIDTH; + g->g.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + acquire_bus(g); + + release_bus(g); + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + acquire_bus(g); + + 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; + + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)g->p.ptr > 100) + g->p.ptr = (void *)100; + set_backlight(g, (unsigned)g->p.ptr); + g->g.Backlight = (unsigned)g->p.ptr; + return; + + //case GDISP_CONTROL_CONTRAST: + default: + return; + } + } +#endif +*/ +#if GDISP_NEED_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + 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: case powerOn: case powerSleep: case powerDeepSleep: + //board_power(g, (powermode_t)g->p.ptr); + 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: + case GDISP_ROTATE_180: + write_index(g, PCF8812_SET_FUNC | PCF8812_H | 0x01); + if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + write_index(g, PCF8812_SET_FUNC | PCF8812_V | 0x01); + if (g->g.Orientation == GDISP_ROTATE_0 || g->g.Orientation == GDISP_ROTATE_180) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + //board_backlight(g, (unsigned)g->p.ptr); + g->g.Backlight = (unsigned)g->p.ptr; + return; + + case GDISP_CONTROL_CONTRAST: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + //board_contrast(g, (unsigned)g->p.ptr); + g->g.Contrast = (unsigned)g->p.ptr; + return; + } + } +#endif + #endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCF8812/gdisp_lld_config.h b/drivers/gdisp/PCF8812/gdisp_lld_config.h index 598f71af..6ad8a571 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_config.h +++ b/drivers/gdisp/PCF8812/gdisp_lld_config.h @@ -16,8 +16,12 @@ #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_DRAWPIXEL TRUE +#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +// Set this to your frame buffer pixel format. +#ifndef GDISP_LLD_PIXELFORMAT + #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +#endif #endif /* GFX_USE_GDISP */ -- cgit v1.2.3 From 28f9e7f7669c900a471aef6936d56a3a51b243ea Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 19:29:50 +0300 Subject: fixed orientation 0 90 180 270 degree --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 107 +++--------------------------- 1 file changed, 11 insertions(+), 96 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index cf4518b4..91f77351 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -38,11 +38,8 @@ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -//#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) -//#define xybit(y) (1 << ((y) & 7)) - -#define xyaddr(x, y) ((((y) / 8) * GDISP_MATRIX_WIDTH) + (x)) -#define xybit(y) (1 << ((y) % 8)) +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) +#define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ /* Driver exported functions. */ @@ -56,7 +53,7 @@ * Display 96 * 65 / 8 = 780 */ -#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) +//#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) #define GDISP_MATRIX_BYTES ((GDISP_MATRIX_WIDTH * GDISP_MATRIX_HEIGHT) / 8) // real height 65 pixels, this fix 65 / 8 != 9 LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { @@ -76,9 +73,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); write_index(g, PCF8812_SET_FUNC | PCF8812_H); - write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); - write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_index(g, PCF8812_SET_VOP | 0x00); + write_index(g, PCF8812_SET_BIAS | PCF8812_BIAS_MODE_7); + write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_2); + write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_0); + write_index(g, PCF8812_SET_VOP | 0xFF); write_index(g, PCF8812_SET_FUNC); write_index(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); write_index(g, PCF8812_SET_X); // X = 0 @@ -146,14 +144,14 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: x = g->p.y; - y = g->g.Height - g->p.x-1; + y = g->p.x; break; case GDISP_ROTATE_180: - x = g->g.Width - g->p.x-1; - y = g->g.Height - g->p.y-1; + x = g->g.Width - g->p.x - 1; + y = g->g.Height - g->p.y - 1; break; case GDISP_ROTATE_270: - x = g->g.Height - g->p.y-1; + x = g->g.Height - g->p.y - 1; y = g->p.x; break; } @@ -172,87 +170,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif -/* -#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL - LLDSPEC void gdisp_lld_control(GDisplay *g) { - 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); - - release_bus(g); - break; - case powerOn: - acquire_bus(g); - - release_bus(g); - break; - case powerSleep: - acquire_bus(g); - - 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); - - release_bus(g); - g->g.Height = GDISP_SCREEN_HEIGHT; - g->g.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - acquire_bus(g); - - release_bus(g); - g->g.Height = GDISP_SCREEN_WIDTH; - g->g.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - acquire_bus(g); - - release_bus(g); - g->g.Height = GDISP_SCREEN_HEIGHT; - g->g.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - acquire_bus(g); - - 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; - - case GDISP_CONTROL_BACKLIGHT: - if ((unsigned)g->p.ptr > 100) - g->p.ptr = (void *)100; - set_backlight(g, (unsigned)g->p.ptr); - g->g.Backlight = (unsigned)g->p.ptr; - return; - - //case GDISP_CONTROL_CONTRAST: - default: - return; - } - } -#endif -*/ #if GDISP_NEED_CONTROL LLDSPEC void gdisp_lld_control(GDisplay *g) { switch(g->p.x) { @@ -275,7 +192,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { switch((orientation_t)g->p.ptr) { case GDISP_ROTATE_0: case GDISP_ROTATE_180: - write_index(g, PCF8812_SET_FUNC | PCF8812_H | 0x01); if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { coord_t tmp; @@ -286,7 +202,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: case GDISP_ROTATE_270: - write_index(g, PCF8812_SET_FUNC | PCF8812_V | 0x01); if (g->g.Orientation == GDISP_ROTATE_0 || g->g.Orientation == GDISP_ROTATE_180) { coord_t tmp; -- cgit v1.2.3 From 76625b646bf3bbbb70a612be993e7003b0033e22 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 19:56:54 +0300 Subject: fixed orientation 90 degree --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 91f77351..c4543d45 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -144,7 +144,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: x = g->p.y; - y = g->p.x; + y = (g->g.Width - g->p.x - 1); break; case GDISP_ROTATE_180: x = g->g.Width - g->p.x - 1; -- cgit v1.2.3 From b2a85002310b36cd663e2af5b7664c29f4a28404 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 21:14:24 +0300 Subject: power manager --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index c4543d45..2fcff54b 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -177,8 +177,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { if (g->g.Powermode == (powermode_t)g->p.ptr) return; switch((powermode_t)g->p.ptr) { - case powerOff: case powerOn: case powerSleep: case powerDeepSleep: - //board_power(g, (powermode_t)g->p.ptr); + case powerOff: + case powerSleep: + case powerDeepSleep: + write_index(g, PCF8812_SET_FUNC | PCF8812_PD); + break; + case powerOn: + write_index(g, PCF8812_SET_FUNC); break; default: return; @@ -218,13 +223,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { case GDISP_CONTROL_BACKLIGHT: if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; - //board_backlight(g, (unsigned)g->p.ptr); + set_backlight(g, (unsigned)g->p.ptr); g->g.Backlight = (unsigned)g->p.ptr; return; case GDISP_CONTROL_CONTRAST: if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; - //board_contrast(g, (unsigned)g->p.ptr); + // ToDo g->g.Contrast = (unsigned)g->p.ptr; return; } -- cgit v1.2.3 From f103da84bcc8f2de985e31bb34d04fee65947b23 Mon Sep 17 00:00:00 2001 From: pashamray Date: Mon, 7 Jul 2014 08:49:57 +0000 Subject: README.md --- drivers/gdisp/PCF8812/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 drivers/gdisp/PCF8812/README.md (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/README.md b/drivers/gdisp/PCF8812/README.md new file mode 100644 index 00000000..3cc98179 --- /dev/null +++ b/drivers/gdisp/PCF8812/README.md @@ -0,0 +1,4 @@ +=== Driver for PCF8812/OM6206 controller === +Displays based on this controller: + Nokia 3410 + Siemens C55/A55/A52 \ No newline at end of file -- cgit v1.2.3 From 4611a10bc93031e45c739da646ec09bae16eaa64 Mon Sep 17 00:00:00 2001 From: pashamray Date: Mon, 7 Jul 2014 08:54:14 +0000 Subject: README.md --- drivers/gdisp/PCF8812/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/README.md b/drivers/gdisp/PCF8812/README.md index 3cc98179..b8b9a84a 100644 --- a/drivers/gdisp/PCF8812/README.md +++ b/drivers/gdisp/PCF8812/README.md @@ -1,4 +1,5 @@ -=== Driver for PCF8812/OM6206 controller === +Driver for PCF8812/OM6206 controller +========================== Displays based on this controller: Nokia 3410 Siemens C55/A55/A52 \ No newline at end of file -- cgit v1.2.3 From 0afcec1ddb9990b857ae06eadb8fbdbad86c9ca4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jul 2014 21:25:02 +0300 Subject: finish commit --- drivers/gdisp/PCF8812/PCF8812.h | 2 +- drivers/gdisp/PCF8812/gdisp_lld.mk | 2 -- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 28 +++++++++++++--------------- 3 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 drivers/gdisp/PCF8812/gdisp_lld.mk (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h index 95e7c217..3064f9b1 100644 --- a/drivers/gdisp/PCF8812/PCF8812.h +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -13,7 +13,7 @@ #define PCF8812_V 0x02 #define PCF8812_PD 0x04 -#define PCF8812_DISPLAY 0x08 +#define PCF8812_SET_DISPLAY 0x08 #define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 #define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 #define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 diff --git a/drivers/gdisp/PCF8812/gdisp_lld.mk b/drivers/gdisp/PCF8812/gdisp_lld.mk deleted file mode 100644 index f2394eaf..00000000 --- a/drivers/gdisp/PCF8812/gdisp_lld.mk +++ /dev/null @@ -1,2 +0,0 @@ -GFXINC += $(GFXLIB)/drivers/gdisp/PCF8812 -GFXSRC += $(GFXLIB)/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 2fcff54b..5377b7cd 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -72,15 +72,14 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_index(g, PCF8812_SET_FUNC | PCF8812_H); - write_index(g, PCF8812_SET_BIAS | PCF8812_BIAS_MODE_7); - write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_2); - write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_0); - write_index(g, PCF8812_SET_VOP | 0xFF); - write_index(g, PCF8812_SET_FUNC); - write_index(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); - write_index(g, PCF8812_SET_X); // X = 0 - write_index(g, PCF8812_SET_Y); // Y = 0 + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_2); + write_cmd(g, PCF8812_SET_BIAS | PCF8812_BIAS_MODE_4); + write_cmd(g, PCF8812_SET_VOP | (0x40)); + write_cmd(g, PCF8812_SET_FUNC); + write_cmd(g, PCF8812_SET_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_cmd(g, PCF8812_SET_X); // X = 0 + write_cmd(g, PCF8812_SET_Y); // Y = 0 coord_t i; @@ -118,8 +117,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_index(g, PCF8812_SET_X | 0); // X = 0 - write_index(g, PCF8812_SET_Y | 0); // Y = 0 + write_cmd(g, PCF8812_SET_X | 0); // X = 0 + write_cmd(g, PCF8812_SET_Y | 0); // Y = 0 coord_t i; @@ -144,7 +143,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: x = g->p.y; - y = (g->g.Width - g->p.x - 1); + y = g->g.Width - g->p.x - 1; break; case GDISP_ROTATE_180: x = g->g.Width - g->p.x - 1; @@ -180,10 +179,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { case powerOff: case powerSleep: case powerDeepSleep: - write_index(g, PCF8812_SET_FUNC | PCF8812_PD); + write_cmd(g, PCF8812_SET_FUNC | PCF8812_PD); break; case powerOn: - write_index(g, PCF8812_SET_FUNC); + write_cmd(g, PCF8812_SET_FUNC); break; default: return; @@ -229,7 +228,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { case GDISP_CONTROL_CONTRAST: if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; - // ToDo g->g.Contrast = (unsigned)g->p.ptr; return; } -- cgit v1.2.3 From a3de59d7ad7a62ae80331e0fbf0c72398a18d2ee Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jul 2014 22:01:59 +0300 Subject: first commit --- drivers/gdisp/PCD8544/PCD8544.h | 45 +++++ drivers/gdisp/PCD8544/board_PCD8544_template.h | 43 +++++ drivers/gdisp/PCD8544/driver.mk | 2 + drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c | 233 +++++++++++++++++++++++++ drivers/gdisp/PCD8544/gdisp_lld_config.h | 28 +++ 5 files changed, 351 insertions(+) create mode 100644 drivers/gdisp/PCD8544/PCD8544.h create mode 100644 drivers/gdisp/PCD8544/board_PCD8544_template.h create mode 100644 drivers/gdisp/PCD8544/driver.mk create mode 100644 drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c create mode 100644 drivers/gdisp/PCD8544/gdisp_lld_config.h (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCD8544/PCD8544.h b/drivers/gdisp/PCD8544/PCD8544.h new file mode 100644 index 00000000..1a269ab4 --- /dev/null +++ b/drivers/gdisp/PCD8544/PCD8544.h @@ -0,0 +1,45 @@ +/* + * 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 _PCD8544_H +#define _PCD8544_H + +#define PCD8544_SET_FUNC 0x20 // Function set +#define PCD8544_H 0x01 +#define PCD8544_V 0x02 +#define PCD8544_PD 0x04 + +#define PCD8544_SET_DISPLAY 0x08 +#define PCD8544_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCD8544_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCD8544_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCD8544_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 + +#define PCD8544_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCD8544_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 + +// ========================================= + +#define PCD8544_SET_TEMP 0x04 // set temperature coefficient (TCx) +#define PCD8544_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCD8544_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCD8544_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCD8544_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 + +#define PCD8544_SET_BIAS 0x10 // set bias system (BSx) +#define PCD8544_BIAS_MODE_7 0x00 // 1 to 100 +#define PCD8544_BIAS_MODE_6 0x01 // 1 to 80 +#define PCD8544_BIAS_MODE_5 0x02 // 1 to 65 +#define PCD8544_BIAS_MODE_4 0x03 // 1 to 48 +#define PCD8544_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCD8544_BIAS_MODE_2 0x05 // 1 to 24 +#define PCD8544_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCD8544_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 + +#define PCD8544_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 + +#endif /* _PCD8544_H */ diff --git a/drivers/gdisp/PCD8544/board_PCD8544_template.h b/drivers/gdisp/PCD8544/board_PCD8544_template.h new file mode 100644 index 00000000..08ec130d --- /dev/null +++ b/drivers/gdisp/PCD8544/board_PCD8544_template.h @@ -0,0 +1,43 @@ +/* + * 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 acquire_bus(GDisplay *g) { + (void) g; +} + +static inline void release_bus(GDisplay *g) { + (void) g; +} + +static inline void write_cmd(GDisplay *g, uint8_t cmd) { + (void) g; + (void) cmd; +} + +static inline void write_data(GDisplay *g, uint8_t* data, uint16_t length) { + (void) g; + (void) data; + (void) length; +} + +#endif /* _GDISP_LLD_BOARD_H */ diff --git a/drivers/gdisp/PCD8544/driver.mk b/drivers/gdisp/PCD8544/driver.mk new file mode 100644 index 00000000..262550d3 --- /dev/null +++ b/drivers/gdisp/PCD8544/driver.mk @@ -0,0 +1,2 @@ +GFXINC += $(GFXLIB)/drivers/gdisp/PCD8544 +GFXSRC += $(GFXLIB)/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c diff --git a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c new file mode 100644 index 00000000..8ebd619a --- /dev/null +++ b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c @@ -0,0 +1,233 @@ +/* + * 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 + */ + +#include "gfx.h" + +#if GFX_USE_GDISP + +#define GDISP_DRIVER_VMT GDISPVMT_PCD8544 +#include "drivers/gdisp/PCD8544/gdisp_lld_config.h" +#include "src/gdisp/driver.h" +#include "board_PCD8544.h" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define GDISP_SCREEN_HEIGHT 48 +#define GDISP_SCREEN_WIDTH 84 + +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 + +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) + +#include "drivers/gdisp/PCD8544/PCD8544.h" + +/*===========================================================================*/ +/* Driver local routines . */ +/*===========================================================================*/ + +// Some common routines and macros +#define RAM(g) ((uint8_t *)g->priv) + +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) +#define xybit(y) (1 << ((y) & 7)) + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* + * As this controller can't update on a pixel boundary we need to maintain the + * the entire display surface in memory so that we can do the necessary bit + * operations. Fortunately it is a small display in monochrome. + * Display 48 * 84 / 8 = 504 + */ + +#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) + +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { + // The private area is the display surface. + if (!(g->priv = gfxAlloc(GDISP_SCREEN_BYTES))) + gfxHalt("GDISP PCD8544: Failed to allocate private memory"); + + // Initialise the board interface + init_board(g); + + // Hardware reset + setpin_reset(g, TRUE); + gfxSleepMilliseconds(100); + setpin_reset(g, FALSE); + gfxSleepMilliseconds(100); + + acquire_bus(g); + + write_cmd(g, PCD8544_SET_FUNC | PCD8544_H); + write_cmd(g, PCD8544_SET_TEMP | PCD8544_TEMP_MODE_2); + write_cmd(g, PCD8544_SET_BIAS | PCD8544_BIAS_MODE_4); + write_cmd(g, PCD8544_SET_VOP | (0x40)); + write_cmd(g, PCD8544_SET_FUNC); + write_cmd(g, PCD8544_SET_DISPLAY | PCD8544_DISPLAY_MODE_NORMAL); + write_cmd(g, PCD8544_SET_X); // X = 0 + write_cmd(g, PCD8544_SET_Y); // Y = 0 + + coord_t i; + + for (i = 0; i < GDISP_SCREEN_BYTES; i++) { + write_data(g, 0x00, 1); + } + + // Finish Init + post_init_board(g); + + // Release the bus + release_bus(g); + + /* Turn on the back-light */ + set_backlight(g, GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure */ + 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_FLUSH + LLDSPEC void gdisp_lld_flush(GDisplay *g) { + + // Don't flush if we don't need it. + if (!(g->flags & GDISP_FLG_NEEDFLUSH)) { + return; + } + + acquire_bus(g); + + write_cmd(g, PCD8544_SET_X | 0); // X = 0 + write_cmd(g, PCD8544_SET_Y | 0); // Y = 0 + + coord_t i; + + for (i = 0; i < GDISP_SCREEN_BYTES; i++) { + write_data(g, RAM(g)[i], 1); + } + + release_bus(g); + } +#endif + +#if GDISP_HARDWARE_DRAWPIXEL + LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { + coord_t x, y; + + #if GDISP_NEED_CONTROL + switch(g->g.Orientation) { + default: + case GDISP_ROTATE_0: + x = g->p.x; + y = g->p.y; + break; + case GDISP_ROTATE_90: + x = g->p.y; + y = g->g.Width - g->p.x - 1; + break; + case GDISP_ROTATE_180: + x = g->g.Width - g->p.x - 1; + y = g->g.Height - g->p.y - 1; + break; + case GDISP_ROTATE_270: + x = g->g.Height - g->p.y - 1; + y = g->p.x; + break; + } + #else + x = g->p.x; + y = g->p.y; + #endif + + if (gdispColor2Native(g->p.color) != Black) { + RAM(g)[xyaddr(x, y)] |= xybit(y); + } else { + RAM(g)[xyaddr(x, y)] &= ~xybit(y); + } + + g->flags |= GDISP_FLG_NEEDFLUSH; + } +#endif + +#if GDISP_NEED_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + 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: + case powerSleep: + case powerDeepSleep: + write_cmd(g, PCD8544_SET_FUNC | PCD8544_PD); + break; + case powerOn: + write_cmd(g, PCD8544_SET_FUNC); + 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: + case GDISP_ROTATE_180: + if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + if (g->g.Orientation == GDISP_ROTATE_0 || g->g.Orientation == GDISP_ROTATE_180) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + set_backlight(g, (unsigned)g->p.ptr); + g->g.Backlight = (unsigned)g->p.ptr; + return; + + case GDISP_CONTROL_CONTRAST: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + write_cmd(g, PCD8544_SET_VOP | (unsigned)g->p.ptr); + g->g.Contrast = (unsigned)g->p.ptr; + return; + } + } +#endif + +#endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCD8544/gdisp_lld_config.h b/drivers/gdisp/PCD8544/gdisp_lld_config.h new file mode 100644 index 00000000..6ad8a571 --- /dev/null +++ b/drivers/gdisp/PCD8544/gdisp_lld_config.h @@ -0,0 +1,28 @@ +/* + * 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_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing +#define GDISP_HARDWARE_DRAWPIXEL TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +// Set this to your frame buffer pixel format. +#ifndef GDISP_LLD_PIXELFORMAT + #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +#endif + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ -- cgit v1.2.3 From 538f9fcea3150b926cc1da0360b92254cc544a47 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 9 Jul 2014 22:53:01 +0200 Subject: whitespaces --- drivers/gdisp/PCD8544/PCD8544.h | 50 ++++++++++++++++----------------- drivers/gdisp/PCF8812/PCF8812.h | 62 ++++++++++++++++++++--------------------- 2 files changed, 56 insertions(+), 56 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCD8544/PCD8544.h b/drivers/gdisp/PCD8544/PCD8544.h index 1a269ab4..3716a4a8 100644 --- a/drivers/gdisp/PCD8544/PCD8544.h +++ b/drivers/gdisp/PCD8544/PCD8544.h @@ -8,38 +8,38 @@ #ifndef _PCD8544_H #define _PCD8544_H -#define PCD8544_SET_FUNC 0x20 // Function set +#define PCD8544_SET_FUNC 0x20 // Function set #define PCD8544_H 0x01 #define PCD8544_V 0x02 #define PCD8544_PD 0x04 -#define PCD8544_SET_DISPLAY 0x08 -#define PCD8544_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 -#define PCD8544_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 -#define PCD8544_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 -#define PCD8544_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 +#define PCD8544_SET_DISPLAY 0x08 +#define PCD8544_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCD8544_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCD8544_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCD8544_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 -#define PCD8544_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 -#define PCD8544_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 +#define PCD8544_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCD8544_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 // ========================================= -#define PCD8544_SET_TEMP 0x04 // set temperature coefficient (TCx) -#define PCD8544_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 -#define PCD8544_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 -#define PCD8544_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 -#define PCD8544_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 - -#define PCD8544_SET_BIAS 0x10 // set bias system (BSx) -#define PCD8544_BIAS_MODE_7 0x00 // 1 to 100 -#define PCD8544_BIAS_MODE_6 0x01 // 1 to 80 -#define PCD8544_BIAS_MODE_5 0x02 // 1 to 65 -#define PCD8544_BIAS_MODE_4 0x03 // 1 to 48 -#define PCD8544_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 -#define PCD8544_BIAS_MODE_2 0x05 // 1 to 24 -#define PCD8544_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 -#define PCD8544_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 - -#define PCD8544_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 +#define PCD8544_SET_TEMP 0x04 // set temperature coefficient (TCx) +#define PCD8544_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCD8544_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCD8544_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCD8544_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 + +#define PCD8544_SET_BIAS 0x10 // set bias system (BSx) +#define PCD8544_BIAS_MODE_7 0x00 // 1 to 100 +#define PCD8544_BIAS_MODE_6 0x01 // 1 to 80 +#define PCD8544_BIAS_MODE_5 0x02 // 1 to 65 +#define PCD8544_BIAS_MODE_4 0x03 // 1 to 48 +#define PCD8544_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCD8544_BIAS_MODE_2 0x05 // 1 to 24 +#define PCD8544_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCD8544_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 + +#define PCD8544_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 #endif /* _PCD8544_H */ diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h index 3064f9b1..c2695b71 100644 --- a/drivers/gdisp/PCF8812/PCF8812.h +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -8,46 +8,46 @@ #ifndef _PCF8812_H #define _PCF8812_H -#define PCF8812_SET_FUNC 0x20 // Function set +#define PCF8812_SET_FUNC 0x20 // Function set #define PCF8812_H 0x01 #define PCF8812_V 0x02 #define PCF8812_PD 0x04 -#define PCF8812_SET_DISPLAY 0x08 -#define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 -#define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 -#define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 -#define PCF8812_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 +#define PCF8812_SET_DISPLAY 0x08 +#define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCF8812_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 -#define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select +#define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select -#define PCF8812_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 -#define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 +#define PCF8812_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 // ========================================= -#define PCF8812_SET_TEMP 0x04 // set temperature coefficient (TCx) -#define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 -#define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 -#define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 -#define PCF8812_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 - -#define PCF8812_SET_VMULT 0x08 // Set voltage multiplier factor -#define PCF8812_VMULT_MODE_0 0x00 // S1 = 0, S0 = 0 - 2 × voltage multiplier -#define PCF8812_VMULT_MODE_1 0x01 // S1 = 0, S0 = 1 - 3 × voltage multiplier -#define PCF8812_VMULT_MODE_2 0x02 // S1 = 1, S0 = 0 - 4 × voltage multiplier -#define PCF8812_VMULT_MODE_3 0x03 // S1 = 1, S0 = 1 - 5 × voltage multiplier +#define PCF8812_SET_TEMP 0x04 // set temperature coefficient (TCx) +#define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCF8812_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 + +#define PCF8812_SET_VMULT 0x08 // Set voltage multiplier factor +#define PCF8812_VMULT_MODE_0 0x00 // S1 = 0, S0 = 0 - 2 × voltage multiplier +#define PCF8812_VMULT_MODE_1 0x01 // S1 = 0, S0 = 1 - 3 × voltage multiplier +#define PCF8812_VMULT_MODE_2 0x02 // S1 = 1, S0 = 0 - 4 × voltage multiplier +#define PCF8812_VMULT_MODE_3 0x03 // S1 = 1, S0 = 1 - 5 × voltage multiplier -#define PCF8812_SET_BIAS 0x10 // set bias system (BSx) -#define PCF8812_BIAS_MODE_7 0x00 // 1 to 100 -#define PCF8812_BIAS_MODE_6 0x01 // 1 to 80 -#define PCF8812_BIAS_MODE_5 0x02 // 1 to 65 -#define PCF8812_BIAS_MODE_4 0x03 // 1 to 48 -#define PCF8812_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 -#define PCF8812_BIAS_MODE_2 0x05 // 1 to 24 -#define PCF8812_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 -#define PCF8812_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 - -#define PCF8812_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 +#define PCF8812_SET_BIAS 0x10 // set bias system (BSx) +#define PCF8812_BIAS_MODE_7 0x00 // 1 to 100 +#define PCF8812_BIAS_MODE_6 0x01 // 1 to 80 +#define PCF8812_BIAS_MODE_5 0x02 // 1 to 65 +#define PCF8812_BIAS_MODE_4 0x03 // 1 to 48 +#define PCF8812_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCF8812_BIAS_MODE_2 0x05 // 1 to 24 +#define PCF8812_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCF8812_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 + +#define PCF8812_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 #endif /* _PCF8812_H */ -- cgit v1.2.3 From 5c8c0c7b36cd8f2c94b67cce56e99804a048a906 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 9 Jul 2014 22:57:57 +0200 Subject: more whitepsaces --- drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c | 10 +++++----- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/gdisp') diff --git a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c index 8ebd619a..377f3d8b 100644 --- a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c +++ b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c @@ -21,21 +21,21 @@ #define GDISP_SCREEN_HEIGHT 48 #define GDISP_SCREEN_WIDTH 84 -#define GDISP_INITIAL_CONTRAST 51 -#define GDISP_INITIAL_BACKLIGHT 100 +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 -#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCD8544/PCD8544.h" /*===========================================================================*/ -/* Driver local routines . */ +/* Driver local routines. */ /*===========================================================================*/ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) #define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 5377b7cd..27ce5b91 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -24,22 +24,22 @@ #define GDISP_SCREEN_HEIGHT 65 #define GDISP_SCREEN_WIDTH 96 -#define GDISP_INITIAL_CONTRAST 51 -#define GDISP_INITIAL_BACKLIGHT 100 +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 -#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCF8812/PCF8812.h" /*===========================================================================*/ -/* Driver local routines . */ +/* Driver local routines. */ /*===========================================================================*/ // Some common routines and macros -#define RAM(g) ((uint8_t *)g->priv) +#define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) -#define xybit(y) (1 << ((y) & 7)) +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) +#define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ /* Driver exported functions. */ -- cgit v1.2.3