Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
21f76bb7
Commit
21f76bb7
authored
May 23, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fwatch: convert menu application to new model
Signed-off-by:
Federico Vaga
<
federico.vaga@gmail.com
>
parent
40fc588c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
28 deletions
+29
-28
menu.c
sw/freewatch/src/apps/menu.c
+29
-28
No files found.
sw/freewatch/src/apps/menu.c
View file @
21f76bb7
...
...
@@ -169,7 +169,7 @@ static void run(menu_entry *entry) {
static
void
go_back
()
{
if
(
current_menu
==
menu_stack
)
{
clock_app
.
main
(
NULL
);
fwatch_application_run
(
&
clock_app
);
}
else
{
menu_size
=
0
;
selected_item
=
0
;
...
...
@@ -181,44 +181,45 @@ static void go_back() {
menu_ui_init
();
}
void
menu_main
(
void
*
params
)
{
(
void
)(
params
);
// suppress unused parameter warning
struct
event
evt
;
int
ret
;
static
int
menu_setup
(
application
*
app
)
{
battery_update
();
menu_size
=
get_menu_size
(
*
current_menu
);
// run clock as the the initial application
clock_app
.
main
(
NULL
);
fwatch_application_run
(
&
clock_app
);
menu_ui_init
();
return
0
;
}
static
void
menu_loop
(
application
*
app
)
{
struct
event
evt
;
int
ret
;
ret
=
xQueueReceive
(
appQueue
,
&
evt
,
portMAX_DELAY
);
if
(
ret
!=
pdTRUE
)
return
;
// Once it is deactivated - display the menu
while
(
1
)
{
ret
=
xQueueReceive
(
appQueue
,
&
evt
,
portMAX_DELAY
);
if
(
ret
!=
pdTRUE
)
continue
;
switch
(
evt
.
type
)
{
case
BUTTON_PRESSED
:
if
(
evt
.
data
.
button
==
BUT_TL
)
{
go_back
();
}
else
if
(
evt
.
data
.
button
==
BUT_TR
)
{
// run the selected application or submenu
run
(
&
(
*
current_menu
)
->
entries
[
selected_item
]);
}
else
{
ui_update
(
&
evt
);
}
break
;
default:
// suppress warnings
switch
(
evt
.
type
)
{
case
BUTTON_PRESSED
:
if
(
evt
.
data
.
button
==
BUT_TL
)
{
go_back
();
}
else
if
(
evt
.
data
.
button
==
BUT_TR
)
{
// run the selected application or submenu
run
(
&
(
*
current_menu
)
->
entries
[
selected_item
]);
}
else
{
ui_update
(
&
evt
);
break
;
}
break
;
default:
// suppress warnings
ui_update
(
&
evt
);
break
;
}
}
application
menu
=
{
.
name
=
"Menu"
,
.
main
=
menu_main
.
setup
=
menu_setup
,
.
loop
=
menu_loop
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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