Use new MP API

This commit is contained in:
iabdalkader 2014-04-10 17:06:11 +02:00
parent d6f66bc2f9
commit 5f2b17f62c
10 changed files with 96 additions and 125 deletions

View File

@ -19,6 +19,7 @@
#include "py_time.h"
#include "py_spi.h"
#include "py_gpio.h"
#include "py_image.h"
#include "libcc3k.h"
int errno;
@ -219,15 +220,16 @@ typedef struct {
const mp_obj_module_t *(*init)(void);
} module_t;
static module_t exported_modules[] ={
static const module_t exported_modules[] ={
{MP_QSTR_sensor,py_sensor_init},
{MP_QSTR_led, py_led_init},
{MP_QSTR_time, py_time_init},
{MP_QSTR_sensor,py_sensor_init},
{MP_QSTR_gpio, py_gpio_init},
{MP_QSTR_spi, py_spi_init},
{NULL, NULL}
};
#include "mdefs.h"
int main(void)
{
rcc_ctrl_set_frequency(SYSCLK_168_MHZ);
@ -245,16 +247,16 @@ int main(void)
rng_init();
/* Add functions to the global python namespace */
rt_store_global(qstr_from_str("help"), rt_make_function_n(0, py_help));
rt_store_global(qstr_from_str("open"), rt_make_function_n(2, py_file_open));
rt_store_global(qstr_from_str("vcp_connected"), rt_make_function_n(0, py_vcp_connected));
rt_store_global(qstr_from_str("info"), rt_make_function_n(0, py_info));
rt_store_global(qstr_from_str("gc_collect"), rt_make_function_n(0, py_gc_collect));
py_image_init();
mp_store_global(qstr_from_str("help"), mp_make_function_n(0, py_help));
mp_store_global(qstr_from_str("open"), mp_make_function_n(2, py_file_open));
mp_store_global(qstr_from_str("vcp_connected"), mp_make_function_n(0, py_vcp_connected));
mp_store_global(qstr_from_str("info"), mp_make_function_n(0, py_info));
mp_store_global(qstr_from_str("gc_collect"), mp_make_function_n(0, py_gc_collect));
mp_store_global(qstr_from_str("Image"), mp_make_function_n(1, py_image_load_image));
mp_store_global(qstr_from_str("HaarCascade"), mp_make_function_n(1, py_image_load_cascade));
/* Export Python modules to the global python namespace */
for (module_t *p = exported_modules; p->name != NULL; p++) {
for (const module_t *p = exported_modules; p->name != NULL; p++) {
const mp_obj_module_t *module = p->init();
if (module == NULL) {
__fatal_error("failed to init module");
@ -263,7 +265,6 @@ int main(void)
}
}
/* Try to mount the flash fs */
bool reset_filesystem = false;
FRESULT res = f_mount(&fatfs0, "0:", 1);

View File

@ -53,19 +53,21 @@ static MP_DEFINE_CONST_FUN_OBJ_1(py_clock_fps_obj, py_clock_fps);
static MP_DEFINE_CONST_FUN_OBJ_1(py_clock_avg_obj, py_clock_avg);
static MP_DEFINE_CONST_FUN_OBJ_1(py_clock_reset_obj, py_clock_reset);
static const mp_method_t py_clock_methods[] = {
{ "tick", &py_clock_tick_obj},
{ "fps", &py_clock_fps_obj},
{ "avg", &py_clock_avg_obj},
{ "reset", &py_clock_reset_obj},
static const mp_map_elem_t locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_tick), (mp_obj_t)&py_clock_tick_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_fps), (mp_obj_t)&py_clock_fps_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_avg), (mp_obj_t)&py_clock_avg_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_reset), (mp_obj_t)&py_clock_reset_obj},
{ NULL, NULL },
};
STATIC MP_DEFINE_CONST_DICT(locals_dict, locals_dict_table);
static const mp_obj_type_t py_clock_type = {
{ &mp_type_type },
.name = MP_QSTR_Clock,
.print = py_clock_print,
.methods = py_clock_methods,
.locals_dict = (mp_obj_t)&locals_dict,
};
mp_obj_t py_clock()

View File

@ -79,18 +79,20 @@ static MP_DEFINE_CONST_FUN_OBJ_1(py_file_close_obj, py_file_close);
static MP_DEFINE_CONST_FUN_OBJ_2(py_file_read_obj, py_file_read);
static MP_DEFINE_CONST_FUN_OBJ_2(py_file_write_obj, py_file_write);
static const mp_method_t py_file_methods[] = {
{ "close", &py_file_close_obj},
{ "read", &py_file_read_obj},
{ "write", &py_file_write_obj},
static const mp_map_elem_t locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&py_file_close_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&py_file_read_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&py_file_write_obj},
{ NULL, NULL },
};
STATIC MP_DEFINE_CONST_DICT(locals_dict, locals_dict_table);
static const mp_obj_type_t py_file_type = {
{ &mp_type_type },
.name = MP_QSTR_File,
.print = py_file_print,
.methods = py_file_methods,
.name = MP_QSTR_file,
.print = py_file_print,
.locals_dict = (mp_obj_t)&locals_dict,
};
mp_obj_t py_file_open(mp_obj_t path, mp_obj_t mode_str)

View File

@ -56,17 +56,19 @@ static void py_gpio_print(void (*print)(void *env, const char *fmt, ...), void *
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_gpio_low_obj, py_gpio_low);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_gpio_high_obj, py_gpio_high);
static const mp_method_t py_gpio_methods[] = {
{ "low", &py_gpio_low_obj},
{ "high", &py_gpio_high_obj},
{ NULL, NULL },
static const mp_map_elem_t locals_dict_table[] = {
{MP_OBJ_NEW_QSTR(MP_QSTR_low), (mp_obj_t)&py_gpio_low_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_high), (mp_obj_t)&py_gpio_high_obj},
{NULL, NULL },
};
STATIC MP_DEFINE_CONST_DICT(locals_dict, locals_dict_table);
static const mp_obj_type_t py_gpio_type = {
{ &mp_type_type },
.name = MP_QSTR_gpio,
.print = py_gpio_print,
.methods = py_gpio_methods,
.name = MP_QSTR_gpio,
.print = py_gpio_print,
.locals_dict = (mp_obj_t)&locals_dict,
};
static void gpio_init(const gpio_t *gpio)
@ -96,7 +98,8 @@ mp_obj_t py_gpio_new(mp_obj_t id_obj)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_gpio_new_obj, py_gpio_new);
STATIC const mp_map_elem_t module_globals_table[] = {
static const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_gpio) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_P1), MP_OBJ_NEW_SMALL_INT(GPIO_PC10)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_P2), MP_OBJ_NEW_SMALL_INT(GPIO_PC11)},
@ -107,18 +110,12 @@ STATIC const mp_map_elem_t module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO), (mp_obj_t)&py_gpio_new_obj },
};
STATIC const mp_map_t module_globals = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.alloc = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.table = (mp_map_elem_t*)module_globals_table,
};
STATIC MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table);
static const mp_obj_module_t py_gpio_module = {
const mp_obj_module_t py_gpio_module = {
.base = { &mp_type_module },
.name = MP_QSTR_gpio,
.globals = (mp_map_t*)&module_globals,
.globals = (mp_obj_t)&globals_dict,
};
const mp_obj_module_t *py_gpio_init()

View File

@ -262,17 +262,15 @@ static mp_obj_t py_image_find_blobs(mp_obj_t image_obj)
blobs = imlib_count_blobs(image);
/* Create empty Python list */
objects_list = rt_build_list(0, NULL);
objects_list = mp_obj_new_list(0, NULL);
if (array_length(blobs)) {
for (int j=0; j<array_length(blobs); j++) {
rectangle_t *b = array_at(blobs, j);
mp_obj_t r[4];
r[0] = mp_obj_new_int(b->x);
r[1] = mp_obj_new_int(b->y);
r[2] = mp_obj_new_int(b->w);
r[3] = mp_obj_new_int(b->h);
rt_list_append(objects_list, rt_build_tuple(4, r));
mp_obj_list_append(objects_list, mp_obj_new_int(b->x));
mp_obj_list_append(objects_list, mp_obj_new_int(b->y));
mp_obj_list_append(objects_list, mp_obj_new_int(b->w));
mp_obj_list_append(objects_list, mp_obj_new_int(b->h));
}
}
array_free(blobs);
@ -300,7 +298,7 @@ static mp_obj_t py_image_find_features(mp_obj_t image_obj, mp_obj_t cascade_obj)
objects_array = imlib_detect_objects(image, cascade);
/* Create empty Python list */
objects_list = rt_build_list(0, NULL);
objects_list = mp_obj_new_list(0, NULL);
/* Add detected objects to the list */
for (int i=0; i<array_length(objects_array); i++) {
@ -310,7 +308,7 @@ static mp_obj_t py_image_find_features(mp_obj_t image_obj, mp_obj_t cascade_obj)
rec_obj[1] = mp_obj_new_int(r->y);
rec_obj[2] = mp_obj_new_int(r->w);
rec_obj[3] = mp_obj_new_int(r->h);
rt_list_append(objects_list, rt_build_tuple(4, rec_obj));
mp_obj_list_append(objects_list, mp_obj_new_tuple(4, rec_obj));
}
/* Free the objects array */
@ -344,7 +342,7 @@ static mp_obj_t py_image_find_template(mp_obj_t image_obj, mp_obj_t template_obj
rec_obj[1] = mp_obj_new_int(r.y);
rec_obj[2] = mp_obj_new_int(r.w);
rec_obj[3] = mp_obj_new_int(r.h);
obj=rt_build_tuple(4, rec_obj);
obj = mp_obj_new_tuple(4, rec_obj);
}
return obj;
}
@ -417,7 +415,7 @@ static mp_obj_t py_image_find_keypoints_match(mp_obj_t image_obj, mp_obj_t surf1
return mp_const_none;
}
static mp_obj_t py_image_load_image(mp_obj_t path_obj)
mp_obj_t py_image_load_image(mp_obj_t path_obj)
{
mp_obj_t image_obj =NULL;
struct image *image;
@ -435,7 +433,7 @@ static mp_obj_t py_image_load_image(mp_obj_t path_obj)
return image_obj;
}
static mp_obj_t py_image_load_cascade(mp_obj_t path_obj)
mp_obj_t py_image_load_cascade(mp_obj_t path_obj)
{
py_cascade_obj_t *o =NULL;
@ -458,52 +456,51 @@ static mp_obj_t py_image_load_cascade(mp_obj_t path_obj)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_save_obj, 2, py_image_save);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_blit_obj, py_image_blit);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_histeq_obj, py_image_histeq);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_median_obj, 1, py_image_median);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_threshold_obj, py_image_threshold);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_blit_obj, py_image_blit);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_histeq_obj, py_image_histeq);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_median_obj, 1, py_image_median);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_threshold_obj, py_image_threshold);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_draw_circle_obj, py_image_draw_circle);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_draw_rectangle_obj, py_image_draw_rectangle);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_draw_keypoints_obj, py_image_draw_keypoints);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_draw_circle_obj, py_image_draw_circle);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_draw_rectangle_obj, py_image_draw_rectangle);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_draw_keypoints_obj, py_image_draw_keypoints);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_find_blobs_obj, py_image_find_blobs);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_find_template_obj, py_image_find_template);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_find_features_obj, py_image_find_features);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_find_blobs_obj, py_image_find_blobs);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_find_template_obj, py_image_find_template);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_find_features_obj, py_image_find_features);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_keypoints_obj, 1, py_image_find_keypoints);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_find_keypoints_match_obj, py_image_find_keypoints_match);
//STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_load_cascade_obj, py_image_load_cascade);
//STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_load_image_obj, py_image_load_image);
static const mp_method_t py_image_methods[] = {
static const mp_map_elem_t locals_dict_table[] = {
/* basic image functions */
{"save", &py_image_save_obj},
{"blit", &py_image_blit_obj},
{"histeq", &py_image_histeq_obj},
{"median", &py_image_median_obj},
{"threshold", &py_image_threshold_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_save), (mp_obj_t)&py_image_save_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_blit), (mp_obj_t)&py_image_blit_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_histeq), (mp_obj_t)&py_image_histeq_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_median), (mp_obj_t)&py_image_median_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_threshold), (mp_obj_t)&py_image_threshold_obj},
/* drawing functions */
{"draw_circle", &py_image_draw_circle_obj},
{"draw_rectangle", &py_image_draw_rectangle_obj},
{"draw_keypoints", &py_image_draw_keypoints_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_draw_circle), (mp_obj_t)&py_image_draw_circle_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_draw_rectangle), (mp_obj_t)&py_image_draw_rectangle_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_draw_keypoints), (mp_obj_t)&py_image_draw_keypoints_obj},
/* objects/feature detection */
{"find_blobs", &py_image_find_blobs_obj},
{"find_template", &py_image_find_template_obj},
{"find_features", &py_image_find_features_obj},
{"find_keypoints", &py_image_find_keypoints_obj},
{"find_keypoints_match",&py_image_find_keypoints_match_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_find_blobs), (mp_obj_t)&py_image_find_blobs_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_find_template), (mp_obj_t)&py_image_find_template_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_find_features), (mp_obj_t)&py_image_find_features_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_find_keypoints), (mp_obj_t)&py_image_find_keypoints_obj},
{MP_OBJ_NEW_QSTR(MP_QSTR_find_keypoints_match),(mp_obj_t)&py_image_find_keypoints_match_obj},
{ NULL, NULL },
};
STATIC MP_DEFINE_CONST_DICT(locals_dict, locals_dict_table);
static const mp_obj_type_t py_image_type = {
{ &mp_type_type },
.name = MP_QSTR_Image,
.print = py_image_print,
.methods = py_image_methods,
.name = MP_QSTR_image,
.print = py_image_print,
.locals_dict = (mp_obj_t)&locals_dict,
};
mp_obj_t py_image(int w, int h, int bpp, void *pixels)
@ -518,12 +515,6 @@ mp_obj_t py_image(int w, int h, int bpp, void *pixels)
return o;
}
void py_image_init()
{
rt_store_global(qstr_from_str("Image"), rt_make_function_n(1, py_image_load_image));
rt_store_global(qstr_from_str("HaarCascade"), rt_make_function_n(1, py_image_load_cascade));
}
#if 0
typedef struct _mp_obj_array_it_t {
mp_obj_base_t base;

View File

@ -1,5 +1,7 @@
#ifndef __PY_IMAGE_H__
#define __PY_IMAGE_H__
mp_obj_t py_image_load_image(mp_obj_t path_obj);
mp_obj_t py_image_load_cascade(mp_obj_t path_obj);
mp_obj_t py_image(int width, int height, int bpp, void *pixels);
void *py_image_cobj(mp_obj_t image);
#endif /* __PY_IMAGE_H__ */

View File

@ -20,7 +20,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_led_on_obj, py_led_on);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_led_off_obj, py_led_off);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_led_toggle_obj, py_led_toggle);
STATIC const mp_map_elem_t module_globals_table[] = {
static const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_led) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_RED), MP_OBJ_NEW_SMALL_INT(LED_RED)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_GREEN), MP_OBJ_NEW_SMALL_INT(LED_GREEN)},
@ -30,18 +30,12 @@ STATIC const mp_map_elem_t module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_toggle), (mp_obj_t)&py_led_toggle_obj },
};
STATIC const mp_map_t module_globals = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.alloc = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.table = (mp_map_elem_t*)module_globals_table,
};
STATIC MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table);
static const mp_obj_module_t py_led_module = {
.base = { &mp_type_module },
.name = MP_QSTR_led,
.globals = (mp_map_t*)&module_globals,
.globals = (mp_obj_t)&globals_dict,
};
const mp_obj_module_t *py_led_init()

