Fixed formatting in some of the examples

This commit is contained in:
Kristian Sloth Lauszus 2016-01-19 16:58:31 +01:00
parent a0d163b8fb
commit b946a41576
8 changed files with 98 additions and 98 deletions

View file

@ -138,8 +138,8 @@ void KbdRptParser::OnKeyPressed(uint8_t key)
Serial.println((char)key);
};
USBHost usb;
USBHub Hub(&usb);
USBHost usb;
USBHub Hub(&usb);
HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&usb);

View file

@ -10,70 +10,70 @@
class MouseRptParser : public MouseReportParser
{
protected:
void OnMouseMove (MOUSEINFO *mi);
void OnLeftButtonUp (MOUSEINFO *mi);
void OnLeftButtonDown (MOUSEINFO *mi);
void OnRightButtonUp (MOUSEINFO *mi);
void OnRightButtonDown (MOUSEINFO *mi);
void OnMiddleButtonUp (MOUSEINFO *mi);
void OnMiddleButtonDown (MOUSEINFO *mi);
void OnMouseMove (MOUSEINFO *mi);
void OnLeftButtonUp (MOUSEINFO *mi);
void OnLeftButtonDown (MOUSEINFO *mi);
void OnRightButtonUp (MOUSEINFO *mi);
void OnRightButtonDown (MOUSEINFO *mi);
void OnMiddleButtonUp (MOUSEINFO *mi);
void OnMiddleButtonDown (MOUSEINFO *mi);
};
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
{
Serial.print("dx=");
Serial.print(mi->dX, DEC);
Serial.print(" dy=");
Serial.println(mi->dY, DEC);
Serial.print("dx=");
Serial.print(mi->dX, DEC);
Serial.print(" dy=");
Serial.println(mi->dY, DEC);
};
void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
{
Serial.println("L Butt Up");
Serial.println("L Butt Up");
};
void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
{
Serial.println("L Butt Dn");
Serial.println("L Butt Dn");
};
void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
{
Serial.println("R Butt Up");
Serial.println("R Butt Up");
};
void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
{
Serial.println("R Butt Dn");
Serial.println("R Butt Dn");
};
void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
{
Serial.println("M Butt Up");
Serial.println("M Butt Up");
};
void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
{
Serial.println("M Butt Dn");
Serial.println("M Butt Dn");
};
USBHost usb;
USBHub Hub(&usb);
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&usb);
USBHost usb;
USBHub Hub(&usb);
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&usb);
uint32_t next_time;
MouseRptParser Prs;
MouseRptParser Prs;
void setup()
{
Serial.begin( 115200 );
Serial.begin( 115200 );
#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
Serial.println("Start");
Serial.println("Start");
if (usb.Init() == -1)
Serial.println("OSC did not start.");
if (usb.Init() == -1)
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()

View file

@ -17,22 +17,22 @@ JoystickEvents JoyEvents;
JoystickReportParser Joy(&JoyEvents);
void setup() {
Serial.begin(115200);
Serial.begin(115200);
#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
Serial.println("Start");
Serial.println("Start");
if (usb.Init() == -1)
Serial.println("OSC did not start.");
if (usb.Init() == -1)
Serial.println("OSC did not start.");
delay(200);
delay(200);
if (!Hid.SetReportParser(0, &Joy))
ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
if (!Hid.SetReportParser(0, &Joy))
ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
}
void loop() {
usb.Task();
usb.Task();
}

View file

@ -21,31 +21,31 @@ protected:
uint8_t HIDUniversal2::OnInitSuccessful()
{
uint8_t rcode;
uint8_t rcode;
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
ReportDescParser Rpt;
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
ReportDescParser Rpt;
if ((rcode = GetReportDescr(0, &Hex)))
goto FailGetReportDescr1;
if ((rcode = GetReportDescr(0, &Hex)))
goto FailGetReportDescr1;
if ((rcode = GetReportDescr(0, &Rpt)))
goto FailGetReportDescr2;
if ((rcode = GetReportDescr(0, &Rpt)))
goto FailGetReportDescr2;
return 0;
return 0;
FailGetReportDescr1:
USBTRACE("GetReportDescr1:");
goto Fail;
USBTRACE("GetReportDescr1:");
goto Fail;
FailGetReportDescr2:
USBTRACE("GetReportDescr2:");
goto Fail;
USBTRACE("GetReportDescr2:");
goto Fail;
Fail:
Serial.println(rcode, HEX);
Release();
return rcode;
Serial.println(rcode, HEX);
Release();
return rcode;
}
USBHost usb;
@ -62,16 +62,16 @@ void setup()
Serial.println("Start");
if (usb.Init() == -1)
Serial.println("OSC did not start.");
Serial.println("OSC did not start.");
delay( 200 );
if (!Hid.SetReportParser(0, &Uni))
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
}
void loop()
{
usb.Task();
usb.Task();
}

View file

@ -27,16 +27,16 @@ void setup()
Serial.println("Start");
if (usb.Init() == -1)
Serial.println("OSC did not start.");
Serial.println("OSC did not start.");
delay( 200 );
if (!Hid.SetReportParser(0, &Joy))
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
}
void loop()
{
usb.Task();
usb.Task();
}

View file

@ -13,12 +13,12 @@
#include <SPI.h>
#endif
USBHost usb;
USBHub Hub(&usb);
HIDUniversal Hid(&usb);
Max_LCD LCD(&usb);
ScaleEvents ScaleEvents(&LCD);
ScaleReportParser Scale(&ScaleEvents);
USBHost usb;
USBHub Hub(&usb);
HIDUniversal Hid(&usb);
Max_LCD LCD(&usb);
ScaleEvents ScaleEvents(&LCD);
ScaleReportParser Scale(&ScaleEvents);
void setup()
{
@ -29,23 +29,23 @@ void setup()
Serial.println("Start");
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:
LCD.begin(16, 2);
LCD.clear();
LCD.home();
LCD.setCursor(0,0);
LCD.write('R');
// set up the LCD's number of rows and columns:
LCD.begin(16, 2);
LCD.clear();
LCD.home();
LCD.setCursor(0, 0);
LCD.write('R');
delay( 200 );
if (!Hid.SetReportParser(0, &Scale))
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
}
void loop()
{
usb.Task();
usb.Task();
}

View file

@ -12,48 +12,48 @@
#endif
USBHost usb;
USBHub Hub1(&usb);
USBHub Hub2(&usb);
USBHub Hub1(&usb);
USBHub Hub2(&usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&usb);
ADK adk(&usb,"Circuits@Home, ltd.",
"USBHost Host Shield",
"Arduino Terminal for Android",
"1.0",
"http://www.circuitsathome.com",
"0000000000000001");
ADK adk(&usb, "Circuits@Home, ltd.",
"USBHost Host Shield",
"Arduino Terminal for Android",
"1.0",
"http://www.circuitsathome.com",
"0000000000000001");
class KbdRptParser : public KeyboardReportParser
{
protected:
void OnKeyDown (uint8_t mod, uint8_t key);
void OnKeyPressed(uint8_t key);
void OnKeyDown(uint8_t mod, uint8_t key);
void OnKeyPressed(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)
OnKeyPressed(c);
if (c)
OnKeyPressed(c);
}
/* what to do when symbol arrives */
void KbdRptParser::OnKeyPressed(uint8_t key)
{
const char* new_line = "\n";
uint8_t rcode;
uint8_t keylcl;
const char* new_line = "\n";
uint8_t rcode;
uint8_t keylcl;
if( adk.isReady() == false ) {
return;
}
if ( adk.isReady() == false ) {
return;
}
keylcl = key;
if( keylcl == 0x13 ) {
if ( keylcl == 0x13 ) {
rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
}
else {
@ -77,7 +77,7 @@ void setup()
if (usb.Init() == -1) {
Serial.println("OSCOKIRQ failed to assert");
while(1); //halt
while (1); //halt
}//if (usb.Init() == -1...
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs);

View file

@ -7,7 +7,7 @@
#include <SPI.h>
#endif
USBHost usb;
USBHost usb;
USBHub Hub1(&usb);
USBHub Hub2(&usb);
USBHub Hub3(&usb);