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
64805071
Commit
64805071
authored
Aug 26, 2014
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apps: Added a template for applications.
parent
d9cb2636
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
229 additions
and
1 deletion
+229
-1
bitmaps.c
sw/bitmaps/bitmaps.c
+36
-0
bitmaps.h
sw/bitmaps/bitmaps.h
+2
-1
example_icon.bmp
sw/bitmaps/example_icon.bmp
+0
-0
Makefile
sw/freertos/Makefile
+1
-0
app_list.h
sw/freertos/src/apps/app_list.h
+1
-0
example_app.c
sw/freertos/src/apps/example_app.c
+153
-0
example_app.h
sw/freertos/src/apps/example_app.h
+35
-0
menu_struct.c
sw/freertos/src/apps/menu_struct.c
+1
-0
No files found.
sw/bitmaps/bitmaps.c
View file @
64805071
#include <bitmaps.h>
static
const
uint8_t
example_icon_data
[]
=
{
0x2e
,
0x81
,
0x05
,
0x81
,
0x04
,
0x81
,
0x05
,
0x82
,
0x16
,
0x80
,
0x0d
,
0x80
,
0x0d
,
0x80
,
0x08
,
0x80
,
0x09
,
0x80
,
0x02
,
0x80
,
0x08
,
0x81
,
0x02
,
0x81
,
0x06
,
0x81
,
0x04
,
0x83
,
0x01
,
0x82
,
0x08
,
0x83
,
0x14
};
const
struct
rle_bitmap
example_icon
=
{
15
,
15
,
example_icon_data
};
static
const
uint8_t
gps_receiving_data
[]
=
{
0x06
,
0x83
,
...
...
sw/bitmaps/bitmaps.h
View file @
64805071
...
...
@@ -10,10 +10,11 @@ struct rle_bitmap
uint8_t
*
data
;
};
extern
const
struct
rle_bitmap
example_icon
;
extern
const
struct
rle_bitmap
gps_receiving
;
extern
const
struct
rle_bitmap
battery
;
extern
const
struct
rle_bitmap
gps_disconnected
;
extern
const
struct
rle_bitmap
battery_charging
;
extern
const
struct
rle_bitmap
gps_searching
;
#endif
BITMAPS_H
#endif
/* BITMAPS_H */
sw/bitmaps/example_icon.bmp
0 → 100644
View file @
64805071
842 Bytes
sw/freertos/Makefile
View file @
64805071
...
...
@@ -165,6 +165,7 @@ FreeRTOS/Source/portable/GCC/ARM_CM3/port.c \
src/apps/widgets/status_bar.c
\
src/apps/application.c
\
src/apps/clock.c
\
src/apps/example_app.c
\
src/apps/menu.c
\
src/apps/menu_struct.c
\
src/main.c
\
...
...
sw/freertos/src/apps/app_list.h
View file @
64805071
...
...
@@ -31,6 +31,7 @@
extern
application
menu
;
extern
application
clock
;
extern
application
example
;
#endif
/* APP_LIST_H */
sw/freertos/src/apps/example_app.c
0 → 100644
View file @
64805071
/*
* 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
*/
/**
* Application template.
*/
#include "application.h"
#include "widgets/status_bar.h"
#include <string.h> // for strcpy
static
char
message
[
32
]
=
"hello world"
;
static
void
widget_redraw
(
struct
ui_widget
*
w
)
{
gfx_clear
(
&
w
->
dc
,
0
);
gfx_text
(
&
w
->
dc
,
&
font_helv17b
,
0
,
0
,
message
,
1
);
}
static
void
widget_event
(
struct
ui_widget
*
w
,
const
struct
event
*
evt
)
{
// screen needs redrawing
w
->
flags
|=
WF_DIRTY
;
switch
(
evt
->
type
)
{
case
BUTTON_PRESSED
:
switch
(
evt
->
data
.
button
)
{
case
BUT_TR
:
strcpy
(
message
,
"top right"
);
break
;
case
BUT_BR
:
strcpy
(
message
,
"bottom right"
);
break
;
case
BUT_BL
:
strcpy
(
message
,
"bottom left"
);
break
;
case
BUT_TL
:
// this should not happen, it is handled
break
;
// in the main loop
}
case
RTC_TICK
:
// commented out, because it interferes with other messages
//strcpy(message, "tick-tock");
break
;
default:
// suppress warnings
// ok, we do not need redrawing
w
->
flags
&=
~
WF_DIRTY
;
break
;
}
}
struct
ui_widget
widget
=
{
widget_redraw
,
// drawing function, called when widget is marked as dirty
widget_event
,
// event handler
{
0
,
20
,
127
,
59
},
// dimensions
0
,
// surface pointer; do not change
WF_ACTIVE
|
WF_VISIBLE
// flags
};
struct
ui_widget
example_screen
=
{
// main screen, contains all widgets
NULL
,
NULL
,
{
0
,
0
,
127
,
127
},
0
,
WF_ACTIVE
|
WF_VISIBLE
};
void
example_main
(
void
*
params
)
{
(
void
)(
params
);
// suppress unused parameter warning
struct
event
evt
;
// this is a good place for hardware initialization
// (configure interrupts, backlight settings, etc.)
// initialize user interface
ui_clear
();
// initialize widgets before adding them
ui_init_widget
(
&
example_screen
);
ui_init_widget
(
&
widget
);
ui_add_widget
(
&
widget
);
// widget belongs to the main screen
ui_add_child
(
&
example_screen
,
&
widget
);
ui_add_widget
(
&
example_screen
);
// if you want to have fullscreen just for you
// commenting the lines below will disable the status bar
ui_init_widget
(
&
status_bar
);
ui_add_widget
(
&
status_bar
);
// draw the screen for the first time
ui_update
(
NULL
);
// event loop
while
(
1
)
{
// "0" in the line below, if you set it to a positive value then
// you may have a block of code that is executed when no event arrives
// for details, see below (else block)
if
(
xQueueReceive
(
appQueue
,
&
evt
,
0
))
{
switch
(
evt
.
type
)
{
// decide which events are relevant and should be handled
// you may save some cycles if you list them here instead of
// lazily handling all of them
case
BUTTON_PRESSED
:
// current convention is to use the top left button to go back
if
(
evt
.
data
.
button
==
BUT_TL
)
return
;
// go back to the main menu
// no break; fall through
case
RTC_TICK
:
// there was no break, it handles BUTTON_PRESSED too
ui_update
(
&
evt
);
// forward event to widgets
default:
// suppress warnings
// ignore events that were not mentioned above
break
;
}
}
else
{
// that part is executed if timeout occurs
}
}
}
application
example
=
{
.
name
=
"Example"
,
// this will be shown in menu
.
main
=
example_main
};
sw/freertos/src/apps/example_app.h
0 → 100644
View file @
64805071
/*
* 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
*/
/**
* Clock application.
*/
#ifndef CLOCK_H
#define CLOCK_H
#include "application.h"
extern
application
clock
;
#endif
/* CLOCK_H */
sw/freertos/src/apps/menu_struct.c
View file @
64805071
...
...
@@ -50,6 +50,7 @@ menu_list sub_menu = {
menu_list
main_menu
=
{
"Main menu"
,
{
{
APP
,
&
example_icon
,
{
.
app
=
&
example
}
},
{
APP
,
&
gps_receiving
,
{
.
app
=
&
clock
}
},
{
APP
,
&
battery_charging
,
{
.
app
=
&
clock
}
},
{
SUBMENU
,
NULL
,
{
.
submenu
=
&
sub_menu
}
},
...
...
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