ugfx_release_2.6
Tectu 2012-06-01 12:44:48 +02:00
parent 5e37443a6f
commit a7295f47e9
3 changed files with 31 additions and 13 deletions

10
glcd.c
View File

@ -69,17 +69,11 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
}
uint16_t lcdGetHeight(void) {
if(PORTRAIT)
return lcd_height;
else if(LANDSCAPE)
return lcd_width;
return lcd_height;
}
uint16_t lcdGetWidth(void) {
if(PORTRAIT)
return lcd_width;
else if(LANDSCAPE)
return lcd_height;
return lcd_width;
}
static void lcdSetCursor(uint16_t x, uint16_t y) {

View File

@ -13,7 +13,7 @@ void tpInit(void) {
spiStart(&SPID1, &spicfg);
}
uint16_t tpReadX(void) {
static uint16_t readX(void) {
uint8_t txbuf[1];
uint8_t rxbuf[2];
uint16_t x;
@ -27,12 +27,10 @@ uint16_t tpReadX(void) {
x = rxbuf[0] << 4;
x |= rxbuf[1] >> 4;
x = (((lcdGetWidth()-1) * x)/2048);
return x;
}
uint16_t tpReadY(void) {
static uint16_t readY(void) {
uint8_t txbuf[1];
uint8_t rxbuf[2];
uint16_t y;
@ -46,8 +44,32 @@ uint16_t tpReadY(void) {
y = rxbuf[0] << 4;
y |= rxbuf[1] >> 4;
y = (((lcdGetHeight()-1) * y)/2048);
return y;
}
uint16_t tpReadX(void) {
uint32_t results;
uint16_t i, x;
for(i=0; i<CONVERSIONS; i++) {
results += readX();
}
x = (((lcdGetWidth()-1) * (results/CONVERSIONS)) / 2048);
return x;
}
uint16_t tpReadY(void) {
uint32_t results;
uint16_t i, y;
for(i=0; i<CONVERSIONS; i++)
results += readY();
y = (((lcdGetHeight()-1) * (results/CONVERSIONS)) / 2048);
return y;
}

View File

@ -4,6 +4,8 @@
#include "ch.h"
#include "hal.h"
#define CONVERSIONS 3
#define SET_CS(a) (TP_PORT->BSRR = 1 << (TP_CS + (a ? 0 : 16)))
void tpInit(void);