I just got the R4 WiFi. I've been playing with the matrix on it. Pretty cool.
I want to use it to read and xbox controller and send commands over wifi. I expected to find libraries that weren't ready yet.
I'm compiling the XBOXUSB.ino example code from the library.
/*
Example sketch for the Xbox 360 USB library - developed by Kristian Lauszus
For more information visit my blog: http://blog.tkjelectronics.dk/ or
send me an e-mail: kristianl@tkjelectronics.com
*/
#include <XBOXUSB.h>
// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>
USB Usb;
XBOXUSB Xbox(&Usb);
void setup() {
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
#endif
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nXBOX USB Library Started"));
}
void loop() {
Usb.Task();
if (Xbox.Xbox360Connected) {
if (Xbox.getButtonPress(LT) || Xbox.getButtonPress(RT)) {
Serial.print("LT: ");
Serial.print(Xbox.getButtonPress(LT));
Serial.print("\tRT: ");
Serial.println(Xbox.getButtonPress(RT));
Xbox.setRumbleOn(Xbox.getButtonPress(LT), Xbox.getButtonPress(RT));
} else
Xbox.setRumbleOn(0, 0);
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) {
Serial.print(F("LeftHatX: "));
Serial.print(Xbox.getAnalogHat(LeftHatX));
Serial.print("\t");
}
if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) {
Serial.print(F("LeftHatY: "));
Serial.print(Xbox.getAnalogHat(LeftHatY));
Serial.print("\t");
}
if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) {
Serial.print(F("RightHatX: "));
Serial.print(Xbox.getAnalogHat(RightHatX));
Serial.print("\t");
}
if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
Serial.print(F("RightHatY: "));
Serial.print(Xbox.getAnalogHat(RightHatY));
}
Serial.println();
}
if (Xbox.getButtonClick(UP)) {
Xbox.setLedOn(LED1);
Serial.println(F("Up"));
}
if (Xbox.getButtonClick(DOWN)) {
Xbox.setLedOn(LED4);
Serial.println(F("Down"));
}
if (Xbox.getButtonClick(LEFT)) {
Xbox.setLedOn(LED3);
Serial.println(F("Left"));
}
if (Xbox.getButtonClick(RIGHT)) {
Xbox.setLedOn(LED2);
Serial.println(F("Right"));
}
if (Xbox.getButtonClick(START)) {
Xbox.setLedMode(ALTERNATING);
Serial.println(F("Start"));
}
if (Xbox.getButtonClick(BACK)) {
Xbox.setLedBlink(ALL);
Serial.println(F("Back"));
}
if (Xbox.getButtonClick(L3))
Serial.println(F("L3"));
if (Xbox.getButtonClick(R3))
Serial.println(F("R3"));
if (Xbox.getButtonClick(LB))
Serial.println(F("LB"));
if (Xbox.getButtonClick(RB))
Serial.println(F("RB"));
if (Xbox.getButtonClick(XBOX)) {
Xbox.setLedMode(ROTATING);
Serial.println(F("Xbox"));
}
if (Xbox.getButtonClick(A))
Serial.println(F("A"));
if (Xbox.getButtonClick(B))
Serial.println(F("B"));
if (Xbox.getButtonClick(X))
Serial.println(F("X"));
if (Xbox.getButtonClick(Y))
Serial.println(F("Y"));
}
delay(1);
}
And I get these errors for the USB_Host_Shield library:
In file included from /home/david/Arduino/libraries/USB_Host_Shield_Library_2.0/Usb.h:41:0,
from /home/david/Arduino/libraries/USB_Host_Shield_Library_2.0/XBOXUSB.h:21,
from /tmp/.arduinoIDE-unsaved2023726-254136-3tud5r.1e47o/XBOXUSB/XBOXUSB.ino:7:
/home/david/Arduino/libraries/USB_Host_Shield_Library_2.0/avrpins.h:1442:2: error: #error "Please define board in avrpins.h"
#error "Please define board in avrpins.h"
^~~~~
In file included from /home/david/Arduino/libraries/USB_Host_Shield_Library_2.0/Usb.h:43:0,
from /home/david/Arduino/libraries/USB_Host_Shield_Library_2.0/XBOXUSB.h:21,
from /tmp/.arduinoIDE-unsaved2023726-254136-3tud5r.1e47o/XBOXUSB/XBOXUSB.ino:7:
/home/david/Arduino/libraries/USB_Host_Shield_Library_2.0/usbhost.h:126:2: error: #error "No SPI entry in usbhost.h"
#error "No SPI entry in usbhost.h"
^~~~~
exit status 1
Compilation error: exit status 1
If anyone wants to give me a head start I'd appreciate it. Otherwise I intend to try to solve this one tomorrow.