diff options
author | Kevin Ferrare <kevin@rockbox.org> | 2007-08-04 03:01:46 +0000 |
---|---|---|
committer | Kevin Ferrare <kevin@rockbox.org> | 2007-08-04 03:01:46 +0000 |
commit | 93b2f9fd447b73fff736d71826880ef9ac64bd94 (patch) | |
tree | 1a4f54016c312738d66fb9dd2348ea0ef14f1255 /apps/plugins/clock/clock_counter.c | |
parent | ffbbc60f38ddc8aeadc9cea1102077e22ca84a1a (diff) | |
download | rockbox-93b2f9fd447b73fff736d71826880ef9ac64bd94.tar.gz rockbox-93b2f9fd447b73fff736d71826880ef9ac64bd94.zip |
Rewrote the clock plugin in a cleaner and more modular way so that it can scale on remote screens. Use left-right keys to change the type of clock displayed (analogic, digital, binary) and up/downto change the look of the clock
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14174 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/clock/clock_counter.c')
-rw-r--r-- | apps/plugins/clock/clock_counter.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/plugins/clock/clock_counter.c b/apps/plugins/clock/clock_counter.c new file mode 100644 index 0000000000..7137eeaf38 --- /dev/null +++ b/apps/plugins/clock/clock_counter.c | |||
@@ -0,0 +1,42 @@ | |||
1 | #include "clock_counter.h" | ||
2 | #include "clock_bitmap_strings.h" | ||
3 | |||
4 | void counter_init(struct counter* counter){ | ||
5 | counter->ticks_since_started=0; | ||
6 | counter->ticks_at_last_unpause=0; | ||
7 | counter->paused=true; | ||
8 | } | ||
9 | |||
10 | int counter_get_ticks_since_last_pause(struct counter* counter){ | ||
11 | if(!counter->paused) | ||
12 | return(*rb->current_tick - counter->ticks_at_last_unpause); | ||
13 | return(0); | ||
14 | } | ||
15 | |||
16 | void counter_toggle(struct counter* counter){ | ||
17 | counter_pause(counter, !counter->paused); | ||
18 | } | ||
19 | |||
20 | void counter_pause(struct counter* counter, bool pause){ | ||
21 | if(pause){ | ||
22 | counter->ticks_since_started+=counter_get_ticks_since_last_pause(counter); | ||
23 | }else{ | ||
24 | counter->ticks_at_last_unpause=*rb->current_tick; | ||
25 | } | ||
26 | counter->paused=pause; | ||
27 | } | ||
28 | |||
29 | void counter_get_elapsed_time(struct counter* counter, struct time* elapsed_time){ | ||
30 | int total_time=counter_get_ticks_since_last_pause(counter); | ||
31 | total_time+=counter->ticks_since_started; | ||
32 | total_time/=HZ;/* converts ticks to seconds */ | ||
33 | |||
34 | elapsed_time->second = total_time%60; | ||
35 | elapsed_time->minute = (total_time%3600) / 60; | ||
36 | elapsed_time->hour = total_time / 3600; | ||
37 | /* not yet ! */ | ||
38 | elapsed_time->day=0; | ||
39 | elapsed_time->month=0; | ||
40 | elapsed_time->year=0; | ||
41 | } | ||
42 | |||