as3525v1: duplicate the right channel into the left channel when recording microphone
[kugel-rb.git] / apps / plugins / clock / clock_counter.c
blob7137eeaf381221edcd7425ad43fa7b92461cb41d
1 #include "clock_counter.h"
2 #include "clock_bitmap_strings.h"
4 void counter_init(struct counter* counter){
5 counter->ticks_since_started=0;
6 counter->ticks_at_last_unpause=0;
7 counter->paused=true;
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);
16 void counter_toggle(struct counter* counter){
17 counter_pause(counter, !counter->paused);
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;
26 counter->paused=pause;
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 */
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;