aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2013-01-19 03:00:05 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2013-01-19 03:00:05 +1000
commit1985906bea97a015d6e035ebb3f91b6e4f94aff1 (patch)
tree08d6d74c7e02b341dadf1cb4278d8f5bf4e29cf7 /include
parent333fcad87fe0f62b8679845c23fb8f885e656109 (diff)
downloaduGFX-1985906bea97a015d6e035ebb3f91b6e4f94aff1.tar.gz
uGFX-1985906bea97a015d6e035ebb3f91b6e4f94aff1.tar.bz2
uGFX-1985906bea97a015d6e035ebb3f91b6e4f94aff1.zip
TDISP cleanup
Seperate High level and low level code better Implement tdispControl Cleanup
Diffstat (limited to 'include')
-rw-r--r--include/tdisp/lld/tdisp_lld.h110
-rw-r--r--include/tdisp/options.h59
-rw-r--r--include/tdisp/tdisp.h353
3 files changed, 284 insertions, 238 deletions
diff --git a/include/tdisp/lld/tdisp_lld.h b/include/tdisp/lld/tdisp_lld.h
index de6266f3..4efc3579 100644
--- a/include/tdisp/lld/tdisp_lld.h
+++ b/include/tdisp/lld/tdisp_lld.h
@@ -1,57 +1,53 @@
-/*
- ChibiOS/GFX - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-/**
- * @file include/tdisp/lld/tdisp_lld.h
- * @brief TDISP driver subsystem low level driver header.
- *
- * @addtogroup TDISP
- * @{
- */
-
-#ifndef _TDISP_LLD_H
-#define _TDISP_LLD_H
-
-#if GFX_USE_TDISP || defined(__DOXYGEN__)
-
-#include "tdisp_lld_config.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void tdisp_lld_write_cmd(uint8_t data);
-extern void tdisp_lld_write_data(uint8_t data);
-extern bool_t tdisp_lld_init(void);
-extern void tdisp_lld_set_cursor(coord_t col, coord_t row);
-extern void tdisp_lld_create_char(uint8_t address, char *charmap);
-extern void tdisp_lld_clear(void);
-extern void tdisp_lld_home(void);
-extern void tdisp_lld_control(uint16_t what, void *value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GFX_USE_TDISP */
-
-#endif /* _TDISP_LLD_H */
-/** @} */
-
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file include/tdisp/lld/tdisp_lld.h
+ * @brief TDISP driver subsystem low level driver header.
+ *
+ * @addtogroup TDISP
+ * @{
+ */
+
+#ifndef _TDISP_LLD_H
+#define _TDISP_LLD_H
+
+#if GFX_USE_TDISP || defined(__DOXYGEN__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ bool_t tdisp_lld_init(void);
+ void tdisp_lld_clear(void);
+ void tdisp_lld_draw_char(char c);
+ void tdisp_lld_set_cursor(coord_t col, coord_t row);
+ void tdisp_lld_create_char(uint8_t address, uint8_t *charmap);
+ void tdisp_lld_control(uint16_t what, void *value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_TDISP */
+
+#endif /* _TDISP_LLD_H */
+/** @} */
+
diff --git a/include/tdisp/options.h b/include/tdisp/options.h
index 69d24b64..77d562af 100644
--- a/include/tdisp/options.h
+++ b/include/tdisp/options.h
@@ -31,53 +31,44 @@
#if GFX_USE_TDISP
/**
- * @name TDISP configuration
+ * @name TDISP Functionality to be included
+ * @{
+ */
+/**
+ * @}
+ *
+ * @name TDISP Multi-Threading Options
* @{
*/
-
- /**
- * @brief How many rows of characters the TDISP provides
- */
- #ifndef TDISP_ROWS
- #define TDISP_ROWS 2
- #endif
-
/**
- * @brief How many columns of characters the TDISP provides
+ * @brief Do the display functions need to be thread-safe.
+ * @details Defaults to FALSE
*/
- #ifndef TDISP_COLUMNS
- #define TDISP_COLUMNS 16
+ #ifndef TDISP_NEED_MULTITHREAD
+ #define TDISP_NEED_MULTITHREAD FALSE
#endif
-
-/** @} */
-
/**
- * @name TDISP interface configuration
- * @note Only one of these interfaces can be selected at a time!
+ * @}
+ *
+ * @name TDISP Optional Low Level Driver Defines
* @{
*/
/**
- * @brief Use the 4-bit paralle interface
+ * @brief Use a custom board definition even if a board definition exists.
+ * @details Defaults to FALSE
+ * @details If TRUE, add tdisp_lld_board.h to your project directory and customise it.
+ * @note Not all TDISP low level drivers currently use board definition files.
*/
- #ifndef TDISP_NEED_4BIT_MODE
- #define TDISP_NEED_4BIT_MODE FALSE
+ #ifndef TDISP_USE_CUSTOM_BOARD
+ #define TDISP_USE_CUSTOM_BOARD FALSE
#endif
-
/**
- * @brief Use the 8-bit parallel interface
+ * @brief Set the screen height and width.
+ * @note Ignored by some low level GDISP drivers, optional for others.
+ * @note Where these values are allowed, a default is always provided by the low level driver.
*/
- #ifndef TDISP_NEED_8BIT_MODE
- #define TDISP_NEED_8BIT_MODE FALSE
- #endif
-
- #if (!TDISP_NEED_4BIT_MODE && !TDISP_NEED_8BIT_MODE)
- #error "Either TDISP_NEED_4BIT_MODE or TDISP_NEED_8BIT_MODE needs to be set to TRUE in your gfxconf.h!"
- #endif
-
- #if (TDISP_NEED_4BIT_MODE && TDISP_NEED_8BIT_MODE)
- #error "Only TDISP_NEED_4BIT_MODE or TDISP_NEED_8BIT_MODE can be set to TRUE, not both at one!"
- #endif
-
+ /* #define TDISP_COLUMNS 16 */
+ /* #define TDISP_ROWS 2 */
/** @} */
#endif /* GFX_USE_TDISP */
diff --git a/include/tdisp/tdisp.h b/include/tdisp/tdisp.h
index 01cb76a0..fcb1fc5f 100644
--- a/include/tdisp/tdisp.h
+++ b/include/tdisp/tdisp.h
@@ -1,147 +1,206 @@
-/*
- ChibiOS/GFX - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-/**
- * @file include/tdisp/tdisp.h
- * @brief TDISP Graphic Driver subsystem header file.
- *
- * @addtogroup TDISP
- *
- * @details The TDISP module provides high level abstraction to interface pixel oriented graphic displays.
- * Due the TDISP module is completely encapsulated from the other modules, it's very fast and lightweight.
- *
- * @pre GFX_USE_TDISP must be set to TRUE in gfxconf.h
- *
- * @{
- */
-
-#ifndef _TDISP_H
-#define _TDISP_H
-
-#include "gfx.h"
-
-#if GFX_USE_TDISP || defined(__DOXYGEN__)
-
-/* Include the low level driver information */
-#include "tdisp/lld/tdisp_lld.h"
-
-/**
- * @name TDISP display attributes
- * @{
- */
-#define TDISP_ON 0x01
-#define TDISP_OFF 0x02
-#define TDISP_CURSOR_ON 0x03
-#define TDISP_CURSOR_OFF 0x04
-#define TDISP_CURSOR_BLINK_ON 0x05
-#define TDISP_CURSOR_BLINK_OFF 0x06
-/** @} */
-
-/**
- * @brief TDISP driver initialisation
- * @note This function is not implicitly invoked by @p halInit().
- * It must be called manually.
- *
- * @return TRUE if success, FALSE otherwise
- *
- * @init
- */
-bool_t tdispInit(void);
-
-/**
- * @brief Control different display properties
- * @note A wrapper macro exists for each option, please use them
- * instead of this function manually.
- *
- * @param[in] what What you want to control
- * @param[in] value The value to be assigned
- */
-void tdispControl(uint16_t what, void *value);
-
-/**
- * @brief Clears the display
- */
-void tdispClear(void);
-
-/**
- * @brief Sets the cursor to it's home position ( 0/0 )
- */
-void tdispHome(void);
-
-/**
- * @brief Set cursor to a certain position
- *
- * @param[in] col The column
- * @param[in] row The row
- */
-void tdispSetCursor(coord_t col, coord_t row);
-
-/**
- * @brief Store a custom character in RAM
- *
- * @note This usually must be done after each power-up since most
- * LCDs lose their RAM content.
- *
- * @param[in] address On which address to store the character (from 0 up to max)
- * @param[in] charmap The character to be stored.
- */
-void tdispCreateChar(uint8_t address, char *charmap);
-
-/**
- * @brief Draws a single character at the current cursor position
- *
- * @param[in] c The character to be drawn
- */
-void tdispDrawChar(char c);
-
-/**
- * @brief Draws a string at the current cursor position
- *
- * @param[in] s The string to be drawn
- */
-void tdispDrawString(char *s);
-
-/**
- * @brief Draws a single character at a given position
- * @note This function manipulates the cursor position and it will not be
- * reset to it's original state
- *
- * @param[in] col The column
- * @param[in] row The row
- * @param[in] c The character to be drawn
- */
-void tdispDrawCharLocation(coord_t col, coord_t row, char c);
-
-/**
- * @brief Draws a string at a given position
- * @note This function manipulates the cursor position and it will not be
- * reset to it's original state
- *
- * @param[in] col The column
- * @param[in] row The row
- * @param[in] s The string to be drawn
- */
-void tdispDrawStringLocation(coord_t col, coord_t row, char *s);
-
-#endif /* GFX_USE_TDISP */
-
-#endif /* _TDISP_H */
-/** @} */
-
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file include/tdisp/tdisp.h
+ * @brief TDISP Graphic Driver subsystem header file.
+ *
+ * @addtogroup TDISP
+ *
+ * @details The TDISP module provides high level abstraction to interface pixel oriented graphic displays.
+ * Due the TDISP module is completely encapsulated from the other modules, it's very fast and lightweight.
+ *
+ * @pre GFX_USE_TDISP must be set to TRUE in gfxconf.h
+ *
+ * @{
+ */
+
+#ifndef _TDISP_H
+#define _TDISP_H
+
+#include "gfx.h"
+
+#if GFX_USE_TDISP || defined(__DOXYGEN__)
+
+/**
+ * @brief TDISP cursor shape definitions
+ */
+typedef enum cursorshape_e {
+ cursorOff,
+ cursorBlock,
+ cursorBlinkingBlock,
+ cursorUnderline,
+ cursorBlinkingUnderline,
+ cursorBar,
+ cursorBlinkingBar,
+ } cursorshape;
+
+/**
+ * @name TDISP control values
+ * @note The low level driver may define extra control values
+ * @{
+ */
+#define TDISP_CTRL_BACKLIGHT 0x0000
+#define TDISP_CTRL_CURSOR 0x0001
+/** @} */
+
+/**
+ * @brief The TDISP structure definition
+ */
+typedef struct tdispStruct_t {
+ coord_t columns, rows;
+ coord_t charBitsX, charBitsY;
+ uint16_t maxCustomChars;
+ } tdispStruct;
+
+/**
+ * @brief The TDISP structure
+ */
+extern tdispStruct TDISP;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief TDISP driver initialisation
+ * @note This function is not implicitly invoked by @p halInit().
+ * It must be called manually.
+ *
+ * @return TRUE if success, FALSE otherwise
+ *
+ * @init
+ */
+bool_t tdispInit(void);
+
+/**
+ * @brief Clears the display
+ */
+void tdispClear(void);
+
+/**
+ * @brief Sets the cursor to it's home position ( 0, 0 )
+ */
+void tdispHome(void);
+
+/**
+ * @brief Set cursor to a specified position
+ *
+ * @param[in] col The column (x)
+ * @param[in] row The row (y)
+ */
+void tdispSetCursor(coord_t col, coord_t row);
+
+/**
+ * @brief Store a custom character into the display
+ *
+ * @note This usually must be done after each power-up since most
+ * LCDs lose their RAM content.
+ *
+ * @param[in] address On which address to store the character from 0 up to (@p tdispGetNumCustomChars() - 1)
+ * @param[in] charmap The character to be stored.
+ *
+ * @note The charmap is made up of @p tdispGetCharBitHieght() data values. Each data value is
+ * made up of @p tdispGetCharBitWidth() bits of data. Note that bits in multiple rows are not
+ * packed.
+ */
+void tdispCreateChar(uint8_t address, uint8_t *charmap);
+
+/**
+ * @brief Draws a single character at the current cursor position and advances the cursor
+ *
+ * @param[in] c The character to be drawn
+ *
+ * @note Writing past the end of a row leaves the cursor in an undefined position.
+ */
+void tdispDrawChar(char c);
+
+/**
+ * @brief Draws a string at the current cursor position and advances the cursor
+ *
+ * @param[in] s The string to be drawn
+ *
+ * @note Any characters written past the end of a row may or may not be displayed on
+ * the next row. The cursor is also left in an undefined position.
+ */
+void tdispDrawString(char *s);
+
+/**
+ * @brief Control different display properties
+ * @note A wrapper macro exists for each option, please use them
+ * instead of this function manually unless calling a low
+ * level driver specific value.
+ *
+ * @param[in] what What you want to control
+ * @param[in] value The value to be assigned
+ */
+void tdispControl(uint16_t what, void *value);
+
+/**
+ * @brief Set the backlight level
+ *
+ * @param[in] percent A percentage from 0 to 100%. 0% will turn off the display
+ */
+#define tdispSetBacklight(percent) tdispControl(TDISP_CTRL_BACKLIGHT, (void *)((uint8_t)(percent)))
+
+/**
+ * @brief Set the cursor shape
+ *
+ * @param[in] shape The shape to set the cursor.
+ *
+ * @note Not all shapes are necessarily supported. The driver will make a similar
+ * choice if the one specified is not available.
+ */
+#define tdispSetCursorShape(shape) tdispControl(TDISP_CTRL_CURSOR, (void *)((cursorshape)(shape)))
+
+/**
+ * @brief Get the number of columns (width) in the display
+ */
+#define tdispGetColumns() (TDISP.columns)
+
+/**
+ * @brief Get the number of rows (height) in the display
+ */
+#define tdispGetRows() (TDISP.columns)
+
+/**
+ * @brief Get the number of bits in width of a character
+ */
+#define tdispGetCharBitWidth() (TDISP.charBitsX)
+
+/**
+ * @brief Get the number of bits in height of a character
+ */
+#define tdispGetCharBitHeight() (TDISP.charBitsY)
+
+/**
+ * @brief Get the number of custom characters
+ */
+#define tdispGetNumCustomChars() (TDISP.maxCustomChars)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_TDISP */
+
+#endif /* _TDISP_H */
+/** @} */
+