From f96700a1fe12e33475143439823061f3b88ee57e Mon Sep 17 00:00:00 2001 From: Tectu Date: Fri, 1 Jun 2012 11:46:30 +0200 Subject: [PATCH] cleanup --- fonts.c | 0 fonts.h | 0 glcd.c | 8 ++++---- glcd.h | 3 +++ lcd.mk | 1 + touchpad.c | 19 ++++++------------- touchpad.h | 0 7 files changed, 14 insertions(+), 17 deletions(-) mode change 100755 => 100644 fonts.c mode change 100755 => 100644 fonts.h mode change 100755 => 100644 glcd.c mode change 100755 => 100644 glcd.h mode change 100755 => 100644 touchpad.c mode change 100755 => 100644 touchpad.h diff --git a/fonts.c b/fonts.c old mode 100755 new mode 100644 diff --git a/fonts.h b/fonts.h old mode 100755 new mode 100644 diff --git a/glcd.c b/glcd.c old mode 100755 new mode 100644 index 4d6c4e66..bd9b269b --- a/glcd.c +++ b/glcd.c @@ -69,16 +69,16 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) { } uint16_t lcdGetHeight(void) { - if(orientation == portrait || orientation == portraitInv) + if(PORTRAIT) return lcd_height; - else if(orientation == landscape || orientation == landscapeInv) + else if(LANDSCAPE) return lcd_width; } uint16_t lcdGetWidth(void) { - if(orientation == portrait || orientation == portraitInv) + if(PORTRAIT) return lcd_width; - else if(orientation == landscape || orientation == landscapeInv) + else if(LANDSCAPE) return lcd_height; } diff --git a/glcd.h b/glcd.h old mode 100755 new mode 100644 index f00039fc..2af3ddf0 --- a/glcd.h +++ b/glcd.h @@ -7,6 +7,9 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 +#define PORTRAIT (orientation == portrait || orientation == portraitInv) +#define LANDSCAPE (orientation == landscape || orientation == landscapeInv) + /* uncomment if no board.h file used #define LCD_DATA_PORT GPIOE #define LCD_CMD_PORT GPIOD diff --git a/lcd.mk b/lcd.mk index 670669bb..4acb09cf 100644 --- a/lcd.mk +++ b/lcd.mk @@ -1,6 +1,7 @@ # LCD files. LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \ ${CHIBIOS}/ext/fonts.c \ + ${CHIBIOS}/ext/touchpad.c \ ${CHIBIOS}/ext/graph.c LCDINC = ${CHIBIOS}/ext/lcd diff --git a/touchpad.c b/touchpad.c old mode 100755 new mode 100644 index cb4603d4..d34ea308 --- a/touchpad.c +++ b/touchpad.c @@ -1,4 +1,5 @@ #include "touchpad.h" +#include "glcd.h" static void spicb(SPIDriver *spip); static const SPIConfig spicfg = { @@ -12,18 +13,6 @@ void tpInit(void) { 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) { uint8_t txbuf[1]; uint8_t rxbuf[2]; @@ -37,6 +26,8 @@ uint16_t tpReadX(void) { x = rxbuf[0] << 4; x |= rxbuf[1] >> 4; + + x = (((lcdGetWidth()-1) * x)/2048); return x; } @@ -55,6 +46,8 @@ uint16_t tpReadY(void) { y = rxbuf[0] << 4; y |= rxbuf[1] >> 4; - return y; + y = (((lcdGetHeight()-1) * y)/2048); + + return y; } diff --git a/touchpad.h b/touchpad.h old mode 100755 new mode 100644