support for Sure Electronics's 1602 LCD Display Board with USB from Mikhail

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1126 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
michael
2010-07-13 03:25:44 +00:00
parent 6826450c83
commit a9ed07b8c5
5 changed files with 50 additions and 13 deletions

View File

@@ -58,6 +58,8 @@ static char Name[] = "MatrixOrbital";
static int Model;
static int Protocol;
static char dispBuffer[2][16];
typedef struct {
int type;
char *name;
@@ -98,6 +100,7 @@ static MODEL Models[] = {
{0x36, "LK202-24-USB", 2, 20, 8, 8, 2},
{0x38, "LK204-24-USB", 4, 20, 8, 8, 2},
{0x39, "VK204-24-USB", 4, 20, 8, 8, 2},
{0x40, "DE-LD011", 2, 16, 0, 0, 3}, /* Sure electronics USB LCD board Rev.I */
{0xff, "Unknown", -1, -1, 0, 0, 0}
};
@@ -108,6 +111,8 @@ static MODEL Models[] = {
static void drv_MO_clear(void)
{
int i, j;
switch (Protocol) {
case 1:
drv_generic_serial_write("\014", 1); /* Clear Screen */
@@ -115,6 +120,19 @@ static void drv_MO_clear(void)
case 2:
drv_generic_serial_write("\376\130", 2); /* Clear Screen */
break;
case 3:
/* Sure electronics USB LCD board - clear buffer */
for (i = 0; i < 2; i++) {
for (j = 0; j < 16; j++) {
dispBuffer[i][j] = ' ';
}
}
drv_MO_write(1, 1, dispBuffer[0], 16);
drv_MO_write(1, 2, dispBuffer[1], 16);
break;
}
}
@@ -123,11 +141,18 @@ static void drv_MO_write(const int row, const int col, const char *data, const i
{
char cmd[5] = "\376Gyx";
cmd[2] = (char) col + 1;
cmd[3] = (char) row + 1;
drv_generic_serial_write(cmd, 4);
drv_generic_serial_write(data, len);
if (Models[Model].protocol == 3) { // Sure electronics USB LCD board - full line output
cmd[2] = (char) 1;
cmd[3] = (char) row + 1;
strncpy(&(dispBuffer[row][col]), data, len);
drv_generic_serial_write(cmd, 4);
drv_generic_serial_write(dispBuffer[row], 16);
} else {
cmd[2] = (char) col + 1;
cmd[3] = (char) row + 1;
drv_generic_serial_write(cmd, 4);
drv_generic_serial_write(data, len);
}
}
@@ -302,6 +327,14 @@ static int drv_MO_start(const char *section, const int quiet)
Model = -1;
}
if (Models[i].protocol == 3) { // Sure electronics USB LCD board - full line output
int i, j;
for (i = 0; i < 2; i++) { // Clear buffer
for (j = 0; j < 16; j++) {
dispBuffer[i][j] = ' ';
}
}
}
if (drv_generic_serial_open(section, Name, 0) < 0)
return -1;
@@ -544,11 +577,15 @@ int drv_MO_quit(const int quiet)
/* clear display */
drv_MO_clear();
usleep(300000);
/* say goodbye... */
if (!quiet) {
drv_generic_text_greet("goodbye!", NULL);
}
usleep(300000);
drv_generic_serial_close();
return (0);

View File

@@ -203,7 +203,7 @@ static void drv_PICGraphic_blit(const int row, const int col, const int height,
delayDone = 0;
int row8, height8;
row8 = 8 * (row / 8);
height8 = 8 * (height / 8) + !!(height % 8);
height8 = 8 * (height / 8) + ! !(height % 8);
info("sending blit");
cmd[0] = 'b';
cmd[1] = row8;

View File

@@ -37,9 +37,9 @@
#include "config.h"
#ifdef HAVE_USB_H
# include <usb.h>
#include <usb.h>
#else
# error The USB-HUB driver only makes sense with USB support
#error The USB-HUB driver only makes sense with USB support
#endif
#include "debug.h"

View File

@@ -124,10 +124,10 @@ static struct ftdi_context *Ftdi = NULL;
/* define TRUE and FALSE for better code readability if not already defined */
#ifndef TRUE
# define TRUE 1
#define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#define FALSE 0
#endif

View File

@@ -31,14 +31,14 @@
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
static inline void rep_nop(void)
{
# if defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
#if defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
/* intel or amd64 arch, the "rep" and "nop" opcodes are available */
__asm__ __volatile__("rep; nop");
# else
#else
/* other Arch, maybe add core cooldown code here, too. */
do {
} while (0);
# endif
#endif
}
void udelay_init(void);