2 /* A sketch demonstrating data exchange between two USB devices - a HID barcode scanner and ADK-compatible Android phone */
8 // Satisfy IDE, which only needs to see the include statment in the ino.
10 #include <spi4teensy3.h>
17 HIDBoot<HID_PROTOCOL_KEYBOARD> Keyboard(&Usb);
19 ADK adk(&Usb,"Circuits@Home, ltd.",
21 "Arduino Terminal for Android",
23 "http://www.circuitsathome.com",
27 class KbdRptParser : public KeyboardReportParser
31 void OnKeyDown (uint8_t mod, uint8_t key);
32 void OnKeyPressed(uint8_t key);
35 void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
37 uint8_t c = OemToAscii(mod, key);
43 /* what to do when symbol arrives */
44 void KbdRptParser::OnKeyPressed(uint8_t key)
46 const char* new_line = "\n";
50 if( adk.isReady() == false ) {
56 if( keylcl == 0x13 ) {
57 rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
60 rcode = adk.SndData( 1, &keylcl );
63 Serial.print((char) keylcl );
65 Serial.println( keylcl, HEX );
73 #if !defined(__MIPSEL__)
74 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
76 Serial.println("\r\nADK demo start");
78 if (Usb.Init() == -1) {
79 Serial.println("OSCOKIRQ failed to assert");
81 }//if (Usb.Init() == -1...
83 Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);