Teensy 4.1 and TouchScreenUSB as HID

skyy

Member
Hi,

I'm trying to get single and multi touch working on a windows 10 machine, but without any luck.:confused:

On an android device single and multi-touch they both seem to work perfectly,
however on Ubuntu 20 only single-touch example is working and on my main target "Windows 10" none of them worked :(

Windows 10 detects the touchscreen as HID device but no inputs

I have a Teensy 4.1, with Arduino 1.8.13 and Teensyduino 1.53.
i have tried to select USB type Keyboard+ touchscreen then tried Keyboard+Mouse+Touchscreen nothing changed.

So to summarize my tests:
Android:
- Single-touch -> OK
- Mulit-touch -> OK

Ubuntu
- Single-touch -> OK
- Mulit-touch -> the cursor disappear "so i think it moves but no press?"

Windows:
- Single-touch -> Nothing happens
- Mulit-touch -> Nothing happens


The code below i got from the examples modified it so it run without the button for multi-touch,

Code:
// Multi-touch example
int yoffset = 8000;

void setup() {
  TouchscreenUSB.begin();
}

void drawcircle(int x, int y) {
  float arc = 2.0 * PI / 10.0;
  float r = 3000.0;
  for (float angle = 0; angle < arc; angle += 0.01) {
    for (int i = 0; i < 10; i++) {
      float ph = arc * (float)i;
      TouchscreenUSB.press(i, r * cosf(angle + ph) + x, r * sinf(angle + ph) + y);
    }
    delay(10);
  }
  for (int i = 0; i < 10; i++) {
    TouchscreenUSB.release(i);
  }
}

void loop() {

  drawcircle(16000, yoffset);
  yoffset += 4200;
  if (yoffset > 24000) yoffset = 8000;
  delay(5000);
}

Any ideas or direction?


Thanks
 
Quick update, since all usb types that support Touchscreen don't have a Serial option i added
Code:
 Keyboard.print("Hello World ");
just before
Code:
delay(5000);
i noticed a weird behavior like the Teenssy become non-responsive for couple of seconds and it write something like this
Hello WWWWWWWWWWWWWWWHello WWWWWWWWWWWWWWHeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeello WHello WWWWWWWWWWWWWWWHello WWWWWWWWWWWWWWWH

first thoughts was that the delay might be blocking something so i tried it with millis()

Code:
int yoffset = 500;
unsigned long lastDebounceTime = 0; 
unsigned long debounceDelay = 5000;   
void setup() {
  TouchscreenUSB.begin();
}

void drawline(int x, int y) {
  lastDebounceTime = millis();

 for (int i=0; i < 1000; i += 10) {
   TouchscreenUSB.press(0, x + i, y + i/13);
   delay(10);
 }
 TouchscreenUSB.release(0);
}

void loop() {
  if ((millis() - lastDebounceTime) > debounceDelay) {
    drawline(600, yoffset);
    yoffset += 120;
    if (yoffset > 1000) yoffset = 500;
    Keyboard.print("Hello World ");
    lastDebounceTime = millis();

  }



}

unfortunally that did not change anything, still i'm getting something like:
Hello WWWWWWWWWWWWWWWHello WWWWWWWWWWWWWWWHello WWWWWWWWWWWWWWWHello WWWWWWWWWWWWWWWHello WWWWWWWWWWWWWWWH
 
Here is a preview on the Android Screenshot_20210106-191330_Touch Screen Test.jpg
 
Back
Top