From a2a87ddd458ef0811dfb71510d7027d23038005b Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 9 Jan 2013 14:29:32 +0100 Subject: added TDISP - experimental --- src/tdisp/tdisp.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tdisp/tdisp.mk | 2 ++ 2 files changed, 80 insertions(+) create mode 100644 src/tdisp/tdisp.c create mode 100644 src/tdisp/tdisp.mk (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c new file mode 100644 index 00000000..73db93a1 --- /dev/null +++ b/src/tdisp/tdisp.c @@ -0,0 +1,78 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX 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 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX 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, see . +*/ + +/** + * @file src/tdisp/tdisp.c + * @brief TDISP Driver code. + * + * @addtogroup TDISP + * @{ + */ +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_TDISP || defined(__DOXYGEN__) + +bool_t tdispInit(void) { + bool_t ret; + + ret = TDISP_LLD(init)(); + + return ret; +} + +void tdispClear(void) { + TDISP_LLD(write_cmd)(0x01); +} + +void tdispHome(void) { + TDISP_LLD(write_cmd)(0x02); +} + +void tdispGotoXY(coord_t col, coord_t row) { + uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + + TDISP_LLD(write_cmd)(0x80 | (col + row_offsets[row])); +} + +void tdispDrawChar(char c) { + TDISP_LLD(write_data)(c); +} + +void tdispDrawString(char *s) { + char c; + + while(c = s++) + tdispDrawChar(c); +} + +void tdispDrawCharLocation(coord_t x, coord_t y, char c) { + tdispGotoXY(x, y); + tdispDrawChar(c); +} + +void tdispDrawStringLocation(coord_t x, coord_t y, char *s) { + tdispGotoXY(x, y); + tdispDrawString(s); +} + +#endif /* GFX_USE_TDISP */ + diff --git a/src/tdisp/tdisp.mk b/src/tdisp/tdisp.mk new file mode 100644 index 00000000..a33fa34a --- /dev/null +++ b/src/tdisp/tdisp.mk @@ -0,0 +1,2 @@ +GFXSRC += $(GFXLIB)/src/tdisp/tdisp.c + -- cgit v1.2.3 From 6cc67bad84176614936f2c6439d640637186764d Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 10 Jan 2013 19:47:50 +0100 Subject: some TDISP doxygen --- src/tdisp/tdisp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index 73db93a1..fe794140 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -64,15 +64,16 @@ void tdispDrawString(char *s) { tdispDrawChar(c); } -void tdispDrawCharLocation(coord_t x, coord_t y, char c) { +void tdispDrawCharLocation(coord_t col, coord_t row, char c) { tdispGotoXY(x, y); tdispDrawChar(c); } -void tdispDrawStringLocation(coord_t x, coord_t y, char *s) { +void tdispDrawStringLocation(coord_t col, coord_t row, char *s) { tdispGotoXY(x, y); tdispDrawString(s); } #endif /* GFX_USE_TDISP */ +/** @} */ -- cgit v1.2.3 From d5e7afe756fe4c19dd9360baed23599b268709af Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 10 Jan 2013 14:51:31 +0100 Subject: 4-bit mode implemented --- src/tdisp/tdisp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index fe794140..a6e5e2f5 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -65,12 +65,12 @@ void tdispDrawString(char *s) { } void tdispDrawCharLocation(coord_t col, coord_t row, char c) { - tdispGotoXY(x, y); + tdispGotoXY(col, row); tdispDrawChar(c); } void tdispDrawStringLocation(coord_t col, coord_t row, char *s) { - tdispGotoXY(x, y); + tdispGotoXY(col, row); tdispDrawString(s); } -- cgit v1.2.3 From 77a93bb43d373a59df9da29053b9e64b4b3cf474 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 10 Jan 2013 15:03:34 +0100 Subject: TDISP update --- src/tdisp/tdisp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index a6e5e2f5..edd5b423 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -50,6 +50,9 @@ void tdispHome(void) { void tdispGotoXY(coord_t col, coord_t row) { uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + if(row >= TDISP_ROWS) + row = TDISP_ROWS - 1; + TDISP_LLD(write_cmd)(0x80 | (col + row_offsets[row])); } @@ -60,7 +63,7 @@ void tdispDrawChar(char c) { void tdispDrawString(char *s) { char c; - while(c = s++) + while(c = *s++) tdispDrawChar(c); } -- cgit v1.2.3 From 905bb0292bb3f0e2ce633716528aae143605f767 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jan 2013 13:25:38 +0100 Subject: some tdisp update --- src/tdisp/tdisp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index edd5b423..807dd026 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -39,6 +39,21 @@ bool_t tdispInit(void) { return ret; } +void tdispSetAttributes(uint8_t attributes) { + switch(attributes) { + case TDISP_ON: + break; + case TDISP_OFF: + break; + case TDISP_CURSOR_ON: + break; + case TDISP_CURSOR_OFF: + break; + case TDISP_CURSOR_BLINK: + break; + } +} + void tdispClear(void) { TDISP_LLD(write_cmd)(0x01); } -- cgit v1.2.3 From c974ec449f9f298ca8e02b9985ef7b9595607081 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jan 2013 14:39:27 +0100 Subject: tdisp update --- src/tdisp/tdisp.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index 807dd026..121ebcf5 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -31,10 +31,12 @@ #if GFX_USE_TDISP || defined(__DOXYGEN__) +static uint8_t _displaycontrol; + bool_t tdispInit(void) { bool_t ret; - ret = TDISP_LLD(init)(); + ret = TDIP_LLD(init)(); return ret; } @@ -42,14 +44,28 @@ bool_t tdispInit(void) { void tdispSetAttributes(uint8_t attributes) { switch(attributes) { case TDISP_ON: + _displaycontrol |= 0x04; + TDISP_LLD(write_cmd)(0x08 | _displaycontrol); break; case TDISP_OFF: + _displaycontrol &=~ 0x04; + TDISP_LLD(write_cmd)(0x08 | _displaycontrol); break; case TDISP_CURSOR_ON: + _displaycontrol |= 0x02; + TDISP_LLD(write_cmd)(0x08 | _displaycontrol); break; case TDISP_CURSOR_OFF: + _displaycontrol &=~ 0x02; + TDISP_LLD(write_cmd)(0x08 | _displaycontrol); + break; + case TDISP_CURSOR_BLINK_ON: + _displaycontrol |= 0x00; + TDISP_LLD(write_cmd)(0x08 | _displaycontrol); break; - case TDISP_CURSOR_BLINK: + case TDISP_CURSOR_BLINK_OFF: + _displaycontrol &=~ 0x00; + TDISP_LLD(write_cmd)(0x08 | _displaycontrol); break; } } -- cgit v1.2.3 From 249a1b345f1064957a6fd187fcdfbbcd3c1fecad Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jan 2013 15:04:33 +0100 Subject: added tdisp demo --- src/tdisp/tdisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index 121ebcf5..d57bae56 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -36,7 +36,7 @@ static uint8_t _displaycontrol; bool_t tdispInit(void) { bool_t ret; - ret = TDIP_LLD(init)(); + ret = TDISP_LLD(init)(); return ret; } -- cgit v1.2.3