Merge pull request #5 from abhishek-kakkar/master
Changes in Text Rendering API
This commit is contained in:
commit
25ff65d207
6 changed files with 1161 additions and 713 deletions
|
@ -40,7 +40,7 @@ inline void lld_lcdwrite(uint16_t db)
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t lcdReadData(void) {
|
static __inline uint16_t lcdReadData(void) {
|
||||||
uint16_t value;
|
uint16_t value=0;
|
||||||
|
|
||||||
LCD_RS_HIGH;
|
LCD_RS_HIGH;
|
||||||
LCD_WR_HIGH;
|
LCD_WR_HIGH;
|
||||||
|
@ -83,21 +83,15 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdWriteIndex(uint16_t lcdReg) {
|
void lcdWriteIndex(uint16_t lcdReg) {
|
||||||
LCD_CS_LOW;
|
|
||||||
LCD_RS_LOW;
|
LCD_RS_LOW;
|
||||||
|
|
||||||
lld_lcdwrite(lcdReg);
|
lld_lcdwrite(lcdReg);
|
||||||
|
|
||||||
LCD_RS_HIGH;
|
LCD_RS_HIGH;
|
||||||
LCD_CS_HIGH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdWriteData(uint16_t lcdData) {
|
void lcdWriteData(uint16_t lcdData) {
|
||||||
LCD_CS_LOW;
|
|
||||||
|
|
||||||
lld_lcdwrite(lcdData);
|
lld_lcdwrite(lcdData);
|
||||||
|
|
||||||
LCD_CS_HIGH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) {
|
void lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) {
|
||||||
|
|
39
fonts.h
39
fonts.h
|
@ -1,12 +1,27 @@
|
||||||
#ifndef ASCIILIB_H
|
/*
|
||||||
#define ASCIILIB_H
|
* fonts.h
|
||||||
|
*
|
||||||
#include <string.h>
|
* File containing prototype of the fonts for display
|
||||||
|
*
|
||||||
//#define ASCII_8X16_MS_Gothic
|
*
|
||||||
#define ASCII_8X16_System
|
*/
|
||||||
|
|
||||||
void GetASCIICode(unsigned char* pBuffer,unsigned char ASCII);
|
#include <stdint.h>
|
||||||
|
|
||||||
#endif
|
#ifndef _FONT_
|
||||||
|
#define _FONT_
|
||||||
|
|
||||||
|
#define FONT_TABLE_HEIGHT_IDX 0
|
||||||
|
#define FONT_TABLE_PAD_AFTER_CHAR_IDX 1
|
||||||
|
#define FONT_TABLE_LINE_SPACING_IDX 2
|
||||||
|
#define FONT_TABLE_DECENDERS_HEIGHT_IDX 3
|
||||||
|
#define FONT_TABLE_UNUSED_IDX 4
|
||||||
|
#define FONT_TABLE_CHAR_LOOKUP_IDX 5
|
||||||
|
|
||||||
|
extern const uint8_t font_Small[];
|
||||||
|
extern const uint8_t font_Larger[];
|
||||||
|
//extern const uint8_t font_Medium[];
|
||||||
|
extern const uint8_t font_MediumBold[];
|
||||||
|
extern const uint8_t font_LargeNumbers[];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
557
glcd.c
557
glcd.c
|
@ -1,244 +1,313 @@
|
||||||
#include "glcd.h"
|
#include "glcd.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include <math.h>
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
uint8_t font_width = 8, font_height = 16;
|
|
||||||
uint16_t lcd_width, lcd_height;
|
uint16_t lcd_width, lcd_height;
|
||||||
|
|
||||||
void lcdInit(void) {
|
uint16_t bgcolor=White, fgcolor=Black;
|
||||||
lld_lcdInit();
|
uint16_t cx, cy;
|
||||||
lcd_width = SCREEN_WIDTH;
|
|
||||||
lcd_height = SCREEN_HEIGHT;
|
static uint8_t tpText=0;
|
||||||
}
|
|
||||||
|
const uint8_t* font;
|
||||||
uint16_t lcdGetHeight(void) {
|
|
||||||
return lld_lcdGetHeight();
|
void lcdInit(void) {
|
||||||
}
|
lld_lcdInit();
|
||||||
|
lcd_width = SCREEN_WIDTH;
|
||||||
uint16_t lcdGetWidth(void) {
|
lcd_height = SCREEN_HEIGHT;
|
||||||
return lld_lcdGetWidth();
|
|
||||||
}
|
lcdSetFont(font_MediumBold);
|
||||||
|
}
|
||||||
uint16_t lcdGetOrientation(void) {
|
|
||||||
return lld_lcdGetOrientation();
|
uint16_t lcdGetHeight(void) {
|
||||||
}
|
return lld_lcdGetHeight();
|
||||||
|
}
|
||||||
static void lcdSetCursor(uint16_t x, uint16_t y) {
|
|
||||||
lld_lcdSetCursor(x, y);
|
uint16_t lcdGetWidth(void) {
|
||||||
}
|
return lld_lcdGetWidth();
|
||||||
|
}
|
||||||
void lcdSetOrientation(uint8_t newOrientation) {
|
|
||||||
lld_lcdSetOrientation(newOrientation);
|
uint16_t lcdGetOrientation(void) {
|
||||||
}
|
return lld_lcdGetOrientation();
|
||||||
|
}
|
||||||
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
|
||||||
lld_lcdSetWindow(x0, y0, x1, y1);
|
static void lcdSetCursor(uint16_t x, uint16_t y) {
|
||||||
}
|
lld_lcdSetCursor(x, y);
|
||||||
|
}
|
||||||
void lcdClear(uint16_t color) {
|
|
||||||
lld_lcdClear(color);
|
void lcdSetOrientation(uint8_t newOrientation) {
|
||||||
}
|
lld_lcdSetOrientation(newOrientation);
|
||||||
|
}
|
||||||
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y) {
|
|
||||||
return lld_lcdGetPixelColor(x, y);
|
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
}
|
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||||
|
}
|
||||||
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
|
||||||
lld_lcdDrawPixel(x, y, color);
|
void lcdClear(uint16_t color) {
|
||||||
}
|
lld_lcdClear(color);
|
||||||
|
}
|
||||||
void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
|
||||||
int16_t dy, dx;
|
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y) {
|
||||||
int16_t addx=1, addy=1;
|
return lld_lcdGetPixelColor(x, y);
|
||||||
int16_t P, diff;
|
}
|
||||||
|
|
||||||
int16_t i=0;
|
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
||||||
dx = abs((int16_t)(x2 - x1));
|
lld_lcdDrawPixel(x, y, color);
|
||||||
dy = abs((int16_t)(y2 - y1));
|
}
|
||||||
|
|
||||||
if(x1 > x2)
|
void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
||||||
addx = -1;
|
int16_t dy, dx;
|
||||||
if(y1 > y2)
|
int16_t addx=1, addy=1;
|
||||||
addy = -1;
|
int16_t P, diff;
|
||||||
|
|
||||||
if(dx >= dy)
|
int16_t i=0;
|
||||||
{
|
dx = abs((int16_t)(x2 - x1));
|
||||||
dy *= 2;
|
dy = abs((int16_t)(y2 - y1));
|
||||||
P = dy - dx;
|
|
||||||
diff = P - dx;
|
if(x1 > x2)
|
||||||
|
addx = -1;
|
||||||
for(; i<=dx; ++i)
|
if(y1 > y2)
|
||||||
{
|
addy = -1;
|
||||||
lcdDrawPixel(x1, y1, color);
|
|
||||||
|
if(dx >= dy)
|
||||||
if(P < 0)
|
{
|
||||||
{
|
dy *= 2;
|
||||||
P += dy;
|
P = dy - dx;
|
||||||
x1 += addx;
|
diff = P - dx;
|
||||||
}
|
|
||||||
else
|
for(; i<=dx; ++i)
|
||||||
{
|
{
|
||||||
P += diff;
|
lcdDrawPixel(x1, y1, color);
|
||||||
x1 += addx;
|
|
||||||
y1 += addy;
|
if(P < 0)
|
||||||
}
|
{
|
||||||
}
|
P += dy;
|
||||||
}
|
x1 += addx;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
dx *= 2;
|
{
|
||||||
P = dx - dy;
|
P += diff;
|
||||||
diff = P - dy;
|
x1 += addx;
|
||||||
|
y1 += addy;
|
||||||
for(; i<=dy; ++i)
|
}
|
||||||
{
|
}
|
||||||
lcdDrawPixel(x1, y1, color);
|
}
|
||||||
|
else
|
||||||
if(P < 0)
|
{
|
||||||
{
|
dx *= 2;
|
||||||
P += dx;
|
P = dx - dy;
|
||||||
y1 += addy;
|
diff = P - dy;
|
||||||
}
|
|
||||||
else
|
for(; i<=dy; ++i)
|
||||||
{
|
{
|
||||||
P += diff;
|
lcdDrawPixel(x1, y1, color);
|
||||||
x1 += addx;
|
|
||||||
y1 += addy;
|
if(P < 0)
|
||||||
}
|
{
|
||||||
}
|
P += dx;
|
||||||
}
|
y1 += addy;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
void lcdDrawChar(uint16_t x, uint16_t y, const char c, uint16_t charcolor, uint16_t bkcolor) {
|
{
|
||||||
uint16_t i = 0;
|
P += diff;
|
||||||
uint16_t j = 0;
|
x1 += addx;
|
||||||
unsigned char buffer[16];
|
y1 += addy;
|
||||||
unsigned char tmp_char=0;
|
}
|
||||||
|
}
|
||||||
GetASCIICode(buffer,c);
|
}
|
||||||
|
}
|
||||||
for (i=0;i<16;i++) {
|
|
||||||
tmp_char=buffer[i];
|
void lcdEnableTransparentText(uint8_t en) {
|
||||||
for (j=0;j<8;j++) {
|
tpText=en;
|
||||||
if (((tmp_char >> (7-j)) & 0x01) == 0x01)
|
}
|
||||||
lcdDrawPixel(x+j,y+i,charcolor);
|
|
||||||
else
|
void lcdDrawChar(char c) {
|
||||||
lcdDrawPixel(x+j,y+i,bkcolor);
|
const uint8_t* ptr;
|
||||||
}
|
|
||||||
}
|
uint8_t fontHeight=lcdGetCurFontHeight();
|
||||||
}
|
uint8_t sps=font[FONT_TABLE_PAD_AFTER_CHAR_IDX];
|
||||||
|
|
||||||
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor) {
|
uint16_t chi;
|
||||||
uint8_t TempChar;
|
|
||||||
|
uint16_t x,y;
|
||||||
do {
|
|
||||||
TempChar = *str++;
|
// No support for nongraphic characters, so just ignore them
|
||||||
lcdDrawChar(x, y, TempChar, color, bkcolor);
|
if (c<0x20||c>0x7F) {
|
||||||
if(x<232) {
|
if (c=='\n') lcdLineBreak();
|
||||||
x+=8;
|
return;
|
||||||
} else if(y<304) {
|
}
|
||||||
x=0;
|
|
||||||
y+=16;
|
chi=*(uint16_t*)(&font[FONT_TABLE_CHAR_LOOKUP_IDX+ (c-0x20)*2]);
|
||||||
} else {
|
|
||||||
x=0;
|
ptr=font+chi;
|
||||||
y=0;
|
|
||||||
}
|
uint8_t fontWidth=*(ptr++);
|
||||||
} while(*str != 0);
|
|
||||||
}
|
if (cx+fontWidth>lcdGetWidth()) lcdLineBreak();
|
||||||
|
|
||||||
uint16_t lcdBGR2RGB(uint16_t color) {
|
for (x=0;x<fontWidth;x++) {
|
||||||
uint16_t r, g, b, rgb;
|
chi=*(uint16_t*)ptr;
|
||||||
|
|
||||||
b = ( color>>0 ) & 0x1f;
|
for (y=0;y<fontHeight;y++) {
|
||||||
g = ( color>>5 ) & 0x3f;
|
|
||||||
r = ( color>>11 ) & 0x1f;
|
if (chi&0x01)
|
||||||
|
lcdDrawPixel(cx+x, cy+y, fgcolor);
|
||||||
rgb = (b<<11) + (g<<5) + (r<<0);
|
else if (!tpText)
|
||||||
|
lcdDrawPixel(cx+x, cy+y, bgcolor);
|
||||||
return( rgb );
|
|
||||||
}
|
chi>>=1;
|
||||||
|
}
|
||||||
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
ptr+=2;
|
||||||
lcdDrawRect(x0, y0, x1, y1, filled, color);
|
}
|
||||||
/*
|
|
||||||
uint32_t index = 0, area;
|
cx+=fontWidth;
|
||||||
|
if (sps!=0) {
|
||||||
area = ((x1-x0)*(y1-y0));
|
if (!tpText) lcdFillArea(cx,cy,sps,fontHeight,fgcolor);
|
||||||
|
cx+=sps;
|
||||||
lcdSetWindow(x0, y0, x1, y1);
|
}
|
||||||
Clr_CS;
|
}
|
||||||
lcdWriteIndex(0x0022);
|
|
||||||
for(index = 0; index < area; index++)
|
void lcdPutString(const char *str) {
|
||||||
lcdWriteData(color);
|
while (*str) lcdDrawChar(*str++);
|
||||||
Set_CS;
|
}
|
||||||
*/
|
|
||||||
}
|
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor) {
|
||||||
|
uint16_t _bg=bgcolor, _fg=fgcolor;
|
||||||
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
cx=x;
|
||||||
uint16_t i, TempX;
|
cy=y;
|
||||||
uint16_t j, TempY;
|
bgcolor=bkcolor;
|
||||||
|
fgcolor=color;
|
||||||
if (x0 > x1) {
|
lcdPutString(str);
|
||||||
TempX = x1;
|
bgcolor=_bg;
|
||||||
x1 = x0;
|
fgcolor=_fg;
|
||||||
x0 = TempX;
|
}
|
||||||
}
|
|
||||||
if (y0 > y1) {
|
uint16_t lcdMeasureChar(char c) {
|
||||||
TempY = y1;
|
const uint8_t* ptr;
|
||||||
y1 = y0;
|
|
||||||
y0 = TempY;
|
// First get spaces after each character, usually 0 but can change
|
||||||
}
|
uint8_t sps=font[FONT_TABLE_PAD_AFTER_CHAR_IDX];
|
||||||
if(filled) {
|
|
||||||
for(i=x0; i<x1; i++)
|
uint16_t chi;
|
||||||
for(j=y0; j<y1; j++)
|
|
||||||
lcdDrawPixel(i , j , color);
|
if (c<0x20||c>0x7F) {
|
||||||
} else {
|
return 0;
|
||||||
lcdDrawLine(x0, y0, x1, y0, color);
|
}
|
||||||
lcdDrawLine(x0, y1, x1, y1, color);
|
|
||||||
lcdDrawLine(x0, y0, x0, y1, color);
|
chi=*(uint16_t*)(&font[FONT_TABLE_CHAR_LOOKUP_IDX+ (c-0x20)*2]);
|
||||||
lcdDrawLine(x1, y0, x1, y1, color);
|
|
||||||
}
|
ptr=font+chi;
|
||||||
}
|
|
||||||
|
uint8_t fontWidth=*(ptr++);
|
||||||
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t *str, uint16_t fontColor, uint16_t bkColor) {
|
|
||||||
if(((strlen(str)*8) < (x1-x0)) && ((y1-y0) > font_height)) {
|
return fontWidth+sps;
|
||||||
uint16_t off_left, off_up;
|
}
|
||||||
|
|
||||||
off_left = ((x1-x0) - (strlen(str) * font_width)) / 2;
|
uint16_t lcdMeasureString(const char* str) {
|
||||||
off_up = ((y1-y0) - font_height) / 2;
|
uint16_t result=0;
|
||||||
|
while (*str) result+=lcdMeasureChar(*str++);
|
||||||
lcdDrawRect(x0, y0, x1, y1, 1, bkColor);
|
return result;
|
||||||
lcdDrawString(x0 + off_left, y0 + off_up, str, fontColor, bkColor);
|
}
|
||||||
}
|
|
||||||
}
|
void lcdLineBreak() {
|
||||||
|
// x=0 seems too much on the edge. So I keep it at 3
|
||||||
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color) {
|
cx=3;
|
||||||
int16_t a, b, P;
|
cy+=lcdGetCurFontHeight();
|
||||||
a = 0;
|
}
|
||||||
b = radius;
|
|
||||||
P = 1 - radius;
|
uint16_t lcdBGR2RGB(uint16_t color) {
|
||||||
|
uint16_t r, g, b, rgb;
|
||||||
do {
|
|
||||||
if(filled) {
|
b = ( color>>0 ) & 0x1f;
|
||||||
lcdDrawLine(x-a, y+b, x+a, y+b, color);
|
g = ( color>>5 ) & 0x3f;
|
||||||
lcdDrawLine(x-a, y-b, x+a, y-b, color);
|
r = ( color>>11 ) & 0x1f;
|
||||||
lcdDrawLine(x-b, y+a, x+b, y+a, color);
|
|
||||||
lcdDrawLine(x-b, y-a, x+b, y-a, color);
|
rgb = (b<<11) + (g<<5) + (r<<0);
|
||||||
} else {
|
|
||||||
lcdDrawPixel(a+x, b+y, color);
|
return( rgb );
|
||||||
lcdDrawPixel(b+x, a+y, color);
|
}
|
||||||
lcdDrawPixel(x-a, b+y, color);
|
|
||||||
lcdDrawPixel(x-b, a+y, color);
|
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||||
lcdDrawPixel(b+x, y-a, color);
|
lcdDrawRect(x0, y0, x1, y1, filled, color);
|
||||||
lcdDrawPixel(a+x, y-b, color);
|
/*
|
||||||
lcdDrawPixel(x-a, y-b, color);
|
uint32_t index = 0, area;
|
||||||
lcdDrawPixel(x-b, y-a, color);
|
|
||||||
}
|
area = ((x1-x0)*(y1-y0));
|
||||||
|
|
||||||
if(P < 0)
|
lcdSetWindow(x0, y0, x1, y1);
|
||||||
P += 3 + 2*a++;
|
Clr_CS;
|
||||||
else
|
lcdWriteIndex(0x0022);
|
||||||
P += 5 + 2*(a++ - b--);
|
for(index = 0; index < area; index++)
|
||||||
} while(a <= b);
|
lcdWriteData(color);
|
||||||
}
|
Set_CS;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
||||||
|
uint16_t i, TempX;
|
||||||
|
uint16_t j, TempY;
|
||||||
|
|
||||||
|
if (x0 > x1) {
|
||||||
|
TempX = x1;
|
||||||
|
x1 = x0;
|
||||||
|
x0 = TempX;
|
||||||
|
}
|
||||||
|
if (y0 > y1) {
|
||||||
|
TempY = y1;
|
||||||
|
y1 = y0;
|
||||||
|
y0 = TempY;
|
||||||
|
}
|
||||||
|
if(filled) {
|
||||||
|
for(i=x0; i<x1; i++)
|
||||||
|
for(j=y0; j<y1; j++)
|
||||||
|
lcdDrawPixel(i , j , color);
|
||||||
|
} else {
|
||||||
|
lcdDrawLine(x0, y0, x1, y0, color);
|
||||||
|
lcdDrawLine(x0, y1, x1, y1, color);
|
||||||
|
lcdDrawLine(x0, y0, x0, y1, color);
|
||||||
|
lcdDrawLine(x1, y0, x1, y1, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char *str, uint16_t fontColor, uint16_t bkColor) {
|
||||||
|
uint16_t off_left, off_up;
|
||||||
|
|
||||||
|
off_left = ((x1-x0)-lcdMeasureString(str))/2;
|
||||||
|
off_up = ((y1-y0) - lcdGetCurFontHeight()) / 2;
|
||||||
|
|
||||||
|
lcdDrawRect(x0, y0, x1, y1, 1, bkColor);
|
||||||
|
|
||||||
|
lcdDrawString(x0+off_left, y0+off_up, str, fontColor, bkColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color) {
|
||||||
|
int16_t a, b, P;
|
||||||
|
a = 0;
|
||||||
|
b = radius;
|
||||||
|
P = 1 - radius;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if(filled) {
|
||||||
|
lcdDrawLine(x-a, y+b, x+a, y+b, color);
|
||||||
|
lcdDrawLine(x-a, y-b, x+a, y-b, color);
|
||||||
|
lcdDrawLine(x-b, y+a, x+b, y+a, color);
|
||||||
|
lcdDrawLine(x-b, y-a, x+b, y-a, color);
|
||||||
|
} else {
|
||||||
|
lcdDrawPixel(a+x, b+y, color);
|
||||||
|
lcdDrawPixel(b+x, a+y, color);
|
||||||
|
lcdDrawPixel(x-a, b+y, color);
|
||||||
|
lcdDrawPixel(x-b, a+y, color);
|
||||||
|
lcdDrawPixel(b+x, y-a, color);
|
||||||
|
lcdDrawPixel(a+x, y-b, color);
|
||||||
|
lcdDrawPixel(x-a, y-b, color);
|
||||||
|
lcdDrawPixel(x-b, y-a, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(P < 0)
|
||||||
|
P += 3 + 2*a++;
|
||||||
|
else
|
||||||
|
P += 5 + 2*(a++ - b--);
|
||||||
|
} while(a <= b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
123
glcd.h
123
glcd.h
|
@ -1,51 +1,72 @@
|
||||||
#ifndef GLCD_H
|
#ifndef GLCD_H
|
||||||
#define GLCD_H
|
#define GLCD_H
|
||||||
|
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "drivers/ssd1289_lld.h"
|
#include "drivers/ssd1289_lld.h"
|
||||||
#include "drivers/s6d1121_lld.h"
|
#include "drivers/s6d1121_lld.h"
|
||||||
|
|
||||||
#define SCREEN_WIDTH 240
|
#define SCREEN_WIDTH 240
|
||||||
#define SCREEN_HEIGHT 320
|
#define SCREEN_HEIGHT 320
|
||||||
|
|
||||||
#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
|
#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
|
||||||
#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
|
#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
|
||||||
|
|
||||||
/* LCD color */
|
/* LCD color */
|
||||||
#define White 0xFFFF
|
#define White 0xFFFF
|
||||||
#define Black 0x0000
|
#define Black 0x0000
|
||||||
#define Grey 0xF7DE
|
#define Grey 0xF7DE
|
||||||
#define Blue 0x001F
|
#define Blue 0x001F
|
||||||
#define Blue2 0x051F
|
#define Blue2 0x051F
|
||||||
#define Red 0xF800
|
#define Red 0xF800
|
||||||
#define Magenta 0xF81F
|
#define Magenta 0xF81F
|
||||||
#define Green 0x07E0
|
#define Green 0x07E0
|
||||||
#define Cyan 0x7FFF
|
#define Cyan 0x7FFF
|
||||||
#define Yellow 0xFFE0
|
#define Yellow 0xFFE0
|
||||||
|
|
||||||
#define RGB565CONVERT(red, green, blue) \
|
#define RGB565CONVERT(red, green, blue) \
|
||||||
(uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 ))
|
(uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 ))
|
||||||
|
|
||||||
enum orientation {portrait, landscape, portraitInv, landscapeInv};
|
enum orientation {portrait, landscape, portraitInv, landscapeInv};
|
||||||
enum filled {frame, filled};
|
enum filled {frame, filled};
|
||||||
|
|
||||||
void lcdInit(void);
|
// For text rendering only
|
||||||
void lcdClear(uint16_t color);
|
extern uint16_t bgcolor, fgcolor;
|
||||||
void lcdSetOrientation(uint8_t newOrientation);
|
extern uint16_t cx, cy;
|
||||||
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
extern const uint8_t* font;
|
||||||
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
|
||||||
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point);
|
// A few macros
|
||||||
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
#define lcdGotoXY(x,y) { cx=x; cy=y; }
|
||||||
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color);
|
#define lcdGetCurFontHeight() (font[FONT_TABLE_HEIGHT_IDX])
|
||||||
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t* str, uint16_t fontColor, uint16_t bkColor);
|
#define lcdSetFont(fnt) { font=fnt; }
|
||||||
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
|
|
||||||
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkColor);
|
void lcdInit(void);
|
||||||
void lcdDrawChar(uint16_t x, uint16_t y, const char c, uint16_t charcolor, uint16_t bkColor);
|
|
||||||
uint16_t lcdGetHeight(void);
|
void lcdClear(uint16_t color);
|
||||||
uint16_t lcdGetWidth(void);
|
void lcdSetOrientation(uint8_t newOrientation);
|
||||||
uint16_t lcdGetOrientation(void);
|
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
uint16_t lcdBGR2RGB(uint16_t color);
|
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y);
|
|
||||||
|
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point);
|
||||||
#endif
|
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
|
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color);
|
||||||
|
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, uint16_t fontColor, uint16_t bkColor);
|
||||||
|
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
|
||||||
|
|
||||||
|
void lcdEnableTransparentText(uint8_t en);
|
||||||
|
void lcdDrawChar(char c);
|
||||||
|
void lcdPutString(const char *str);
|
||||||
|
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor);
|
||||||
|
void lcdLineBreak(void);
|
||||||
|
|
||||||
|
uint16_t lcdMeasureChar(char c);
|
||||||
|
uint16_t lcdMeasureString(const char* str);
|
||||||
|
|
||||||
|
uint16_t lcdGetHeight(void);
|
||||||
|
uint16_t lcdGetWidth(void);
|
||||||
|
uint16_t lcdGetOrientation(void);
|
||||||
|
|
||||||
|
uint16_t lcdBGR2RGB(uint16_t color);
|
||||||
|
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -122,6 +122,7 @@ void tpCalibrate(void) {
|
||||||
|
|
||||||
lcdSetOrientation(portrait);
|
lcdSetOrientation(portrait);
|
||||||
lcdClear(Red);
|
lcdClear(Red);
|
||||||
|
cx=40; cy=10;
|
||||||
lcdDrawString(40, 10, "Touchpad Calibration", White, Red);
|
lcdDrawString(40, 10, "Touchpad Calibration", White, Red);
|
||||||
|
|
||||||
for(i=0; i<2; i++) {
|
for(i=0; i<2; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue