소스 검색

Added Contact Count to Teensy 4 USB Touchscreen

main
PaulStoffregen 4 년 전
부모
커밋
80385bae5a
3개의 변경된 파일18개의 추가작업 그리고 4개의 파일을 삭제
  1. +5
    -0
      teensy4/usb_desc.c
  2. +3
    -3
      teensy4/usb_desc.h
  3. +10
    -1
      teensy4/usb_touch.c

+ 5
- 0
teensy4/usb_desc.c 파일 보기

@@ -413,6 +413,11 @@ static uint8_t multitouch_report_desc[] = {
0x95, 0x01, // Report Count (1)
0x09, 0x56, // Usage (Scan Time)
0x81, 0x02, // Input (variable,absolute)
0x09, 0x54, // USAGE (Contact count)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x0D, // Usage Page (Digitizers)
0x09, 0x55, // Usage (Contact Count Maximum)
0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)

+ 3
- 3
teensy4/usb_desc.h 파일 보기

@@ -350,7 +350,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define KEYMEDIA_INTERVAL 4
#define MULTITOUCH_INTERFACE 3 // Touchscreen
#define MULTITOUCH_ENDPOINT 5
#define MULTITOUCH_SIZE 8
#define MULTITOUCH_SIZE 9
#define MULTITOUCH_FINGERS 10
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
@@ -388,7 +388,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define MOUSE_INTERVAL 2
#define MULTITOUCH_INTERFACE 4 // Touchscreen
#define MULTITOUCH_ENDPOINT 5
#define MULTITOUCH_SIZE 8
#define MULTITOUCH_SIZE 9
#define MULTITOUCH_FINGERS 10
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
@@ -891,7 +891,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define AUDIO_SYNC_ENDPOINT 14
#define MULTITOUCH_INTERFACE 12 // Touchscreen
#define MULTITOUCH_ENDPOINT 15
#define MULTITOUCH_SIZE 8
#define MULTITOUCH_SIZE 9
#define MULTITOUCH_FINGERS 10
#define ENDPOINT1_CONFIG ENDPOINT_TRANSMIT_ONLY
#define ENDPOINT2_CONFIG ENDPOINT_TRANSMIT_AND_RECEIVE

+ 10
- 1
teensy4/usb_touch.c 파일 보기

@@ -105,12 +105,14 @@ void usb_touchscreen_release(uint8_t finger)
// 5: Y msb
// 6: scan time lsb
// 7: scan time msb
// 8: contact count

// Called by the start-of-frame interrupt.
//
void usb_touchscreen_update_callback(void)
{
static uint8_t microframe_count=0;
uint8_t contact_count = 0;

if (usb_high_speed) {
// if 480 speed, run only every 8th micro-frame
@@ -130,6 +132,12 @@ void usb_touchscreen_update_callback(void)
if (scan_index == 0) {
scan_timestamp = millis() * 10;
scan_count = 0;
// Get the contact count (usage 0x54)
// Only set this value on first contact
// Subsequent concurrent contacts should report 0
for (uint8_t i = 0; i < MULTITOUCH_FINGERS; i++) {
if (contactid[i]) contact_count++;
}
}
while (scan_index < MULTITOUCH_FINGERS) {
uint32_t press = pressure[scan_index];
@@ -142,7 +150,7 @@ void usb_touchscreen_update_callback(void)
id &= 0xFE;
contactid[scan_index] = 0;
}
uint8_t buffer[MULTITOUCH_SIZE]; // MULTITOUCH_SIZE = 8
//uint8_t buffer[MULTITOUCH_SIZE]; // MULTITOUCH_SIZE = 8
txbuffer[0] = id;
txbuffer[1] = press;
txbuffer[2] = xpos[scan_index];
@@ -151,6 +159,7 @@ void usb_touchscreen_update_callback(void)
txbuffer[5] = ypos[scan_index] >> 8;
txbuffer[6] = scan_timestamp;
txbuffer[7] = scan_timestamp >> 8;
txbuffer[8] = contact_count;
//delayNanoseconds(30);
usb_prepare_transfer(&tx_transfer, txbuffer, MULTITOUCH_SIZE, 0);
arm_dcache_flush_delete(txbuffer, TX_BUFSIZE);

Loading…
취소
저장