Wakeup: Disable RTC & enable SR for Inky, always include shift function.
Due to quirks with how QSTRs are passed, conditionally including a function is difficult. Instead, always include "get_shift_state" but throw a RuntimeError if its use is invalid (no shift register).
This commit is contained in:
parent
05d26aeecb
commit
ba100ae069
|
@ -45,6 +45,11 @@ include(pcf85063a/micropython)
|
|||
include(adcfft/micropython)
|
||||
include(wakeup/micropython)
|
||||
|
||||
# Configure wakeup for Enviro
|
||||
target_compile_definitions(usermod_wakeup INTERFACE
|
||||
-DWAKEUP_HAS_RTC=1
|
||||
)
|
||||
|
||||
# LEDs & Matrices
|
||||
include(plasma/micropython)
|
||||
|
||||
|
|
|
@ -45,6 +45,11 @@ include(pcf85063a/micropython)
|
|||
include(adcfft/micropython)
|
||||
include(wakeup/micropython)
|
||||
|
||||
# Configure wakeup for Inky Frame
|
||||
target_compile_definitions(usermod_wakeup INTERFACE
|
||||
-DWAKEUP_HAS_SHIFT_REGISTER=1
|
||||
)
|
||||
|
||||
# LEDs & Matrices
|
||||
include(plasma/micropython)
|
||||
|
||||
|
@ -56,4 +61,5 @@ include(motor/micropython)
|
|||
|
||||
# include(micropython-common)
|
||||
|
||||
include(modules_py/modules_py)
|
||||
include(modules_py/modules_py)
|
||||
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
#include "wakeup.h"
|
||||
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_get_gpio_state_obj, Wakeup_get_gpio_state);
|
||||
#if WAKEUP_HAS_SHIFT_REGISTER==1
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_get_shift_state_obj, Wakeup_get_shift_state);
|
||||
#endif
|
||||
|
||||
STATIC const mp_map_elem_t wakeup_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wakeup) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_gpio_state), MP_ROM_PTR(&Wakeup_get_gpio_state_obj) },
|
||||
#if WAKEUP_HAS_SHIFT_REGISTER==1
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_shift_state), MP_ROM_PTR(&Wakeup_get_shift_state_obj) }
|
||||
#endif
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_wakeup_globals, wakeup_globals_table);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef WAKEUP_HAS_RTC
|
||||
#define WAKEUP_HAS_RTC (1)
|
||||
#define WAKEUP_HAS_RTC (0)
|
||||
#endif
|
||||
|
||||
#ifndef WAKEUP_HAS_SHIFT_REGISTER
|
||||
|
|
|
@ -62,10 +62,11 @@ mp_obj_t Wakeup_get_gpio_state() {
|
|||
return mp_obj_new_int(runtime_wakeup_gpio_state);
|
||||
}
|
||||
|
||||
#if WAKEUP_HAS_SHIFT_REGISTER==1
|
||||
mp_obj_t Wakeup_get_shift_state() {
|
||||
#if WAKEUP_HAS_SHIFT_REGISTER==1
|
||||
return mp_obj_new_int(wakeup.shift_register_state);
|
||||
#endif
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Wakeup_get_shift_state: board does not have a shift register.");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
|
@ -2,6 +2,4 @@
|
|||
#include "py/objstr.h"
|
||||
|
||||
extern mp_obj_t Wakeup_get_gpio_state();
|
||||
#if WAKEUP_HAS_SHIFT_REGISTER==1
|
||||
extern mp_obj_t Wakeup_get_shift_state();
|
||||
#endif
|
||||
extern mp_obj_t Wakeup_get_shift_state();
|
Loading…
Reference in New Issue