Skip to content

Commit 6caa8e5

Browse files
committed
Minor changes to the Sweep library
Added motor speed code for 0 Hz and corresponding entry in keywords.txt Changed 2 boolean functions (_writeCommand & _writeCommandWithArgument) which each had no return statement to void functions Fixed Sweep::getMotorReady() which had no return statement for the case where _readResponseInfoSetting() returns false
1 parent be7d0bc commit 6caa8e5

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Sweep/Sweep.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ bool Sweep::getMotorReady()
8181
// readyCode == 0 indicates device is ready
8282
return _ascii_bytes_to_integer(readyCode) == 0;
8383
}
84+
return false;
8485
}
8586

8687
bool Sweep::waitUntilMotorReady()
@@ -177,14 +178,14 @@ void Sweep::reset()
177178
_writeCommand(_RESET_DEVICE);
178179
}
179180

180-
bool Sweep::_writeCommand(const uint8_t cmd[2])
181+
void Sweep::_writeCommand(const uint8_t cmd[2])
181182
{
182183
const uint8_t command[3] = {cmd[0], cmd[1], _COMMAND_TERMINATION};
183184

184185
_serial.write(command, 3);
185186
}
186187

187-
bool Sweep::_writeCommandWithArgument(const uint8_t cmd[2], const uint8_t arg[2])
188+
void Sweep::_writeCommandWithArgument(const uint8_t cmd[2], const uint8_t arg[2])
188189
{
189190
const uint8_t command[5] = {cmd[0], cmd[1], arg[0], arg[1], _COMMAND_TERMINATION};
190191

@@ -287,4 +288,4 @@ void Sweep::_flushInputBuffer()
287288
{
288289
_serial.read();
289290
}
290-
}
291+
}

Sweep/Sweep.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define sweepArrLen(x) (sizeof(x) / sizeof(*x))
1313

1414
// Available Motor Speed Codes for the setMotorSpeed method
15+
const uint8_t MOTOR_SPEED_CODE_0_HZ[2] = {'0', '0'};
1516
const uint8_t MOTOR_SPEED_CODE_1_HZ[2] = {'0', '1'};
1617
const uint8_t MOTOR_SPEED_CODE_2_HZ[2] = {'0', '2'};
1718
const uint8_t MOTOR_SPEED_CODE_3_HZ[2] = {'0', '3'};
@@ -161,9 +162,9 @@ class Sweep
161162
uint8_t _responseInfoSetting[5];
162163

163164
// Write command without any argument
164-
bool _writeCommand(const uint8_t cmd[2]);
165+
void _writeCommand(const uint8_t cmd[2]);
165166
// Write command with a 2 character argument code
166-
bool _writeCommandWithArgument(const uint8_t cmd[2], const uint8_t arg[2]);
167+
void _writeCommandWithArgument(const uint8_t cmd[2], const uint8_t arg[2]);
167168

168169
// Read various types of responses
169170
bool _readResponseHeader();
@@ -196,4 +197,4 @@ class Sweep
196197
}
197198
};
198199

199-
#endif
200+
#endif

Sweep/keywords.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ reset KEYWORD2
2626
#######################################
2727
# Constants (LITERAL1)
2828
#######################################
29+
MOTOR_SPEED_CODE_0_HZ LITERAL1
2930
MOTOR_SPEED_CODE_1_HZ LITERAL1
3031
MOTOR_SPEED_CODE_2_HZ LITERAL1
3132
MOTOR_SPEED_CODE_3_HZ LITERAL1
@@ -39,4 +40,4 @@ MOTOR_SPEED_CODE_10_HZ LITERAL1
3940

4041
SAMPLE_RATE_CODE_500_HZ LITERAL1
4142
SAMPLE_RATE_CODE_750_HZ LITERAL1
42-
SAMPLE_RATE_CODE_1000_HZ LITERAL1
43+
SAMPLE_RATE_CODE_1000_HZ LITERAL1

0 commit comments

Comments
 (0)