Fix compilation issues for arduino devices

This commit is contained in:
Paul Dino Jones 2024-03-05 00:34:29 -05:00
parent eb18a05c51
commit e29cc12ab4
6 changed files with 23 additions and 23 deletions

View File

@ -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;

View File

@ -1,5 +1,5 @@
#include <FastLED.h>
#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;

View File

@ -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);

View File

@ -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));
}

View File

@ -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);

View File

@ -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)
{