diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/clock/clock_draw_analog.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/apps/plugins/clock/clock_draw_analog.c b/apps/plugins/clock/clock_draw_analog.c index 04d6c5a06e..0ab058e3fa 100644 --- a/apps/plugins/clock/clock_draw_analog.c +++ b/apps/plugins/clock/clock_draw_analog.c | |||
@@ -28,27 +28,35 @@ | |||
28 | #define ANALOG_MINUTE_RADIUS(screen, round) \ | 28 | #define ANALOG_MINUTE_RADIUS(screen, round) \ |
29 | (round?MIN(screen->height/2 -10, screen->width/2 -10):screen->height/2) | 29 | (round?MIN(screen->height/2 -10, screen->width/2 -10):screen->height/2) |
30 | #define ANALOG_HOUR_RADIUS(screen, round) \ | 30 | #define ANALOG_HOUR_RADIUS(screen, round) \ |
31 | (ANALOG_MINUTE_RADIUS(screen, round)/2) | 31 | (2*ANALOG_MINUTE_RADIUS(screen, round)/3) |
32 | 32 | ||
33 | #define HOUR_ANGLE(hour, minute, second) (30*(hour) +(minute)/2) | 33 | #define HOUR_ANGLE(hour, minute, second) (30*(hour) +(minute)/2) |
34 | #define MINUTE_ANGLE(minute, second) (6*(minute)+(second)/10) | 34 | #define MINUTE_ANGLE(minute, second) (6*(minute)+(second)/10) |
35 | #define SECOND_ANGLE(second) (6 * (second)) | 35 | #define SECOND_ANGLE(second) (6 * (second)) |
36 | 36 | ||
37 | /* Note that the given angle's origin is midday and not 3 o'clock */ | 37 | /* Note that the given angle's origin is midday and not 3 o'clock */ |
38 | void polar_to_cartesian(int a, int r, int* x, int* y){ | 38 | void polar_to_cartesian(int a, int r, int* x, int* y) |
39 | { | ||
40 | #if CONFIG_LCD == LCD_SSD1815 | ||
41 | /* Correct non-square pixel aspect of archos recorder LCD */ | ||
42 | *x = (sin_int(a) * 5 / 4 * r) >> 14; | ||
43 | #else | ||
39 | *x = (sin_int(a) * r) >> 14; | 44 | *x = (sin_int(a) * r) >> 14; |
45 | #endif | ||
40 | *y = (sin_int(a-90) * r) >> 14; | 46 | *y = (sin_int(a-90) * r) >> 14; |
41 | } | 47 | } |
42 | 48 | ||
43 | void polar_to_cartesian_screen_centered(struct screen * display, | 49 | void polar_to_cartesian_screen_centered(struct screen * display, |
44 | int a, int r, int* x, int* y){ | 50 | int a, int r, int* x, int* y) |
51 | { | ||
45 | polar_to_cartesian(a, r, x, y); | 52 | polar_to_cartesian(a, r, x, y); |
46 | *x+=display->width/2; | 53 | *x+=display->width/2; |
47 | *y+=display->height/2; | 54 | *y+=display->height/2; |
48 | } | 55 | } |
49 | 56 | ||
50 | void angle_to_square(int square_width, int square_height, | 57 | void angle_to_square(int square_width, int square_height, |
51 | int a, int* x, int* y){ | 58 | int a, int* x, int* y) |
59 | { | ||
52 | a = (a+360-90)%360; | 60 | a = (a+360-90)%360; |
53 | if(a>45 && a<=135){/* top line */ | 61 | if(a>45 && a<=135){/* top line */ |
54 | a-=45; | 62 | a-=45; |
@@ -74,14 +82,16 @@ void angle_to_square(int square_width, int square_height, | |||
74 | 82 | ||
75 | void angle_to_square_screen_centered(struct screen * display, | 83 | void angle_to_square_screen_centered(struct screen * display, |
76 | int square_width, int square_height, | 84 | int square_width, int square_height, |
77 | int a, int* x, int* y){ | 85 | int a, int* x, int* y) |
86 | { | ||
78 | angle_to_square(square_width, square_height, a, x, y); | 87 | angle_to_square(square_width, square_height, a, x, y); |
79 | *x+=display->width/2; | 88 | *x+=display->width/2; |
80 | *y+=display->height/2; | 89 | *y+=display->height/2; |
81 | } | 90 | } |
82 | 91 | ||
83 | void draw_hand(struct screen* display, int angle, | 92 | void draw_hand(struct screen* display, int angle, |
84 | int radius, int thickness, bool round){ | 93 | int radius, int thickness, bool round) |
94 | { | ||
85 | int x1, y1; /* the longest */ | 95 | int x1, y1; /* the longest */ |
86 | int x2, y2, x3, y3; /* the base */ | 96 | int x2, y2, x3, y3; /* the base */ |
87 | if(round){/* round clock */ | 97 | if(round){/* round clock */ |
@@ -99,10 +109,13 @@ void draw_hand(struct screen* display, int angle, | |||
99 | polar_to_cartesian_screen_centered(display, (angle+240)%360, | 109 | polar_to_cartesian_screen_centered(display, (angle+240)%360, |
100 | radius/40+thickness, &x3, &y3); | 110 | radius/40+thickness, &x3, &y3); |
101 | xlcd_filltriangle_screen(display, x1, y1, x2, y2, x3, y3); | 111 | xlcd_filltriangle_screen(display, x1, y1, x2, y2, x3, y3); |
112 | rb->lcd_drawline(x1, y1, x2, y2); | ||
113 | rb->lcd_drawline(x1, y1, x3, y3); | ||
102 | } | 114 | } |
103 | 115 | ||
104 | void draw_hands(struct screen* display, int hour, int minute, int second, | 116 | void draw_hands(struct screen* display, int hour, int minute, int second, |
105 | int thickness, bool round, bool draw_seconds){ | 117 | int thickness, bool round, bool draw_seconds) |
118 | { | ||
106 | if(draw_seconds){ | 119 | if(draw_seconds){ |
107 | draw_hand(display, SECOND_ANGLE(second), | 120 | draw_hand(display, SECOND_ANGLE(second), |
108 | ANALOG_SECOND_RADIUS(display, round), thickness, round); | 121 | ANALOG_SECOND_RADIUS(display, round), thickness, round); |
@@ -113,7 +126,8 @@ void draw_hands(struct screen* display, int hour, int minute, int second, | |||
113 | ANALOG_HOUR_RADIUS(display, round), thickness+2, round); | 126 | ANALOG_HOUR_RADIUS(display, round), thickness+2, round); |
114 | } | 127 | } |
115 | 128 | ||
116 | void draw_counter(struct screen* display, struct counter* counter){ | 129 | void draw_counter(struct screen* display, struct counter* counter) |
130 | { | ||
117 | char buffer[10]; | 131 | char buffer[10]; |
118 | int second_str_w, hour_str_w, str_h; | 132 | int second_str_w, hour_str_w, str_h; |
119 | const struct picture* smalldigits_bitmaps = | 133 | const struct picture* smalldigits_bitmaps = |
@@ -134,7 +148,8 @@ void draw_counter(struct screen* display, struct counter* counter){ | |||
134 | display->height-str_h); | 148 | display->height-str_h); |
135 | } | 149 | } |
136 | 150 | ||
137 | void draw_date(struct screen* display, struct time* time, int date_format){ | 151 | void draw_date(struct screen* display, struct time* time, int date_format) |
152 | { | ||
138 | char buffer[10]; | 153 | char buffer[10]; |
139 | int year_str_w, monthday_str_w, str_h; | 154 | int year_str_w, monthday_str_w, str_h; |
140 | int year_line=date_format==JAPANESE?1:2; | 155 | int year_line=date_format==JAPANESE?1:2; |
@@ -159,7 +174,8 @@ void draw_date(struct screen* display, struct time* time, int date_format){ | |||
159 | display->height-monthday_line*str_h); | 174 | display->height-monthday_line*str_h); |
160 | } | 175 | } |
161 | 176 | ||
162 | void draw_border(struct screen* display, int skin){ | 177 | void draw_border(struct screen* display, int skin) |
178 | { | ||
163 | /* Draws square dots every 5 minutes */ | 179 | /* Draws square dots every 5 minutes */ |
164 | int i; | 180 | int i; |
165 | int x, y; | 181 | int x, y; |
@@ -180,7 +196,8 @@ void draw_border(struct screen* display, int skin){ | |||
180 | } | 196 | } |
181 | 197 | ||
182 | void draw_hour(struct screen* display, struct time* time, | 198 | void draw_hour(struct screen* display, struct time* time, |
183 | bool show_seconds, int skin){ | 199 | bool show_seconds, int skin) |
200 | { | ||
184 | int hour=time->hour; | 201 | int hour=time->hour; |
185 | if(hour >= 12) | 202 | if(hour >= 12) |
186 | hour -= 12; | 203 | hour -= 12; |
@@ -201,7 +218,8 @@ void draw_hour(struct screen* display, struct time* time, | |||
201 | 0, skin, show_seconds); | 218 | 0, skin, show_seconds); |
202 | } | 219 | } |
203 | 220 | ||
204 | void draw_center_cover(struct screen* display){ | 221 | void draw_center_cover(struct screen* display) |
222 | { | ||
205 | display->drawline((display->width/2)-1, (display->height/2)+3, | 223 | display->drawline((display->width/2)-1, (display->height/2)+3, |
206 | (display->width/2)+1, (display->height/2)+3); | 224 | (display->width/2)+1, (display->height/2)+3); |
207 | display->drawline((display->width/2)-3, (display->height/2)+2, | 225 | display->drawline((display->width/2)-3, (display->height/2)+2, |
@@ -221,7 +239,8 @@ void draw_center_cover(struct screen* display){ | |||
221 | void analog_clock_draw(struct screen* display, struct time* time, | 239 | void analog_clock_draw(struct screen* display, struct time* time, |
222 | struct clock_settings* settings, | 240 | struct clock_settings* settings, |
223 | struct counter* counter, | 241 | struct counter* counter, |
224 | int skin){ | 242 | int skin) |
243 | { | ||
225 | 244 | ||
226 | draw_hour(display, time, settings->analog.show_seconds, skin); | 245 | draw_hour(display, time, settings->analog.show_seconds, skin); |
227 | if(settings->analog.show_border) | 246 | if(settings->analog.show_border) |