summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--platformio.ini3
-rw-r--r--src/gyronardo.cpp7
3 files changed, 11 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 5acb669..4dec283 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
build
.vscode
+.pio
diff --git a/platformio.ini b/platformio.ini
index 758ca9a..718ffc5 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -4,7 +4,10 @@ build_dir = build
[env:leonardo]
platform = atmelavr
board = leonardo
+# board = leonardo-xinput
framework = arduino
+lib_deps =
+ https://github.com/dmadison/ArduinoXInput
src_build_flags =
-Wextra
-Wpedantic
diff --git a/src/gyronardo.cpp b/src/gyronardo.cpp
index 1c75c80..7c01985 100644
--- a/src/gyronardo.cpp
+++ b/src/gyronardo.cpp
@@ -5,6 +5,7 @@
#include <Arduino.h>
#include <Wire.h>
+#include <XInput.h>
constexpr uint8_t SENSOR_ADDRESS = 0x68U;
constexpr uint32_t SENSOR_THROTTLE_TIME = 50U; // milliseconds
@@ -68,6 +69,8 @@ void setup()
<< "Gyro Z: " << sensor.gyro_cal_z << "\n";
sout << "Starting..." << endl;
+
+ XInput.begin();
}
void loop()
@@ -90,4 +93,8 @@ void loop()
}
sout << "Pitch: " << sensor.getPitch() << " Roll: " << sensor.getRoll() << endl;
+
+ XInput.setJoystick(JOY_LEFT, static_cast<int32_t>(sensor.getRoll()),
+ static_cast<int32_t>(sensor.getPitch()));
+ XInput.printDebug(Serial);
}