From bd616caaba9aebaa52854145e38b59d48a435fc0 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 9 Feb 2020 17:58:45 -0800 Subject: [PATCH] Have touch functions read to passed pointer --- nano_gui.cpp | 22 +++++++++++----------- nano_gui.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nano_gui.cpp b/nano_gui.cpp index 5ef0429..4fcd79a 100644 --- a/nano_gui.cpp +++ b/nano_gui.cpp @@ -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; diff --git a/nano_gui.h b/nano_gui.h index 5ca5582..37d9826 100644 --- a/nano_gui.h +++ b/nano_gui.h @@ -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