Have touch functions read to passed pointer

This commit is contained in:
Reed Nightingale 2020-02-09 17:58:45 -08:00
parent d9667d6756
commit bd616caaba
2 changed files with 13 additions and 13 deletions

View File

@ -145,18 +145,18 @@ static void touch_update(){
}
bool readTouch(){
bool readTouch(Point *const touch_point_out){
touch_update();
if (zraw >= Z_THRESHOLD) {
ts_point.x = xraw;
ts_point.y = yraw;
touch_point_out->x = xraw;
touch_point_out->y = yraw;
//Serial.print(ts_point.x); Serial.print(",");Serial.println(ts_point.y);
return true;
}
return false;
}
void scaleTouch(struct Point *p){
void scaleTouch(Point *const p){
p->x = ((long)(p->x - globalSettings.touchOffsetX) * 10L)/ (long)globalSettings.touchSlopeX;
p->y = ((long)(p->y - globalSettings.touchOffsetY) * 10L)/ (long)globalSettings.touchSlopeY;
@ -267,9 +267,9 @@ void setupTouch(){
displayHline(10,20,20,DISPLAY_WHITE);
displayVline(20,10,20, DISPLAY_WHITE);
while(!readTouch())
while(!readTouch(&ts_point))
delay(100);
while(readTouch())
while(readTouch(&ts_point))
delay(100);
x1 = ts_point.x;
y1 = ts_point.y;
@ -284,9 +284,9 @@ void setupTouch(){
displayHline(290,20,20,DISPLAY_WHITE);
displayVline(300,10,20, DISPLAY_WHITE);
while(!readTouch())
while(!readTouch(&ts_point))
delay(100);
while(readTouch())
while(readTouch(&ts_point))
delay(100);
x2 = ts_point.x;
y2 = ts_point.y;
@ -300,12 +300,12 @@ void setupTouch(){
displayHline(10,220,20,DISPLAY_WHITE);
displayVline(20,210,20, DISPLAY_WHITE);
while(!readTouch())
while(!readTouch(&ts_point))
delay(100);
x3 = ts_point.x;
y3 = ts_point.y;
while(readTouch())
while(readTouch(&ts_point))
delay(100);
displayHline(10,220,20,DISPLAY_BLACK);
displayVline(20,210,20, DISPLAY_BLACK);
@ -316,7 +316,7 @@ void setupTouch(){
displayHline(290,220,20,DISPLAY_WHITE);
displayVline(300,210,20, DISPLAY_WHITE);
while(!readTouch())
while(!readTouch(&ts_point))
delay(100);
x4 = ts_point.x;
y4 = ts_point.y;

View File

@ -27,9 +27,9 @@ void displayText(char *text, int x1, int y1, int w, int h, int color, int backgr
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size, uint8_t fixed_width = 0);
/* touch functions */
bool readTouch();
bool readTouch(Point *const p);
void scaleTouch(struct Point *p);
void scaleTouch(Point *const p);
#define TEXT_LINE_HEIGHT 18
#define TEXT_LINE_INDENT 5