2002-10-11 11:10:52 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
2002-10-18 09:20:48 +00:00
|
|
|
#include "hwcompat.h"
|
2002-10-11 11:10:52 +00:00
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "file.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "system.h"
|
2002-10-21 20:20:09 +00:00
|
|
|
|
|
|
|
#include "font-player.h"
|
2002-10-28 20:00:19 +00:00
|
|
|
#include "lcd-playersim.h"
|
2002-10-11 11:10:52 +00:00
|
|
|
|
|
|
|
/*** definitions ***/
|
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
#define CHAR_WIDTH 6
|
|
|
|
#define CHAR_HEIGHT 8
|
2002-10-28 20:00:19 +00:00
|
|
|
#define ICON_HEIGHT 24
|
|
|
|
#define CHAR_PIXEL 4
|
|
|
|
#define BORDER_MARGIN 1
|
2002-10-18 09:20:48 +00:00
|
|
|
|
2002-10-28 20:00:19 +00:00
|
|
|
unsigned char lcd_buffer[2][11];
|
2002-10-11 11:10:52 +00:00
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
static int double_height=1;
|
2002-10-28 20:00:19 +00:00
|
|
|
extern bool lcd_display_redraw;
|
|
|
|
extern unsigned const char *lcd_ascii;
|
|
|
|
|
2002-10-11 11:10:52 +00:00
|
|
|
|
2002-10-21 20:20:09 +00:00
|
|
|
void lcd_print_icon(int x, int icon_line, bool enable, char **icon)
|
2002-10-11 11:10:52 +00:00
|
|
|
{
|
2002-10-21 20:20:09 +00:00
|
|
|
int xpos = x;
|
|
|
|
int ypos = icon_line*(ICON_HEIGHT+CHAR_HEIGHT*2);
|
|
|
|
int row=0, col;
|
2002-10-28 20:00:19 +00:00
|
|
|
|
|
|
|
int p=0, cp=0;
|
|
|
|
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
|
|
|
|
struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT];
|
2002-10-21 20:20:09 +00:00
|
|
|
|
|
|
|
while (icon[row]) {
|
|
|
|
col=0;
|
|
|
|
while (icon[row][col]) {
|
2002-10-28 20:00:19 +00:00
|
|
|
switch(icon[row][col]) {
|
|
|
|
case '*':
|
|
|
|
if (enable) {
|
|
|
|
/* set a dot */
|
|
|
|
points[p].x = xpos + col +BORDER_MARGIN;
|
|
|
|
points[p].y = ypos+row +BORDER_MARGIN;
|
|
|
|
p++; /* increase the point counter */
|
|
|
|
} else {
|
|
|
|
/* clear a dot */
|
|
|
|
clearpoints[cp].x = xpos + col +BORDER_MARGIN;
|
|
|
|
clearpoints[cp].y = ypos+row +BORDER_MARGIN;
|
|
|
|
cp++; /* increase the point counter */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ' ': /* Clear bit */
|
|
|
|
/* clear a dot */
|
|
|
|
clearpoints[cp].x = xpos + col+BORDER_MARGIN;
|
|
|
|
clearpoints[cp].y = ypos+row+BORDER_MARGIN;
|
|
|
|
cp++; /* increase the point counter */
|
|
|
|
break;
|
2002-10-21 20:20:09 +00:00
|
|
|
}
|
|
|
|
col++;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
2002-10-21 20:20:09 +00:00
|
|
|
row++;
|
|
|
|
}
|
2002-10-28 20:00:19 +00:00
|
|
|
drawdots(0, &clearpoints[0], cp);
|
|
|
|
drawdots(1, &points[0], p);
|
2002-10-21 20:20:09 +00:00
|
|
|
}
|
2002-10-11 11:10:52 +00:00
|
|
|
|
2002-10-28 20:00:19 +00:00
|
|
|
void lcd_print_char(int x, int y)
|
2002-10-21 20:20:09 +00:00
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
int xpos = x * CHAR_WIDTH * CHAR_PIXEL;
|
|
|
|
int ypos = y * CHAR_HEIGHT * CHAR_PIXEL + ICON_HEIGHT;
|
2002-10-21 20:20:09 +00:00
|
|
|
int col, row;
|
2002-10-28 20:00:19 +00:00
|
|
|
int p=0, cp=0;
|
|
|
|
struct rectangle points[CHAR_HEIGHT*CHAR_WIDTH];
|
|
|
|
struct rectangle clearpoints[CHAR_HEIGHT*CHAR_WIDTH];
|
|
|
|
unsigned char ch=lcd_buffer[y][x];
|
|
|
|
|
2002-10-21 20:20:09 +00:00
|
|
|
if (double_height == 2 && y == 1)
|
|
|
|
return; /* Second row can't be printed in double height. ??*/
|
|
|
|
|
2002-10-28 20:00:19 +00:00
|
|
|
/* Clear all char
|
|
|
|
clearpoints[cp].x = xpos +BORDER_MARGIN;
|
|
|
|
clearpoints[cp].y = ypos +BORDER_MARGIN;
|
|
|
|
clearpoints[cp].width=CHAR_WIDTH*CHAR_PIXEL;
|
|
|
|
clearpoints[cp].height=7*CHAR_PIXEL*double_height;
|
|
|
|
cp++;
|
|
|
|
*/
|
2002-10-21 20:20:09 +00:00
|
|
|
for (col=0; col<5; col++) {
|
|
|
|
for (row=0; row<7; row++) {
|
2002-10-28 20:00:19 +00:00
|
|
|
char fontbit=(*font_player)[ch][col]&(1<<row);
|
|
|
|
int height=CHAR_PIXEL*double_height;
|
2002-10-21 20:20:09 +00:00
|
|
|
|
2002-10-28 20:00:19 +00:00
|
|
|
y=CHAR_PIXEL*(double_height*row)+ypos;
|
|
|
|
if (double_height==2) {
|
|
|
|
if (row == 3) /* Adjust for blank row in the middle */
|
|
|
|
height=CHAR_PIXEL;
|
|
|
|
}
|
2002-10-21 20:20:09 +00:00
|
|
|
|
2002-10-28 20:00:19 +00:00
|
|
|
if (fontbit) {
|
|
|
|
/* set a dot */
|
|
|
|
points[p].x = xpos + col*CHAR_PIXEL +BORDER_MARGIN;
|
|
|
|
points[p].y = y +BORDER_MARGIN;
|
|
|
|
points[p].width=CHAR_PIXEL;
|
|
|
|
points[p].height=height;
|
|
|
|
p++; /* increase the point counter */
|
|
|
|
} else {
|
|
|
|
clearpoints[cp].x = xpos + col*CHAR_PIXEL +BORDER_MARGIN;
|
|
|
|
clearpoints[cp].y = y +BORDER_MARGIN;
|
|
|
|
clearpoints[cp].width=CHAR_PIXEL;
|
|
|
|
clearpoints[cp].height=height;
|
|
|
|
cp++;
|
2002-10-21 20:20:09 +00:00
|
|
|
}
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
2002-10-21 20:20:09 +00:00
|
|
|
}
|
2002-10-28 20:00:19 +00:00
|
|
|
drawrectangles(0, &clearpoints[0], cp);
|
|
|
|
drawrectangles(1, &points[0], p);
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
2002-10-21 20:20:09 +00:00
|
|
|
|
|
|
|
/*
|
2002-10-11 11:10:52 +00:00
|
|
|
* Draw a rectangle with upper left corner at (x, y)
|
|
|
|
* and size (nx, ny)
|
|
|
|
*/
|
|
|
|
void lcd_drawrect (int x, int y, int nx, int ny)
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x;
|
|
|
|
(void)y;
|
|
|
|
(void)nx;
|
|
|
|
(void)ny;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Invert a rectangular area at (x, y), size (nx, ny) */
|
|
|
|
void lcd_invertrect (int x, int y, int nx, int ny)
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x;
|
|
|
|
(void)y;
|
|
|
|
(void)nx;
|
|
|
|
(void)ny;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_drawline( int x1, int y1, int x2, int y2 )
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x1;
|
|
|
|
(void)x2;
|
|
|
|
(void)y1;
|
|
|
|
(void)y2;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_clearline( int x1, int y1, int x2, int y2 )
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x1;
|
|
|
|
(void)x2;
|
|
|
|
(void)y1;
|
|
|
|
(void)y2;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a single pixel
|
|
|
|
*/
|
|
|
|
void lcd_drawpixel(int x, int y)
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x;
|
|
|
|
(void)y;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear a single pixel
|
|
|
|
*/
|
|
|
|
void lcd_clearpixel(int x, int y)
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x;
|
|
|
|
(void)y;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Invert a single pixel
|
|
|
|
*/
|
|
|
|
void lcd_invertpixel(int x, int y)
|
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
(void)x;
|
|
|
|
(void)y;
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
void lcd_clear_display(void)
|
2002-10-11 11:10:52 +00:00
|
|
|
{
|
2002-10-28 20:00:19 +00:00
|
|
|
int x, y;
|
|
|
|
for (y=0; y<2; y++) {
|
|
|
|
for (x=0; x<11; x++) {
|
2002-10-29 10:43:30 +00:00
|
|
|
lcd_buffer[y][x]=lcd_ascii[' '];
|
2002-10-28 20:00:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lcd_update();
|
2002-10-18 09:20:48 +00:00
|
|
|
}
|
2002-10-11 11:10:52 +00:00
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
void lcd_puts(int x, int y, unsigned char *str)
|
2002-10-11 11:10:52 +00:00
|
|
|
{
|
2002-10-21 20:20:09 +00:00
|
|
|
int i;
|
2002-10-29 10:43:30 +00:00
|
|
|
DEBUGF("lcd_puts(%d, %d, \"", x, y);
|
|
|
|
for (i=0; *str && x<11; i++) {
|
|
|
|
#ifdef DEBUGF
|
|
|
|
if (*str>=32 && *str<128)
|
|
|
|
{DEBUGF("%c", *str);}
|
|
|
|
else
|
|
|
|
{DEBUGF("(0x%02x)", *str);}
|
|
|
|
#endif
|
|
|
|
lcd_buffer[y][x++]=lcd_ascii[*str++];
|
|
|
|
}
|
|
|
|
DEBUGF("\")\n");
|
2002-10-21 20:20:09 +00:00
|
|
|
for (; x<11; x++)
|
2002-10-28 20:00:19 +00:00
|
|
|
lcd_buffer[y][x]=lcd_ascii[' '];
|
2002-10-18 09:20:48 +00:00
|
|
|
lcd_update();
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
void lcd_double_height(bool on)
|
2002-10-11 11:10:52 +00:00
|
|
|
{
|
2002-10-18 09:20:48 +00:00
|
|
|
double_height = 1;
|
|
|
|
if (on)
|
|
|
|
double_height = 2;
|
2002-10-29 10:43:30 +00:00
|
|
|
lcd_display_redraw=true;
|
|
|
|
lcd_update();
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
void lcd_define_pattern(int which, char *pattern, int length)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
int pat = which / 8;
|
|
|
|
char icon[8];
|
|
|
|
memset(icon, 0, sizeof icon);
|
2002-10-21 20:20:09 +00:00
|
|
|
|
2002-10-29 10:43:30 +00:00
|
|
|
DEBUGF("Defining pattern %d:", pat);
|
2002-10-18 09:20:48 +00:00
|
|
|
for (j = 0; j <= 5; j++) {
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
if ((pattern[i])&(1<<(j)))
|
|
|
|
icon[5-j] |= (1<<(i));
|
2002-10-11 11:10:52 +00:00
|
|
|
}
|
2002-10-18 09:20:48 +00:00
|
|
|
}
|
2002-10-21 20:20:09 +00:00
|
|
|
for (i = 1; i <= 5; i++)
|
2002-10-18 09:20:48 +00:00
|
|
|
{
|
2002-10-29 10:43:30 +00:00
|
|
|
DEBUGF(" 0x%02x", icon[i]);
|
2002-10-28 20:00:19 +00:00
|
|
|
(*font_player)[pat][i-1] = icon[i];
|
2002-10-18 09:20:48 +00:00
|
|
|
}
|
2002-10-29 10:43:30 +00:00
|
|
|
DEBUGF("\n");
|
2002-10-28 20:00:19 +00:00
|
|
|
lcd_display_redraw=true;
|
|
|
|
lcd_update();
|
2002-10-18 09:20:48 +00:00
|
|
|
}
|
2002-10-11 11:10:52 +00:00
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
extern void lcd_puts(int x, int y, unsigned char *str);
|
2002-10-11 11:10:52 +00:00
|
|
|
|
2002-10-18 09:20:48 +00:00
|
|
|
void lcd_putc(int x, int y, unsigned char ch)
|
|
|
|
{
|
2002-10-29 10:43:30 +00:00
|
|
|
DEBUGF("lcd_putc(%d, %d, %d '0x%02x')\n", x, y, ch, ch);
|
2002-10-28 20:00:19 +00:00
|
|
|
lcd_buffer[y][x]=lcd_ascii[ch];
|
2002-10-18 09:20:48 +00:00
|
|
|
lcd_update();
|
|
|
|
}
|