Hi,
I searched A LOT on both this forum and the internet but I really cannot find an answer to my problem
I'm using the TouchScreen library to read finger position and a RN-42 (from sparkfun) to send these info to my tablet the problem is that the mouse is not moving in the "right" way. I managed to move to cursor to the top/bottom right/left position but as I said before everything is acting in a "weird" way (I can record a video if you want.
Here's my script
#include <stdint.h>
#include <TouchScreen.h>
#include <SoftwareSerial.h>
SoftwareSerial rn42 = SoftwareSerial(4,5); //RN-42 TX attached to Digital 4, RX attached to Digital 5
uint8_t buffer[7];
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A1 // must be an analog pin, use "An" notation!
#define YM A3 // can be a digital pin
#define XP A0 // can be a digital pin
//TouchScreen ts = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins
TouchScreen ts = TouchScreen(YP, XP, YM, XM); //init TouchScreen port pins
void setup()
{
Serial.begin(115200); // setup serial
rn42.begin(115200);
}
void MoveMouse(int x, int y){
buffer[0] = 0xFD;
buffer[1] = 0x05;
buffer[2] = 0x02;
buffer[3] = 0x00; //Buttons
buffer[4] = byte(x); //X-stop
buffer[5] = byte(y); //Y-stop
buffer[6] = 0x00; //Wheel
rn42.write(buffer, 7);
}
void loop()
{
// a point object holds x y and z coordinates
TSPoint p = ts.getPoint();
// we have some minimum pressure we consider 'valid' pressure of 0 means no pressing!
if(p.x < 180 || p.x > 190){//(ts.pressureThreshhold > 0) {//
MoveMouse(-p.x, -p.y);
Serial.print("X = "); Serial.print(p.x);
Serial.print("\tY = "); Serial.print(p.y);
Serial.println("");
}
delay(100);
}