diff --git a/gyroscope-test/.gitignore b/gyroscope-test/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/gyroscope-test/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/gyroscope-test/Makefile b/gyroscope-test/Makefile new file mode 100644 index 0000000..35ded5b --- /dev/null +++ b/gyroscope-test/Makefile @@ -0,0 +1,15 @@ + +compile: + arduino-cli compile --build-path build/ --verbose --warnings all + +upload: + arduino-cli compile --build-path build/ --verbose --warnings all --upload + +monitor: + arduino-cli monitor -p /dev/ttyACM0 + +graph: + arduino-cli monitor -p /dev/ttyACM0 | graphstream "255,255,0;0,0,255;0,255,0;0,255,255;255,0,255;255,0,0" + +clean: + rm -rf build/ diff --git a/gyroscope-test/gyroscope-test.ino b/gyroscope-test/gyroscope-test.ino new file mode 100644 index 0000000..99dac3e --- /dev/null +++ b/gyroscope-test/gyroscope-test.ino @@ -0,0 +1,45 @@ +#include + +MKRIoTCarrier carrier; + +[[noreturn]] void halt() +{ + while (true) { + delay(1); + } +} + +void setup() { + Serial.begin(115200); + if (carrier.begin() != 0) { + Serial.println("error: carrier.begin() failed"); + } +} + +template +String& operator<<(String& rhs, T&& lhs) +{ + rhs += lhs; + return rhs; +} + +void loop() { + if (carrier.IMUmodule.accelerationAvailable() + && carrier.IMUmodule.gyroscopeAvailable()) { + + float x, y, z; + float a, b, c; + carrier.IMUmodule.readAcceleration(x, y, z); + carrier.IMUmodule.readGyroscope(a, b, c); + + String packet; + packet + << x * 200 + << ";" << y * 200 + << ";" << z * 200 + << ";" << a + << ";" << b + << ";" << c; + Serial.println(packet); + } +} diff --git a/gyroscope-test/sketch.yaml b/gyroscope-test/sketch.yaml new file mode 100644 index 0000000..1c61b48 --- /dev/null +++ b/gyroscope-test/sketch.yaml @@ -0,0 +1,26 @@ +profiles: + mkr: + fqbn: arduino:samd:mkrwifi1010 + platforms: + - platform: arduino:samd (1.8.14) + libraries: + - dependency: Adafruit BusIO (1.17.4) + - dependency: Adafruit DotStar (1.2.5) + - dependency: Adafruit GFX Library (1.12.5) + - dependency: Adafruit ST7735 and ST7789 Library (1.11.0) + - dependency: Adafruit seesaw Library (1.7.9) + - dependency: Arduino_APDS9960 (1.0.4) + - dependency: Arduino_BQ24195 (0.9.2) + - dependency: Arduino_HTS221 (1.0.0) + - dependency: Arduino_LPS22HB (1.0.2) + - dependency: Arduino_LSM6DS3 (1.0.3) + - dependency: Arduino_LSM6DSOX (1.1.2) + - dependency: Arduino_MCHPTouch (1.2.3) + - Arduino_MKRIoTCarrier (2.1.0) + - dependency: BSEC Software Library (1.8.1492) + - dependency: SD (1.3.0) + - dependency: TFT_eSPI (2.5.43) + +default_profile: mkr +default_fqbn: arduino:samd:mkrwifi1010 +default_port: /dev/ttyACM0