Last active
          March 24, 2018 13:36 
        
      - 
      
- 
        Save boochow/70312bbc6c3e61689727023786343a36 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include "py/runtime.h" | |
| #include "py/mphal.h" | |
| #include "py/obj.h" | |
| // キーワード型引数を持つ関数 | |
| // pos_argsはpositional args、kw_argsはkeyword args | |
| STATIC mp_obj_t gpu_fb_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { | |
| return mp_const_none; | |
| } | |
| // 関数から関数オブジェクトを生成。第二引数の「2」はpositional argsの個数(必須の引数の個数) | |
| STATIC MP_DEFINE_CONST_FUN_OBJ_KW(gpu_fb_init_obj, 2, gpu_fb_init); | |
| // 引数の無い関数 | |
| STATIC mp_obj_t gpu_fb_data(void) { | |
| return mp_const_none; | |
| } | |
| // マクロ名末尾の「0」が引数の個数を表す | |
| STATIC MP_DEFINE_CONST_FUN_OBJ_0(gpu_fb_data_obj, gpu_fb_data); | |
| STATIC mp_obj_t gpu_fb_rowbytes(void) { | |
| return mp_const_none; | |
| } | |
| STATIC MP_DEFINE_CONST_FUN_OBJ_0(gpu_fb_rowbytes_obj, gpu_fb_rowbytes); | |
| // モジュール内グローバルオブジェクトのリスト | |
| // dir(モジュール名)でMP_QSR_XXXXのXXXXの部分が一覧される | |
| STATIC const mp_rom_map_elem_t gpu_module_globals_table[] = { | |
| { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gpu) }, | |
| { MP_ROM_QSTR(MP_QSTR_fb_init), MP_ROM_PTR(&gpu_fb_init_obj) }, | |
| { MP_ROM_QSTR(MP_QSTR_fb_data), MP_ROM_PTR(&gpu_fb_data_obj) }, | |
| { MP_ROM_QSTR(MP_QSTR_fb_rowbytes), MP_ROM_PTR(&gpu_fb_rowbytes_obj) }, | |
| }; | |
| STATIC MP_DEFINE_CONST_DICT(gpu_module_globals, gpu_module_globals_table); | |
| // モジュールの実体を表す定数 | |
| // この定数名をmpconfigport.hのMICROPY_PORT_BUILTIN_MODULESに追加することが必要 | |
| const mp_obj_module_t gpu_module = { | |
| .base = { &mp_type_module }, | |
| .globals = (mp_obj_dict_t*) &gpu_module_globals, | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment