cleanup
This commit is contained in:
parent
08511c7839
commit
f96700a1fe
7 changed files with 14 additions and 17 deletions
0
fonts.c
Executable file → Normal file
0
fonts.c
Executable file → Normal file
0
fonts.h
Executable file → Normal file
0
fonts.h
Executable file → Normal file
8
glcd.c
Executable file → Normal file
8
glcd.c
Executable file → Normal file
|
@ -69,16 +69,16 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t lcdGetHeight(void) {
|
uint16_t lcdGetHeight(void) {
|
||||||
if(orientation == portrait || orientation == portraitInv)
|
if(PORTRAIT)
|
||||||
return lcd_height;
|
return lcd_height;
|
||||||
else if(orientation == landscape || orientation == landscapeInv)
|
else if(LANDSCAPE)
|
||||||
return lcd_width;
|
return lcd_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t lcdGetWidth(void) {
|
uint16_t lcdGetWidth(void) {
|
||||||
if(orientation == portrait || orientation == portraitInv)
|
if(PORTRAIT)
|
||||||
return lcd_width;
|
return lcd_width;
|
||||||
else if(orientation == landscape || orientation == landscapeInv)
|
else if(LANDSCAPE)
|
||||||
return lcd_height;
|
return lcd_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
glcd.h
Executable file → Normal file
3
glcd.h
Executable file → Normal file
|
@ -7,6 +7,9 @@
|
||||||
#define SCREEN_WIDTH 320
|
#define SCREEN_WIDTH 320
|
||||||
#define SCREEN_HEIGHT 240
|
#define SCREEN_HEIGHT 240
|
||||||
|
|
||||||
|
#define PORTRAIT (orientation == portrait || orientation == portraitInv)
|
||||||
|
#define LANDSCAPE (orientation == landscape || orientation == landscapeInv)
|
||||||
|
|
||||||
/* uncomment if no board.h file used
|
/* uncomment if no board.h file used
|
||||||
#define LCD_DATA_PORT GPIOE
|
#define LCD_DATA_PORT GPIOE
|
||||||
#define LCD_CMD_PORT GPIOD
|
#define LCD_CMD_PORT GPIOD
|
||||||
|
|
1
lcd.mk
1
lcd.mk
|
@ -1,6 +1,7 @@
|
||||||
# LCD files.
|
# LCD files.
|
||||||
LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \
|
LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \
|
||||||
${CHIBIOS}/ext/fonts.c \
|
${CHIBIOS}/ext/fonts.c \
|
||||||
|
${CHIBIOS}/ext/touchpad.c \
|
||||||
${CHIBIOS}/ext/graph.c
|
${CHIBIOS}/ext/graph.c
|
||||||
|
|
||||||
LCDINC = ${CHIBIOS}/ext/lcd
|
LCDINC = ${CHIBIOS}/ext/lcd
|
||||||
|
|
17
touchpad.c
Executable file → Normal file
17
touchpad.c
Executable file → Normal file
|
@ -1,4 +1,5 @@
|
||||||
#include "touchpad.h"
|
#include "touchpad.h"
|
||||||
|
#include "glcd.h"
|
||||||
|
|
||||||
static void spicb(SPIDriver *spip);
|
static void spicb(SPIDriver *spip);
|
||||||
static const SPIConfig spicfg = {
|
static const SPIConfig spicfg = {
|
||||||
|
@ -12,18 +13,6 @@ void tpInit(void) {
|
||||||
spiStart(&SPID1, &spicfg);
|
spiStart(&SPID1, &spicfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tpWriteData(uint8_t data) {
|
|
||||||
uint16_t tx = 0xAA;
|
|
||||||
|
|
||||||
SET_CS(0);
|
|
||||||
spiSend(&SPID1, 1, &tx);
|
|
||||||
SET_CS(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t tpReadData(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t tpReadX(void) {
|
uint16_t tpReadX(void) {
|
||||||
uint8_t txbuf[1];
|
uint8_t txbuf[1];
|
||||||
uint8_t rxbuf[2];
|
uint8_t rxbuf[2];
|
||||||
|
@ -38,6 +27,8 @@ uint16_t tpReadX(void) {
|
||||||
x = rxbuf[0] << 4;
|
x = rxbuf[0] << 4;
|
||||||
x |= rxbuf[1] >> 4;
|
x |= rxbuf[1] >> 4;
|
||||||
|
|
||||||
|
x = (((lcdGetWidth()-1) * x)/2048);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +46,8 @@ uint16_t tpReadY(void) {
|
||||||
y = rxbuf[0] << 4;
|
y = rxbuf[0] << 4;
|
||||||
y |= rxbuf[1] >> 4;
|
y |= rxbuf[1] >> 4;
|
||||||
|
|
||||||
|
y = (((lcdGetHeight()-1) * y)/2048);
|
||||||
|
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
0
touchpad.h
Executable file → Normal file
0
touchpad.h
Executable file → Normal file
Loading…
Add table
Reference in a new issue