diff --git a/pybricks/common.h b/pybricks/common.h index c428b6bd7..e4301a217 100644 --- a/pybricks/common.h +++ b/pybricks/common.h @@ -88,7 +88,7 @@ const mp_obj_type_t pb_type_Speaker; #if PYBRICKS_PY_COMMON_IMU -mp_obj_t pb_type_IMU_obj_new(void); +mp_obj_t pb_type_IMU_obj_new(mp_obj_t top_side_axis, mp_obj_t front_side_axis); #endif // PYBRICKS_PY_COMMON_IMU diff --git a/pybricks/common/pb_type_imu.c b/pybricks/common/pb_type_imu.c index acf594cb7..0b76cfee9 100644 --- a/pybricks/common/pb_type_imu.c +++ b/pybricks/common/pb_type_imu.c @@ -99,7 +99,7 @@ STATIC const mp_obj_type_t pb_type_IMU = { STATIC common_IMU_obj_t singleton_obj; // pybricks._common.IMU.__init__ -mp_obj_t pb_type_IMU_obj_new(void) { +mp_obj_t pb_type_IMU_obj_new(mp_obj_t top_side_axis, mp_obj_t front_side_axis) { // Get singleton instance common_IMU_obj_t *self = &singleton_obj; diff --git a/pybricks/hubs/pb_type_primehub.c b/pybricks/hubs/pb_type_primehub.c index 4524a4c25..0330e0be1 100644 --- a/pybricks/hubs/pb_type_primehub.c +++ b/pybricks/hubs/pb_type_primehub.c @@ -15,7 +15,10 @@ #include "py/runtime.h" #include "py/obj.h" +#include + #include +#include #include typedef struct _hubs_PrimeHub_obj_t { @@ -34,11 +37,15 @@ static const pb_obj_enum_member_t *primehub_buttons[] = { }; STATIC mp_obj_t hubs_PrimeHub_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + PB_PARSE_ARGS_CLASS(n_args, n_kw, args, + PB_ARG_DEFAULT_OBJ(top_side, pb_Axis_Z_obj), + PB_ARG_DEFAULT_OBJ(front_side, pb_Axis_X_obj)); + hubs_PrimeHub_obj_t *self = m_new_obj(hubs_PrimeHub_obj_t); self->base.type = (mp_obj_type_t *)type; self->buttons = pb_type_Keypad_obj_new(PBIO_ARRAY_SIZE(primehub_buttons), primehub_buttons); self->display = pb_type_Lightmatrix_obj_new(pbsys_hub_light_matrix); - self->imu = pb_type_IMU_obj_new(); + self->imu = pb_type_IMU_obj_new(top_side_in, front_side_in); self->light = common_ColorLight_internal_obj_new(pbsys_status_light); self->speaker = mp_call_function_0(MP_OBJ_FROM_PTR(&pb_type_Speaker)); return MP_OBJ_FROM_PTR(self); diff --git a/pybricks/hubs/pb_type_technichub.c b/pybricks/hubs/pb_type_technichub.c index 6c703a2b9..a832a2790 100644 --- a/pybricks/hubs/pb_type_technichub.c +++ b/pybricks/hubs/pb_type_technichub.c @@ -8,7 +8,10 @@ #include #include +#include + #include +#include #include typedef struct _hubs_TechnicHub_obj_t { @@ -18,9 +21,13 @@ typedef struct _hubs_TechnicHub_obj_t { } hubs_TechnicHub_obj_t; STATIC mp_obj_t hubs_TechnicHub_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + PB_PARSE_ARGS_CLASS(n_args, n_kw, args, + PB_ARG_DEFAULT_OBJ(top_side, pb_Axis_Z_obj), + PB_ARG_DEFAULT_OBJ(front_side, pb_Axis_X_obj)); + hubs_TechnicHub_obj_t *self = m_new_obj(hubs_TechnicHub_obj_t); self->base.type = (mp_obj_type_t *)type; - self->imu = pb_type_IMU_obj_new(); + self->imu = pb_type_IMU_obj_new(top_side_in, front_side_in); self->light = common_ColorLight_internal_obj_new(pbsys_status_light); return MP_OBJ_FROM_PTR(self); }