View File

@ -132,7 +132,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_brightness_obj, py_sensor_set_br
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_sensor_write_reg_obj, py_sensor_write_reg);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_read_reg_obj, py_sensor_read_reg);
STATIC const mp_map_elem_t module_globals_table[] = {
STATIC const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_sensor) },
/* Pixel format */
{ MP_OBJ_NEW_QSTR(MP_QSTR_RGB565), MP_OBJ_NEW_SMALL_INT(PIXFORMAT_RGB565)}, /* 2BPP/RGB565*/
@ -160,18 +160,12 @@ STATIC const mp_map_elem_t module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___read_reg), (mp_obj_t)&py_sensor_read_reg_obj },
};
STATIC const mp_map_t module_globals = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.alloc = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.table = (mp_map_elem_t*)module_globals_table,
};
STATIC MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table);
static const mp_obj_module_t py_sensor_module = {
.base = { &mp_type_module },
.name = MP_QSTR_sensor,
.globals = (mp_map_t*)&module_globals,
.globals = (mp_obj_t)&globals_dict,
};
const mp_obj_module_t *py_sensor_init()

View File

@ -37,25 +37,19 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_spi_read_obj, py_spi_read);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_spi_write_obj, py_spi_write);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_spi_write_image_obj, py_spi_write_image);
STATIC const mp_map_elem_t module_globals_table[] = {
static const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_spi) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&py_spi_read_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&py_spi_write_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_write_image), (mp_obj_t)&py_spi_write_image_obj },
};
STATIC const mp_map_t module_globals = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.alloc = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.table = (mp_map_elem_t*)module_globals_table,
};
STATIC MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table);
static const mp_obj_module_t py_spi_module = {
.base = { &mp_type_module },
.name = MP_QSTR_spi,
.globals = (mp_map_t*)&module_globals,
.globals = (mp_obj_t)&globals_dict,
};
const mp_obj_module_t *py_spi_init()

View File

@ -23,25 +23,19 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_time_ticks_obj, py_time_ticks);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_time_clock_obj, py_time_clock);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_time_sleep_obj, py_time_sleep);
STATIC const mp_map_elem_t module_globals_table[] = {
static const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_time) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks), (mp_obj_t)&py_time_ticks_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_clock), (mp_obj_t)&py_time_clock_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep), (mp_obj_t)&py_time_sleep_obj },
};
STATIC const mp_map_t module_globals = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.alloc = sizeof(module_globals_table) / sizeof(mp_map_elem_t),
.table = (mp_map_elem_t*)module_globals_table,
};
STATIC MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table);
static const mp_obj_module_t py_time_module = {
.base = { &mp_type_module },
.name = MP_QSTR_time,
.globals = (mp_map_t*)&module_globals,
.globals = (mp_obj_t)&globals_dict,
};
const mp_obj_module_t *py_time_init()