forked from len0rd/rockbox
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
This commit is contained in:
parent
ffbbc60f38
commit
93b2f9fd44
56 changed files with 1969 additions and 1746 deletions
42
apps/plugins/clock/clock_counter.c
Normal file
42
apps/plugins/clock/clock_counter.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "clock_counter.h"
|
||||
#include "clock_bitmap_strings.h"
|
||||
|
||||
void counter_init(struct counter* counter){
|
||||
counter->ticks_since_started=0;
|
||||
counter->ticks_at_last_unpause=0;
|
||||
counter->paused=true;
|
||||
}
|
||||
|
||||
int counter_get_ticks_since_last_pause(struct counter* counter){
|
||||
if(!counter->paused)
|
||||
return(*rb->current_tick - counter->ticks_at_last_unpause);
|
||||
return(0);
|
||||
}
|
||||
|
||||
void counter_toggle(struct counter* counter){
|
||||
counter_pause(counter, !counter->paused);
|
||||
}
|
||||
|
||||
void counter_pause(struct counter* counter, bool pause){
|
||||
if(pause){
|
||||
counter->ticks_since_started+=counter_get_ticks_since_last_pause(counter);
|
||||
}else{
|
||||
counter->ticks_at_last_unpause=*rb->current_tick;
|
||||
}
|
||||
counter->paused=pause;
|
||||
}
|
||||
|
||||
void counter_get_elapsed_time(struct counter* counter, struct time* elapsed_time){
|
||||
int total_time=counter_get_ticks_since_last_pause(counter);
|
||||
total_time+=counter->ticks_since_started;
|
||||
total_time/=HZ;/* converts ticks to seconds */
|
||||
|
||||
elapsed_time->second = total_time%60;
|
||||
elapsed_time->minute = (total_time%3600) / 60;
|
||||
elapsed_time->hour = total_time / 3600;
|
||||
/* not yet ! */
|
||||
elapsed_time->day=0;
|
||||
elapsed_time->month=0;
|
||||
elapsed_time->year=0;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue