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
71e51349
Commit
71e51349
authored
Sep 14, 2014
by
=
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clock: Uses standard library for time conversion.
Displays date.
parent
e0a30c6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
49 deletions
+37
-49
app_list.h
sw/freertos/src/apps/app_list.h
+1
-1
clock.c
sw/freertos/src/apps/clock.c
+19
-31
menu.c
sw/freertos/src/apps/menu.c
+2
-2
menu_struct.c
sw/freertos/src/apps/menu_struct.c
+15
-15
No files found.
sw/freertos/src/apps/app_list.h
View file @
71e51349
...
...
@@ -30,7 +30,7 @@
#include "application.h"
extern
application
menu
;
extern
application
clock
;
extern
application
clock
_app
;
extern
application
example
;
#endif
/* APP_LIST_H */
...
...
sw/freertos/src/apps/clock.c
View file @
71e51349
...
...
@@ -30,40 +30,34 @@
#include <drivers/rtc.h>
#include <stdio.h>
#include <time.h>
static
unsigned
int
hour
,
mins
,
secs
,
msecs
;
static
struct
rtc_time
rtc
;
static
struct
tm
cur_time
;
static
void
digital_watch_redraw
(
struct
ui_widget
*
w
)
{
char
buf
[
20
];
sprintf
(
buf
,
"%02d:%02d"
,
hour
,
mins
);
char
buf
[
32
];
strftime
(
buf
,
sizeof
(
buf
),
"%H:%M"
,
&
cur_time
);
/*sprintf(buf,"%02d:%02d", cur_time.tm_hour, cur_time.tm_min);*/
gfx_clear
(
&
w
->
dc
,
0
);
gfx_text
(
&
w
->
dc
,
&
font_helv38b
,
0
,
0
,
buf
,
1
);
gfx_text
(
&
w
->
dc
,
&
font_helv38b
,
4
,
0
,
buf
,
1
);
sprintf
(
buf
,
"%02d.%01d"
,
secs
,
msecs
/
100
);
gfx_text
(
&
w
->
dc
,
&
font_helv22b
,
84
,
14
,
buf
,
1
);
// sprintf must be used, so we can display msecs too
sprintf
(
buf
,
"%02d.%01d"
,
cur_time
.
tm_sec
,
rtc
.
msecs
/
100
);
gfx_text
(
&
w
->
dc
,
&
font_helv22b
,
88
,
14
,
buf
,
1
);
strftime
(
buf
,
sizeof
(
buf
),
"%a %d %b %Y"
,
&
cur_time
);
gfx_centered_text
(
&
w
->
dc
,
&
font_helv17
,
40
,
buf
,
1
);
}
static
void
digital_watch_event
(
struct
ui_widget
*
w
,
const
struct
event
*
evt
)
{
// Hour has changed, it is time to redraw the clock
if
(
evt
->
type
==
RTC_TICK
)
{
msecs
+=
200
;
if
(
1000
==
msecs
)
{
++
secs
;
msecs
=
0
;
}
++
secs
;
if
(
60
==
secs
)
{
++
mins
;
secs
=
0
;
if
(
60
==
mins
)
{
++
hour
;
mins
=
0
;
if
(
24
==
hour
)
hour
=
0
;
// TODO 12/24 hour format
}
}
rtc
=
rtc_get_time
();
localtime_r
((
time_t
*
)
&
rtc
.
epoch
,
&
cur_time
);
w
->
flags
|=
WF_DIRTY
;
}
...
...
@@ -72,7 +66,7 @@ static void digital_watch_event(struct ui_widget *w, const struct event *evt)
struct
ui_widget
digital_watch
=
{
digital_watch_redraw
,
digital_watch_event
,
{
0
,
20
,
127
,
59
},
{
0
,
35
,
127
,
35
+
53
},
0
,
WF_ACTIVE
|
WF_VISIBLE
};
...
...
@@ -90,14 +84,8 @@ void clock_main(void* params) {
struct
event
evt
;
// Restore clock
struct
rtc_time
time
=
rtc_get_time
();
msecs
=
time
.
msecs
;
secs
=
time
.
epoch
;
mins
=
secs
/
60
;
hour
=
mins
/
60
;
secs
%=
60
;
mins
%=
60
;
hour
%=
24
;
rtc
=
rtc_get_time
();
localtime_r
((
time_t
*
)
&
rtc
.
epoch
,
&
cur_time
);
// Initialize user interface
ui_clear
();
...
...
@@ -135,7 +123,7 @@ void clock_main(void* params) {
}
}
application
clock
=
{
application
clock
_app
=
{
.
name
=
"Clock"
,
.
main
=
clock_main
};
...
...
sw/freertos/src/apps/menu.c
View file @
71e51349
...
...
@@ -145,7 +145,7 @@ static void run(menu_entry *entry) {
static
void
go_back
()
{
if
(
current_menu
==
menu_stack
)
{
clock
.
main
(
NULL
);
clock
_app
.
main
(
NULL
);
}
else
{
menu_size
=
0
;
selected_item
=
0
;
...
...
@@ -164,7 +164,7 @@ void menu_main(void* params) {
menu_size
=
get_menu_size
(
*
current_menu
);
// run clock as the the initial application
clock
.
main
(
NULL
);
clock
_app
.
main
(
NULL
);
menu_ui_init
();
// Once it is deactivated - display the menu
...
...
sw/freertos/src/apps/menu_struct.c
View file @
71e51349
...
...
@@ -40,9 +40,9 @@ int get_menu_size(const menu_list *menu) {
menu_list
sub_menu
=
{
"Submenu"
,
{
{
APP
,
&
gps_receiving
,
{
.
app
=
&
clock
}
},
{
APP
,
&
battery
,
{
.
app
=
&
clock
}
},
{
APP
,
&
gps_disconnected
,
{
.
app
=
&
clock
}
},
{
APP
,
&
gps_receiving
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
&
battery
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
&
gps_disconnected
,
{
.
app
=
&
clock
_app
}
},
{
END
,
&
gps_searching
,
{
NULL
}
}
}
};
...
...
@@ -51,23 +51,23 @@ menu_list main_menu = {
"Main menu"
,
{
{
APP
,
&
example_icon
,
{
.
app
=
&
example
}
},
{
APP
,
&
gps_receiving
,
{
.
app
=
&
clock
}
},
{
APP
,
&
battery_charging
,
{
.
app
=
&
clock
}
},
{
APP
,
&
gps_receiving
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
&
battery_charging
,
{
.
app
=
&
clock
_app
}
},
{
SUBMENU
,
NULL
,
{
.
submenu
=
&
sub_menu
}
},
{
APP
,
&
battery
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
&
gps_disconnected
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
&
battery
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
&
gps_disconnected
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
SUBMENU
,
&
battery_charging
,
{
.
submenu
=
&
sub_menu
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
SUBMENU
,
NULL
,
{
.
submenu
=
&
sub_menu
}
},
{
SUBMENU
,
NULL
,
{
.
submenu
=
&
sub_menu
}
},
{
SUBMENU
,
NULL
,
{
.
submenu
=
&
sub_menu
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
APP
,
NULL
,
{
.
app
=
&
clock
_app
}
},
{
END
,
NULL
,
{
NULL
}
}
}
};
...
...
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