fix
This commit is contained in:
parent
5e37443a6f
commit
a7295f47e9
3 changed files with 31 additions and 13 deletions
6
glcd.c
6
glcd.c
|
@ -69,17 +69,11 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t lcdGetHeight(void) {
|
uint16_t lcdGetHeight(void) {
|
||||||
if(PORTRAIT)
|
|
||||||
return lcd_height;
|
return lcd_height;
|
||||||
else if(LANDSCAPE)
|
|
||||||
return lcd_width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t lcdGetWidth(void) {
|
uint16_t lcdGetWidth(void) {
|
||||||
if(PORTRAIT)
|
|
||||||
return lcd_width;
|
return lcd_width;
|
||||||
else if(LANDSCAPE)
|
|
||||||
return lcd_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcdSetCursor(uint16_t x, uint16_t y) {
|
static void lcdSetCursor(uint16_t x, uint16_t y) {
|
||||||
|
|
32
touchpad.c
32
touchpad.c
|
@ -13,7 +13,7 @@ void tpInit(void) {
|
||||||
spiStart(&SPID1, &spicfg);
|
spiStart(&SPID1, &spicfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t tpReadX(void) {
|
static uint16_t readX(void) {
|
||||||
uint8_t txbuf[1];
|
uint8_t txbuf[1];
|
||||||
uint8_t rxbuf[2];
|
uint8_t rxbuf[2];
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
|
@ -27,12 +27,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t tpReadY(void) {
|
static uint16_t readY(void) {
|
||||||
uint8_t txbuf[1];
|
uint8_t txbuf[1];
|
||||||
uint8_t rxbuf[2];
|
uint8_t rxbuf[2];
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
|
@ -46,8 +44,32 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
|
#define CONVERSIONS 3
|
||||||
|
|
||||||
#define SET_CS(a) (TP_PORT->BSRR = 1 << (TP_CS + (a ? 0 : 16)))
|
#define SET_CS(a) (TP_PORT->BSRR = 1 << (TP_CS + (a ? 0 : 16)))
|
||||||
|
|
||||||
void tpInit(void);
|
void tpInit(void);
|
||||||
|
|
Loading…
Add table
Reference in a new issue