File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ void setup() {
142142#else
143143 if (!arcada.filesysBegin ()) fatal (" No filesystem found!" , 250 );
144144#endif
145+
146+ user_setup ();
147+
145148 arcada.displayBegin ();
146149
147150 DISPLAY_SIZE = min (ARCADA_TFT_WIDTH, ARCADA_TFT_HEIGHT);
@@ -415,8 +418,6 @@ void setup() {
415418 boopThreshold = boopThreshold * 110 / 100 ; // 10% overhead
416419 }
417420
418- user_setup ();
419-
420421 lastLightReadTime = micros () + 2000000 ; // Delay initial light reading
421422}
422423
Original file line number Diff line number Diff line change 1+ #if 0 // Change to 1 to enable this code (must enable ONE user*.cpp only!)
2+
3+ #include <Arduino.h>
4+ #include "Adafruit_TinyUSB.h"
5+ #include "globals.h"
6+
7+ #define KEYCODE_TO_SEND HID_KEY_SPACE
8+
9+ // HID report descriptor using TinyUSB's template
10+ // Single Report (no ID) descriptor
11+ uint8_t const desc_hid_report[] =
12+ {
13+ TUD_HID_REPORT_DESC_KEYBOARD(),
14+ };
15+
16+ Adafruit_USBD_HID usb_hid;
17+
18+ void user_setup(void) {
19+ usb_hid.setPollInterval(20);
20+ usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
21+
22+ usb_hid.begin();
23+
24+ pinMode(13, OUTPUT);
25+ digitalWrite(13, LOW);
26+
27+ // wait until device mounted
28+ while( !USBDevice.mounted() ) delay(1);
29+ }
30+
31+ void user_loop(void) {
32+ if ( !usb_hid.ready() ) {
33+ Serial.println("not ready");
34+ return;
35+ }
36+
37+ uint8_t keycode[6] = { 0 };
38+
39+ uint32_t buttonState = arcada.readButtons();
40+ if (buttonState & ARCADA_BUTTONMASK_A) {
41+ Serial.println("A");
42+ keycode[0] = KEYCODE_TO_SEND;
43+ usb_hid.keyboardReport(0, 0, keycode);
44+ } else {
45+ usb_hid.keyboardRelease(0);
46+ }
47+ }
48+
49+ #endif
You can’t perform that action at this time.
0 commit comments