@@ -318,7 +318,7 @@ MotorEncoder *encoders[] = {new MotorEncoder(specs[51], specs[50], "Port A"),
318
318
new MotorEncoder (specs[17 ], specs[13 ], " Port C" ),
319
319
new MotorEncoder (specs[27 ], specs[26 ], " Port D" )};
320
320
321
- std::optional<Motor> get_motor (int32_t motor_index) {
321
+ std::optional<Motor> get_motor (uint32_t motor_index) {
322
322
if (motor_index > 3 ) {
323
323
return {};
324
324
}
@@ -329,7 +329,7 @@ std::optional<Motor> get_motor(int32_t motor_index) {
329
329
def_prim (drive_motor, threeToNoneU32) {
330
330
int32_t brake = arg0.int32 ;
331
331
int32_t speed = arg1.int32 ;
332
- int32_t motor_index = arg2.int32 ;
332
+ uint32_t motor_index = arg2.uint32 ;
333
333
334
334
printf (" drive_motor(%d, %d, %d)\n " , motor_index, speed, brake);
335
335
@@ -352,7 +352,7 @@ def_prim(drive_motor, threeToNoneU32) {
352
352
353
353
def_prim (drive_motor_ms, twoToNoneU32) {
354
354
int32_t motor_index = arg1.int32 ;
355
- int32_t speed = ( int32_t ) arg0.uint32 ;
355
+ int32_t speed = arg0.int32 ;
356
356
printf (" drive_motor_ms(%d, %d)\n " , motor_index, speed);
357
357
358
358
Motor motor = get_motor (motor_index).value ();
@@ -363,24 +363,24 @@ def_prim(drive_motor_ms, twoToNoneU32) {
363
363
return true ;
364
364
}
365
365
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) {
367
367
if (auto motor = get_motor (motor_index)) {
368
368
motor->drive_to_angle (speed, degrees);
369
369
return true ;
370
370
}
371
371
return false ;
372
372
}
373
373
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) {
375
375
MotorEncoder *encoder = encoders[motor_index];
376
376
drive_motor_degrees_absolute (motor_index, encoder->get_target_angle () + degrees, speed);
377
377
return true ;
378
378
}
379
379
380
380
def_prim (drive_motor_degrees, threeToNoneU32) {
381
381
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 ;
384
384
pop_args (3 );
385
385
return drive_motor_degrees_relative (motor_index, degrees, speed);
386
386
}
0 commit comments