cleanups
This commit is contained in:
parent
3b19353f88
commit
7069b4b245
2 changed files with 45 additions and 35 deletions
38
glcd.c
38
glcd.c
|
@ -2,7 +2,10 @@
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static uint16_t DeviceCode;
|
#define LANDSCAPE 1
|
||||||
|
|
||||||
|
static uint8_t orientation;
|
||||||
|
static uint16_t DeviceCode, temp;
|
||||||
|
|
||||||
static __inline void lcdWriteIndex(uint16_t index) {
|
static __inline void lcdWriteIndex(uint16_t index) {
|
||||||
Clr_RS;
|
Clr_RS;
|
||||||
|
@ -34,7 +37,7 @@ static __inline uint16_t lcdReadData(void) {
|
||||||
LCD_DATA_PORT->CRH = 0x44444444;
|
LCD_DATA_PORT->CRH = 0x44444444;
|
||||||
LCD_DATA_PORT->CRL = 0x44444444;
|
LCD_DATA_PORT->CRL = 0x44444444;
|
||||||
|
|
||||||
value = LCD_DATA_PORT->IDR;
|
value = LCD_DATA_PORT->IDR; // dummy
|
||||||
value = LCD_DATA_PORT->IDR;
|
value = LCD_DATA_PORT->IDR;
|
||||||
|
|
||||||
// change pin mode back to digital output
|
// change pin mode back to digital output
|
||||||
|
@ -53,12 +56,13 @@ static __inline void lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
|
||||||
Set_CS;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
uint16_t lcdReadReg(uint16_t lcdReg) {
|
||||||
uint16_t lcdRAM;
|
uint16_t lcdRAM;
|
||||||
|
|
||||||
Clr_CS;
|
Clr_CS;
|
||||||
lcdWriteIndex(lcdReg);
|
lcdWriteIndex(lcdReg);
|
||||||
lcdRAM = lcdReadData();
|
lcdRAM = lcdReadData();
|
||||||
|
|
||||||
Set_CS;
|
Set_CS;
|
||||||
|
|
||||||
return lcdRAM;
|
return lcdRAM;
|
||||||
|
@ -84,12 +88,15 @@ static void lcdSetCursor(uint16_t Xpos,uint16_t Ypos) {
|
||||||
|
|
||||||
static void lcdDelay(uint16_t nCount) {
|
static void lcdDelay(uint16_t nCount) {
|
||||||
uint16_t TimingDelay;
|
uint16_t TimingDelay;
|
||||||
while(nCount--)
|
while(nCount--) {
|
||||||
{
|
for(TimingDelay=0;TimingDelay<10000;TimingDelay++)
|
||||||
for(TimingDelay=0;TimingDelay<10000;TimingDelay++);
|
asm("nop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcdSetOrientation(uint8_t orientation) {
|
||||||
|
orientation = orientation;
|
||||||
|
}
|
||||||
|
|
||||||
void lcdSetWindows(uint16_t xStart,uint16_t yStart,uint16_t xLong,uint16_t yLong) {
|
void lcdSetWindows(uint16_t xStart,uint16_t yStart,uint16_t xLong,uint16_t yLong) {
|
||||||
lcdSetCursor(xStart,yStart);
|
lcdSetCursor(xStart,yStart);
|
||||||
|
@ -99,15 +106,14 @@ void lcdSetWindows(uint16_t xStart,uint16_t yStart,uint16_t xLong,uint16_t yLong
|
||||||
lcdWriteReg(0x0053,yStart+yLong-1);
|
lcdWriteReg(0x0053,yStart+yLong-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdClear(uint16_t Color) {
|
void lcdClear(uint16_t color) {
|
||||||
uint32_t index=0;
|
uint32_t index=0;
|
||||||
|
|
||||||
lcdSetCursor(0,0);
|
lcdSetCursor(0,0);
|
||||||
Clr_CS;
|
Clr_CS;
|
||||||
lcdWriteIndex(0x0022);
|
lcdWriteIndex(0x0022);
|
||||||
for(index=0;index<76800;index++)
|
for(index=0;index<76800;index++)
|
||||||
{
|
lcdWriteData(color);
|
||||||
lcdWriteData(Color);
|
|
||||||
}
|
|
||||||
Set_CS;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +200,7 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdChar(unsigned short Xpos,unsigned short Ypos,unsigned char c,unsigned short charColor,unsigned short bkColor) {
|
void lcdChar(unsigned short Xpos,unsigned short Ypos,unsigned char c,unsigned short charcolor,unsigned short bkcolor) {
|
||||||
unsigned short i=0;
|
unsigned short i=0;
|
||||||
unsigned short j=0;
|
unsigned short j=0;
|
||||||
unsigned char buffer[16];
|
unsigned char buffer[16];
|
||||||
|
@ -207,22 +213,22 @@ void lcdChar(unsigned short Xpos,unsigned short Ypos,unsigned char c,unsigned sh
|
||||||
{
|
{
|
||||||
if (((tmp_char >> (7-j)) & 0x01) == 0x01)
|
if (((tmp_char >> (7-j)) & 0x01) == 0x01)
|
||||||
{
|
{
|
||||||
lcdDrawPixel(Xpos+j,Ypos+i,charColor);
|
lcdDrawPixel(Xpos+j,Ypos+i,charcolor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcdDrawPixel(Xpos+j,Ypos+i,bkColor);
|
lcdDrawPixel(Xpos+j,Ypos+i,bkcolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdString(uint16_t Xpos, uint16_t Ypos, uint8_t *str,uint16_t Color, uint16_t bkColor) {
|
void lcdString(uint16_t Xpos, uint16_t Ypos, uint8_t *str,uint16_t color, uint16_t bkcolor) {
|
||||||
uint8_t TempChar;
|
uint8_t TempChar;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
TempChar=*str++;
|
TempChar=*str++;
|
||||||
lcdChar(Xpos,Ypos,TempChar,Color,bkColor);
|
lcdChar(Xpos,Ypos,TempChar,color,bkcolor);
|
||||||
if (Xpos<232) {
|
if (Xpos<232) {
|
||||||
Xpos+=8;
|
Xpos+=8;
|
||||||
} else if (Ypos<304) {
|
} else if (Ypos<304) {
|
||||||
|
@ -632,7 +638,7 @@ void lcdInit() {
|
||||||
lcdWriteReg(0x000D,0x080C); lcdDelay(5);
|
lcdWriteReg(0x000D,0x080C); lcdDelay(5);
|
||||||
lcdWriteReg(0x000E,0x2B00); lcdDelay(5);
|
lcdWriteReg(0x000E,0x2B00); lcdDelay(5);
|
||||||
lcdWriteReg(0x001E,0x00B0); lcdDelay(5);
|
lcdWriteReg(0x001E,0x00B0); lcdDelay(5);
|
||||||
lcdWriteReg(0x0001,0x2B3F); lcdDelay(5);
|
lcdWriteReg(0x0001,0x2B3F);
|
||||||
lcdWriteReg(0x0002,0x0600); lcdDelay(5);
|
lcdWriteReg(0x0002,0x0600); lcdDelay(5);
|
||||||
lcdWriteReg(0x0010,0x0000); lcdDelay(5);
|
lcdWriteReg(0x0010,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0011,0x6070); lcdDelay(5);
|
lcdWriteReg(0x0011,0x6070); lcdDelay(5);
|
||||||
|
|
10
glcd.h
10
glcd.h
|
@ -33,11 +33,15 @@
|
||||||
(( green >> 2 ) << 5 ) | \
|
(( green >> 2 ) << 5 ) | \
|
||||||
( blue >> 3 ))
|
( blue >> 3 ))
|
||||||
|
|
||||||
|
enum orientation { Portrait = 0, Landscape = 1 };
|
||||||
|
|
||||||
|
uint16_t lcdReadReg(uint16_t reg);
|
||||||
void lcdInit(void);
|
void lcdInit(void);
|
||||||
void lcdClear(uint16_t Color);
|
void lcdClear(uint16_t color);
|
||||||
void lcdTest(void);
|
void lcdTest(void);
|
||||||
uint16_t lcdBGR2RGB(uint16_t color);
|
uint16_t lcdBGR2RGB(uint16_t color);
|
||||||
uint16_t lcdGetPoint(uint16_t Xpos,uint16_t Ypos);
|
uint16_t lcdGetPoint(uint16_t Xpos,uint16_t Ypos);
|
||||||
|
void lcdSetOrientation(uint8_t orientation);
|
||||||
void lcdDrawPixel(uint16_t Xpos,uint16_t Ypos,uint16_t point);
|
void lcdDrawPixel(uint16_t Xpos,uint16_t Ypos,uint16_t point);
|
||||||
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
void lcdDrawRect(uint8_t x0, uint16_t y0, uint8_t x1, uint16_t y1, uint8_t filled, uint16_t color);
|
void lcdDrawRect(uint8_t x0, uint16_t y0, uint8_t x1, uint16_t y1, uint8_t filled, uint16_t color);
|
||||||
|
@ -45,7 +49,7 @@ void lcdDrawCircle(uint8_t x, uint16_t y, uint16_t radius, uint8_t filled, uint1
|
||||||
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
void lcdFillArea2(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
void lcdFillArea2(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
void lcdSetWindows(uint16_t xStart,uint16_t yStart,uint16_t xLong,uint16_t yLong);
|
void lcdSetWindows(uint16_t xStart,uint16_t yStart,uint16_t xLong,uint16_t yLong);
|
||||||
void lcdString(uint16_t Xpos, uint16_t Ypos, uint8_t *str,uint16_t Color, uint16_t bkColor);
|
void lcdString(uint16_t Xpos, uint16_t Ypos, uint8_t *str,uint16_t color, uint16_t bkcolor);
|
||||||
void lcdChar(unsigned short Xpos,unsigned short Ypos,unsigned char c,unsigned short charColor,unsigned short bkColor);
|
void lcdChar(unsigned short Xpos,unsigned short Ypos,unsigned char c,unsigned short charcolor,unsigned short bkcolor);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue