TDISP merge - NOT TESTED!!!
This commit is contained in:
commit
08f2305aeb
9 changed files with 695 additions and 592 deletions
|
@ -32,120 +32,131 @@
|
||||||
|
|
||||||
#if GFX_USE_TDISP /*|| defined(__DOXYGEN__)*/
|
#if GFX_USE_TDISP /*|| defined(__DOXYGEN__)*/
|
||||||
|
|
||||||
#include "tdisp_lld_board_example.h"
|
/* The user may override the default display size */
|
||||||
|
#ifndef TDISP_COLUMNS
|
||||||
|
#define TDISP_COLUMNS 16
|
||||||
|
#endif
|
||||||
|
#ifndef TDISP_ROWS
|
||||||
|
#define TDISP_ROWS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
static void _writeData(uint8_t data) {
|
/* Controller Specific Properties */
|
||||||
write_bus(data);
|
#define CUSTOM_CHAR_COUNT 8
|
||||||
|
#define CUSTOM_CHAR_XBITS 5
|
||||||
|
#define CUSTOM_CHAR_YBITS 8
|
||||||
|
|
||||||
setpin_e(TRUE);
|
/* Define the properties of our controller */
|
||||||
chThdSleepMicroseconds(1);
|
tdispStruct TDISP = {
|
||||||
setpin_e(FALSE);
|
TDISP_COLUMNS, TDISP_ROWS, /* cols, rows */
|
||||||
chThdSleepMicroseconds(5);
|
CUSTOM_CHAR_XBITS, CUSTOM_CHAR_YBITS, /* charBitsX, charBitsY */
|
||||||
}
|
CUSTOM_CHAR_COUNT /* maxCustomChars */
|
||||||
|
};
|
||||||
|
|
||||||
void tdisp_lld_write_cmd(uint8_t data) {
|
/* Include the hardware interface details */
|
||||||
setpin_rs(FALSE);
|
#if defined(TDISP_USE_CUSTOM_BOARD) && TDISP_USE_CUSTOM_BOARD
|
||||||
setpin_rw(FALSE);
|
/* Include the user supplied board definitions */
|
||||||
|
#include "tdisp_lld_board.h"
|
||||||
|
#elif defined(BOARD_UNKNOWN)
|
||||||
|
#include "gdisp_lld_board_unknown.h"
|
||||||
|
#else
|
||||||
|
/* Include the user supplied board definitions */
|
||||||
|
#include "gdisp_lld_board.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TDISP_NEED_4BIT_MODE
|
/* Our display control */
|
||||||
_writeData(data>>4);
|
#define DISPLAY_ON 0x04
|
||||||
#endif
|
#define CURSOR_ON 0x02
|
||||||
_writeData(data);
|
#define CURSOR_BLINK 0x01
|
||||||
}
|
|
||||||
|
|
||||||
void tdisp_lld_write_data(uint8_t data) {
|
static uint8_t displaycontrol;
|
||||||
setpin_rs(TRUE);
|
|
||||||
setpin_rw(FALSE);
|
|
||||||
|
|
||||||
#if TDISP_NEED_4BIT_MODE
|
|
||||||
_writeData(data>>4);
|
|
||||||
#endif
|
|
||||||
_writeData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool_t tdisp_lld_init(void) {
|
bool_t tdisp_lld_init(void) {
|
||||||
/* initialise MCU hardware */
|
/* initialise hardware */
|
||||||
init_board();
|
init_board();
|
||||||
|
|
||||||
/* wait some time */
|
/* wait some time */
|
||||||
chThdSleepMilliseconds(50);
|
chThdSleepMilliseconds(50);
|
||||||
|
|
||||||
tdisp_lld_write_cmd(0x38);
|
write_cmd(0x38);
|
||||||
chThdSleepMilliseconds(64);
|
chThdSleepMilliseconds(64);
|
||||||
|
|
||||||
tdisp_lld_write_cmd(0x0f);
|
displaycontrol = DISPLAY_ON | CURSOR_ON | CURSOR_BLINK; // The default displaycontrol
|
||||||
|
write_cmd(0x08 | displaycontrol);
|
||||||
chThdSleepMicroseconds(50);
|
chThdSleepMicroseconds(50);
|
||||||
|
|
||||||
tdisp_lld_write_cmd(0x01);
|
write_cmd(0x01); // Clear the screen
|
||||||
chThdSleepMilliseconds(5);
|
chThdSleepMilliseconds(5);
|
||||||
|
|
||||||
tdisp_lld_write_cmd(0x06);
|
write_cmd(0x06);
|
||||||
chThdSleepMicroseconds(50);
|
chThdSleepMicroseconds(50);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdisp_lld_set_cursor(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]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void tdisp_lld_create_char(uint8_t address, char *charmap) {
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
/* make sure we don't write somewhere we're not supposed to */
|
|
||||||
address &= TDISP_MAX_CUSTOM_CHARS;
|
|
||||||
|
|
||||||
tdisp_lld_write_cmd(0x40 | (address << 3));
|
|
||||||
|
|
||||||
for(i = 0; i < 8; i++) {
|
|
||||||
tdisp_lld_write_data(charmap[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tdisp_lld_clear(void) {
|
void tdisp_lld_clear(void) {
|
||||||
tdisp_lld_write_cmd(0x01);
|
write_cmd(0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdisp_lld_home(void) {
|
void tdisp_lld_draw_char(char c) {
|
||||||
tdisp_lld_write_cmd(0x02);
|
write_data(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tdisp_lld_set_cursor(coord_t col, coord_t row) {
|
||||||
|
static const uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Short-cut:
|
||||||
|
*
|
||||||
|
* If x and y = 0 then use the home command.
|
||||||
|
*
|
||||||
|
* Note: There is probably no advantage as both commands are a single byte
|
||||||
|
*/
|
||||||
|
// if (col == 0 && row == 0) {
|
||||||
|
// write_cmd(0x02);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
write_cmd(0x80 | (col + row_offsets[row]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void tdisp_lld_create_char(uint8_t address, uint8_t *charmap) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
write_cmd(0x40 | (address << 3));
|
||||||
|
for(i = 0; i < CUSTOM_CHAR_YBITS; i++)
|
||||||
|
write_data(charmap[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdisp_lld_control(uint16_t what, void *value) {
|
void tdisp_lld_control(uint16_t what, void *value) {
|
||||||
(void)what;
|
switch(what) {
|
||||||
(void)value;
|
case TDISP_CTRL_BACKLIGHT:
|
||||||
/*
|
if ((uint8_t)value)
|
||||||
switch(attributes) {
|
displaycontrol |= DISPLAY_ON;
|
||||||
case TDISP_ON:
|
else
|
||||||
_displaycontrol |= 0x04;
|
displaycontrol &= ~DISPLAY_ON;
|
||||||
tdisp_lld_write_cmd(0x08 | _displaycontrol);
|
write_cmd(0x08 | displaycontrol);
|
||||||
break;
|
break;
|
||||||
case TDISP_OFF:
|
case TDISP_CTRL_CURSOR:
|
||||||
_displaycontrol &=~ 0x04;
|
switch((cursorshape)value) {
|
||||||
tdisp_lld_write_cmd(0x08 | _displaycontrol);
|
case cursorOff:
|
||||||
|
displaycontrol &= ~CURSOR_ON;
|
||||||
break;
|
break;
|
||||||
case TDISP_CURSOR_ON:
|
case cursorBlock:
|
||||||
_displaycontrol |= 0x02;
|
case cursorUnderline:
|
||||||
tdisp_lld_write_cmd(0x08 | _displaycontrol);
|
case cursorBar:
|
||||||
|
displaycontrol = (displaycontrol | CURSOR_ON) & ~CURSOR_BLINK;
|
||||||
break;
|
break;
|
||||||
case TDISP_CURSOR_OFF:
|
case cursorBlinkingBlock:
|
||||||
_displaycontrol &=~ 0x02;
|
case cursorBlinkingUnderline:
|
||||||
tdisp_lld_write_cmd(0x08 | _displaycontrol);
|
case cursorBlinkingBar:
|
||||||
break;
|
default:
|
||||||
case TDISP_CURSOR_BLINK_ON:
|
displaycontrol |= (CURSOR_ON | CURSOR_BLINK);
|
||||||
_displaycontrol |= 0x00;
|
break;
|
||||||
tdisp_lld_write_cmd(0x08 | _displaycontrol);
|
}
|
||||||
break;
|
write_cmd(0x08 | displaycontrol);
|
||||||
case TDISP_CURSOR_BLINK_OFF:
|
|
||||||
_displaycontrol &=~ 0x00;
|
|
||||||
tdisp_lld_write_cmd(0x08 | _displaycontrol);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* GFX_USE_TDISP */
|
#endif /* GFX_USE_TDISP */
|
||||||
|
|
|
@ -29,36 +29,20 @@
|
||||||
#ifndef _TDISP_LLD_BOARD_H
|
#ifndef _TDISP_LLD_BOARD_H
|
||||||
#define _TDISP_LLD_BOARD_H
|
#define _TDISP_LLD_BOARD_H
|
||||||
|
|
||||||
void init_board(void) {
|
static void init_board(void) {
|
||||||
palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
/* Code here */
|
||||||
palSetGroupMode(GPIOG, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
#error "tdispHD44780: You must supply a definition for init_board for your board"
|
||||||
}
|
}
|
||||||
|
|
||||||
void setpin_e(bool_t state) {
|
static void write_cmd(uint8_t data) {
|
||||||
if(state)
|
/* Code here */
|
||||||
palSetPad(GPIOE, 2);
|
#error "tdispHD44780: You must supply a definition for write_cmd for your board"
|
||||||
else
|
|
||||||
palClearPad(GPIOE, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setpin_rs(bool_t state) {
|
static void write_data(uint8_t data) {
|
||||||
if(state)
|
/* Code here */
|
||||||
palSetPad(GPIOE, 0);
|
#error "tdispHD44780: You must supply a definition for write_data for your board"
|
||||||
else
|
|
||||||
palClearPad(GPIOE, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setpin_rw(bool_t state) {
|
|
||||||
if(state)
|
|
||||||
palSetPad(GPIOE, 1);
|
|
||||||
else
|
|
||||||
palClearPad(GPIOE, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_bus(uint8_t data) {
|
|
||||||
palWritePort(GPIOG, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _TDISP_LLD_BOARD_H */
|
#endif /* _TDISP_LLD_BOARD_H */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
71
drivers/tdisp/HD44780/tdisp_lld_board_unknown.h
Normal file
71
drivers/tdisp/HD44780/tdisp_lld_board_unknown.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
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 drivers/tdisp/HD44780/tdisp_lld_board_unknown.h
|
||||||
|
* @brief TDISP driver subsystem board interface for the HD44780 display
|
||||||
|
*
|
||||||
|
* @addtogroup TDISP
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TDISP_LLD_BOARD_H
|
||||||
|
#define _TDISP_LLD_BOARD_H
|
||||||
|
|
||||||
|
/* Configure these to match the hardware connections on your board */
|
||||||
|
#define BUS_4BITS FALSE
|
||||||
|
#define PORT_DATA GPIOG
|
||||||
|
#define PORT_CTRL GPIOE
|
||||||
|
#define PIN_RS 0
|
||||||
|
#define PIN_RW 1
|
||||||
|
#define PIN_EN 2
|
||||||
|
|
||||||
|
static void init_board(void) {
|
||||||
|
palSetGroupMode(PORT_CTRL, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
|
palSetGroupMode(PORT_DATA, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
|
palClearPad(PORT_CTRL, PIN_RW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void writeToLCD(uint8_t data) {
|
||||||
|
palWritePort(PORT_DATA, data);
|
||||||
|
palSetPad(PORT_CTRL, PIN_EN);
|
||||||
|
chThdSleepMicroseconds(1);
|
||||||
|
palClearPad(PORT_CTRL, PIN_EN);
|
||||||
|
chThdSleepMicroseconds(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_cmd(uint8_t data) {
|
||||||
|
palClearPad(PORT_CTRL, PIN_RS);
|
||||||
|
#if BUS_4BITS
|
||||||
|
writeToLCD(data>>4);
|
||||||
|
#endif
|
||||||
|
writeToLCD(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_data(uint8_t data) {
|
||||||
|
palSetPad(PORT_CTRL, PIN_RS);
|
||||||
|
#if BUS_4BITS
|
||||||
|
writeToLCD(data>>4);
|
||||||
|
#endif
|
||||||
|
writeToLCD(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _TDISP_LLD_BOARD_H */
|
||||||
|
/** @} */
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
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 drivers/tdisp/HD44780/tdisp_lld_config.h
|
|
||||||
* @brief TDISP Driver subsystem low level driver header for the HD44780 display.
|
|
||||||
*
|
|
||||||
* @addtogroup TDISP
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TDISP_LLD_CONFIG_H
|
|
||||||
#define _TDISP_LLD_CONFIG_H
|
|
||||||
|
|
||||||
#if GFX_USE_TDISP
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver hardware support. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
#define TDISP_DRIVER_NAME "HD44780"
|
|
||||||
|
|
||||||
#define TDISP_MAX_CUSTOM_CHARS 0x07
|
|
||||||
|
|
||||||
#endif /* GFX_USE_TDISP */
|
|
||||||
|
|
||||||
#endif /* _TDISP_LLD_CONFIG_H */
|
|
||||||
/** @} */
|
|
|
@ -48,11 +48,8 @@
|
||||||
#define GDISP_INCLUDE_FONT_UI2 TRUE
|
#define GDISP_INCLUDE_FONT_UI2 TRUE
|
||||||
#define GDISP_INCLUDE_FONT_LARGENUMBERS TRUE
|
#define GDISP_INCLUDE_FONT_LARGENUMBERS TRUE
|
||||||
|
|
||||||
/* TDISP options */
|
/* Features for the TDISP subsystem. */
|
||||||
#define TDISP_COLUMNS 16
|
#define TDISP_NEED_MULTITHREAD FALSE
|
||||||
#define TDISP_ROWS 2
|
|
||||||
#define TDISP_NEED_4BIT_MODE FALSE
|
|
||||||
#define TDISP_NEED_8BIT_MODE FALSE
|
|
||||||
|
|
||||||
/* Features for the GWIN subsystem. */
|
/* Features for the GWIN subsystem. */
|
||||||
#define GWIN_NEED_BUTTON FALSE
|
#define GWIN_NEED_BUTTON FALSE
|
||||||
|
@ -99,6 +96,13 @@
|
||||||
#define GDISP_SCREEN_HEIGHT 240
|
#define GDISP_SCREEN_HEIGHT 240
|
||||||
#define GDISP_USE_FSMC
|
#define GDISP_USE_FSMC
|
||||||
#define GDISP_USE_GPIO
|
#define GDISP_USE_GPIO
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
#define GDISP_VMT_NAME1(x) x##YourDriver1
|
||||||
|
#define GDISP_VMT_NAME2(x) x##YourDriver2
|
||||||
|
#define TDISP_COLUMNS 16
|
||||||
|
#define TDISP_ROWS 2
|
||||||
|
>>>>>>> 1985906bea97a015d6e035ebb3f91b6e4f94aff1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif /* _GFXCONF_H */
|
#endif /* _GFXCONF_H */
|
||||||
|
|
|
@ -31,20 +31,16 @@
|
||||||
|
|
||||||
#if GFX_USE_TDISP || defined(__DOXYGEN__)
|
#if GFX_USE_TDISP || defined(__DOXYGEN__)
|
||||||
|
|
||||||
#include "tdisp_lld_config.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void tdisp_lld_write_cmd(uint8_t data);
|
bool_t tdisp_lld_init(void);
|
||||||
extern void tdisp_lld_write_data(uint8_t data);
|
void tdisp_lld_clear(void);
|
||||||
extern bool_t tdisp_lld_init(void);
|
void tdisp_lld_draw_char(char c);
|
||||||
extern void tdisp_lld_set_cursor(coord_t col, coord_t row);
|
void tdisp_lld_set_cursor(coord_t col, coord_t row);
|
||||||
extern void tdisp_lld_create_char(uint8_t address, char *charmap);
|
void tdisp_lld_create_char(uint8_t address, uint8_t *charmap);
|
||||||
extern void tdisp_lld_clear(void);
|
void tdisp_lld_control(uint16_t what, void *value);
|
||||||
extern void tdisp_lld_home(void);
|
|
||||||
extern void tdisp_lld_control(uint16_t what, void *value);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,53 +31,44 @@
|
||||||
|
|
||||||
#if GFX_USE_TDISP
|
#if GFX_USE_TDISP
|
||||||
/**
|
/**
|
||||||
* @name TDISP configuration
|
* @name TDISP Functionality to be included
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
#ifndef TDISP_COLUMNS
|
|
||||||
#define TDISP_COLUMNS 16
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name TDISP interface configuration
|
* @}
|
||||||
* @note Only one of these interfaces can be selected at a time!
|
*
|
||||||
|
* @name TDISP Multi-Threading Options
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief Use the 4-bit paralle interface
|
* @brief Do the display functions need to be thread-safe.
|
||||||
|
* @details Defaults to FALSE
|
||||||
*/
|
*/
|
||||||
#ifndef TDISP_NEED_4BIT_MODE
|
#ifndef TDISP_NEED_MULTITHREAD
|
||||||
#define TDISP_NEED_4BIT_MODE FALSE
|
#define TDISP_NEED_MULTITHREAD FALSE
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*
|
||||||
|
* @name TDISP Optional Low Level Driver Defines
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief Use the 8-bit parallel 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_8BIT_MODE
|
#ifndef TDISP_USE_CUSTOM_BOARD
|
||||||
#define TDISP_NEED_8BIT_MODE FALSE
|
#define TDISP_USE_CUSTOM_BOARD FALSE
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
#if (!TDISP_NEED_4BIT_MODE && !TDISP_NEED_8BIT_MODE)
|
* @brief Set the screen height and width.
|
||||||
#error "Either TDISP_NEED_4BIT_MODE or TDISP_NEED_8BIT_MODE needs to be set to TRUE in your gfxconf.h!"
|
* @note Ignored by some low level GDISP drivers, optional for others.
|
||||||
#endif
|
* @note Where these values are allowed, a default is always provided by the low level driver.
|
||||||
|
*/
|
||||||
#if (TDISP_NEED_4BIT_MODE && TDISP_NEED_8BIT_MODE)
|
/* #define TDISP_COLUMNS 16 */
|
||||||
#error "Only TDISP_NEED_4BIT_MODE or TDISP_NEED_8BIT_MODE can be set to TRUE, not both at one!"
|
/* #define TDISP_ROWS 2 */
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif /* GFX_USE_TDISP */
|
#endif /* GFX_USE_TDISP */
|
||||||
|
|
|
@ -39,21 +39,46 @@
|
||||||
|
|
||||||
#if GFX_USE_TDISP || defined(__DOXYGEN__)
|
#if GFX_USE_TDISP || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/* Include the low level driver information */
|
/**
|
||||||
#include "tdisp/lld/tdisp_lld.h"
|
* @brief TDISP cursor shape definitions
|
||||||
|
*/
|
||||||
|
typedef enum cursorshape_e {
|
||||||
|
cursorOff,
|
||||||
|
cursorBlock,
|
||||||
|
cursorBlinkingBlock,
|
||||||
|
cursorUnderline,
|
||||||
|
cursorBlinkingUnderline,
|
||||||
|
cursorBar,
|
||||||
|
cursorBlinkingBar,
|
||||||
|
} cursorshape;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name TDISP display attributes
|
* @name TDISP control values
|
||||||
|
* @note The low level driver may define extra control values
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define TDISP_ON 0x01
|
#define TDISP_CTRL_BACKLIGHT 0x0000
|
||||||
#define TDISP_OFF 0x02
|
#define TDISP_CTRL_CURSOR 0x0001
|
||||||
#define TDISP_CURSOR_ON 0x03
|
|
||||||
#define TDISP_CURSOR_OFF 0x04
|
|
||||||
#define TDISP_CURSOR_BLINK_ON 0x05
|
|
||||||
#define TDISP_CURSOR_BLINK_OFF 0x06
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
* @brief TDISP driver initialisation
|
||||||
* @note This function is not implicitly invoked by @p halInit().
|
* @note This function is not implicitly invoked by @p halInit().
|
||||||
|
@ -65,10 +90,63 @@
|
||||||
*/
|
*/
|
||||||
bool_t tdispInit(void);
|
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
|
* @brief Control different display properties
|
||||||
* @note A wrapper macro exists for each option, please use them
|
* @note A wrapper macro exists for each option, please use them
|
||||||
* instead of this function manually.
|
* instead of this function manually unless calling a low
|
||||||
|
* level driver specific value.
|
||||||
*
|
*
|
||||||
* @param[in] what What you want to control
|
* @param[in] what What you want to control
|
||||||
* @param[in] value The value to be assigned
|
* @param[in] value The value to be assigned
|
||||||
|
@ -76,69 +154,50 @@ bool_t tdispInit(void);
|
||||||
void tdispControl(uint16_t what, void *value);
|
void tdispControl(uint16_t what, void *value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the display
|
* @brief Set the backlight level
|
||||||
|
*
|
||||||
|
* @param[in] percent A percentage from 0 to 100%. 0% will turn off the display
|
||||||
*/
|
*/
|
||||||
void tdispClear(void);
|
#define tdispSetBacklight(percent) tdispControl(TDISP_CTRL_BACKLIGHT, (void *)((uint8_t)(percent)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the cursor to it's home position ( 0/0 )
|
* @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.
|
||||||
*/
|
*/
|
||||||
void tdispHome(void);
|
#define tdispSetCursorShape(shape) tdispControl(TDISP_CTRL_CURSOR, (void *)((cursorshape)(shape)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set cursor to a certain position
|
* @brief Get the number of columns (width) in the display
|
||||||
*
|
|
||||||
* @param[in] col The column
|
|
||||||
* @param[in] row The row
|
|
||||||
*/
|
*/
|
||||||
void tdispSetCursor(coord_t col, coord_t row);
|
#define tdispGetColumns() (TDISP.columns)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Store a custom character in RAM
|
* @brief Get the number of rows (height) in 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 max)
|
|
||||||
* @param[in] charmap The character to be stored.
|
|
||||||
*/
|
*/
|
||||||
void tdispCreateChar(uint8_t address, char *charmap);
|
#define tdispGetRows() (TDISP.columns)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Draws a single character at the current cursor position
|
* @brief Get the number of bits in width of a character
|
||||||
*
|
|
||||||
* @param[in] c The character to be drawn
|
|
||||||
*/
|
*/
|
||||||
void tdispDrawChar(char c);
|
#define tdispGetCharBitWidth() (TDISP.charBitsX)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Draws a string at the current cursor position
|
* @brief Get the number of bits in height of a character
|
||||||
*
|
|
||||||
* @param[in] s The string to be drawn
|
|
||||||
*/
|
*/
|
||||||
void tdispDrawString(char *s);
|
#define tdispGetCharBitHeight() (TDISP.charBitsY)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Draws a single character at a given position
|
* @brief Get the number of custom characters
|
||||||
* @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);
|
#define tdispGetNumCustomChars() (TDISP.maxCustomChars)
|
||||||
|
|
||||||
/**
|
#ifdef __cplusplus
|
||||||
* @brief Draws a string at a given position
|
}
|
||||||
* @note This function manipulates the cursor position and it will not be
|
#endif
|
||||||
* 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 /* GFX_USE_TDISP */
|
||||||
|
|
||||||
|
|
|
@ -31,55 +31,87 @@
|
||||||
|
|
||||||
#if GFX_USE_TDISP || defined(__DOXYGEN__)
|
#if GFX_USE_TDISP || defined(__DOXYGEN__)
|
||||||
|
|
||||||
static uint8_t _displaycontrol;
|
#include "tdisp/lld/tdisp_lld.h"
|
||||||
|
|
||||||
|
#if TDISP_NEED_MULTITHREAD
|
||||||
|
#if !CH_USE_MUTEXES
|
||||||
|
#error "TDISP: CH_USE_MUTEXES must be defined in chconf.h because TDISP_NEED_MULTITHREAD is defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static Mutex tdispMutex;
|
||||||
|
|
||||||
|
#define MUTEX_INIT() chMtxInit(&tdispMutex)
|
||||||
|
#define MUTEX_ENTER() chMtxLock(&tdispMutex)
|
||||||
|
#define MUTEX_LEAVE() chMtxUnlock()
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MUTEX_INIT()
|
||||||
|
#define MUTEX_ENTER()
|
||||||
|
#define MUTEX_LEAVE()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool_t tdispInit(void) {
|
bool_t tdispInit(void) {
|
||||||
bool_t ret;
|
bool_t res;
|
||||||
|
|
||||||
ret = tdisp_lld_init();
|
MUTEX_INIT();
|
||||||
|
|
||||||
return ret;
|
MUTEX_ENTER();
|
||||||
}
|
res = tdisp_lld_init();
|
||||||
|
MUTEX_LEAVE();
|
||||||
|
|
||||||
void tdispControl(uint16_t what, void *value) {
|
return res;
|
||||||
tdisp_lld_control(what, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdispClear(void) {
|
void tdispClear(void) {
|
||||||
|
MUTEX_ENTER();
|
||||||
tdisp_lld_clear();
|
tdisp_lld_clear();
|
||||||
|
MUTEX_LEAVE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdispHome(void) {
|
void tdispHome(void) {
|
||||||
tdisp_lld_home();
|
MUTEX_ENTER();
|
||||||
}
|
tdisp_lld_set_cursor(0, 0);
|
||||||
|
MUTEX_LEAVE();
|
||||||
void tdispCreateChar(uint8_t address, char *charmap) {
|
|
||||||
tdisp_lld_create_char(address, charmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdispSetCursor(coord_t col, coord_t row) {
|
void tdispSetCursor(coord_t col, coord_t row) {
|
||||||
|
/* Keep the input range valid */
|
||||||
|
if (row >= TDISP.rows)
|
||||||
|
row = TDISP.rows - 1;
|
||||||
|
MUTEX_ENTER();
|
||||||
tdisp_lld_set_cursor(col, row);
|
tdisp_lld_set_cursor(col, row);
|
||||||
|
MUTEX_LEAVE();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tdispCreateChar(uint8_t address, uint8_t *charmap) {
|
||||||
|
/* make sure we don't write somewhere we're not supposed to */
|
||||||
|
if (address < TDISP.maxCustomChars) {
|
||||||
|
MUTEX_ENTER();
|
||||||
|
tdisp_lld_create_char(address, charmap);
|
||||||
|
MUTEX_LEAVE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdispDrawChar(char c) {
|
void tdispDrawChar(char c) {
|
||||||
tdisp_lld_write_data(c);
|
MUTEX_ENTER();
|
||||||
|
tdisp_lld_draw_char(c);
|
||||||
|
MUTEX_LEAVE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdispDrawString(char *s) {
|
void tdispDrawString(char *s) {
|
||||||
|
MUTEX_ENTER();
|
||||||
while(*s)
|
while(*s)
|
||||||
tdispDrawChar(*s++);
|
tdisp_lld_draw_char(*s++);
|
||||||
|
MUTEX_LEAVE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdispDrawCharLocation(coord_t col, coord_t row, char c) {
|
void tdispControl(uint16_t what, void *value) {
|
||||||
tdispSetCursor(col, row);
|
MUTEX_ENTER();
|
||||||
tdispDrawChar(c);
|
tdisp_lld_control(what, value);
|
||||||
}
|
MUTEX_LEAVE();
|
||||||
|
|
||||||
void tdispDrawStringLocation(coord_t col, coord_t row, char *s) {
|
|
||||||
tdispSetCursor(col, row);
|
|
||||||
tdispDrawString(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* GFX_USE_TDISP */
|
#endif /* GFX_USE_TDISP */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue