mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Moved serial printing into the example
This commit is contained in:
parent
d67e637f2f
commit
73fbb7ab92
2 changed files with 129 additions and 76 deletions
70
SRWS1.cpp
70
SRWS1.cpp
|
@ -36,76 +36,6 @@ void SRWS1::ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
|
|||
buttonClickState.val = srws1Data.btn.val & ~oldButtonState.val; // Update click state variable
|
||||
oldButtonState.val = srws1Data.btn.val;
|
||||
}
|
||||
#if 0
|
||||
if (srws1Data.leftTrigger) {
|
||||
Serial.print(F("L2: "));
|
||||
Serial.println(srws1Data.leftTrigger);
|
||||
}
|
||||
if (srws1Data.rightTrigger) {
|
||||
Serial.print(F("R2: "));
|
||||
Serial.println(srws1Data.rightTrigger);
|
||||
}
|
||||
if (srws1Data.btn.select) {
|
||||
//Serial.println("Select");
|
||||
Serial.println(srws1Data.tilt);
|
||||
}
|
||||
|
||||
if (srws1Data.btn.back) Serial.println(F("Back"));
|
||||
if (srws1Data.btn.lookLeft) Serial.println(F("Look Left"));
|
||||
if (srws1Data.btn.lights) Serial.println(F("Lights"));
|
||||
if (srws1Data.btn.lookBack) Serial.println(F("Look Back"));
|
||||
if (srws1Data.btn.rearBrakeBalance) Serial.println(F("R. Brake Balance"));
|
||||
if (srws1Data.btn.frontBrakeBalance) Serial.println(F("F. Brake Balance"));
|
||||
if (srws1Data.btn.requestPit) Serial.println(F("Request Pit"));
|
||||
if (srws1Data.btn.leftGear) Serial.println(F("Left Gear"));
|
||||
|
||||
if (srws1Data.btn.camera) Serial.println(F("Camera"));
|
||||
if (srws1Data.btn.lookRight) Serial.println(F("Look right"));
|
||||
if (srws1Data.btn.boost) Serial.println(F("Boost"));
|
||||
if (srws1Data.btn.horn) Serial.println(F("Horn"));
|
||||
if (srws1Data.btn.hud) Serial.println(F("HUD"));
|
||||
if (srws1Data.btn.launchControl) Serial.println(F("Launch Control"));
|
||||
if (srws1Data.btn.speedLimiter) Serial.println(F("Speed Limiter"));
|
||||
if (srws1Data.btn.rightGear) Serial.println(F("Right gear"));
|
||||
|
||||
if (srws1Data.assists) Serial.println(srws1Data.assists);
|
||||
if (srws1Data.steeringSensitivity) Serial.println(srws1Data.steeringSensitivity);
|
||||
if (srws1Data.assistValues) Serial.println(srws1Data.assistValues);
|
||||
|
||||
switch (srws1Data.btn.dpad) {
|
||||
case DPAD_UP:
|
||||
Serial.println(F("Up"));
|
||||
break;
|
||||
case DPAD_UP_RIGHT:
|
||||
Serial.println(F("UP & RIGHT"));
|
||||
break;
|
||||
case DPAD_RIGHT:
|
||||
Serial.println(F("Right"));
|
||||
break;
|
||||
case DPAD_RIGHT_DOWN:
|
||||
Serial.println(F("Right & down"));
|
||||
break;
|
||||
case DPAD_DOWN:
|
||||
Serial.println(F("Down"));
|
||||
break;
|
||||
case DPAD_DOWN_LEFT:
|
||||
Serial.println(F("Down & left"));
|
||||
break;
|
||||
case DPAD_LEFT:
|
||||
Serial.println(F("Left"));
|
||||
break;
|
||||
case DPAD_LEFT_UP:
|
||||
Serial.println(F("Left & up"));
|
||||
break;
|
||||
case DPAD_OFF:
|
||||
break;
|
||||
default:
|
||||
Serial.print(F("Unknown state: "));
|
||||
D_PrintHex<uint8_t > (srws1Data.btn.dpad, 0x80);
|
||||
Serial.println();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// See: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-steelseries.c
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
Example sketch for the SteelSeries SRW-S1 Steering Wheel - developed by Kristian Lauszus
|
||||
For more information visit my blog: http://blog.tkjelectronics.dk/ or
|
||||
send me an e-mail: kristianl@tkjelectronics.com
|
||||
*/
|
||||
Example sketch for the SteelSeries SRW-S1 Steering Wheel - developed by Kristian Lauszus
|
||||
For more information visit my blog: http://blog.tkjelectronics.dk/ or
|
||||
send me an e-mail: kristianl@tkjelectronics.com
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "SRWS1.h"
|
||||
|
@ -10,6 +10,8 @@
|
|||
USB Usb;
|
||||
SRWS1 srw1(&Usb);
|
||||
|
||||
bool printTilt;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
#if !defined(__MIPSEL__)
|
||||
|
@ -32,8 +34,7 @@ void loop() {
|
|||
timer = millis(); // Reset timer
|
||||
|
||||
static uint16_t leds = 0;
|
||||
/*D_PrintHex<uint16_t > (leds, 0x80);
|
||||
Serial.println();*/
|
||||
//PrintHex<uint16_t > (leds, 0x80); Serial.println();
|
||||
srw1.setLeds(leds); // Update LEDs
|
||||
|
||||
static bool dirUp = true;
|
||||
|
@ -54,6 +55,128 @@ void loop() {
|
|||
#else
|
||||
srw1.setLeds(1 << map(srw1.srws1Data.tilt, -1800, 1800, 0, 14)); // Turn on a LED according to tilt value
|
||||
#endif
|
||||
|
||||
if (srw1.srws1Data.leftTrigger) {
|
||||
Serial.print(F("L2: "));
|
||||
Serial.println(srw1.srws1Data.leftTrigger);
|
||||
}
|
||||
if (srw1.srws1Data.rightTrigger) {
|
||||
Serial.print(F("R2: "));
|
||||
Serial.println(srw1.srws1Data.rightTrigger);
|
||||
}
|
||||
|
||||
if (srw1.buttonClickState.select) {
|
||||
srw1.buttonClickState.select = 0; // Clear event
|
||||
Serial.println(F("Select"));
|
||||
printTilt = !printTilt; // Print tilt value
|
||||
}
|
||||
|
||||
if (srw1.buttonClickState.back) {
|
||||
srw1.buttonClickState.back = 0; // Clear event
|
||||
Serial.println(F("Back"));
|
||||
}
|
||||
if (srw1.buttonClickState.lookLeft) {
|
||||
srw1.buttonClickState.lookLeft = 0; // Clear event
|
||||
Serial.println(F("Look Left"));
|
||||
}
|
||||
if (srw1.buttonClickState.lights) {
|
||||
srw1.buttonClickState.lights = 0; // Clear event
|
||||
Serial.println(F("Lights"));
|
||||
}
|
||||
if (srw1.buttonClickState.lookBack) {
|
||||
srw1.buttonClickState.lookBack = 0; // Clear event
|
||||
Serial.println(F("Look Back"));
|
||||
}
|
||||
if (srw1.buttonClickState.rearBrakeBalance) {
|
||||
srw1.buttonClickState.rearBrakeBalance = 0; // Clear event
|
||||
Serial.println(F("R. Brake Balance"));
|
||||
}
|
||||
if (srw1.buttonClickState.frontBrakeBalance) {
|
||||
srw1.buttonClickState.frontBrakeBalance = 0; // Clear event
|
||||
Serial.println(F("F. Brake Balance"));
|
||||
}
|
||||
if (srw1.buttonClickState.requestPit) {
|
||||
srw1.buttonClickState.requestPit = 0; // Clear event
|
||||
Serial.println(F("Request Pit"));
|
||||
}
|
||||
if (srw1.buttonClickState.leftGear) {
|
||||
srw1.buttonClickState.leftGear = 0; // Clear event
|
||||
Serial.println(F("Left Gear"));
|
||||
}
|
||||
|
||||
if (srw1.buttonClickState.camera) {
|
||||
srw1.buttonClickState.camera = 0; // Clear event
|
||||
Serial.println(F("Camera"));
|
||||
}
|
||||
if (srw1.buttonClickState.lookRight) {
|
||||
srw1.buttonClickState.lookRight = 0; // Clear event
|
||||
Serial.println(F("Look right"));
|
||||
}
|
||||
if (srw1.buttonClickState.boost) {
|
||||
srw1.buttonClickState.boost = 0; // Clear event
|
||||
Serial.println(F("Boost"));
|
||||
}
|
||||
if (srw1.buttonClickState.horn) {
|
||||
srw1.buttonClickState.horn = 0; // Clear event
|
||||
Serial.println(F("Horn"));
|
||||
}
|
||||
if (srw1.buttonClickState.hud) {
|
||||
srw1.buttonClickState.hud = 0; // Clear event
|
||||
Serial.println(F("HUD"));
|
||||
}
|
||||
if (srw1.buttonClickState.launchControl) {
|
||||
srw1.buttonClickState.launchControl = 0; // Clear event
|
||||
Serial.println(F("Launch Control"));
|
||||
}
|
||||
if (srw1.buttonClickState.speedLimiter) {
|
||||
srw1.buttonClickState.speedLimiter = 0; // Clear event
|
||||
Serial.println(F("Speed Limiter"));
|
||||
}
|
||||
if (srw1.buttonClickState.rightGear) {
|
||||
srw1.buttonClickState.rightGear = 0; // Clear event
|
||||
Serial.println(F("Right gear"));
|
||||
}
|
||||
|
||||
if (srw1.srws1Data.assists) Serial.println(srw1.srws1Data.assists);
|
||||
if (srw1.srws1Data.steeringSensitivity) Serial.println(srw1.srws1Data.steeringSensitivity);
|
||||
if (srw1.srws1Data.assistValues) Serial.println(srw1.srws1Data.assistValues);
|
||||
|
||||
switch (srw1.srws1Data.btn.dpad) {
|
||||
case DPAD_UP:
|
||||
Serial.println(F("Up"));
|
||||
break;
|
||||
case DPAD_UP_RIGHT:
|
||||
Serial.println(F("UP & right"));
|
||||
break;
|
||||
case DPAD_RIGHT:
|
||||
Serial.println(F("Right"));
|
||||
break;
|
||||
case DPAD_RIGHT_DOWN:
|
||||
Serial.println(F("Right & down"));
|
||||
break;
|
||||
case DPAD_DOWN:
|
||||
Serial.println(F("Down"));
|
||||
break;
|
||||
case DPAD_DOWN_LEFT:
|
||||
Serial.println(F("Down & left"));
|
||||
break;
|
||||
case DPAD_LEFT:
|
||||
Serial.println(F("Left"));
|
||||
break;
|
||||
case DPAD_LEFT_UP:
|
||||
Serial.println(F("Left & up"));
|
||||
break;
|
||||
case DPAD_OFF:
|
||||
break;
|
||||
default:
|
||||
Serial.print(F("Unknown state: "));
|
||||
PrintHex<uint8_t > (srw1.srws1Data.btn.dpad, 0x80);
|
||||
Serial.println();
|
||||
break;
|
||||
}
|
||||
|
||||
if (printTilt)
|
||||
Serial.println(srw1.srws1Data.tilt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue