From e29cc12ab48ef82cc2ff1195bce1ce8099a4caa1 Mon Sep 17 00:00:00 2001 From: Paul Dino Jones Date: Tue, 5 Mar 2024 00:34:29 -0500 Subject: [PATCH] Fix compilation issues for arduino devices --- src/arduino/shiftlights/shiftlights.h | 22 ++++++++++++---------- src/arduino/shiftlights/shiftlights.ino | 5 ++--- src/arduino/simwind/simwind.ino | 6 +----- src/monocoque/devices/serial/arduino.c | 3 ++- src/monocoque/devices/serialdevice.c | 2 ++ src/monocoque/devices/sounddevice.c | 8 ++++---- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/arduino/shiftlights/shiftlights.h b/src/arduino/shiftlights/shiftlights.h index a8de8e4..2443424 100755 --- a/src/arduino/shiftlights/shiftlights.h +++ b/src/arduino/shiftlights/shiftlights.h @@ -6,18 +6,20 @@ typedef struct { - char color_1_red; - char color_1_green; - char color_1_blue; - char color_2_red; - char color_2_green; - char color_2_blue; - char color_3_red; - char color_3_green; - char color_3_blue; + unsigned char color_1_red; + unsigned char color_1_green; + unsigned char color_1_blue; + unsigned char color_2_red; + unsigned char color_2_green; + unsigned char color_2_blue; + unsigned char color_3_red; + unsigned char color_3_green; + unsigned char color_3_blue; + unsigned char space_1; + unsigned char space_2; + unsigned char space_3; uint32_t maxrpm; uint32_t rpm; - uint32_t pulses; } ShiftLightsData; diff --git a/src/arduino/shiftlights/shiftlights.ino b/src/arduino/shiftlights/shiftlights.ino index de6039f..20795cb 100644 --- a/src/arduino/shiftlights/shiftlights.ino +++ b/src/arduino/shiftlights/shiftlights.ino @@ -1,5 +1,5 @@ #include -#include "simdata.h" +#include "shiftlights.h" #define SIMDATA_SIZE sizeof(ShiftLightsData) @@ -18,7 +18,7 @@ #define COLOR3C 0 CRGB leds[NUM_LEDS]; -SimData sd; +ShiftLightsData sd; int maxrpm = 0; int rpm = 0; int numlights = NUM_LEDS; @@ -56,7 +56,6 @@ void loop() maxrpm = sd.maxrpm; } - while (l < numlights) { lights[l] = 0; diff --git a/src/arduino/simwind/simwind.ino b/src/arduino/simwind/simwind.ino index 3d00de7..3bffd17 100644 --- a/src/arduino/simwind/simwind.ino +++ b/src/arduino/simwind/simwind.ino @@ -10,7 +10,7 @@ Adafruit_MotorShield AFMS = Adafruit_MotorShield(); Adafruit_DCMotor *myMotor1 = AFMS.getMotor(1); Adafruit_DCMotor *myMotor2 = AFMS.getMotor(3); -SimData sd; +SimWindData sd; int velocity = 0; void setup() { @@ -19,10 +19,6 @@ void setup() { Serial.println("Could not find Motor Shield. Check wiring."); while (1); } - sd.rpms = 0; - sd.maxrpm = 6500; - sd.altitude = 10; - sd.pulses = 40000; sd.velocity = 10; myMotor1->setSpeed(0); diff --git a/src/monocoque/devices/serial/arduino.c b/src/monocoque/devices/serial/arduino.c index bbdfeb9..a44e8c2 100644 --- a/src/monocoque/devices/serial/arduino.c +++ b/src/monocoque/devices/serial/arduino.c @@ -6,13 +6,14 @@ #include "arduino.h" #include "../../slog/slog.h" -#define arduino_timeout 2000 +#define arduino_timeout 5000 int arduino_update(SerialDevice* serialdevice, void* data, size_t size) { int result = 1; if (serialdevice->port) { + slogt("copying %i bytes to arduino device", size); result = check(sp_blocking_write(serialdevice->port, data, size, arduino_timeout)); } diff --git a/src/monocoque/devices/serialdevice.c b/src/monocoque/devices/serialdevice.c index ac19db4..94e36b8 100644 --- a/src/monocoque/devices/serialdevice.c +++ b/src/monocoque/devices/serialdevice.c @@ -26,8 +26,10 @@ int arduino_shiftlights_update(SimDevice* this, SimData* simdata) SerialDevice* serialdevice = (void *) this->derived; int result = 1; + serialdevice->u.shiftlightsdata.maxrpm = simdata->maxrpm; serialdevice->u.shiftlightsdata.rpm = simdata->rpms; + slogt("Updating arduino device rpms to %i", serialdevice->u.shiftlightsdata.rpm); // we can add configs to set all the colors // i can move the size to the initialization since it should not change size_t size = sizeof(ShiftLightsData); diff --git a/src/monocoque/devices/sounddevice.c b/src/monocoque/devices/sounddevice.c index 4813c31..7050d0c 100644 --- a/src/monocoque/devices/sounddevice.c +++ b/src/monocoque/devices/sounddevice.c @@ -45,19 +45,19 @@ int sounddev_tyreslip_update(SimDevice* this, SimData* simdata) double play = 0; if (this->tyre == FRONTLEFT || this->tyre == FRONTS || this->tyre == ALLFOUR) { - play += simdata->wheelslip[0]; + play += simdata->wheelslip0; } if (this->tyre == FRONTRIGHT || this->tyre == FRONTS || this->tyre == ALLFOUR) { - play += simdata->wheelslip[1]; + play += simdata->wheelslip1; } if (this->tyre == REARLEFT || this->tyre == REARS || this->tyre == ALLFOUR) { - play += simdata->wheelslip[2]; + play += simdata->wheelslip2; } if (this->tyre == REARRIGHT || this->tyre == REARS || this->tyre == ALLFOUR) { - play += simdata->wheelslip[3]; + play += simdata->wheelslip3; } if (play > 0) {