New common 5x8 font for t6963, sed1520, mdm166a and i2500vfd. It resembles
the original font of the HD44780 with European character set, but includes only characters from ISO 8859-1 and has been extended with bar graph and icons. The t6963 driver now has its size to be configured in pixels! The size in characters is automatically calculated based on the cell size. This makes internal calculations more easy.
This commit is contained in:
+74
-90
@@ -13,6 +13,10 @@
|
||||
* 17 (Slct) ------------ /RD
|
||||
* + 5V --- FS (6x8 font)
|
||||
*\endverbatim
|
||||
*
|
||||
* \note The driver does not provide cellwidth / cellheight API functions.
|
||||
* Thus the default cell size of 5x8 is assumed by server core! This
|
||||
* works fine with the 5x8 font loaded into the controller.
|
||||
*/
|
||||
|
||||
/*-
|
||||
@@ -30,7 +34,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -40,8 +43,7 @@
|
||||
|
||||
#include "lcd.h"
|
||||
#include "t6963.h"
|
||||
#include "t6963_font.h"
|
||||
|
||||
#include "glcd_font5x8.h"
|
||||
#include "timing.h"
|
||||
#include "report.h"
|
||||
#include "lcd_lib.h"
|
||||
@@ -53,17 +55,16 @@
|
||||
#define nRD nSEL
|
||||
#define nCE nLF
|
||||
#define T_CMD INIT
|
||||
#define T_DATA 0x00
|
||||
#define T_DATA 0x00 /* ~INIT didn't work here */
|
||||
|
||||
/** private data for the \c t6963 driver */
|
||||
typedef struct t6963_private_data {
|
||||
u16 port;
|
||||
u8 *display_buffer1;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int cellwidth;
|
||||
int cellheight;
|
||||
int px_width, px_heigth; /* size in pixels */
|
||||
int width, height; /* size in characters */
|
||||
int bytes_per_line; /* memory allocated per line */
|
||||
short bidirectLPT;
|
||||
short delayBus;
|
||||
} PrivateData;
|
||||
@@ -78,7 +79,7 @@ MODULE_EXPORT char *symbol_prefix = "t6963_";
|
||||
* API: Initialize the driver.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
t6963_init(Driver * drvthis)
|
||||
t6963_init(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p;
|
||||
int w, h;
|
||||
@@ -93,15 +94,9 @@ t6963_init(Driver * drvthis)
|
||||
if (drvthis->store_private_ptr(drvthis, p))
|
||||
return -1;
|
||||
|
||||
/* initialize private data */
|
||||
p->cellwidth = DEFAULT_CELL_WIDTH;
|
||||
p->cellheight = DEFAULT_CELL_HEIGHT;
|
||||
|
||||
debug(RPT_DEBUG, "T6963: reading config file...");
|
||||
|
||||
/* Read config file */
|
||||
|
||||
/* Which size? */
|
||||
/* Read display size in pixels */
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
|
||||
size[sizeof(size) - 1] = '\0';
|
||||
if ((sscanf(size, "%dx%d", &w, &h) != 2)
|
||||
@@ -111,8 +106,18 @@ t6963_init(Driver * drvthis)
|
||||
drvthis->name, size, DEFAULT_SIZE);
|
||||
sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
|
||||
}
|
||||
p->width = w;
|
||||
p->height = h;
|
||||
p->px_width = w;
|
||||
p->px_heigth = h;
|
||||
|
||||
/*
|
||||
* Calculate the size in characters and the number of actual bytes
|
||||
* required per display line. The number of bytes may be different
|
||||
* to the number of columns if the the width in pixels is not a
|
||||
* multiple of the cell width.
|
||||
*/
|
||||
p->width = p->px_width / DEFAULT_CELL_WIDTH;
|
||||
p->bytes_per_line = (p->px_width % DEFAULT_CELL_WIDTH) ? p->width + 1 : p->width;
|
||||
p->height = p->px_heigth / DEFAULT_CELL_HEIGHT;
|
||||
|
||||
/* Which port? */
|
||||
p->port = drvthis->config_get_int(drvthis->name, "Port", 0, DEFAULT_PORT);
|
||||
@@ -142,13 +147,13 @@ t6963_init(Driver * drvthis)
|
||||
}
|
||||
|
||||
/* Allocate and clear memory for frame buffer */
|
||||
p->display_buffer1 = malloc(p->width * p->height);
|
||||
p->display_buffer1 = malloc(p->bytes_per_line * p->height);
|
||||
if (p->display_buffer1 == NULL) {
|
||||
report(RPT_ERR, "%s: No memory for frame buffer", drvthis->name);
|
||||
t6963_close(drvthis);
|
||||
return -1;
|
||||
}
|
||||
memset(p->display_buffer1, ' ', p->width * p->height);
|
||||
memset(p->display_buffer1, ' ', p->bytes_per_line * p->height);
|
||||
|
||||
/* ------------------- I N I T I A L I Z A T I O N --------------- */
|
||||
if (p->bidirectLPT == 1) {
|
||||
@@ -163,22 +168,12 @@ t6963_init(Driver * drvthis)
|
||||
}
|
||||
|
||||
debug(RPT_INFO, "T6963: Sending init to display...");
|
||||
/*
|
||||
* Note: I assume display has a width that is a multiple of 8 (e.g.
|
||||
* 128, 160, 240, etc). If this is not a multiple of the cellwidth
|
||||
* the display has excess pixels on the right. In this case make the
|
||||
* controller think we have one column more which will be filled with
|
||||
* a space on flush. This avoids incorrect excess pixels on the right.
|
||||
*/
|
||||
w = p->width;
|
||||
if ((p->width * p->cellwidth) % 8)
|
||||
w++;
|
||||
|
||||
/* Set text and graphic addresses */
|
||||
t6963_low_command_word(drvthis, SET_GRAPHIC_HOME_ADDRESS, GRAPHIC_BASE);
|
||||
t6963_low_command_word(drvthis, SET_GRAPHIC_AREA, w);
|
||||
t6963_low_command_word(drvthis, SET_GRAPHIC_AREA, p->bytes_per_line);
|
||||
t6963_low_command_word(drvthis, SET_TEXT_HOME_ADDRESS, TEXT_BASE);
|
||||
t6963_low_command_word(drvthis, SET_TEXT_AREA, w);
|
||||
t6963_low_command_word(drvthis, SET_TEXT_AREA, p->bytes_per_line);
|
||||
|
||||
/* Enable external character generator */
|
||||
t6963_low_command(drvthis, SET_MODE | OR_MODE | EXTERNAL_CG);
|
||||
@@ -206,7 +201,7 @@ t6963_init(Driver * drvthis)
|
||||
* API: Close the driver.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_close(Driver * drvthis)
|
||||
t6963_close(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
@@ -227,7 +222,7 @@ t6963_close(Driver * drvthis)
|
||||
* API: Returns the display width
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
t6963_width(Driver * drvthis)
|
||||
t6963_width(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
@@ -238,7 +233,7 @@ t6963_width(Driver * drvthis)
|
||||
* API: Returns the display height
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
t6963_height(Driver * drvthis)
|
||||
t6963_height(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
@@ -249,12 +244,12 @@ t6963_height(Driver * drvthis)
|
||||
* API: Clears the LCD screen (clear display buffer)
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_clear(Driver * drvthis)
|
||||
t6963_clear(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
debug(RPT_DEBUG, "Clearing Display of size %d x %d", p->width, p->height);
|
||||
memset(p->display_buffer1, ' ', p->width * p->height);
|
||||
debug(RPT_DEBUG, "Clearing Display of size %d x %d", p->bytes_per_line, p->height);
|
||||
memset(p->display_buffer1, ' ', p->bytes_per_line * p->height);
|
||||
debug(RPT_DEBUG, "Done");
|
||||
}
|
||||
|
||||
@@ -263,19 +258,11 @@ t6963_clear(Driver * drvthis)
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
static void
|
||||
t6963_graphic_clear(Driver * drvthis)
|
||||
t6963_graphic_clear(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int i, num;
|
||||
|
||||
/*
|
||||
* If width * cellwidth is not a multiple of 8 we have an additional
|
||||
* column on the right.
|
||||
*/
|
||||
if ((p->width * p->cellwidth) % 8)
|
||||
num = (p->width + 1) * p->height * p->cellheight;
|
||||
else
|
||||
num = p->width * p->height * p->cellheight;
|
||||
int num = p->bytes_per_line * p->px_heigth;
|
||||
int i;
|
||||
|
||||
debug(RPT_DEBUG, "Clearing Graphic %d bytes", num);
|
||||
|
||||
@@ -290,7 +277,7 @@ t6963_graphic_clear(Driver * drvthis)
|
||||
* API: Flushes all output to the lcd.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_flush(Driver * drvthis)
|
||||
t6963_flush(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int r, c, line_address;
|
||||
@@ -313,10 +300,10 @@ t6963_flush(Driver * drvthis)
|
||||
t6963_low_auto_write(drvthis, p->display_buffer1[line_address + c]);
|
||||
}
|
||||
/*
|
||||
* If width * cellwidth is not a multiple of 8 write a space
|
||||
* into an additional column on the right.
|
||||
* If width is not identical with bytes_per_line there must be
|
||||
* one additional empty column on the right.
|
||||
*/
|
||||
if ((p->width * p->cellwidth) % 8)
|
||||
if (p->width != p->bytes_per_line)
|
||||
t6963_low_auto_write(drvthis, ' ');
|
||||
}
|
||||
t6963_low_command(drvthis, AUTO_RESET);
|
||||
@@ -327,7 +314,7 @@ t6963_flush(Driver * drvthis)
|
||||
* upper-left is (1,1), and the lower right should be (width,height).
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_string(Driver * drvthis, int x, int y, const char string[])
|
||||
t6963_string(Driver *drvthis, int x, int y, const char string[])
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int len;
|
||||
@@ -354,7 +341,7 @@ t6963_string(Driver * drvthis, int x, int y, const char string[])
|
||||
* upper-left is (1,1), and the lower right should be (width,height).
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_chr(Driver * drvthis, int x, int y, char c)
|
||||
t6963_chr(Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
@@ -381,18 +368,17 @@ t6963_chr(Driver * drvthis, int x, int y, char c)
|
||||
static void
|
||||
t6963_set_nchar(Driver *drvthis, int n, int num)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int chr, row;
|
||||
char letter;
|
||||
unsigned char mask = (1 << p->cellwidth) - 1;
|
||||
unsigned char mask = (1 << GLCD_FONT_WIDTH) - 1;
|
||||
|
||||
debug(RPT_DEBUG, "Loading font");
|
||||
|
||||
t6963_low_command_word(drvthis, SET_ADDRESS_POINTER, CHARGEN_BASE + n * p->cellheight);
|
||||
t6963_low_command_word(drvthis, SET_ADDRESS_POINTER, CHARGEN_BASE + n * DEFAULT_CELL_HEIGHT);
|
||||
t6963_low_command(drvthis, AUTO_WRITE);
|
||||
for (chr = 0; chr < num; chr++) {
|
||||
for (row = 0; row < p->cellheight; row++) {
|
||||
letter = fontdata_6x8[chr][row] & mask;
|
||||
for (row = 0; row < DEFAULT_CELL_HEIGHT; row++) {
|
||||
letter = glcd_iso8859_1[chr][row] & mask;
|
||||
t6963_low_auto_write(drvthis, letter);
|
||||
}
|
||||
}
|
||||
@@ -404,12 +390,12 @@ t6963_set_nchar(Driver *drvthis, int n, int num)
|
||||
* overwriting an existing character.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_set_char(Driver * drvthis, int n, unsigned char *dat)
|
||||
t6963_set_char(Driver *drvthis, int n, unsigned char *dat)
|
||||
{
|
||||
if (!dat || n < 0 || n > 255)
|
||||
return;
|
||||
|
||||
memcpy(fontdata_6x8[n], dat, 8);
|
||||
memcpy(glcd_iso8859_1[n], dat, 8);
|
||||
t6963_set_nchar(drvthis, n, 1);
|
||||
}
|
||||
|
||||
@@ -417,45 +403,43 @@ t6963_set_char(Driver * drvthis, int n, unsigned char *dat)
|
||||
* API: Draws a vertical bar, from the bottom of the screen up.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_vbar(Driver * drvthis, int x, int y, int len, int promille, int options)
|
||||
t6963_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, 211);
|
||||
lib_vbar_static(drvthis, x, y, len, promille, options, DEFAULT_CELL_HEIGHT, 0x90);
|
||||
}
|
||||
|
||||
/**
|
||||
* API: Draws a horizontal bar to the right.
|
||||
*
|
||||
* \note For hBars the actual width of the font (5) has to be used instead
|
||||
* of the cell width (6)!
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
t6963_hbar(Driver * drvthis, int x, int y, int len, int promille, int options)
|
||||
t6963_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int pixels = ((long) 2 * len * GLCD_FONT_WIDTH) * promille / 2000;
|
||||
int pos;
|
||||
|
||||
lib_hbar_static(drvthis, x, y, len, promille, options, p->cellwidth, 219);
|
||||
for (pos = 0; pos < len; pos++) {
|
||||
if (pixels >= GLCD_FONT_WIDTH )
|
||||
t6963_chr(drvthis, x + pos, y, 0x9e);
|
||||
else if (pixels >= 1)
|
||||
t6963_chr(drvthis, x + pos, y, 0x99 + pixels);
|
||||
else
|
||||
; /* do nothing */
|
||||
pixels -= GLCD_FONT_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API: Sets an icon...
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
t6963_icon(Driver * drvthis, int x, int y, int icon)
|
||||
t6963_icon(Driver *drvthis, int x, int y, int icon)
|
||||
{
|
||||
debug(RPT_DEBUG, "T6963: set icon %d", icon);
|
||||
switch (icon) {
|
||||
case ICON_BLOCK_FILLED:
|
||||
t6963_chr(drvthis, x, y, 219);
|
||||
break;
|
||||
case ICON_HEART_FILLED:
|
||||
t6963_chr(drvthis, x, y, 3);
|
||||
break;
|
||||
case ICON_HEART_OPEN:
|
||||
t6963_chr(drvthis, x, y, 4);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return (glcd_icon5x8(drvthis, x, y, icon));
|
||||
}
|
||||
|
||||
|
||||
@@ -466,7 +450,7 @@ t6963_icon(Driver * drvthis, int x, int y, int icon)
|
||||
* \return 0 on success, -1 if ready could not be read
|
||||
*/
|
||||
static inline int
|
||||
t6963_low_dsp_ready(Driver * drvthis, u8 sta)
|
||||
t6963_low_dsp_ready(Driver *drvthis, u8 sta)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int portcontrol = 0;
|
||||
@@ -515,7 +499,7 @@ t6963_low_dsp_ready(Driver * drvthis, u8 sta)
|
||||
* \param byte Data byte.
|
||||
*/
|
||||
static inline void
|
||||
t6963_low_send(Driver * drvthis, u8 type, u8 byte)
|
||||
t6963_low_send(Driver *drvthis, u8 type, u8 byte)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int portcontrol = 0;
|
||||
@@ -539,7 +523,7 @@ t6963_low_send(Driver * drvthis, u8 type, u8 byte)
|
||||
* \param byte Data byte.
|
||||
*/
|
||||
static void
|
||||
t6963_low_data(Driver * drvthis, u8 byte)
|
||||
t6963_low_data(Driver *drvthis, u8 byte)
|
||||
{
|
||||
t6963_low_dsp_ready(drvthis, STA0|STA1);
|
||||
t6963_low_send(drvthis, T_DATA, byte);
|
||||
@@ -551,7 +535,7 @@ t6963_low_data(Driver * drvthis, u8 byte)
|
||||
* \param byte Command byte.
|
||||
*/
|
||||
static void
|
||||
t6963_low_command(Driver * drvthis, u8 byte)
|
||||
t6963_low_command(Driver *drvthis, u8 byte)
|
||||
{
|
||||
t6963_low_dsp_ready(drvthis, STA0|STA1);
|
||||
t6963_low_send(drvthis, T_CMD, byte);
|
||||
@@ -577,7 +561,7 @@ t6963_low_auto_write(Driver *drvthis, u8 byte)
|
||||
* \param byte Data value.
|
||||
*/
|
||||
static void
|
||||
t6963_low_command_byte(Driver * drvthis, u8 cmd, u8 byte)
|
||||
t6963_low_command_byte(Driver *drvthis, u8 cmd, u8 byte)
|
||||
{
|
||||
t6963_low_data(drvthis, byte);
|
||||
t6963_low_command(drvthis, cmd);
|
||||
@@ -591,7 +575,7 @@ t6963_low_command_byte(Driver * drvthis, u8 cmd, u8 byte)
|
||||
* \param word Data value (2 bytes)
|
||||
*/
|
||||
static void
|
||||
t6963_low_command_word(Driver * drvthis, u8 cmd, u16 word)
|
||||
t6963_low_command_word(Driver *drvthis, u8 cmd, u16 word)
|
||||
{
|
||||
t6963_low_data(drvthis, word & 0xFF);
|
||||
t6963_low_data(drvthis, (word >> 8) & 0xFF);
|
||||
|
||||
Reference in New Issue
Block a user