Serial8 (#11)
* Using 8 bits per int for serial devices * Refactor simwind code slightly to improve performance
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t litleds;
|
||||
uint8_t litleds;
|
||||
//unsigned char color_1_red;
|
||||
//unsigned char color_1_green;
|
||||
//unsigned char color_1_blue;
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t motor1;
|
||||
uint32_t effect1;
|
||||
uint32_t motor2;
|
||||
uint32_t effect2;
|
||||
uint32_t motor3;
|
||||
uint32_t effect3;
|
||||
uint32_t motor4;
|
||||
uint32_t effect4;
|
||||
uint8_t motor1;
|
||||
uint8_t effect1;
|
||||
uint8_t motor2;
|
||||
uint8_t effect2;
|
||||
uint8_t motor3;
|
||||
uint8_t effect3;
|
||||
uint8_t motor4;
|
||||
uint8_t effect4;
|
||||
}
|
||||
SimHapticData;
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t velocity;
|
||||
float fanpower;
|
||||
uint8_t velocity;
|
||||
uint8_t fanpower;
|
||||
}
|
||||
SimWindData;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ SimWindData sd;
|
||||
int velocity = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.begin(9600);
|
||||
if (!AFMS.begin()) {
|
||||
Serial.println("Could not find Motor Shield. Check wiring.");
|
||||
while (1);
|
||||
@@ -37,11 +37,7 @@ void loop() {
|
||||
memcpy(&sd, &buff, BYTE_SIZE);
|
||||
velocity = sd.velocity;
|
||||
}
|
||||
int v = ceil(velocity * KPHTOMPH);
|
||||
if (v >= 255)
|
||||
{
|
||||
v = 255;
|
||||
}
|
||||
myMotor1->setSpeed(v*FANPOWER);
|
||||
myMotor2->setSpeed(v*FANPOWER);
|
||||
|
||||
myMotor1->setSpeed(velocity*FANPOWER);
|
||||
myMotor2->setSpeed(velocity*FANPOWER);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user