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
b8878a5c
Commit
b8878a5c
authored
Aug 21, 2014
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menu: Menu is generated basing on data structures.
parent
fe2dbbaa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
3 deletions
+140
-3
Makefile
sw/freertos/Makefile
+1
-0
menu.c
sw/freertos/src/apps/menu.c
+14
-3
menu_struct.c
sw/freertos/src/apps/menu_struct.c
+50
-0
menu_struct.h
sw/freertos/src/apps/menu_struct.h
+75
-0
No files found.
sw/freertos/Makefile
View file @
b8878a5c
...
...
@@ -163,6 +163,7 @@ src/apps/widgets/status_bar.c \
src/apps/application.c
\
src/apps/clock.c
\
src/apps/menu.c
\
src/apps/menu_struct.c
\
src/main.c
\
src/irq_dispatcher.c
\
src/low_power_tick_management.c
...
...
sw/freertos/src/apps/menu.c
View file @
b8878a5c
...
...
@@ -25,6 +25,7 @@
*/
#include "menu.h"
#include "menu_struct.h"
#include "clock.h"
#include "widgets/status_bar.h"
...
...
@@ -37,15 +38,25 @@ static void menu_screen_redraw(struct ui_widget *w)
int
i
;
gfx_clear
(
&
w
->
dc
,
0
);
for
(
i
=
0
;
i
<
5
;
++
i
)
for
(
i
=
0
;
i
<
get_length
(
&
main_menu
)
;
++
i
)
{
if
(
i
==
selected_item
)
{
gfx_box
(
&
w
->
dc
,
LEFT_MARGIN
,
i
*
LINE_HEIGHT
,
127
,
(
i
+
1
)
*
LINE_HEIGHT
,
1
);
}
gfx_text
(
&
w
->
dc
,
&
font_helv17
,
LEFT_MARGIN
,
i
*
LINE_HEIGHT
,
"Application"
,
i
!=
selected_item
);
menu_entry
*
ent
=
&
main_menu
.
entries
[
i
];
if
(
ent
->
type
==
APP
)
{
application
*
a
=
ent
->
data
.
app
;
gfx_text
(
&
w
->
dc
,
&
font_helv17
,
LEFT_MARGIN
,
i
*
LINE_HEIGHT
,
a
->
name
,
i
!=
selected_item
);
}
else
if
(
ent
->
type
==
SUBMENU
)
{
menu_list
*
l
=
ent
->
data
.
submenu
;
gfx_text
(
&
w
->
dc
,
&
font_helv17
,
LEFT_MARGIN
,
i
*
LINE_HEIGHT
,
l
->
name
,
i
!=
selected_item
);
}
}
}
...
...
sw/freertos/src/apps/menu_struct.c
0 → 100644
View file @
b8878a5c
/*
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* Menu structure.
*/
#include "menu_struct.h"
#include "clock.h"
int
get_length
(
const
menu_list
*
menu
)
{
int
len
=
0
;
const
menu_entry
*
ptr
=
menu
->
entries
;
// Look for sentinel
while
((
*
ptr
++
).
type
!=
END
)
++
len
;
return
len
;
}
menu_list
main_menu
=
{
"Main menu"
,
{
{
APP
,
{
&
clock
}
},
{
APP
,
{
&
clock
}
},
{
APP
,
{
&
clock
}
},
{
APP
,
{
&
clock
}
},
{
END
,
{
NULL
}
}
}
};
sw/freertos/src/apps/menu_struct.h
0 → 100644
View file @
b8878a5c
/*
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Menu data structures.
*/
#ifndef MENU_STRUCT_H
#define MENU_STRUCT_H
#include "application.h"
/**
* @brief Type of menu entry.
*/
enum
entry_type
{
APP
,
SUBMENU
,
END
// sentinel, should be put as the last entry
};
/**
* @brief Structure that represents a single
* entry - either application or submenu.
*/
typedef
struct
menu_entry_t
{
enum
entry_type
type
;
union
{
application
*
app
;
struct
menu_list_t
*
submenu
;
}
data
;
}
menu_entry
;
/**
* @brief Structure that contains a list
* of menu entries (submenu).
*/
typedef
struct
menu_list_t
{
char
name
[
16
];
menu_entry
entries
[];
}
menu_list
;
/**
* @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
);
/**
* @brief Stores the main menu structure.
*/
extern
menu_list
main_menu
;
#endif
/* MENU_H */
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