Skip to content

Commit e2f3c56

Browse files
committed
Misc type conversions
1 parent 5000e46 commit e2f3c56

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Primitives/zephyr.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ MotorEncoder *encoders[] = {new MotorEncoder(specs[51], specs[50], "Port A"),
318318
new MotorEncoder(specs[17], specs[13], "Port C"),
319319
new MotorEncoder(specs[27], specs[26], "Port D")};
320320

321-
std::optional<Motor> get_motor(int32_t motor_index) {
321+
std::optional<Motor> get_motor(uint32_t motor_index) {
322322
if (motor_index > 3) {
323323
return {};
324324
}
@@ -329,7 +329,7 @@ std::optional<Motor> get_motor(int32_t motor_index) {
329329
def_prim(drive_motor, threeToNoneU32) {
330330
int32_t brake = arg0.int32;
331331
int32_t speed = arg1.int32;
332-
int32_t motor_index = arg2.int32;
332+
uint32_t motor_index = arg2.uint32;
333333

334334
printf("drive_motor(%d, %d, %d)\n", motor_index, speed, brake);
335335

@@ -352,7 +352,7 @@ def_prim(drive_motor, threeToNoneU32) {
352352

353353
def_prim(drive_motor_ms, twoToNoneU32) {
354354
int32_t motor_index = arg1.int32;
355-
int32_t speed = (int32_t)arg0.uint32;
355+
int32_t speed = arg0.int32;
356356
printf("drive_motor_ms(%d, %d)\n", motor_index, speed);
357357

358358
Motor motor = get_motor(motor_index).value();
@@ -363,24 +363,24 @@ def_prim(drive_motor_ms, twoToNoneU32) {
363363
return true;
364364
}
365365

366-
bool drive_motor_degrees_absolute(int32_t motor_index, int32_t degrees, int32_t speed) {
366+
bool drive_motor_degrees_absolute(uint32_t motor_index, int32_t degrees, int32_t speed) {
367367
if (auto motor = get_motor(motor_index)) {
368368
motor->drive_to_angle(speed, degrees);
369369
return true;
370370
}
371371
return false;
372372
}
373373

374-
bool drive_motor_degrees_relative(int32_t motor_index, int32_t degrees, int32_t speed) {
374+
bool drive_motor_degrees_relative(uint32_t motor_index, int32_t degrees, int32_t speed) {
375375
MotorEncoder *encoder = encoders[motor_index];
376376
drive_motor_degrees_absolute(motor_index, encoder->get_target_angle() + degrees, speed);
377377
return true;
378378
}
379379

380380
def_prim(drive_motor_degrees, threeToNoneU32) {
381381
int32_t speed = arg0.int32;
382-
int32_t degrees = arg1.uint32;
383-
int32_t motor_index = arg2.uint32;
382+
int32_t degrees = arg1.int32;
383+
uint32_t motor_index = arg2.uint32;
384384
pop_args(3);
385385
return drive_motor_degrees_relative(motor_index, degrees, speed);
386386
}

0 commit comments

Comments
 (0)