EV3: No inversion by default.
@@ -14,7 +14,7 @@ typedef struct _motor_DcMotor_obj_t {
// Port
uint8_t DcMotor_port;
// Reverse
- bool DcMotor_clockwise_positive;
+ bool DcMotor_inverted;
} motor_DcMotor_obj_t;
STATIC void motor_DcMotor_print( const mp_print_t *print,
@@ -23,9 +23,9 @@ STATIC void motor_DcMotor_print( const mp_print_t *print,
// get a pointer to self
motor_DcMotor_obj_t *self = MP_OBJ_TO_PTR(self_in);
// print the attributes
- printf("Port: %c\n", self->DcMotor_port+65);
+ printf("Port: %c\n", self->DcMotor_port);
printf("Positive speed means: ");
- if(!self->DcMotor_clockwise_positive){
+ if(!self->DcMotor_inverted){
printf("counter");
}
printf("clockwise");
@@ -44,10 +44,10 @@ mp_obj_t motor_DcMotor_make_new( const mp_obj_type_t *type,
self->base.type = &motor_DcMotor_type;
// set the member number with the first argument of the constructor
self->DcMotor_port = mp_obj_get_int(args[0]); // TODO: Check valid range using mp_arg_parse_all
- // set the clockwise_positive member if given
- self->DcMotor_clockwise_positive = (n_args == 2) ? mp_obj_is_true(args[1]) : true;
+ // set the inverted member if given
+ self->DcMotor_inverted = (n_args == 2) ? mp_obj_is_true(args[1]) : false;
// Apply settings to the motor
- pbio_motor_set_direction(self->DcMotor_port, self->DcMotor_clockwise_positive);
+ pbio_motor_set_direction(self->DcMotor_port, self->DcMotor_inverted);
return MP_OBJ_FROM_PTR(self);
}
@@ -124,7 +124,7 @@ typedef struct _motor_EncodedMotor_obj_t {
// Port
uint8_t EncodedMotor_port;
// Reverse
- bool EncodedMotor_clockwise_positive;
+ bool EncodedMotor_inverted;
} motor_EncodedMotor_obj_t;
mp_obj_t motor_EncodedMotor_make_new( const mp_obj_type_t *type,
@@ -139,10 +139,10 @@ mp_obj_t motor_EncodedMotor_make_new( const mp_obj_type_t *type,
self->base.type = &motor_EncodedMotor_type;
// set the member number with the first argument of the constructor
self->EncodedMotor_port = mp_obj_get_int(args[0]); // TODO: Check valid range using mp_arg_parse_all
- // set the clockwise_positive member if given
- self->EncodedMotor_clockwise_positive = (n_args == 2) ? mp_obj_is_true(args[1]) : true;
+ // set the inverted member if given
+ self->EncodedMotor_inverted = (n_args == 2) ? mp_obj_is_true(args[1]) : false;
// Apply settings to the motor
- pbio_motor_set_direction(self->EncodedMotor_port, self->EncodedMotor_clockwise_positive);
+ pbio_motor_set_direction(self->EncodedMotor_port, self->EncodedMotor_inverted);
return MP_OBJ_FROM_PTR(self);
}
@@ -155,7 +155,7 @@ STATIC void motor_EncodedMotor_print( const mp_print_t *print,
motor_DcMotor_print(print, self_in, kind);
// Print other attributes
printf("\nOther stuff\n");
- printf("Port: %c", self->DcMotor_port+65);
+ printf("Port: %c", self->DcMotor_port);
}
//
