66
77#include "pybricks/experimental/odometry.h"
88
9- // The function logic
9+ // MicroPython usually defines STATIC in mpconfig.h
10+ #ifndef STATIC
11+ #define STATIC static
12+ #endif
13+
14+ // 1. The benchmark function logic
1015STATIC mp_obj_t experimental_odometry_benchmark (size_t n_args , const mp_obj_t * args ) {
1116 int num_iters = mp_obj_get_int (args [0 ]);
1217 float wheel_circ = mp_obj_get_float (args [1 ]);
@@ -16,16 +21,18 @@ STATIC mp_obj_t experimental_odometry_benchmark(size_t n_args, const mp_obj_t *a
1621
1722 return calculate_odometry (num_iters , wheel_circ , axle_track , right_func , left_func );
1823}
24+
25+ // 2. Define the function object
1926STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (experimental_odometry_benchmark_obj , 5 , 5 , experimental_odometry_benchmark );
2027
21- // The dict table. The name must match exactly: pb_module_<filename_without_pb_module>_globals
28+ // 3. Create the globals table.
29+ // The name must match pb_module_<filename>_globals for the auto-generator.
2230STATIC const mp_rom_map_elem_t pb_module_experimental_globals_table [] = {
2331 { MP_ROM_QSTR (MP_QSTR_odometry_benchmark ), MP_ROM_PTR (& experimental_odometry_benchmark_obj ) },
2432};
2533STATIC MP_DEFINE_CONST_DICT (pb_module_experimental_globals , pb_module_experimental_globals_table );
2634
27- // We define the module struct here so the linker finds it,
28- // but we do NOT use MP_REGISTER_MODULE because the Makefile does it for us.
35+ // 4. Define the module structure
2936const mp_obj_module_t pb_module_experimental = {
3037 .base = { & mp_type_module },
3138 .globals = (mp_obj_dict_t * )& pb_module_experimental_globals ,
0 commit comments