1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Copyright Kévin Ferrare
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include "clock_draw_digital.h"
24 #include "clock_bitmap_strings.h"
25 #include "clock_bitmaps.h"
26 #include "lib/picture.h"
28 const struct picture
* digits_skin
[]={digits
,segments
};
29 const struct picture
* smalldigits_skin
[]={smalldigits
,smallsegments
};
31 #define buffer_printf(buffer, buffer_pos, ... ) \
32 buffer_pos+=rb->snprintf(&buffer[buffer_pos], sizeof(buffer)-buffer_pos, __VA_ARGS__);
34 void digital_clock_draw(struct screen
* display
,
36 struct clock_settings
* settings
,
37 struct counter
* counter
,
40 const struct picture
* digits_bitmaps
= &(digits_skin
[skin
][display
->screen_type
]);
41 const struct picture
* smalldigits_bitmaps
= &(smalldigits_skin
[skin
][display
->screen_type
]);
47 if(settings
->digital
.blinkcolon
){
48 display_colon
=(time
->second
%2==0);
53 if(settings
->general
.hour_format
==H12
&& time
->hour
>12)/* AM/PM format */
56 buffer_printf(buffer
, buffer_pos
, "%02d", hour
);
57 buffer_printf(buffer
, buffer_pos
, "%c", display_colon
?':':' ');
58 buffer_printf(buffer
, buffer_pos
, "%02d", time
->minute
);
59 if(settings
->general
.hour_format
==H12
){
61 buffer_printf(buffer
, buffer_pos
, "P");/* PM */
63 buffer_printf(buffer
, buffer_pos
, "A");/* AM */
66 getstringsize(digits_bitmaps
, buffer
, &str_w
, &str_h
);
67 draw_string(display
, digits_bitmaps
, buffer
,
68 (display
->getwidth()-str_w
)/2, 0);
69 if(settings
->digital
.show_seconds
){
71 buffer_printf(buffer
, buffer_pos
, "%02d", time
->second
);
72 getstringsize(digits_bitmaps
, buffer
, &str_w
, &str_h
);
73 draw_string(display
, digits_bitmaps
, buffer
,
74 (display
->getwidth()-str_w
)/2,
75 digits_bitmaps
->slide_height
);
77 if(settings
->general
.date_format
!=NONE
){
78 format_date(buffer
, time
, settings
->general
.date_format
);
79 getstringsize(smalldigits_bitmaps
, buffer
, &str_w
, &str_h
);
80 draw_string(display
, smalldigits_bitmaps
, buffer
,
81 (display
->getwidth()-str_w
)/2,
82 display
->getheight()-smalldigits_bitmaps
->slide_height
*2);
85 struct time counter_time
;
86 counter_get_elapsed_time(counter
, &counter_time
);
87 rb
->snprintf(buffer
, 20, "%02d:%02d:%02d",
88 counter_time
.hour
, counter_time
.minute
, counter_time
.second
);
89 getstringsize(smalldigits_bitmaps
, buffer
, &str_w
, &str_h
);
90 draw_string(display
, smalldigits_bitmaps
, buffer
,
91 (display
->getwidth()-str_w
)/2, display
->getheight()-str_h
);