turgu1 / ESP-IDF-InkPlate

A porting effort to the ESP-IDF framework for the e-Radionica InkPlate software.
15 stars 9 forks source link

touchscreen points returned by tsGetData not scaled properly #21

Open ventosus opened 1 year ago

ventosus commented 1 year ago

The touchscreen points need to be scaled by x/y_resolution somewhere, afaict.

If not, the output is garbage.

This does the trick for me (I'm running with rotation=3):

diff --git a/include/graphical/inkplate.hpp b/include/graphical/inkplate.hpp
index 770d3cc..7f8f5a3 100644
--- a/include/graphical/inkplate.hpp
+++ b/include/graphical/inkplate.hpp
@@ -87,6 +87,11 @@ class Inkplate : public Graphics
       inline bool    tsAvailable() { return touch_screen.is_screen_touched(); }      
       inline uint8_t tsGetData(TouchScreen::TouchPositions & xPos, TouchScreen::TouchPositions & yPos) { 
         uint8_t count = touch_screen.get_position(xPos, yPos);
+                               for(int i=0; i<count; i++)
+                               {
+                                       xPos[i] = xPos[i] * e_ink.get_height() / touch_screen.get_x_resolution();
+                                       yPos[i] = yPos[i] * e_ink.get_width() / touch_screen.get_y_resolution();
+                               }
         rotateFromPhy(xPos, yPos, count);
         return count; 
       }