Refactored serial arduino devices. Created custom structs for sending data to arduino devices.
This commit is contained in:
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#ifndef _SHIFTLIGHTSDATA_H
|
||||
#define _SHIFTLIGHTSDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
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;
|
||||
uint32_t maxrpm;
|
||||
uint32_t rpm;
|
||||
uint32_t pulses;
|
||||
}
|
||||
ShiftLightsData;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <FastLED.h>
|
||||
#include "simdata.h"
|
||||
|
||||
#define SIMDATA_SIZE sizeof(SimData)
|
||||
#define SIMDATA_SIZE sizeof(ShiftLightsData)
|
||||
|
||||
#define LED_PIN 7
|
||||
#define NUM_LEDS 6
|
||||
@@ -39,11 +39,8 @@ void setup()
|
||||
}
|
||||
FastLED.clear();
|
||||
|
||||
sd.rpms = 0;
|
||||
sd.rpm = 0;
|
||||
sd.maxrpm = 6500;
|
||||
sd.altitude = 10;
|
||||
sd.pulses = 40000;
|
||||
sd.velocity = 10;
|
||||
}
|
||||
|
||||
void loop()
|
||||
@@ -55,9 +52,8 @@ void loop()
|
||||
{
|
||||
Serial.readBytes(buff, SIMDATA_SIZE);
|
||||
memcpy(&sd, &buff, SIMDATA_SIZE);
|
||||
rpm = sd.rpms;
|
||||
rpm = sd.rpm;
|
||||
maxrpm = sd.maxrpm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#ifndef _SIMWINDDATA_H
|
||||
#define _SIMWINDDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float velocity;
|
||||
float fanpower;
|
||||
}
|
||||
SimWindData;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <Adafruit_MotorShield.h>
|
||||
#include "simdata.h"
|
||||
#include "simwind.h"
|
||||
|
||||
#define BYTE_SIZE sizeof(SimData)
|
||||
#define BYTE_SIZE sizeof(SimWindData)
|
||||
#define KPHTOMPH .621317
|
||||
#define FANPOWER .6
|
||||
|
||||
|
||||
Reference in New Issue
Block a user