Fix issues with data not being correctly sent to motors for sim haptic.
This commit is contained in:
@@ -6,8 +6,14 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int motor;
|
||||
int effect;
|
||||
uint32_t motor1;
|
||||
uint32_t effect1;
|
||||
uint32_t motor2;
|
||||
uint32_t effect2;
|
||||
uint32_t motor3;
|
||||
uint32_t effect3;
|
||||
uint32_t motor4;
|
||||
uint32_t effect4;
|
||||
}
|
||||
SimHapticData;
|
||||
|
||||
|
||||
@@ -12,8 +12,14 @@ Adafruit_DCMotor *myMotor3 = AFMS.getMotor(3);
|
||||
//Adafruit_DCMotor *myMotor4 = AFMS.getMotor(4);
|
||||
|
||||
SimHapticData sd;
|
||||
int effect = 0;
|
||||
int motor = 15;
|
||||
int motor1 = 0;
|
||||
int motor2 = 0;
|
||||
int motor3 = 0;
|
||||
int motor4 = 0;
|
||||
int effect1 = 0;
|
||||
int effect2 = 0;
|
||||
int effect3 = 0;
|
||||
int effect4 = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
@@ -21,8 +27,10 @@ void setup() {
|
||||
Serial.println("Could not find Motor Shield. Check wiring.");
|
||||
while (1);
|
||||
}
|
||||
sd.effect = 0;
|
||||
sd.motor = 15;
|
||||
sd.motor1 = 0;
|
||||
sd.motor2 = 0;
|
||||
sd.motor3 = 0;
|
||||
sd.motor4 = 0;
|
||||
|
||||
myMotor1->setSpeed(0);
|
||||
myMotor1->run(FORWARD);
|
||||
@@ -44,24 +52,36 @@ void loop() {
|
||||
{
|
||||
Serial.readBytes(buff, BYTE_SIZE);
|
||||
memcpy(&sd, &buff, BYTE_SIZE);
|
||||
effect = sd.effect;
|
||||
motor = sd.motor;
|
||||
motor1 = sd.motor1;
|
||||
motor2 = sd.motor2;
|
||||
motor3 = sd.motor3;
|
||||
motor4 = sd.motor4;
|
||||
effect1 = sd.effect1;
|
||||
effect2 = sd.effect2;
|
||||
effect3 = sd.effect3;
|
||||
effect4 = sd.effect4;
|
||||
}
|
||||
|
||||
if (motor == 0 || motor == 4 || motor == 7 || motor == 8 || motor == 10 || motor == 11 || motor == 13 || motor == 14)
|
||||
//if (motor == 0 || motor == 4 || motor == 7 || motor == 8 || motor == 10 || motor == 11 || motor == 13 || motor == 14)
|
||||
//{
|
||||
if (motor1 >= 1)
|
||||
{
|
||||
myMotor1->setSpeed(effect);
|
||||
myMotor1->setSpeed(effect1);
|
||||
}
|
||||
//}
|
||||
//if (motor == 1 || motor == 5 || motor == 7 || motor == 9 || motor == 10 || motor == 11 || motor == 12 || motor == 13)
|
||||
//{
|
||||
// myMotor2->setSpeed(v*POWER);
|
||||
// myMotor2->setSpeed(motor2);
|
||||
//}
|
||||
if (motor == 2 || motor == 6 || motor == 8 || motor == 9 || motor == 10 || motor == 11 || motor == 12 || motor == 14)
|
||||
//if (motor == 2 || motor == 6 || motor == 8 || motor == 9 || motor == 10 || motor == 11 || motor == 12 || motor == 14)
|
||||
//{
|
||||
if (motor3 >= 1)
|
||||
{
|
||||
myMotor3->setSpeed(effect);
|
||||
myMotor3->setSpeed(effect3);
|
||||
}
|
||||
//}
|
||||
//if (motor == 3 || motor == 4 || motor == 5 || motor == 6 || motor == 10 || motor == 12 || motor == 13 || motor == 14)
|
||||
//{
|
||||
// myMotor4->setSpeed(v*POWER);
|
||||
// myMotor4->setSpeed(motor4);
|
||||
//}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user