kopia lustrzana https://github.com/pimoroni/pimoroni-pico
SCD4X: Support low power periodic measurements.
rodzic
b79814cae3
commit
185bea2065
|
@ -13,6 +13,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(scd41_init_obj, 0, scd41_init);
|
||||||
|
|
||||||
// Start/Stop measurement, no args (module-level, so no "self")
|
// Start/Stop measurement, no args (module-level, so no "self")
|
||||||
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_start_periodic_measurement_obj, scd41_start_periodic_measurement);
|
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_start_periodic_measurement_obj, scd41_start_periodic_measurement);
|
||||||
|
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_start_low_power_periodic_measurement_obj, scd41_start_low_power_periodic_measurement);
|
||||||
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_stop_periodic_measurement_obj, scd41_stop_periodic_measurement);
|
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_stop_periodic_measurement_obj, scd41_stop_periodic_measurement);
|
||||||
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_get_data_ready_obj, scd41_get_data_ready);
|
static MP_DEFINE_CONST_FUN_OBJ_0(scd41_get_data_ready_obj, scd41_get_data_ready);
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ static const mp_map_elem_t scd41_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_breakout_scd41) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_breakout_scd41) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&scd41_init_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&scd41_init_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&scd41_start_periodic_measurement_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&scd41_start_periodic_measurement_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_start_low_power), MP_ROM_PTR(&scd41_start_low_power_periodic_measurement_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&scd41_stop_periodic_measurement_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&scd41_stop_periodic_measurement_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_measure), MP_ROM_PTR(&scd41_read_measurement_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_measure), MP_ROM_PTR(&scd41_read_measurement_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_ready), MP_ROM_PTR(&scd41_get_data_ready_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_ready), MP_ROM_PTR(&scd41_get_data_ready_obj) },
|
||||||
|
|
|
@ -64,6 +64,19 @@ mp_obj_t scd41_start_periodic_measurement() {
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mp_obj_t scd41_start_low_power_periodic_measurement() {
|
||||||
|
if(!scd41_initialised) {
|
||||||
|
mp_raise_msg(&mp_type_RuntimeError, NOT_INITIALISED_MSG);
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
int error = scd4x_start_low_power_periodic_measurement();
|
||||||
|
if(error) {
|
||||||
|
mp_raise_msg(&mp_type_RuntimeError, FAIL_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
|
||||||
mp_obj_t scd41_get_data_ready() {
|
mp_obj_t scd41_get_data_ready() {
|
||||||
if(!scd41_initialised) {
|
if(!scd41_initialised) {
|
||||||
mp_raise_msg(&mp_type_RuntimeError, NOT_INITIALISED_MSG);
|
mp_raise_msg(&mp_type_RuntimeError, NOT_INITIALISED_MSG);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
// Declare the functions we'll make available in Python
|
// Declare the functions we'll make available in Python
|
||||||
extern mp_obj_t scd41_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t scd41_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||||
extern mp_obj_t scd41_start_periodic_measurement();
|
extern mp_obj_t scd41_start_periodic_measurement();
|
||||||
|
extern mp_obj_t scd41_start_low_power_periodic_measurement();
|
||||||
extern mp_obj_t scd41_stop_periodic_measurement();
|
extern mp_obj_t scd41_stop_periodic_measurement();
|
||||||
extern mp_obj_t scd41_read_measurement();
|
extern mp_obj_t scd41_read_measurement();
|
||||||
extern mp_obj_t scd41_get_data_ready();
|
extern mp_obj_t scd41_get_data_ready();
|
||||||
|
|
Ładowanie…
Reference in New Issue