Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
13e2a23c
Verified
Commit
13e2a23c
authored
Aug 17, 2019
by
fleur
Committed by
Rahix
Aug 17, 2019
Browse files
feat(pycardium): Add buttons module
parent
6ed72445
Changes
4
Hide whitespace changes
Inline
Side-by-side
pycardium/meson.build
View file @
13e2a23c
name
=
'pycardium'
modsrc
=
files
(
'modules/buttons.c'
,
'modules/fat_file.c'
,
'modules/fat_reader_import.c'
,
'modules/interrupt.c'
,
...
...
pycardium/modules/buttons.c
0 → 100644
View file @
13e2a23c
#include
"py/obj.h"
#include
"py/objlist.h"
#include
"py/runtime.h"
#include
<stdio.h>
#include
"epicardium.h"
static
mp_obj_t
mp_buttons_read
(
mp_obj_t
mask_in
)
{
uint8_t
mask
=
mp_obj_get_int
(
mask_in
);
uint8_t
button_states
=
epic_buttons_read
(
mask
);
return
MP_OBJ_NEW_SMALL_INT
(
button_states
);
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
buttons_read_obj
,
mp_buttons_read
);
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_read
),
MP_ROM_PTR
(
&
buttons_read_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_BOTTOM_LEFT
),
MP_OBJ_NEW_SMALL_INT
(
BUTTON_LEFT_BOTTOM
)
},
{
MP_ROM_QSTR
(
MP_QSTR_BOTTOM_RIGHT
),
MP_OBJ_NEW_SMALL_INT
(
BUTTON_RIGHT_BOTTOM
)
},
{
MP_ROM_QSTR
(
MP_QSTR_TOP_RIGHT
),
MP_OBJ_NEW_SMALL_INT
(
BUTTON_RIGHT_TOP
)
},
{
MP_ROM_QSTR
(
MP_QSTR_TOP_LEFT
),
MP_OBJ_NEW_SMALL_INT
(
BUTTON_LEFT_TOP
)
},
{
MP_ROM_QSTR
(
MP_QSTR_RESET
),
MP_OBJ_NEW_SMALL_INT
(
BUTTON_RESET
)
},
};
static
MP_DEFINE_CONST_DICT
(
buttons_module_globals
,
buttons_module_globals_table
);
const
mp_obj_module_t
buttons_module
=
{
.
base
=
{
&
mp_type_module
},
.
globals
=
(
mp_obj_dict_t
*
)
&
buttons_module_globals
,
};
/* clang-format off */
MP_REGISTER_MODULE
(
MP_QSTR_buttons
,
buttons_module
,
MODULE_BUTTONS_ENABLED
);
pycardium/modules/qstrdefs.h
View file @
13e2a23c
...
...
@@ -24,6 +24,15 @@ Q(BOTTOM_RIGHT)
Q
(
TOP_LEFT
)
Q
(
TOP_RIGHT
)
/* buttons */
Q
(
buttons
)
Q
(
read
)
Q
(
BOTTOM_LEFT
)
Q
(
TOP_LEFT
)
Q
(
BOTTOM_RIGHT
)
Q
(
TOP_RIGHT
)
Q
(
RESET
)
/* utime */
Q
(
utime
)
Q
(
alarm
)
...
...
pycardium/mpconfigport.h
View file @
13e2a23c
...
...
@@ -39,6 +39,7 @@
#define MICROPY_PY_UERRNO (1)
/* Modules */
#define MODULE_BUTTONS_ENABLED (1)
#define MODULE_DISPLAY_ENABLED (1)
#define MODULE_INTERRUPT_ENABLED (1)
#define MODULE_LEDS_ENABLED (1)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment