Creating Pyb Modules
注:
2016.03.10更新后,Micro Python中的Qstring由makefile脚本自动生成,无需在qstrdefsport.h手动添加。
自动生成的规则是,makefile会调用一个脚本(makeqstrdefs.py),使用正则查找源代码(.c)中以”MP_QSTR_”为前缀的字符。例如在led.c中:
...
STATIC const mp_map_elem_t led_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_on), (mp_obj_t)&led_obj_on_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_off), (mp_obj_t)&led_obj_off_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_toggle), (mp_obj_t)&led_obj_toggle_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_intensity), (mp_obj_t)&led_obj_intensity_obj },
};
...
那么makefile脚本就会自动生成MP_QSTR_on,MP_QSTR_off,MP_QSTR_toggle和MP_QSTR_intensity这4个字符串定义,在自动生成的头文件qstrdefs.generated.h内:
...
QDEF(MP_QSTR_intensity, (const byte*)"\xca\x3d\x09" "intensity")
...
Is 32kByte enough for micropyhton?
Wanted: Porting guide / developer guide