Skip to content
Snippets Groups Projects
Commit d26a45fc authored by Václav Jelínek's avatar Václav Jelínek
Browse files

Delete redundant type assignment

parent 3e541d99
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,6 @@ static mp_obj_t motor_make_new(const mp_obj_type_t *type, size_t n_args, size_t
}
motor_obj_t *obj = mp_obj_malloc_with_finaliser(motor_obj_t, &motor_type);
obj->base.type = type;
if (!reg_motor_init(&obj->motor, port, mtype, mdir == DIRECTION_CLOCKWISE)) {
m_del_obj(motor_obj_t, obj);
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("Motor port %d already opened"), port + 1);
......
......@@ -25,7 +25,6 @@ static mp_obj_t analog_sensor_make_new(const mp_obj_type_t* type, size_t n_args,
analog_sensor_obj_t *self = mp_obj_malloc_with_finaliser(analog_sensor_obj_t, &opencube_analog_sensor);
self->port = port;
self->base.type = type;
opencube_analog_sensor_init(self->port);
......
......@@ -19,7 +19,6 @@ static void ICM_print(const mp_print_t *print, mp_obj_t self_in);
// Called on ICM init
static mp_obj_t ICM_make_new(const mp_obj_type_t* type, size_t n_args, size_t n_kw, const mp_obj_t* args) {
ICM_obj_t *self = mp_obj_malloc_with_finaliser(ICM_obj_t, &opencube_ICM_type);
self->base.type = type;
//self->icm = (ICM42688_t*)malloc(sizeof(ICM42688_t));
opencube_lock_i2c_or_raise();
ICM42688_init(&self->icm);
......
......@@ -66,7 +66,6 @@ static MP_DEFINE_CONST_FUN_OBJ_1(battery_deinit_obj, battery_deinit);
// Called on Battery init
static mp_obj_t battery_make_new(const mp_obj_type_t* type, size_t n_args, size_t n_kw, const mp_obj_t* args) {
battery_obj_t *self = mp_obj_malloc_with_finaliser(battery_obj_t, &opencube_battery_type);
self->base.type = type;
self->multiplier = 1.0;
// Initialise the ADC peripheral if it's not already running.
// (this check is borrowed from machine_adc.c)
......
......@@ -21,7 +21,6 @@ static mp_obj_t encoder_make_new(const mp_obj_type_t *type, size_t n_args, size_
opencube_encoders_init(port);
encoder_obj_t *self = mp_obj_malloc_with_finaliser(encoder_obj_t, &opencube_encoder_type);
self->base.type = type;
self->port = port;
self->ref_position = opencube_encoders_get_position(self->port);
if (n_args > 1) {
......
......@@ -9,6 +9,8 @@ typedef struct {
uint port;
} motor_obj_t;
const mp_obj_type_t opencube_motor_type;
// Called on Motor init
// Initialize Motor on given port
static mp_obj_t motor_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
......@@ -19,8 +21,7 @@ static mp_obj_t motor_make_new(const mp_obj_type_t *type, size_t n_args, size_t
mp_raise_msg_varg(&mp_type_ValueError, "Port %d is not a valid motor port", port+1);
}
motor_obj_t *self = m_new_obj(motor_obj_t);
self->base.type = type;
motor_obj_t *self = mp_obj_malloc_with_finaliser(motor_obj_t, &opencube_motor_type);
self->port = port;
opencube_motor_init(self->port);
return MP_OBJ_FROM_PTR(self);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment