Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit f6eca1e

Browse files
Fixed small compile errors and formatting
1 parent 41c1983 commit f6eca1e

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

arduino_controller/arduino_controller.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
// function declarations
1111
void RecvWithStartEndMarkers();
1212
void ProcessData();
13-
void CheckSwitch();
13+
int CheckSwitch();
1414
void PopulateArray();
15-
void CheckSwitch();
1615

1716
// variables for communication
1817
const byte num_chars = 32;

arduino_controller/arduino_controller_functions.ino

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,28 @@ void ProcessData()
3737
Invalid();
3838
}
3939
}
40-
40+
4141
bool go = true;
4242
int total_turns = 0;
4343

44-
while (go == true)
44+
while (go == true)
4545
{
46-
46+
// subtract from motor rotations when a rotation is detected
4747
for (int i = 0; i < NUMBER_MOTORS; i++)
4848
{
4949
motor_sensor_counter2[i] = motor_sensor_counter1[i];
50-
motor_sensor_counter1 = CheckSwitch(i,ports[i][0]);
50+
motor_sensor_counter1[i] = CheckSwitch(i, ports[i][0]);
5151

52-
if(motor_sensor_counter1 == 1 && motor_sensor_counter2 == 0) {
52+
if (motor_sensor_counter1[i] == 1 && motor_sensor_counter2[i] == 0)
53+
{
5354
motor_commands[i][1] = motor_commands[i][1] - 1;
5455
}
55-
}
56-
56+
}
5757
// stop motors that have reached 0
5858
for (int i = 0; i < NUMBER_MOTORS; i++)
5959
{
60-
if (motor_commands[i][1] <= 0) {
60+
if (motor_commands[i][1] <= 0)
61+
{
6162
my_servo[i].write(90);
6263
}
6364
}
@@ -67,7 +68,8 @@ void ProcessData()
6768
total_turns += motor_commands[i][1];
6869
}
6970
// exit loop if there are no more motor rotations remaining
70-
if (total_turns <= 0) {
71+
if (total_turns <= 0)
72+
{
7173
go = false;
7274
}
7375
total_turns = 0;
@@ -138,7 +140,7 @@ void PopulateArray()
138140
//////////////////////////////////////////////////////////////////////////////
139141
//////////////////////////////////////////////////////////////////////////////
140142

141-
void CheckSwitch(int motor_number, int switchPort)
143+
int CheckSwitch(int motor_number, int switchPort)
142144
{
143145
/* Step 1: Update the integrator based on the input signal. Note that the
144146
integrator follows the input, decreasing or increasing towards the limits
@@ -158,10 +160,10 @@ void CheckSwitch(int motor_number, int switchPort)
158160
either 0 or MAXIMUM. */
159161

160162
if (integrator[motor_number] == 0)
161-
reuturn(0)
163+
return (0);
162164
else if (integrator[motor_number] >= MAXIMUM)
163165
{
164-
return(1);
165-
integrator[motor_number] = MAXIMUM; /* defensive code if integrator got corrupted */
166+
return (1);
167+
integrator[motor_number] = MAXIMUM; /* defensive code if integrator got corrupted */
166168
}
167169
}

0 commit comments

Comments
 (0)