mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Fixed formatting in some of the examples
This commit is contained in:
parent
a0d163b8fb
commit
b946a41576
8 changed files with 98 additions and 98 deletions
|
@ -138,8 +138,8 @@ void KbdRptParser::OnKeyPressed(uint8_t key)
|
||||||
Serial.println((char)key);
|
Serial.println((char)key);
|
||||||
};
|
};
|
||||||
|
|
||||||
USBHost usb;
|
USBHost usb;
|
||||||
USBHub Hub(&usb);
|
USBHub Hub(&usb);
|
||||||
|
|
||||||
HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&usb);
|
HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&usb);
|
||||||
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&usb);
|
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&usb);
|
||||||
|
|
|
@ -10,70 +10,70 @@
|
||||||
class MouseRptParser : public MouseReportParser
|
class MouseRptParser : public MouseReportParser
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void OnMouseMove (MOUSEINFO *mi);
|
void OnMouseMove (MOUSEINFO *mi);
|
||||||
void OnLeftButtonUp (MOUSEINFO *mi);
|
void OnLeftButtonUp (MOUSEINFO *mi);
|
||||||
void OnLeftButtonDown (MOUSEINFO *mi);
|
void OnLeftButtonDown (MOUSEINFO *mi);
|
||||||
void OnRightButtonUp (MOUSEINFO *mi);
|
void OnRightButtonUp (MOUSEINFO *mi);
|
||||||
void OnRightButtonDown (MOUSEINFO *mi);
|
void OnRightButtonDown (MOUSEINFO *mi);
|
||||||
void OnMiddleButtonUp (MOUSEINFO *mi);
|
void OnMiddleButtonUp (MOUSEINFO *mi);
|
||||||
void OnMiddleButtonDown (MOUSEINFO *mi);
|
void OnMiddleButtonDown (MOUSEINFO *mi);
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
|
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.print("dx=");
|
Serial.print("dx=");
|
||||||
Serial.print(mi->dX, DEC);
|
Serial.print(mi->dX, DEC);
|
||||||
Serial.print(" dy=");
|
Serial.print(" dy=");
|
||||||
Serial.println(mi->dY, DEC);
|
Serial.println(mi->dY, DEC);
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
|
void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.println("L Butt Up");
|
Serial.println("L Butt Up");
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
|
void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.println("L Butt Dn");
|
Serial.println("L Butt Dn");
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
|
void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.println("R Butt Up");
|
Serial.println("R Butt Up");
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
|
void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.println("R Butt Dn");
|
Serial.println("R Butt Dn");
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
|
void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.println("M Butt Up");
|
Serial.println("M Butt Up");
|
||||||
};
|
};
|
||||||
void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
|
void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
|
||||||
{
|
{
|
||||||
Serial.println("M Butt Dn");
|
Serial.println("M Butt Dn");
|
||||||
};
|
};
|
||||||
|
|
||||||
USBHost usb;
|
USBHost usb;
|
||||||
USBHub Hub(&usb);
|
USBHub Hub(&usb);
|
||||||
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&usb);
|
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&usb);
|
||||||
|
|
||||||
uint32_t next_time;
|
uint32_t next_time;
|
||||||
|
|
||||||
MouseRptParser Prs;
|
MouseRptParser Prs;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin( 115200 );
|
Serial.begin( 115200 );
|
||||||
#if !defined(__MIPSEL__)
|
#if !defined(__MIPSEL__)
|
||||||
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
||||||
#endif
|
#endif
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
|
|
||||||
if (usb.Init() == -1)
|
if (usb.Init() == -1)
|
||||||
Serial.println("OSC did not start.");
|
Serial.println("OSC did not start.");
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
next_time = millis() + 5000;
|
next_time = millis() + 5000;
|
||||||
|
|
||||||
HidMouse.SetReportParser(0,(HIDReportParser*)&Prs);
|
HidMouse.SetReportParser(0, (HIDReportParser*)&Prs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|
|
@ -17,22 +17,22 @@ JoystickEvents JoyEvents;
|
||||||
JoystickReportParser Joy(&JoyEvents);
|
JoystickReportParser Joy(&JoyEvents);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
#if !defined(__MIPSEL__)
|
#if !defined(__MIPSEL__)
|
||||||
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
||||||
#endif
|
#endif
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
|
|
||||||
if (usb.Init() == -1)
|
if (usb.Init() == -1)
|
||||||
Serial.println("OSC did not start.");
|
Serial.println("OSC did not start.");
|
||||||
|
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|
||||||
if (!Hid.SetReportParser(0, &Joy))
|
if (!Hid.SetReportParser(0, &Joy))
|
||||||
ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
|
ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
usb.Task();
|
usb.Task();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,31 +21,31 @@ protected:
|
||||||
|
|
||||||
uint8_t HIDUniversal2::OnInitSuccessful()
|
uint8_t HIDUniversal2::OnInitSuccessful()
|
||||||
{
|
{
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
|
|
||||||
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
|
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
|
||||||
ReportDescParser Rpt;
|
ReportDescParser Rpt;
|
||||||
|
|
||||||
if ((rcode = GetReportDescr(0, &Hex)))
|
if ((rcode = GetReportDescr(0, &Hex)))
|
||||||
goto FailGetReportDescr1;
|
goto FailGetReportDescr1;
|
||||||
|
|
||||||
if ((rcode = GetReportDescr(0, &Rpt)))
|
if ((rcode = GetReportDescr(0, &Rpt)))
|
||||||
goto FailGetReportDescr2;
|
goto FailGetReportDescr2;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetReportDescr1:
|
FailGetReportDescr1:
|
||||||
USBTRACE("GetReportDescr1:");
|
USBTRACE("GetReportDescr1:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
FailGetReportDescr2:
|
FailGetReportDescr2:
|
||||||
USBTRACE("GetReportDescr2:");
|
USBTRACE("GetReportDescr2:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
Serial.println(rcode, HEX);
|
Serial.println(rcode, HEX);
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
USBHost usb;
|
USBHost usb;
|
||||||
|
@ -62,16 +62,16 @@ void setup()
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
|
|
||||||
if (usb.Init() == -1)
|
if (usb.Init() == -1)
|
||||||
Serial.println("OSC did not start.");
|
Serial.println("OSC did not start.");
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
if (!Hid.SetReportParser(0, &Uni))
|
if (!Hid.SetReportParser(0, &Uni))
|
||||||
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
usb.Task();
|
usb.Task();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,16 @@ void setup()
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
|
|
||||||
if (usb.Init() == -1)
|
if (usb.Init() == -1)
|
||||||
Serial.println("OSC did not start.");
|
Serial.println("OSC did not start.");
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
if (!Hid.SetReportParser(0, &Joy))
|
if (!Hid.SetReportParser(0, &Joy))
|
||||||
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
usb.Task();
|
usb.Task();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USBHost usb;
|
USBHost usb;
|
||||||
USBHub Hub(&usb);
|
USBHub Hub(&usb);
|
||||||
HIDUniversal Hid(&usb);
|
HIDUniversal Hid(&usb);
|
||||||
Max_LCD LCD(&usb);
|
Max_LCD LCD(&usb);
|
||||||
ScaleEvents ScaleEvents(&LCD);
|
ScaleEvents ScaleEvents(&LCD);
|
||||||
ScaleReportParser Scale(&ScaleEvents);
|
ScaleReportParser Scale(&ScaleEvents);
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -29,23 +29,23 @@ void setup()
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
|
|
||||||
if (usb.Init() == -1)
|
if (usb.Init() == -1)
|
||||||
Serial.println("OSC did not start.");
|
Serial.println("OSC did not start.");
|
||||||
|
|
||||||
// set up the LCD's number of rows and columns:
|
// set up the LCD's number of rows and columns:
|
||||||
LCD.begin(16, 2);
|
LCD.begin(16, 2);
|
||||||
LCD.clear();
|
LCD.clear();
|
||||||
LCD.home();
|
LCD.home();
|
||||||
LCD.setCursor(0,0);
|
LCD.setCursor(0, 0);
|
||||||
LCD.write('R');
|
LCD.write('R');
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
if (!Hid.SetReportParser(0, &Scale))
|
if (!Hid.SetReportParser(0, &Scale))
|
||||||
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
usb.Task();
|
usb.Task();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,48 +12,48 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USBHost usb;
|
USBHost usb;
|
||||||
USBHub Hub1(&usb);
|
USBHub Hub1(&usb);
|
||||||
USBHub Hub2(&usb);
|
USBHub Hub2(&usb);
|
||||||
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&usb);
|
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&usb);
|
||||||
|
|
||||||
ADK adk(&usb,"Circuits@Home, ltd.",
|
ADK adk(&usb, "Circuits@Home, ltd.",
|
||||||
"USBHost Host Shield",
|
"USBHost Host Shield",
|
||||||
"Arduino Terminal for Android",
|
"Arduino Terminal for Android",
|
||||||
"1.0",
|
"1.0",
|
||||||
"http://www.circuitsathome.com",
|
"http://www.circuitsathome.com",
|
||||||
"0000000000000001");
|
"0000000000000001");
|
||||||
|
|
||||||
|
|
||||||
class KbdRptParser : public KeyboardReportParser
|
class KbdRptParser : public KeyboardReportParser
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnKeyDown (uint8_t mod, uint8_t key);
|
void OnKeyDown(uint8_t mod, uint8_t key);
|
||||||
void OnKeyPressed(uint8_t key);
|
void OnKeyPressed(uint8_t key);
|
||||||
};
|
};
|
||||||
|
|
||||||
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
|
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
|
||||||
{
|
{
|
||||||
uint8_t c = OemToAscii(mod, key);
|
uint8_t c = OemToAscii(mod, key);
|
||||||
|
|
||||||
if (c)
|
if (c)
|
||||||
OnKeyPressed(c);
|
OnKeyPressed(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* what to do when symbol arrives */
|
/* what to do when symbol arrives */
|
||||||
void KbdRptParser::OnKeyPressed(uint8_t key)
|
void KbdRptParser::OnKeyPressed(uint8_t key)
|
||||||
{
|
{
|
||||||
const char* new_line = "\n";
|
const char* new_line = "\n";
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
uint8_t keylcl;
|
uint8_t keylcl;
|
||||||
|
|
||||||
if( adk.isReady() == false ) {
|
if ( adk.isReady() == false ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
keylcl = key;
|
keylcl = key;
|
||||||
|
|
||||||
if( keylcl == 0x13 ) {
|
if ( keylcl == 0x13 ) {
|
||||||
rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
|
rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -77,7 +77,7 @@ void setup()
|
||||||
|
|
||||||
if (usb.Init() == -1) {
|
if (usb.Init() == -1) {
|
||||||
Serial.println("OSCOKIRQ failed to assert");
|
Serial.println("OSCOKIRQ failed to assert");
|
||||||
while(1); //halt
|
while (1); //halt
|
||||||
}//if (usb.Init() == -1...
|
}//if (usb.Init() == -1...
|
||||||
|
|
||||||
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs);
|
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USBHost usb;
|
USBHost usb;
|
||||||
USBHub Hub1(&usb);
|
USBHub Hub1(&usb);
|
||||||
USBHub Hub2(&usb);
|
USBHub Hub2(&usb);
|
||||||
USBHub Hub3(&usb);
|
USBHub Hub3(&usb);
|
||||||
|
|
Loading…
Reference in a new issue