2021-05-11 19:02:18 +00:00
|
|
|
#include "breakout_potentiometer.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// BreakoutPotentiometer Class
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/***** Methods *****/
|
2021-05-11 20:58:44 +00:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutPotentiometer_set_address_obj, 2, BreakoutPotentiometer_set_address);
|
2021-05-11 19:02:18 +00:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutPotentiometer_get_adc_vref_obj, BreakoutPotentiometer_get_adc_vref);
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutPotentiometer_set_adc_vref_obj, 2, BreakoutPotentiometer_set_adc_vref);
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutPotentiometer_get_direction_obj, BreakoutPotentiometer_get_direction);
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutPotentiometer_set_direction_obj, 2, BreakoutPotentiometer_set_direction);
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutPotentiometer_set_brightness_obj, 2, BreakoutPotentiometer_set_brightness);
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutPotentiometer_set_led_obj, 4, BreakoutPotentiometer_set_led);
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutPotentiometer_read_obj, BreakoutPotentiometer_read);
|
2021-05-12 16:20:42 +00:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutPotentiometer_read_raw_obj, BreakoutPotentiometer_read_raw);
|
2021-05-11 19:02:18 +00:00
|
|
|
|
|
|
|
/***** Binding of Methods *****/
|
2024-02-29 12:12:24 +00:00
|
|
|
static const mp_rom_map_elem_t BreakoutPotentiometer_locals_dict_table[] = {
|
2021-05-11 20:58:44 +00:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_set_address), MP_ROM_PTR(&BreakoutPotentiometer_set_address_obj) },
|
2021-05-11 19:02:18 +00:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_get_adc_vref), MP_ROM_PTR(&BreakoutPotentiometer_get_adc_vref_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_set_adc_vref), MP_ROM_PTR(&BreakoutPotentiometer_set_adc_vref_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_get_direction), MP_ROM_PTR(&BreakoutPotentiometer_get_direction_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_set_direction), MP_ROM_PTR(&BreakoutPotentiometer_set_direction_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_set_brightness), MP_ROM_PTR(&BreakoutPotentiometer_set_brightness_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_set_led), MP_ROM_PTR(&BreakoutPotentiometer_set_led_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&BreakoutPotentiometer_read_obj) },
|
2021-05-12 16:20:42 +00:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_read_raw), MP_ROM_PTR(&BreakoutPotentiometer_read_raw_obj) },
|
2021-05-12 17:27:03 +00:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_DIRECTION_CW), MP_ROM_INT(1) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_DIRECTION_CCW), MP_ROM_INT(0) },
|
2021-05-11 19:02:18 +00:00
|
|
|
};
|
2024-02-29 12:12:24 +00:00
|
|
|
static MP_DEFINE_CONST_DICT(BreakoutPotentiometer_locals_dict, BreakoutPotentiometer_locals_dict_table);
|
2021-05-11 19:02:18 +00:00
|
|
|
|
|
|
|
/***** Class Definition *****/
|
2022-09-20 11:38:46 +00:00
|
|
|
#ifdef MP_DEFINE_CONST_OBJ_TYPE
|
|
|
|
MP_DEFINE_CONST_OBJ_TYPE(
|
|
|
|
breakout_potentiometer_BreakoutPotentiometer_type,
|
|
|
|
MP_QSTR_BreakoutPotentiometer,
|
|
|
|
MP_TYPE_FLAG_NONE,
|
|
|
|
make_new, BreakoutPotentiometer_make_new,
|
|
|
|
locals_dict, (mp_obj_dict_t*)&BreakoutPotentiometer_locals_dict
|
|
|
|
);
|
|
|
|
#else
|
2021-05-11 19:02:18 +00:00
|
|
|
const mp_obj_type_t breakout_potentiometer_BreakoutPotentiometer_type = {
|
|
|
|
{ &mp_type_type },
|
2022-06-13 19:06:39 +00:00
|
|
|
.name = MP_QSTR_BreakoutPotentiometer,
|
2021-05-11 19:02:18 +00:00
|
|
|
.make_new = BreakoutPotentiometer_make_new,
|
|
|
|
.locals_dict = (mp_obj_dict_t*)&BreakoutPotentiometer_locals_dict,
|
|
|
|
};
|
2022-09-20 11:38:46 +00:00
|
|
|
#endif
|
2021-05-11 19:02:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// breakout_potentiometer Module
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/***** Globals Table *****/
|
2024-02-29 12:12:24 +00:00
|
|
|
static const mp_map_elem_t breakout_potentiometer_globals_table[] = {
|
2021-05-11 19:02:18 +00:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_breakout_potentiometer) },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_BreakoutPotentiometer), (mp_obj_t)&breakout_potentiometer_BreakoutPotentiometer_type },
|
|
|
|
};
|
2024-02-29 12:12:24 +00:00
|
|
|
static MP_DEFINE_CONST_DICT(mp_module_breakout_potentiometer_globals, breakout_potentiometer_globals_table);
|
2021-05-11 19:02:18 +00:00
|
|
|
|
|
|
|
/***** Module Definition *****/
|
|
|
|
const mp_obj_module_t breakout_potentiometer_user_cmodule = {
|
|
|
|
.base = { &mp_type_module },
|
|
|
|
.globals = (mp_obj_dict_t*)&mp_module_breakout_potentiometer_globals,
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2022-06-14 09:58:56 +00:00
|
|
|
#if MICROPY_VERSION <= 70144
|
2021-05-11 19:02:18 +00:00
|
|
|
MP_REGISTER_MODULE(MP_QSTR_breakout_potentiometer, breakout_potentiometer_user_cmodule, MODULE_BREAKOUT_POTENTIOMETER_ENABLED);
|
2022-06-14 09:58:56 +00:00
|
|
|
#else
|
|
|
|
MP_REGISTER_MODULE(MP_QSTR_breakout_potentiometer, breakout_potentiometer_user_cmodule);
|
|
|
|
#endif
|
2021-05-11 19:02:18 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|