Skip to content
Snippets Groups Projects
Select Git revision
  • 61c4faab66dc125d83847d01e87f443f9d6e4ccf
  • master default protected
  • backslash
  • nickname-match-configs
  • genofire/leds_rgb_get_state
  • genofire/rockets-state
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • ios-workarounds
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
34 results

display.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    sys_ble.c 2.18 KiB
    #include "epicardium.h"
    
    #include "py/obj.h"
    #include "py/objlist.h"
    #include "py/runtime.h"
    
    #include <stdint.h>
    
    static mp_obj_t mp_ble_confirm_compare_value(mp_obj_t confirmed_obj)
    {
    	bool confirmed = mp_obj_is_true(confirmed_obj);
    	epic_ble_compare_response(confirmed);
    	return mp_const_none;
    }
    static MP_DEFINE_CONST_FUN_OBJ_1(
    	ble_confirm_compare_value_obj, mp_ble_confirm_compare_value
    );
    
    static mp_obj_t mp_ble_get_compare_value(void)
    {
    	return mp_obj_new_int(epic_ble_get_compare_value());
    }
    static MP_DEFINE_CONST_FUN_OBJ_0(
    	ble_get_compare_value_obj, mp_ble_get_compare_value
    );
    
    static mp_obj_t mp_ble_get_event(void)
    {
    	return mp_obj_new_int(epic_ble_get_event());
    }
    static MP_DEFINE_CONST_FUN_OBJ_0(ble_get_event_obj, mp_ble_get_event);
    
    static mp_obj_t mp_ble_set_bondable(mp_obj_t bondable_obj)
    {
    	bool bondable = mp_obj_is_true(bondable_obj);
    	epic_ble_set_bondable(bondable);
    	return mp_const_none;
    }
    static MP_DEFINE_CONST_FUN_OBJ_1(ble_set_bondable_obj, mp_ble_set_bondable);
    
    static const mp_rom_map_elem_t ble_module_globals_table[] = {
    	{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys_ble) },
    	{ MP_ROM_QSTR(MP_QSTR_confirm_compare_value),
    	  MP_ROM_PTR(&ble_confirm_compare_value_obj) },
    	{ MP_ROM_QSTR(MP_QSTR_get_compare_value),
    	  MP_ROM_PTR(&ble_get_compare_value_obj) },
    	{ MP_ROM_QSTR(MP_QSTR_get_event), MP_ROM_PTR(&ble_get_event_obj) },
    	{ MP_ROM_QSTR(MP_QSTR_set_bondable),
    	  MP_ROM_PTR(&ble_set_bondable_obj) },
    
    	/* Event Numbers */
    	{ MP_ROM_QSTR(MP_QSTR_EVENT_NONE),
    	  MP_OBJ_NEW_SMALL_INT(BLE_EVENT_NONE) },
    	{ MP_ROM_QSTR(MP_QSTR_EVENT_HANDLE_NUMERIC_COMPARISON),
    	  MP_OBJ_NEW_SMALL_INT(BLE_EVENT_HANDLE_NUMERIC_COMPARISON) },
    	{ MP_ROM_QSTR(MP_QSTR_EVENT_PAIRING_FAILED),
    	  MP_OBJ_NEW_SMALL_INT(BLE_EVENT_PAIRING_FAILED) },
    	{ MP_ROM_QSTR(MP_QSTR_EVENT_PAIRING_COMPLETE),
    	  MP_OBJ_NEW_SMALL_INT(BLE_EVENT_PAIRING_COMPLETE) },
    
    };
    static MP_DEFINE_CONST_DICT(ble_module_globals, ble_module_globals_table);
    
    const mp_obj_module_t ble_module = {
    	.base    = { &mp_type_module },
    	.globals = (mp_obj_dict_t *)&ble_module_globals,
    };
    
    /* Register the module to make it available in Python */
    /* clang-format off */
    MP_REGISTER_MODULE(MP_QSTR_sys_ble, ble_module, MODULE_BLE_ENABLED);