Skip to content
Snippets Groups Projects
Commit 1fc10c8f authored by fleur's avatar fleur
Browse files

debloated, docs added.

listen to theme song from m.a.s.k. cartoon when
merging this. oh also pb.c is now obsolete. well it was before, but even
more now.
parent ad463826
No related branches found
No related tags found
No related merge requests found
...@@ -86,11 +86,6 @@ typedef _Bool bool; ...@@ -86,11 +86,6 @@ typedef _Bool bool;
#define API_LIGHT_SENSOR_STOP 0x82 #define API_LIGHT_SENSOR_STOP 0x82
#define API_BUTTONS_READ 0x90 #define API_BUTTONS_READ 0x90
#define API_BUTTONS_UPDATE 0x91
#define API_BUTTONS_READ_BOTTOM_LEFT_FROMCACHE 0x92
#define API_BUTTONS_READ_BOTTOM_RIGHT_FROMCACHE 0x93
#define API_BUTTONS_READ_TOP_RIGHT_FROMCACHE 0x94
#define API_BUTTONS_READ_RESET_FROMCACHE 0x95
/* clang-format on */ /* clang-format on */
typedef uint32_t api_int_id_t; typedef uint32_t api_int_id_t;
...@@ -232,12 +227,14 @@ API_ISR(EPIC_INT_CTRL_C, epic_isr_ctrl_c); ...@@ -232,12 +227,14 @@ API_ISR(EPIC_INT_CTRL_C, epic_isr_ctrl_c);
* *
*/ */
/**
* Reads buttons. Returns nonzero value if unmasked buttons are pushed.
*
* Always reads all buttons, use mask=15 for not wasting slow-ish API calls and extract values in pycardium. Note: The reset button cannot be unmapped from reset functionality afaik.
*
* :param uint8_t mask: The first 4 LSBs enable readout from corresponding button. The zeroeth bit corresponds to bottom left pin, increasing counterclockwise. If buttons module is imported in micropython also the designators BOTTOM_LEFT, BOTTOM_RIGHT, TOP_RIGHT, TOP_LEFT and RESET can be used with the latter two being identical.
*/
API(API_BUTTONS_READ, uint8_t epic_buttons_read(uint8_t mask)); API(API_BUTTONS_READ, uint8_t epic_buttons_read(uint8_t mask));
API(API_BUTTONS_UPDATE, void epic_buttons_update(void));
API(API_BUTTONS_READ_BOTTOM_LEFT_FROMCACHE, uint8_t epic_buttons_read_bottom_left_fromcache(void));
API(API_BUTTONS_READ_BOTTOM_RIGHT_FROMCACHE, uint8_t epic_buttons_read_bottom_right_fromcache(void));
API(API_BUTTONS_READ_TOP_RIGHT_FROMCACHE, uint8_t epic_buttons_read_top_right_fromcache(void));
API(API_BUTTONS_READ_RESET_FROMCACHE, uint8_t epic_buttons_read_reset_fromcache(void));
/** /**
* LEDs * LEDs
......
//#include "pb.h"
#include "portexpander.h" #include "portexpander.h"
#include "MAX77650-Arduino-Library.h" #include "MAX77650-Arduino-Library.h"
#include <stdint.h> #include <stdint.h>
...@@ -9,19 +8,8 @@ ...@@ -9,19 +8,8 @@
static const uint8_t ButtonPin[] = {BOTTOM_LEFT,BOTTOM_RIGHT,TOP_RIGHT}; static const uint8_t ButtonPin[] = {BOTTOM_LEFT,BOTTOM_RIGHT,TOP_RIGHT};
static uint8_t button_states[4]; //as defined by button pin, 3->reset button static uint8_t button_states[4]; //as defined by button pin, 3->reset button
#if 0
uint8_t epic_buttons_poll(uint8_t mask){ //legacy af
uint8_t button_status=0;
for(int i=0; i<4; i++){
if((mask>>i)&1){
button_status += PB_Get(i+1)<<i;
}
}
return button_status;
}
#endif
void epic_buttons_update(){ static void epic_buttons_update(){
button_states[3] = MAX77650_getDebounceStatusnEN0(); button_states[3] = MAX77650_getDebounceStatusnEN0();
if(portexpander_detected()){ if(portexpander_detected()){
uint8_t button_status = portexpander_get(); uint8_t button_status = portexpander_get();
...@@ -42,18 +30,3 @@ uint8_t epic_buttons_read(uint8_t mask){ ...@@ -42,18 +30,3 @@ uint8_t epic_buttons_read(uint8_t mask){
return button_status; return button_status;
} }
uint8_t epic_buttons_read_bottom_left_fromcache(){
return button_states[0];
}
uint8_t epic_buttons_read_bottom_right_fromcache(){
return button_states[1];
}
uint8_t epic_buttons_read_top_right_fromcache(){
return button_states[2];
}
uint8_t epic_buttons_read_reset_fromcache(){
return button_states[3];
}
...@@ -5,73 +5,6 @@ ...@@ -5,73 +5,6 @@
#include "epicardium.h" #include "epicardium.h"
static mp_obj_t mp_buttons_update()
{
epic_buttons_update();
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_update_obj, mp_buttons_update);
static mp_obj_t mp_buttons_read_bottom_left()
{
epic_buttons_update();
uint8_t retval = epic_buttons_read_bottom_left_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_bottom_left_obj, mp_buttons_read_bottom_left);
static mp_obj_t mp_buttons_read_bottom_right()
{
epic_buttons_update();
uint8_t retval = epic_buttons_read_bottom_right_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_bottom_right_obj, mp_buttons_read_bottom_right);
static mp_obj_t mp_buttons_read_top_right()
{
epic_buttons_update();
uint8_t retval = epic_buttons_read_top_right_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_top_right_obj, mp_buttons_read_top_right);
static mp_obj_t mp_buttons_read_reset()
{
epic_buttons_update();
uint8_t retval = epic_buttons_read_reset_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_reset_obj, mp_buttons_read_reset);
static mp_obj_t mp_buttons_read_bottom_left_fromcache()
{
uint8_t retval = epic_buttons_read_bottom_left_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_bottom_left_fromcache_obj, mp_buttons_read_bottom_left_fromcache);
static mp_obj_t mp_buttons_read_bottom_right_fromcache()
{
uint8_t retval = epic_buttons_read_bottom_right_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_bottom_right_fromcache_obj, mp_buttons_read_bottom_right_fromcache);
static mp_obj_t mp_buttons_read_top_right_fromcache()
{
uint8_t retval = epic_buttons_read_top_right_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_top_right_fromcache_obj, mp_buttons_read_top_right_fromcache);
static mp_obj_t mp_buttons_read_reset_fromcache()
{
uint8_t retval = epic_buttons_read_reset_fromcache();
return MP_OBJ_NEW_SMALL_INT(retval);
}
static MP_DEFINE_CONST_FUN_OBJ_0(buttons_read_reset_fromcache_obj, mp_buttons_read_reset_fromcache);
static mp_obj_t mp_buttons_read(mp_obj_t mask_in) static mp_obj_t mp_buttons_read(mp_obj_t mask_in)
{ {
uint8_t mask = mp_obj_get_int(mask_in); uint8_t mask = mp_obj_get_int(mask_in);
...@@ -83,15 +16,11 @@ static MP_DEFINE_CONST_FUN_OBJ_1(buttons_read_obj, mp_buttons_read); ...@@ -83,15 +16,11 @@ static MP_DEFINE_CONST_FUN_OBJ_1(buttons_read_obj, mp_buttons_read);
static const mp_rom_map_elem_t buttons_module_globals_table[] = { static const mp_rom_map_elem_t buttons_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_buttons) }, { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_buttons) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&buttons_read_obj) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&buttons_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&buttons_update_obj) }, { MP_ROM_QSTR(MP_QSTR_BOTTOM_LEFT), MP_OBJ_NEW_SMALL_INT(0) },
{ MP_ROM_QSTR(MP_QSTR_read_bottom_left), MP_ROM_PTR(&buttons_read_bottom_left_obj) }, { MP_ROM_QSTR(MP_QSTR_BOTTOM_RIGHT), MP_OBJ_NEW_SMALL_INT(1) },
{ MP_ROM_QSTR(MP_QSTR_read_bottom_right), MP_ROM_PTR(&buttons_read_bottom_right_obj) }, { MP_ROM_QSTR(MP_QSTR_TOP_RIGHT), MP_OBJ_NEW_SMALL_INT(2) },
{ MP_ROM_QSTR(MP_QSTR_read_top_right), MP_ROM_PTR(&buttons_read_top_right_obj) }, { MP_ROM_QSTR(MP_QSTR_TOP_LEFT), MP_OBJ_NEW_SMALL_INT(3) },
{ MP_ROM_QSTR(MP_QSTR_read_reset), MP_ROM_PTR(&buttons_read_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_RESET), MP_OBJ_NEW_SMALL_INT(3) },
{ MP_ROM_QSTR(MP_QSTR_read_bottom_left_fromcache), MP_ROM_PTR(&buttons_read_bottom_left_fromcache_obj) },
{ MP_ROM_QSTR(MP_QSTR_read_bottom_right_fromcache), MP_ROM_PTR(&buttons_read_bottom_right_fromcache_obj) },
{ MP_ROM_QSTR(MP_QSTR_read_top_right_fromcache), MP_ROM_PTR(&buttons_read_top_right_fromcache_obj) },
{ MP_ROM_QSTR(MP_QSTR_read_reset_fromcache), MP_ROM_PTR(&buttons_read_reset_fromcache_obj) },
}; };
static MP_DEFINE_CONST_DICT(buttons_module_globals, buttons_module_globals_table); static MP_DEFINE_CONST_DICT(buttons_module_globals, buttons_module_globals_table);
......
...@@ -27,14 +27,11 @@ Q(TOP_RIGHT) ...@@ -27,14 +27,11 @@ Q(TOP_RIGHT)
/* buttons */ /* buttons */
Q(buttons) Q(buttons)
Q(read) Q(read)
Q(read_bottom_left) Q(BOTTOM_LEFT)
Q(read_bottom_right) Q(TOP_LEFT)
Q(read_top_right) Q(BOTTOM_RIGHT)
Q(read_reset) Q(TOP_RIGHT)
Q(read_bottom_left_fromcache) Q(RESET)
Q(read_bottom_right_fromcache)
Q(read_top_right_fromcache)
Q(read_reset_fromcache)
/* utime */ /* utime */
Q(utime) Q(utime)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment