Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
a7083229
Commit
a7083229
authored
5 years ago
by
fleur
Browse files
Options
Downloads
Patches
Plain Diff
minor performance optimisation and code style stuff
parent
1fc10c8f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/modules/buttons.c
+15
-13
15 additions, 13 deletions
epicardium/modules/buttons.c
pycardium/modules/buttons.c
+5
-3
5 additions, 3 deletions
pycardium/modules/buttons.c
with
20 additions
and
16 deletions
epicardium/modules/buttons.c
+
15
−
13
View file @
a7083229
...
...
@@ -5,28 +5,30 @@
#define BOTTOM_RIGHT 3
#define TOP_RIGHT 6
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
void
epic_buttons_update
(){
button_states
[
3
]
=
MAX77650_getDebounceStatusnEN0
();
if
(
portexpander_detected
()){
static
void
epic_buttons_update
(
uint8_t
mask
)
{
if
(
mask
>
7
)
{
button_states
[
3
]
=
MAX77650_getDebounceStatusnEN0
();
}
if
(
portexpander_detected
()
&&
(
mask
%
8
))
{
uint8_t
button_status
=
portexpander_get
();
for
(
int
i
=
0
;
i
<
3
;
i
++
){
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
button_states
[
i
]
=
(
button_status
>>
ButtonPin
[
i
])
&
1
;
}
}
}
uint8_t
epic_buttons_read
(
uint8_t
mask
){
epic_buttons_update
();
uint8_t
button_status
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++
){
if
((
mask
>>
i
)
&
1
){
button_status
+=
button_states
[
i
]
<<
i
;
uint8_t
epic_buttons_read
(
uint8_t
mask
)
{
epic_buttons_update
(
mask
);
uint8_t
button_status
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
if
((
mask
>>
i
)
&
1
)
{
button_status
+=
button_states
[
i
]
<<
i
;
}
}
return
button_status
;
}
This diff is collapsed.
Click to expand it.
pycardium/modules/buttons.c
+
5
−
3
View file @
a7083229
...
...
@@ -7,7 +7,7 @@
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
);
uint8_t
button_states
=
epic_buttons_read
(
mask
);
return
MP_OBJ_NEW_SMALL_INT
(
button_states
);
}
...
...
@@ -22,10 +22,12 @@ static const mp_rom_map_elem_t buttons_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_TOP_LEFT
),
MP_OBJ_NEW_SMALL_INT
(
3
)
},
{
MP_ROM_QSTR
(
MP_QSTR_RESET
),
MP_OBJ_NEW_SMALL_INT
(
3
)
},
};
static
MP_DEFINE_CONST_DICT
(
buttons_module_globals
,
buttons_module_globals_table
);
static
MP_DEFINE_CONST_DICT
(
buttons_module_globals
,
buttons_module_globals_table
);
const
mp_obj_module_t
buttons_module
=
{
.
base
=
{
&
mp_type_module
},
.
base
=
{
&
mp_type_module
},
.
globals
=
(
mp_obj_dict_t
*
)
&
buttons_module_globals
,
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment