Skip to content

Commit 1e0f5cd

Browse files
committed
Use constant for max achievable angle instead of magic number.
1 parent 500419c commit 1e0f5cd

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/Tools/Test_Motor_Angular_Control/Test_Motor_Angular_Control.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void test_motor(int const id)
3535
Serial.println("OK.");
3636
delay(1500);
3737

38-
for (float target_angle = 0.0f; target_angle < 315.0f; target_angle += 1.0f)
38+
for (float target_angle = 0.0f; target_angle < SmartServoClass::MAX_ANGLE; target_angle += 1.0f)
3939
{
4040
Braccio.get(id).move().to(target_angle).in(200ms);
4141
delay(250);

src/lib/motors/SmartServo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ class SmartServoClass
7474
inline int getErrors() const { return _errors; }
7575

7676
static const int BROADCAST = 0xFE;
77+
static float constexpr MAX_ANGLE = 315.0f;
7778

7879
private:
7980

80-
static int constexpr NUM_MOTORS = 6;
81-
static int constexpr MAX_TX_PAYLOAD_LEN = (5*NUM_MOTORS+4);
82-
static int constexpr MAX_RX_PAYLOAD_LEN = 10;
83-
static int constexpr MAX_POSITION = 4000;
84-
static float constexpr MAX_ANGLE = 315.0f;
81+
static int constexpr NUM_MOTORS = 6;
82+
static int constexpr MAX_TX_PAYLOAD_LEN = (5*NUM_MOTORS+4);
83+
static int constexpr MAX_RX_PAYLOAD_LEN = 10;
84+
static int constexpr MAX_POSITION = 4000;
8585

8686
static int constexpr MIN_MOTOR_ID = 1;
8787
static int constexpr MAX_MOTOR_ID = 6;

0 commit comments

Comments
 (0)