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
dc587330
Commit
dc587330
authored
Aug 21, 2014
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menu: Cannot go behind the last menu entry.
parent
c7b492ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
menu.c
sw/freertos/src/apps/menu.c
+12
-4
menu_struct.c
sw/freertos/src/apps/menu_struct.c
+1
-1
menu_struct.h
sw/freertos/src/apps/menu_struct.h
+1
-1
No files found.
sw/freertos/src/apps/menu.c
View file @
dc587330
...
...
@@ -30,6 +30,7 @@
#include "widgets/status_bar.h"
static
int
selected_item
=
0
;
static
int
menu_size
=
0
;
// Store states to navigate between menus
static
menu_list
*
menu_stack
[
8
]
=
{
&
main_menu
,
NULL
,
};
...
...
@@ -42,7 +43,7 @@ static void menu_screen_redraw(struct ui_widget *w)
int
i
;
gfx_clear
(
&
w
->
dc
,
0
);
for
(
i
=
0
;
i
<
get_length
(
&
main_menu
)
;
++
i
)
for
(
i
=
0
;
i
<
menu_size
;
++
i
)
{
if
(
i
==
selected_item
)
{
gfx_box
(
&
w
->
dc
,
LEFT_MARGIN
,
i
*
LINE_HEIGHT
,
...
...
@@ -68,7 +69,7 @@ static void menu_screen_event(struct ui_widget *w, const struct event *evt)
{
if
(
evt
->
type
==
BUTTON_PRESSED
)
{
if
(
evt
->
data
.
button
==
BUT_BR
)
{
if
(
selected_item
<
get_length
(
*
current_menu
)
)
{
if
(
selected_item
<
menu_size
-
1
)
{
++
selected_item
;
w
->
flags
|=
WF_DIRTY
;
}
...
...
@@ -106,10 +107,12 @@ static void run(menu_entry *entry) {
entry
->
data
.
app
->
main
(
NULL
);
}
else
if
(
entry
->
type
==
SUBMENU
)
{
selected_item
=
0
;
menu_size
=
0
;
// keep the operation separate to avoid crashes
// when an interrupt goes off between the two following lines
*
(
current_menu
+
1
)
=
entry
->
data
.
submenu
;
++
current_menu
;
menu_size
=
get_menu_size
(
*
current_menu
);
}
menu_ui_init
();
...
...
@@ -119,8 +122,10 @@ static void go_back() {
if
(
current_menu
==
menu_stack
)
{
clock
.
main
(
NULL
);
}
else
{
--
current_menu
;
menu_size
=
0
;
selected_item
=
0
;
--
current_menu
;
menu_size
=
get_menu_size
(
*
current_menu
);
}
menu_ui_init
();
...
...
@@ -130,7 +135,10 @@ void menu_main(void* params) {
(
void
)(
params
);
// suppress unused parameter warning
struct
event
evt
;
run
(
&
clock
);
menu_size
=
get_menu_size
(
*
current_menu
);
clock
.
main
(
NULL
);
menu_ui_init
();
// Once it is deactivated - display the menu
while
(
1
)
{
...
...
sw/freertos/src/apps/menu_struct.c
View file @
dc587330
...
...
@@ -27,7 +27,7 @@
#include "menu_struct.h"
#include "clock.h"
int
get_
length
(
const
menu_list
*
menu
)
{
int
get_
menu_size
(
const
menu_list
*
menu
)
{
int
len
=
0
;
const
menu_entry
*
ptr
=
menu
->
entries
;
...
...
sw/freertos/src/apps/menu_struct.h
View file @
dc587330
...
...
@@ -64,7 +64,7 @@ typedef struct menu_list_t {
* @brief Returns the number of entries for a given submenu.
* @param menu is the menu that length is returned.
*/
int
get_
length
(
const
menu_list
*
menu
);
int
get_
menu_size
(
const
menu_list
*
menu
);
/**
* @brief Stores the main menu structure.
...
...
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