Skip to content

Commit 50f6bbc

Browse files
committed
pybricks.common.IMU: Update type name.
Update the pattern to match other new code while we are working on this code anyway.
1 parent d16a98f commit 50f6bbc

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

pybricks/common/pb_type_imu.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include <pybricks/util_pb/pb_error.h>
2222
#include <pybricks/util_mp/pb_kwarg_helper.h>
2323

24-
typedef struct _common_IMU_obj_t {
24+
typedef struct _pb_type_imu_obj_t {
2525
mp_obj_base_t base;
26-
} common_IMU_obj_t;
26+
} pb_type_imu_obj_t;
2727

2828
// pybricks._common.IMU.up
29-
STATIC mp_obj_t common_IMU_up(mp_obj_t self_in) {
29+
STATIC mp_obj_t pb_type_imu_up(mp_obj_t self_in) {
3030
switch (pbio_imu_get_up_side()) {
3131
default:
3232
case PBIO_GEOMETRY_SIDE_FRONT:
@@ -43,10 +43,10 @@ STATIC mp_obj_t common_IMU_up(mp_obj_t self_in) {
4343
return MP_OBJ_FROM_PTR(&pb_Side_BOTTOM_obj);
4444
}
4545
}
46-
MP_DEFINE_CONST_FUN_OBJ_1(common_IMU_up_obj, common_IMU_up);
46+
MP_DEFINE_CONST_FUN_OBJ_1(pb_type_imu_up_obj, pb_type_imu_up);
4747

4848
// pybricks._common.IMU.tilt
49-
STATIC mp_obj_t common_IMU_tilt(mp_obj_t self_in) {
49+
STATIC mp_obj_t pb_type_imu_tilt(mp_obj_t self_in) {
5050

5151
// Read acceleration in the user frame.
5252
pbio_geometry_xyz_t accl;
@@ -62,7 +62,7 @@ STATIC mp_obj_t common_IMU_tilt(mp_obj_t self_in) {
6262
tilt[1] = mp_obj_new_int_from_float(roll * 57.296f);
6363
return mp_obj_new_tuple(2, tilt);
6464
}
65-
MP_DEFINE_CONST_FUN_OBJ_1(common_IMU_tilt_obj, common_IMU_tilt);
65+
MP_DEFINE_CONST_FUN_OBJ_1(pb_type_imu_tilt_obj, pb_type_imu_tilt);
6666

6767
STATIC void pb_type_imu_extract_axis(mp_obj_t obj_in, pbio_geometry_xyz_t *vector) {
6868
if (!mp_obj_is_type(obj_in, &pb_type_Matrix)) {
@@ -78,9 +78,9 @@ STATIC void pb_type_imu_extract_axis(mp_obj_t obj_in, pbio_geometry_xyz_t *vecto
7878
}
7979

8080
// pybricks._common.IMU.acceleration
81-
STATIC mp_obj_t common_IMU_acceleration(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
81+
STATIC mp_obj_t pb_type_imu_acceleration(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
8282
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
83-
common_IMU_obj_t, self,
83+
pb_type_imu_obj_t, self,
8484
PB_ARG_DEFAULT_NONE(axis));
8585

8686
(void)self;
@@ -100,12 +100,12 @@ STATIC mp_obj_t common_IMU_acceleration(size_t n_args, const mp_obj_t *pos_args,
100100
pb_assert(pbio_geometry_vector_project(&axis, &acceleration, &projection));
101101
return mp_obj_new_float_from_f(projection);
102102
}
103-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(common_IMU_acceleration_obj, 1, common_IMU_acceleration);
103+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pb_type_imu_acceleration_obj, 1, pb_type_imu_acceleration);
104104

105105
// pybricks._common.IMU.angular_velocity
106-
STATIC mp_obj_t common_IMU_angular_velocity(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
106+
STATIC mp_obj_t pb_type_imu_angular_velocity(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
107107
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
108-
common_IMU_obj_t, self,
108+
pb_type_imu_obj_t, self,
109109
PB_ARG_DEFAULT_NONE(axis));
110110

111111
(void)self;
@@ -125,12 +125,12 @@ STATIC mp_obj_t common_IMU_angular_velocity(size_t n_args, const mp_obj_t *pos_a
125125
pb_assert(pbio_geometry_vector_project(&axis, &angular_velocity, &projection));
126126
return mp_obj_new_float_from_f(projection);
127127
}
128-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(common_IMU_angular_velocity_obj, 1, common_IMU_angular_velocity);
128+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pb_type_imu_angular_velocity_obj, 1, pb_type_imu_angular_velocity);
129129

130130
// pybricks._common.IMU.rotation
131-
STATIC mp_obj_t common_IMU_rotation(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
131+
STATIC mp_obj_t pb_type_imu_rotation(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
132132
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
133-
common_IMU_obj_t, self,
133+
pb_type_imu_obj_t, self,
134134
PB_ARG_DEFAULT_NONE(axis));
135135

136136
(void)self;
@@ -143,24 +143,24 @@ STATIC mp_obj_t common_IMU_rotation(size_t n_args, const mp_obj_t *pos_args, mp_
143143
pb_assert(pbio_imu_get_single_axis_rotation(&axis, &rotation_angle));
144144
return mp_obj_new_float_from_f(rotation_angle);
145145
}
146-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(common_IMU_rotation_obj, 1, common_IMU_rotation);
146+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pb_type_imu_rotation_obj, 1, pb_type_imu_rotation);
147147

148148
// pybricks._common.IMU.ready
149-
STATIC mp_obj_t common_IMU_ready(mp_obj_t self_in) {
149+
STATIC mp_obj_t pb_type_imu_ready(mp_obj_t self_in) {
150150
return mp_obj_new_bool(pbio_imu_is_ready());
151151
}
152-
MP_DEFINE_CONST_FUN_OBJ_1(common_IMU_ready_obj, common_IMU_ready);
152+
MP_DEFINE_CONST_FUN_OBJ_1(pb_type_imu_ready_obj, pb_type_imu_ready);
153153

154154
// pybricks._common.IMU.stationary
155-
STATIC mp_obj_t common_IMU_stationary(mp_obj_t self_in) {
155+
STATIC mp_obj_t pb_type_imu_stationary(mp_obj_t self_in) {
156156
return mp_obj_new_bool(pbio_imu_is_stationary());
157157
}
158-
MP_DEFINE_CONST_FUN_OBJ_1(common_IMU_stationary_obj, common_IMU_stationary);
158+
MP_DEFINE_CONST_FUN_OBJ_1(pb_type_imu_stationary_obj, pb_type_imu_stationary);
159159

160160
// pybricks._common.IMU.settings
161-
STATIC mp_obj_t common_IMU_settings(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
161+
STATIC mp_obj_t pb_type_imu_settings(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
162162
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
163-
common_IMU_obj_t, self,
163+
pb_type_imu_obj_t, self,
164164
PB_ARG_DEFAULT_NONE(angular_velocity_threshold),
165165
PB_ARG_DEFAULT_NONE(acceleration_threshold));
166166

@@ -189,50 +189,50 @@ STATIC mp_obj_t common_IMU_settings(size_t n_args, const mp_obj_t *pos_args, mp_
189189
pbio_imu_set_stationary_thresholds(angular_velocity, acceleration);
190190
return mp_const_none;
191191
}
192-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(common_IMU_settings_obj, 1, common_IMU_settings);
192+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pb_type_imu_settings_obj, 1, pb_type_imu_settings);
193193

194194
// pybricks._common.IMU.heading
195-
STATIC mp_obj_t common_IMU_heading(mp_obj_t self_in) {
195+
STATIC mp_obj_t pb_type_imu_heading(mp_obj_t self_in) {
196196
(void)self_in;
197197
return mp_obj_new_float(pbio_imu_get_heading());
198198
}
199-
MP_DEFINE_CONST_FUN_OBJ_1(common_IMU_heading_obj, common_IMU_heading);
199+
MP_DEFINE_CONST_FUN_OBJ_1(pb_type_imu_heading_obj, pb_type_imu_heading);
200200

201201
// pybricks._common.IMU.reset_heading
202-
STATIC mp_obj_t common_IMU_reset_heading(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
202+
STATIC mp_obj_t pb_type_imu_reset_heading(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
203203
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
204-
common_IMU_obj_t, self,
204+
pb_type_imu_obj_t, self,
205205
PB_ARG_REQUIRED(angle));
206206

207207
// Set the new angle
208208
(void)self;
209209
pbio_imu_set_heading(mp_obj_get_float(angle_in));
210210
return mp_const_none;
211211
}
212-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(common_IMU_reset_heading_obj, 1, common_IMU_reset_heading);
212+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pb_type_imu_reset_heading_obj, 1, pb_type_imu_reset_heading);
213213

214214
// dir(pybricks.common.IMU)
215-
STATIC const mp_rom_map_elem_t common_IMU_locals_dict_table[] = {
216-
{ MP_ROM_QSTR(MP_QSTR_acceleration), MP_ROM_PTR(&common_IMU_acceleration_obj) },
217-
{ MP_ROM_QSTR(MP_QSTR_angular_velocity), MP_ROM_PTR(&common_IMU_angular_velocity_obj)},
218-
{ MP_ROM_QSTR(MP_QSTR_heading), MP_ROM_PTR(&common_IMU_heading_obj) },
219-
{ MP_ROM_QSTR(MP_QSTR_ready), MP_ROM_PTR(&common_IMU_ready_obj) },
220-
{ MP_ROM_QSTR(MP_QSTR_reset_heading), MP_ROM_PTR(&common_IMU_reset_heading_obj) },
221-
{ MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&common_IMU_rotation_obj) },
222-
{ MP_ROM_QSTR(MP_QSTR_settings), MP_ROM_PTR(&common_IMU_settings_obj) },
223-
{ MP_ROM_QSTR(MP_QSTR_stationary), MP_ROM_PTR(&common_IMU_stationary_obj) },
224-
{ MP_ROM_QSTR(MP_QSTR_tilt), MP_ROM_PTR(&common_IMU_tilt_obj) },
225-
{ MP_ROM_QSTR(MP_QSTR_up), MP_ROM_PTR(&common_IMU_up_obj) },
215+
STATIC const mp_rom_map_elem_t pb_type_imu_locals_dict_table[] = {
216+
{ MP_ROM_QSTR(MP_QSTR_acceleration), MP_ROM_PTR(&pb_type_imu_acceleration_obj) },
217+
{ MP_ROM_QSTR(MP_QSTR_angular_velocity), MP_ROM_PTR(&pb_type_imu_angular_velocity_obj)},
218+
{ MP_ROM_QSTR(MP_QSTR_heading), MP_ROM_PTR(&pb_type_imu_heading_obj) },
219+
{ MP_ROM_QSTR(MP_QSTR_ready), MP_ROM_PTR(&pb_type_imu_ready_obj) },
220+
{ MP_ROM_QSTR(MP_QSTR_reset_heading), MP_ROM_PTR(&pb_type_imu_reset_heading_obj) },
221+
{ MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&pb_type_imu_rotation_obj) },
222+
{ MP_ROM_QSTR(MP_QSTR_settings), MP_ROM_PTR(&pb_type_imu_settings_obj) },
223+
{ MP_ROM_QSTR(MP_QSTR_stationary), MP_ROM_PTR(&pb_type_imu_stationary_obj) },
224+
{ MP_ROM_QSTR(MP_QSTR_tilt), MP_ROM_PTR(&pb_type_imu_tilt_obj) },
225+
{ MP_ROM_QSTR(MP_QSTR_up), MP_ROM_PTR(&pb_type_imu_up_obj) },
226226
};
227-
STATIC MP_DEFINE_CONST_DICT(common_IMU_locals_dict, common_IMU_locals_dict_table);
227+
STATIC MP_DEFINE_CONST_DICT(pb_type_imu_locals_dict, pb_type_imu_locals_dict_table);
228228

229229
// type(pybricks.common.IMU)
230230
STATIC MP_DEFINE_CONST_OBJ_TYPE(pb_type_IMU,
231231
MP_QSTR_IMU,
232232
MP_TYPE_FLAG_NONE,
233-
locals_dict, &common_IMU_locals_dict);
233+
locals_dict, &pb_type_imu_locals_dict);
234234

235-
STATIC common_IMU_obj_t singleton_imu_obj = {
235+
STATIC pb_type_imu_obj_t singleton_imu_obj = {
236236
.base.type = &pb_type_IMU,
237237
};
238238

0 commit comments

Comments
 (0)