diff options
-rw-r--r-- | apps/plugins/clock.c | 2707 |
1 files changed, 2176 insertions, 531 deletions
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c index 1df0f709d4..3dae622c60 100644 --- a/apps/plugins/clock.c +++ b/apps/plugins/clock.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id: clock.c,v 1.0 2003/12/8 | 8 | * $Id: clock.c,v 2.0 2003/12/8 |
9 | * | 9 | * |
10 | * Copyright (C) 2003 Zakk Roberts | 10 | * Copyright (C) 2003 Zakk Roberts |
11 | * | 11 | * |
@@ -16,77 +16,2057 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | |||
20 | /******************************** | ||
21 | RELEASE NOTES ******************* | ||
22 | ********************************* | ||
23 | |||
24 | ******************************** | ||
25 | VERSION 2.2 * STABLE *********** | ||
26 | ******************************** | ||
27 | Few small bugs taken care of. | ||
28 | Release version. | ||
29 | |||
30 | Features: | ||
31 | -New mode, "Binary" | ||
32 | -New mode selector - access via PLAY | ||
33 | -New feature, "Counter" - F2 to start/stop, Hold F2 to reset. | ||
34 | -New redesigned 9-page help screen. | ||
35 | -Small bugs fixed. | ||
36 | |||
37 | ********************************* | ||
38 | VERSION 2.1 * STABLE ************ | ||
39 | ********************************* | ||
40 | Even more bugs fixed. Almost bug-free :) | ||
41 | |||
42 | Features: | ||
43 | -Another new mode!! LCD imitation (similar to Digital) | ||
44 | -American/European date modes added | ||
45 | -lots of bugs fixed | ||
46 | |||
47 | ********************************* | ||
48 | VERSION 2.0: * BETA ************* | ||
49 | ********************************* | ||
50 | |||
51 | Major update. Code pretty much rewritten. Lots of bugs fixed. | ||
52 | |||
53 | New Features: ******************* | ||
54 | -New mode, Fullscreen! | ||
55 | -Seperate settings for each mode | ||
56 | -Credits at F2 | ||
57 | -Options at F3 | ||
58 | -Startup / Shutdown logo (choose one by hitting ON) | ||
59 | -CLEANER code! | ||
60 | |||
61 | Analog specific changes: ******** | ||
62 | -removed outer border option | ||
63 | -added 12/24h readout (and am/pm bitmaps for 12h mode) | ||
64 | |||
65 | Digital specific changes: ******* | ||
66 | -now centers date and second readouts | ||
67 | -second readout options, "Digital" (text), "Bar" (progressbar), "Inverse" (inverts the display as the seconds go by) | ||
68 | -12/24h modes as well here (and of course the am/pm bitmaps) | ||
69 | |||
70 | ******************************** | ||
71 | VERSION 1.0 * "ALPHA" (STABLE) * | ||
72 | ******************************** | ||
73 | Release Version. | ||
74 | |||
75 | Features analog / digital modes, | ||
76 | and a few options. | ||
77 | ********************************/ | ||
19 | #include "plugin.h" | 78 | #include "plugin.h" |
20 | #include "time.h" | 79 | #include "time.h" |
21 | 80 | ||
22 | #ifdef HAVE_LCD_BITMAP | 81 | #ifdef HAVE_LCD_BITMAP |
23 | 82 | ||
24 | void draw_7seg_time(int hour, int minute, int x, int y, int width, int height, | 83 | /* prototypes */ |
25 | bool colon); | 84 | void show_logo(bool animate, bool show_clock_text); |
26 | void loadSettings(void); | 85 | void exit_logo(void); |
86 | |||
87 | /* used in help screen */ | ||
88 | int screen = 1; | ||
89 | |||
90 | /* counter misc */ | ||
91 | int start_tick = 0; | ||
92 | int passed_time = 0; | ||
93 | int counter = 0; | ||
94 | int displayed_value = 0; | ||
95 | int count_h, count_m, count_s; | ||
96 | char count_text[8]; | ||
97 | bool counting = false; | ||
27 | 98 | ||
28 | static struct plugin_api* rb; | 99 | static struct plugin_api* rb; |
29 | 100 | ||
30 | /* Used for hands to define lengths at a given time */ | 101 | /*********************************************************** |
31 | static unsigned char yhour[] = { | 102 | * Used for hands to define lengths at a given time - ANALOG |
32 | 47,47,46,46,46,45,44,43,42,41,39,38,36,35,33,32,31,29,28,26,25,23,22,21,20,19,18,18,18,17,17,17,18,18,18,19,20,21,22,23,25,26,28,29,31,32,33,35,36,38,39,41,42,43,44,45,46,46,46,47, | 103 | ***********************************************************/ |
104 | static unsigned char xminute[] = { | ||
105 | 56,59,61,64,67,70,72,75,77,79,80,82,83,84,84,84,84,84,83,82,80,79,77,75,72,70,67,64,61,59,56,53,51,48,45,42,40,37,35,33,32,30,29,28,28,28,28,28,29,30,32,33,35,37,40,42,45,48,51,53, | ||
33 | }; | 106 | }; |
34 | static unsigned char yminute[] = { | 107 | static unsigned char yminute[] = { |
35 | 55,54,54,53,53,51,50,49,47,45,43,41,39,36,34,32,30,28,25,23,21,19,17,15,14,13,11,11,10,10,9,10,10,11,11,13,14,15,17,19,21,23,25,28,30,32,34,36,39,41,43,45,47,49,50,51,53,53,54,54, | 108 | 55,54,54,53,53,51,50,49,47,45,43,41,39,36,34,32,30,28,25,23,21,19,17,15,14,13,11,11,10,10,9,10,10,11,11,13,14,15,17,19,21,23,25,28,30,32,34,36,39,41,43,45,47,49,50,51,53,53,54,54, |
36 | }; | 109 | }; |
110 | static unsigned char yhour[] = { | ||
111 | 47,47,46,46,46,45,44,43,42,41,39,38,36,35,33,32,31,29,28,26,25,23,22,21,20,19,18,18,18,17,17,17,18,18,18,19,20,21,22,23,25,26,28,29,31,32,33,35,36,38,39,41,42,43,44,45,46,46,46,47, | ||
112 | }; | ||
37 | static unsigned char xhour[] = { | 113 | static unsigned char xhour[] = { |
38 | 56,58,59,61,63,65,67,68,70,71,72,73,74,74,75,75,75,74,74,73,72,71,70,68,67,65,63,61,59,58,56,54,53,51,49,47,45,44,42,41,40,39,38,38,37,37,37,38,38,39,40,41,42,44,45,47,49,51,53,54, | 114 | 56,58,59,61,63,65,67,68,70,71,72,73,74,74,75,75,75,74,74,73,72,71,70,68,67,65,63,61,59,58,56,54,53,51,49,47,45,44,42,41,40,39,38,38,37,37,37,38,38,39,40,41,42,44,45,47,49,51,53,54, |
39 | }; | 115 | }; |
40 | static unsigned char xminute[] = { | 116 | |
41 | 56,59,61,64,67,70,72,75,77,79,80,82,83,84,84,84,84,84,83,82,80,79,77,75,72,70,67,64,61,59,56,53,51,48,45,42,40,37,35,33,32,30,29,28,28,28,28,28,29,30,32,33,35,37,40,42,45,48,51,53, | 117 | /************************************************************** |
118 | * Used for hands to define lengths at a give time - FULLSCREEN | ||
119 | **************************************************************/ | ||
120 | static unsigned char xminute_full[] = { | ||
121 | 56,58,61,65,69,74,79,84,91,100,110,110,110,110,110,110,110,110,110,110,110,100,91,84,79,74,69,65,61,58,56,54,51,47,43,38,33,28,21,12,1,1,1,1,1,1,1,1,1,1,1,12,21,28,33,38,43,47,51,54 | ||
122 | }; | ||
123 | static unsigned char yminute_full[] = { | ||
124 | 62,62,62,62,62,62,62,62,62,62,62,53,45,40,36,32,28,24,19,11,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11,19,24,28,32,36,40,45,53,62,62,62,62,62,62,62,62,62,62 | ||
125 | }; | ||
126 | static unsigned char xhour_full[] = { | ||
127 | 56,58,60,63,66,69,73,78,84,91,100,100,100,100,100,100,100,100,100,100,100,91,84,78,73,69,66,63,60,58,56,54,52,49,46,43,39,34,28,21,12,12,12,12,12,12,12,12,12,12,12,21,28,34,39,43,46,49,52,54 | ||
128 | }; | ||
129 | static unsigned char yhour_full[] = { | ||
130 | 52,52,52,52,52,52,52,52,52,52,52,46,41,37,34,32,30,27,23,18,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,18,23,27,30,32,34,37,41,46,52,52,52,52,52,52,52,52,52,52 | ||
131 | }; | ||
132 | |||
133 | /************************************ | ||
134 | * Used for second-progressbar | ||
135 | ************************************/ | ||
136 | static unsigned char seconds100[] = { | ||
137 | 1,2,4,5,7,8,11,13,14,16,17,19,22,23,25,26,28,29,32,34,35,37,38,39,42,43,45,46,48,49,51,52,54,55,57,58,60,61,63,64,66,67,69,72,73,75,76,78,79,82,84,85,87,88,91,93,94,96,97,99 | ||
138 | }; | ||
139 | |||
140 | /************************************ | ||
141 | * Used for seconds-inverse mode | ||
142 | ************************************/ | ||
143 | static unsigned char seconds112[] = { | ||
144 | 1,2,4,6,8,10,12,14,16,18,20,21,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,91,92,94,96,98,100,102,104,106,108,110,111,112 | ||
145 | }; | ||
146 | |||
147 | /**************************** | ||
148 | * BITMAPS | ||
149 | ****************************/ | ||
150 | /**************************** | ||
151 | * "0" bitmap - for binary | ||
152 | ****************************/ | ||
153 | static unsigned char bitmap_0[] = { | ||
154 | 0xc0, 0xf0, 0x3c, 0x0e, 0x06, 0x03, 0x03, 0x03, 0x03, 0x06, 0x0e, 0x3c, 0xf0, | ||
155 | 0xc0, 0x00, | ||
156 | 0x1f, 0x7f, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0x7f, | ||
157 | 0x1f, 0x00, | ||
158 | 0x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x01, 0x00, | ||
159 | 0x00, 0x00 }; | ||
160 | /**************************** | ||
161 | * "1" bitmap - for binary | ||
162 | ****************************/ | ||
163 | static unsigned char bitmap_1[] = { | ||
164 | 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
165 | 0x00, 0x00, | ||
166 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
167 | 0x00, 0x00, | ||
168 | 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, | ||
169 | 0x06, 0x00 }; | ||
170 | /**************************** | ||
171 | * PM indicator (moon + text) | ||
172 | ****************************/ | ||
173 | static unsigned char pm[] = { 0xFF,0xFF,0x33,0x33,0x33,0x1E,0x0C,0x00,0xFF,0xFF,0x06,0x0C,0x06,0xFF,0xFF }; | ||
174 | /**************************** | ||
175 | * AM Indicator (sun and text | ||
176 | ****************************/ | ||
177 | static unsigned char am[] = { 0xFE,0xFF,0x1B,0x1B,0xFF,0xFE,0x00,0x00,0xFF,0xFF,0x06,0x0C,0x06,0xFF,0xFF }; | ||
178 | |||
179 | /***************************************** | ||
180 | * We've got 4 different clock logos... | ||
181 | * The currently used one is #4, | ||
182 | * "clockbox" -- the others are kept here | ||
183 | * in case the logo selector is ever | ||
184 | * brought back or we want to switch.. | ||
185 | ****************************************/ | ||
186 | /* Logo #1 - Standard (by Zakk Roberts) */ | ||
187 | const unsigned char clocklogo_1[] = { | ||
188 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
189 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
190 | 0x00, 0xe0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
191 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
192 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
193 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
194 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, | ||
195 | 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
196 | 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, 0x00, | ||
197 | 0x80, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, | ||
198 | 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x3e, 0x3e, 0x3e, 0x1e, 0x0e, 0x00, 0x00, | ||
199 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf0, | ||
200 | 0xf8, 0xfc, 0xfc, 0x7e, 0x3e, 0x3e, 0x3e, 0x3e, 0xbe, 0xbe, 0x3e, 0x3e, 0x3e, | ||
201 | 0x3e, 0x7e, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x80, 0xe0, | ||
202 | 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, | ||
203 | 0x7e, 0x7e, 0x7e, 0x7e, 0x3e, 0x3e, 0x3e, 0x1e, 0x0e, 0x00, 0x00, 0x00, 0xff, | ||
204 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, | ||
205 | 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x00, | ||
206 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
207 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
208 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, | ||
209 | 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x3f, 0xc0, 0xc0, 0xc0, | ||
210 | 0xc0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, | ||
211 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
212 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, | ||
213 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc7, 0x83, 0x01, | ||
214 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
215 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, | ||
216 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
217 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, | ||
218 | 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, | ||
219 | 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, | ||
220 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, | ||
221 | 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, | ||
222 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, | ||
223 | 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, | ||
224 | 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, | ||
225 | 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x1c, 0x00, 0x00, | ||
226 | 0x00, 0x1f, 0x1f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x1f, 0x1f, | ||
227 | 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, | ||
228 | 0x1f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1f, | ||
229 | 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, | ||
230 | 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x1c, 0x00, 0x00, 0x00, 0x1f, | ||
231 | 0x1f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
232 | 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f | ||
233 | }; | ||
234 | |||
235 | /* Logo #2 - Digital Segments (by Zakk Roberts) */ | ||
236 | const unsigned char clocklogo_2[] = { | ||
237 | 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xfb, 0xf7, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, | ||
238 | 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
239 | 0xfe, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
240 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xfb, 0xf7, | ||
241 | 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf7, 0xfb, | ||
242 | 0xfd, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xfb, 0xf7, 0x0f, 0x0f, 0x0f, 0x0f, | ||
243 | 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, | ||
244 | 0x00, 0xfe, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | ||
245 | 0xe0, 0xf0, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, | ||
246 | 0x00, 0x00, 0x00, 0x00, 0xbf, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
247 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
248 | 0xbf, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
249 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x1f, 0x0f, 0x07, | ||
250 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0f, | ||
251 | 0x1f, 0xbf, 0x00, 0x00, 0x00, 0xbf, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00, | ||
252 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
253 | 0x00, 0xbf, 0x5f, 0xef, 0xf7, 0xf0, 0xf0, 0xf0, 0xe0, 0x40, 0x00, 0x06, 0x07, | ||
254 | 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
255 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
256 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
257 | 0xff, 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
258 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xfc, | ||
259 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, | ||
260 | 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, | ||
261 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
262 | 0x00, 0xff, 0xff, 0xfe, 0xfd, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x3c, | ||
263 | 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
264 | 0xc0, 0x00, 0x40, 0x40, 0x4f, 0x17, 0x1b, 0xdd, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, | ||
265 | 0x1e, 0x1e, 0x1e, 0xde, 0x1e, 0x5e, 0x5c, 0x58, 0x10, 0xc0, 0x00, 0x00, 0xc0, | ||
266 | 0x0f, 0x57, 0x5b, 0x5d, 0x1e, 0x1e, 0x1e, 0x1e, 0xde, 0x1e, 0x1e, 0x1e, 0x9e, | ||
267 | 0x1e, 0x1e, 0x1c, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xd7, 0x1b, 0x5d, | ||
268 | 0x5e, 0x5e, 0x1e, 0xde, 0x1e, 0x1e, 0xde, 0x1e, 0x5e, 0x5e, 0x5e, 0x1d, 0xdb, | ||
269 | 0x17, 0x0f, 0xc0, 0x00, 0x40, 0x4f, 0x57, 0x1b, 0x1d, 0x1e, 0x1e, 0xde, 0x1e, | ||
270 | 0x1e, 0x1e, 0x9e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1c, 0x18, 0x10, 0x00, 0x00, 0x00, | ||
271 | 0x00, 0x0f, 0x07, 0x03, 0x01, 0x40, 0x40, 0x40, 0x00, 0xc0, 0x00, 0x00, 0x00, | ||
272 | 0x00, 0xc1, 0x01, 0x41, 0x40, 0x40, 0x00, 0xc0, | ||
273 | 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, | ||
274 | 0x00, 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x1d, 0x00, 0x00, 0x1d, | ||
275 | 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x02, 0x00, 0x0d, | ||
276 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x02, | ||
277 | 0x00, 0x02, 0x05, 0x18, 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x1d, | ||
278 | 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, | ||
279 | 0x02, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
280 | 0x00, 0x00, 0x00, 0x1c, 0x00, 0x12, 0x10, 0x12, 0x00, 0x01, 0x00, 0x10, 0x10, | ||
281 | 0x00, 0x1d, 0x00, 0x14, 0x10, 0x11, 0x00, 0x1d | ||
282 | }; | ||
283 | |||
284 | /* Logo #3 - Electroplate (by Adam S. & Zakk Roberts) | ||
285 | * Definition: (N) any artifact that has been plated with a thin coat of metal by electrolysis */ | ||
286 | const unsigned char clocklogo_3[] = { | ||
287 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
288 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0xfc, | ||
289 | 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0x5c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
290 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfc, 0xf8, | ||
291 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
292 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
293 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x1c, 0x3c, 0xfc, 0xfc, 0xfc, | ||
294 | 0xfc, 0xf8, 0xe8, 0xb8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
295 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
296 | 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xb0, | ||
297 | 0xf0, 0xd0, 0x70, 0x50, 0x70, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, | ||
298 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x55, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
299 | 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xff, 0xff, 0xff, | ||
300 | 0xf8, 0xf0, 0xf0, 0xf0, 0xa0, 0xe0, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, | ||
301 | 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0x70, 0xf0, | ||
302 | 0xb0, 0xf0, 0x70, 0x70, 0x70, 0x60, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, | ||
303 | 0xff, 0xff, 0xff, 0xaa, 0xff, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, | ||
304 | 0xe0, 0xe0, 0x60, 0xe0, 0x20, 0x00, 0x00, 0x00, | ||
305 | 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaf, 0xfb, 0x0e, 0x01, 0x00, | ||
306 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, | ||
307 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x55, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfe, | ||
308 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x6b, 0x0f, 0x02, 0x01, 0x00, 0xff, 0xff, 0xff, | ||
309 | 0xe0, 0xe0, 0xe1, 0xe3, 0xef, 0xff, 0xff, 0xff, 0xfd, 0xf6, 0xf8, 0xe0, 0xe0, | ||
310 | 0xc0, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xfd, 0x0f, 0x01, 0x00, | ||
311 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, | ||
312 | 0xff, 0xff, 0xff, 0xaa, 0xff, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0x5f, 0xf7, | ||
313 | 0x3f, 0x05, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
314 | 0x00, 0x00, 0x03, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfe, 0xfb, 0xee, 0xf8, 0xd0, | ||
315 | 0xe0, 0xa0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, | ||
316 | 0xff, 0xff, 0xff, 0xff, 0x7f, 0xd5, 0xff, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, | ||
317 | 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfd, 0xf6, 0xf8, 0xf0, 0xf0, 0xf0, 0xf1, 0xf1, | ||
318 | 0xf1, 0xf1, 0xf1, 0xb9, 0xfd, 0x5f, 0x7f, 0x2f, 0x3f, 0x0b, 0x07, 0x01, 0x01, | ||
319 | 0x00, 0x00, 0x03, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfe, 0xfb, 0xee, 0xf8, 0xd0, | ||
320 | 0xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, | ||
321 | 0xff, 0x7f, 0xff, 0xaa, 0x7f, 0x03, 0x03, 0x0f, 0x3f, 0x7f, 0x7f, 0xff, 0xfd, | ||
322 | 0xf6, 0xfc, 0xd8, 0xe0, 0x40, 0x00, 0x00, 0x00, | ||
323 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, | ||
324 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
325 | 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
326 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, | ||
327 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
328 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, | ||
329 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
330 | 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
331 | 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
332 | }; | ||
333 | |||
334 | /* Logo #4 - "Clockbox" (by Adam S.) */ | ||
335 | const unsigned char clocklogo_4[] = { | ||
336 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, | ||
337 | 0x78, 0x78, 0x3c, 0x3c, 0xfc, 0xfc, 0xfc, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, | ||
338 | 0x1e, 0x3c, 0x3c, 0x3c, 0x7c, 0x7c, 0xf8, 0xf8, 0xf0, 0x30, 0x00, 0x00, 0x00, | ||
339 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
340 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
341 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
342 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
343 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
344 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
345 | 0x00, 0x00, 0xe0, 0xf8, 0xfc, 0xfe, 0xff, 0x3f, 0x3f, 0x7f, 0x73, 0xf1, 0xe0, | ||
346 | 0xe0, 0xc0, 0xc0, 0x80, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xe0, | ||
347 | 0xfe, 0xff, 0xff, 0x7f, 0x03, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
348 | 0x80, 0xf0, 0xf8, 0xfc, 0xfe, 0x3e, 0x0e, 0x0f, 0x07, 0x07, 0x0f, 0x1f, 0xfe, | ||
349 | 0xfe, 0xfc, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xf8, 0xfc, 0x7e, 0x1e, | ||
350 | 0x0f, 0x0f, 0x07, 0x0f, 0x0f, 0x0f, 0x1e, 0x1e, 0x00, 0x00, 0x00, 0x00, 0xf0, | ||
351 | 0xff, 0xff, 0xff, 0xff, 0xe1, 0xf0, 0xf8, 0x7c, 0x3e, 0x1f, 0x0f, 0x07, 0x03, | ||
352 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
353 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
354 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
355 | 0x01, 0x01, 0x0f, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x0e, 0x00, 0x40, 0x7c, 0x7f, | ||
356 | 0x7f, 0x7f, 0x77, 0x70, 0x70, 0x70, 0x70, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00, | ||
357 | 0x0f, 0x3f, 0x7f, 0x7f, 0xfd, 0xf0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf8, 0xff, 0xff, | ||
358 | 0xdf, 0xcf, 0xc3, 0xc0, 0xc0, 0x80, 0x80, 0x1f, 0x3f, 0x7f, 0x7f, 0xf8, 0xf0, | ||
359 | 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xfe, 0xff, | ||
360 | 0x7f, 0x3f, 0x07, 0x03, 0x0f, 0x3f, 0x7f, 0xfe, 0xfc, 0xf0, 0xc0, 0x00, 0x00, | ||
361 | 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
362 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
363 | 0x03, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfc, 0xf0, 0xe0, 0xc0, 0x80, 0x80, 0x80, | ||
364 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, | ||
365 | 0xc0, 0xe0, 0xf0, 0xf0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
366 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfe, 0xff, 0xff, 0x7f, 0x73, | ||
367 | 0x71, 0x71, 0xf9, 0xff, 0xff, 0xff, 0x8f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfc, | ||
368 | 0xfe, 0xff, 0xff, 0x07, 0x03, 0x01, 0x01, 0x01, 0x01, 0xc3, 0xff, 0xff, 0xff, | ||
369 | 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc7, 0xff, 0xff, 0xff, 0xfc, | ||
370 | 0xfe, 0xdf, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
371 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
372 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, | ||
373 | 0x07, 0x07, 0x0f, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, | ||
374 | 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
375 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x1f, 0x1f, 0x1f, 0x1f, 0x1c, 0x1c, | ||
376 | 0x1c, 0x1e, 0x1f, 0x0f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, | ||
377 | 0x0f, 0x1f, 0x1f, 0x1e, 0x1c, 0x1c, 0x1c, 0x1e, 0x1f, 0x0f, 0x07, 0x07, 0x01, | ||
378 | 0x00, 0x00, 0x00, 0x10, 0x1c, 0x1e, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x01, 0x07, | ||
379 | 0x1f, 0x1f, 0x1f, 0x1c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
380 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
42 | }; | 381 | }; |
43 | 382 | ||
383 | /* settings saved to this location */ | ||
44 | static char default_filename[] = "/.rockbox/rocks/.clock_settings"; | 384 | static char default_filename[] = "/.rockbox/rocks/.clock_settings"; |
45 | 385 | ||
386 | /* names of contributors */ | ||
387 | char* credits[] = { | ||
388 | "Zakk Roberts", | ||
389 | "Linus N. Feltzing", | ||
390 | "BlueChip", | ||
391 | "T.P. Diffenbach", | ||
392 | "David McIntyre", | ||
393 | "Justin D. Young", | ||
394 | "Lee Pilgrim", | ||
395 | "top_bloke", | ||
396 | "Adam S.", | ||
397 | "Scott Myran", | ||
398 | "Tony Kirk", | ||
399 | "Jason Tye" | ||
400 | }; | ||
401 | |||
402 | /* ...and how they helped */ | ||
403 | char* jobs[] = { | ||
404 | "Code", | ||
405 | "Code", | ||
406 | "Code", | ||
407 | "Code", | ||
408 | "Code", | ||
409 | "Code", | ||
410 | "Code", | ||
411 | "Code", | ||
412 | "Logo", | ||
413 | "Design", | ||
414 | "Design", | ||
415 | "Design" | ||
416 | }; | ||
417 | |||
418 | bool done = false; /* This bool is used for most of the while loops */ | ||
419 | int logo = 4; /* must be set before we show the logo */ | ||
420 | |||
421 | /************************************ | ||
422 | * This is saved to default_filename | ||
423 | ************************************/ | ||
46 | struct saved_settings | 424 | struct saved_settings |
47 | { | 425 | { |
48 | bool is_date_displayed; | 426 | /* general */ |
49 | bool are_digits_displayed; | 427 | int clock; /* 1: analog, 2: digital led, 3: digital lcd, 4: full, 5: binary */ |
50 | bool is_time_displayed; | 428 | bool backlight_on; |
51 | bool is_rect_displayed; | 429 | |
52 | bool analog_clock; | 430 | /* analog */ |
431 | bool analog_digits; | ||
432 | int analog_date; /* 0: off, 1: american, 2: european */ | ||
433 | bool analog_secondhand; | ||
434 | int analog_time; /* 0: off, 1: 24h, 2: 12h */ | ||
435 | |||
436 | /* digital */ | ||
437 | int digital_seconds; /* 0: off, 1: digital, 2: bar, 3: fullscreen */ | ||
438 | int digital_date; /* 0: off, 1: american, 2: european */ | ||
439 | bool digital_blinkcolon; | ||
440 | bool digital_12h; | ||
441 | |||
442 | /* LCD */ | ||
443 | int lcd_seconds; /* 0: off, 1: lcd, 2: bar, 3: fullscreen */ | ||
444 | int lcd_date; /* 0: off, 1: american, 2: european */ | ||
445 | bool lcd_blinkcolon; | ||
446 | bool lcd_12h; | ||
447 | |||
448 | /* fullscreen */ | ||
449 | bool fullscreen_border; | ||
450 | bool fullscreen_secondhand; | ||
451 | bool fullscreen_invertseconds; | ||
53 | } settings; | 452 | } settings; |
54 | 453 | ||
454 | /************************* | ||
455 | * Setting default values | ||
456 | *************************/ | ||
457 | void reset_settings(void) | ||
458 | { | ||
459 | /* general */ | ||
460 | settings.clock = 1; /* 1: analog, 2: digital led, 3: digital lcd, 4: full, 5: binary */ | ||
461 | settings.backlight_on = true; | ||
462 | |||
463 | /* analog */ | ||
464 | settings.analog_digits = false; | ||
465 | settings.analog_date = 0; /* 0: off, 1: american, 2: european */ | ||
466 | settings.analog_secondhand = true; | ||
467 | settings.analog_time = false; /* 0: off, 1: 24h, 2: 12h */ | ||
468 | |||
469 | /* digital */ | ||
470 | settings.digital_seconds = 1; /* 0: off, 1: digital, 2: bar, 3: fullscreen */ | ||
471 | settings.digital_date = 1; /* 0: off, 1: american, 2: european */ | ||
472 | settings.digital_blinkcolon = false; | ||
473 | settings.digital_12h = true; | ||
474 | |||
475 | /* LCD */ | ||
476 | settings.lcd_seconds = 1; /* 0: off, 1: lcd, 2: bar, 3: fullscreen */ | ||
477 | settings.lcd_date = 1; /* 0: off, 1: american, 2: european */ | ||
478 | settings.lcd_blinkcolon = false; | ||
479 | settings.lcd_12h = true; | ||
480 | |||
481 | /* fullscreen */ | ||
482 | settings.fullscreen_border = true; | ||
483 | settings.fullscreen_secondhand = true; | ||
484 | settings.fullscreen_invertseconds = false; | ||
485 | } | ||
55 | 486 | ||
487 | /********************************* | ||
488 | * Saves "saved_settings" to disk | ||
489 | *********************************/ | ||
56 | void save_settings(void) | 490 | void save_settings(void) |
57 | { | 491 | { |
492 | rb->lcd_clear_display(); | ||
493 | |||
494 | show_logo(true, true); | ||
495 | rb->lcd_puts(0, 7, "Saving..."); | ||
496 | |||
497 | rb->lcd_update(); | ||
498 | |||
58 | int fd; | 499 | int fd; |
59 | |||
60 | fd = rb->creat(default_filename, O_WRONLY); | 500 | fd = rb->creat(default_filename, O_WRONLY); |
501 | |||
61 | if(fd >= 0) | 502 | if(fd >= 0) |
62 | { | 503 | { |
63 | rb->write (fd, &settings, sizeof(struct saved_settings)); | 504 | rb->write (fd, &settings, sizeof(struct saved_settings)); |
64 | rb->close(fd); | 505 | rb->close(fd); |
506 | rb->lcd_puts(0, 7, "Save Succeeded"); | ||
65 | } | 507 | } |
66 | else | 508 | else |
67 | { | 509 | rb->lcd_puts(0, 7, "Save Failed"); |
68 | rb->splash(HZ, true, "Setting save failed"); | 510 | |
69 | } | 511 | rb->lcd_update(); |
512 | |||
513 | rb->sleep(HZ); | ||
514 | |||
515 | exit_logo(); | ||
70 | } | 516 | } |
71 | 517 | ||
518 | /*********************************** | ||
519 | * Loads "saved_settings" from disk | ||
520 | ***********************************/ | ||
72 | void load_settings(void) | 521 | void load_settings(void) |
73 | { | 522 | { |
74 | int fd; | 523 | int fd; |
75 | fd = rb->open(default_filename, O_RDONLY); | 524 | fd = rb->open(default_filename, O_RDONLY); |
76 | 525 | ||
77 | /* if file exists, then load. */ | 526 | rb->lcd_setfont(FONT_SYSFIXED); |
78 | if(fd >= 0) | 527 | |
528 | rb->lcd_puts(0, 6, "Clock v2.2"); | ||
529 | |||
530 | if(fd >= 0) /* does file exist? */ | ||
79 | { | 531 | { |
80 | rb->read (fd, &settings, sizeof(struct saved_settings)); | 532 | if(rb->filesize(fd) == sizeof(struct saved_settings)) /* if so, is it the right size? */ |
81 | rb->close(fd); | 533 | { |
534 | rb->lcd_puts(0, 7, "Loading..."); | ||
535 | rb->read(fd, &settings, sizeof(struct saved_settings)); | ||
536 | rb->close(fd); | ||
537 | show_logo(true, true); | ||
538 | rb->lcd_puts(0, 6, "Clock v2.2"); | ||
539 | rb->lcd_puts(0, 7, "Loaded settings"); | ||
540 | } | ||
541 | else /* bail out */ | ||
542 | { | ||
543 | rb->lcd_puts(0, 7, "Old settings file"); | ||
544 | reset_settings(); | ||
545 | } | ||
546 | } | ||
547 | else /* bail out */ | ||
548 | { | ||
549 | rb->lcd_puts(0, 7, "Can't find settings"); | ||
550 | reset_settings(); | ||
551 | } | ||
552 | |||
553 | rb->lcd_update(); | ||
554 | |||
555 | rb->sleep(HZ*2); | ||
556 | |||
557 | exit_logo(); | ||
558 | } | ||
559 | |||
560 | /************************************************************** | ||
561 | * 7-Segment LED/LCD imitation code, by Linus Nielson Feltzing | ||
562 | **************************************************************/ | ||
563 | /* | ||
564 | a 0 b | ||
565 | #########c | ||
566 | # #` | ||
567 | # # | ||
568 | 1# #2 | ||
569 | # # | ||
570 | # 3 # | ||
571 | c ######### d | ||
572 | # # | ||
573 | # # | ||
574 | 4# #5 | ||
575 | # # | ||
576 | # 6 # | ||
577 | e ######### f | ||
578 | */ | ||
579 | static unsigned int point_coords[6][2] = | ||
580 | { | ||
581 | {0, 0}, /* a */ | ||
582 | {1, 0}, /* b */ | ||
583 | {0, 1}, /* c */ | ||
584 | {1, 1}, /* d */ | ||
585 | {0, 2}, /* e */ | ||
586 | {1, 2} /* f */ | ||
587 | }; | ||
588 | |||
589 | /********************************************* | ||
590 | * The end points (a-f) for each segment line | ||
591 | *********************************************/ | ||
592 | static unsigned int seg_points[7][2] = | ||
593 | { | ||
594 | {0,1}, /* a to b */ | ||
595 | {0,2}, /* a to c */ | ||
596 | {1,3}, /* b to d */ | ||
597 | {2,3}, /* c to d */ | ||
598 | {2,4}, /* c to e */ | ||
599 | {3,5}, /* d to f */ | ||
600 | {4,5} /* e to f */ | ||
601 | }; | ||
602 | |||
603 | /*********************************************************************** | ||
604 | * Lists that tell which segments (0-6) to enable for each digit (0-9), | ||
605 | * the list is terminated with -1 | ||
606 | ***********************************************************************/ | ||
607 | static int digit_segs[10][8] = | ||
608 | { | ||
609 | {0,1,2,4,5,6, -1}, /* 0 */ | ||
610 | {2,5, -1}, /* 1 */ | ||
611 | {0,2,3,4,6, -1}, /* 2 */ | ||
612 | {0,2,3,5,6, -1}, /* 3 */ | ||
613 | {1,2,3,5, -1}, /* 4 */ | ||
614 | {0,1,3,5,6, -1}, /* 5 */ | ||
615 | {0,1,3,4,5,6, -1}, /* 6 */ | ||
616 | {0,2,5, -1}, /* 7 */ | ||
617 | {0,1,2,3,4,5,6, -1}, /* 8 */ | ||
618 | {0,1,2,3,5,6, -1} /* 9 */ | ||
619 | }; | ||
620 | |||
621 | /************************************ | ||
622 | * Draws one segment - LED imitation | ||
623 | ************************************/ | ||
624 | void draw_seg_led(int seg, int x, int y, int width, int height) | ||
625 | { | ||
626 | int p1 = seg_points[seg][0]; | ||
627 | int p2 = seg_points[seg][1]; | ||
628 | int x1 = point_coords[p1][0]; | ||
629 | int y1 = point_coords[p1][1]; | ||
630 | int x2 = point_coords[p2][0]; | ||
631 | int y2 = point_coords[p2][1]; | ||
632 | |||
633 | /* It draws parallel lines of different lengths for thicker segments */ | ||
634 | if(seg == 0 || seg == 3 || seg == 6) | ||
635 | { | ||
636 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2, | ||
637 | x + x2 * width - 1 , y + y2 * height / 2); | ||
638 | |||
639 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 - 1, | ||
640 | x + x2 * width - 2, y + y2 * height / 2 - 1); | ||
641 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 1, | ||
642 | x + x2 * width - 2, y + y2 * height / 2 + 1); | ||
643 | |||
644 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 - 2, | ||
645 | x + x2 * width - 3, y + y2 * height / 2 - 2); | ||
646 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 + 2, | ||
647 | x + x2 * width - 3, y + y2 * height / 2 + 2); | ||
648 | } | ||
649 | else | ||
650 | { | ||
651 | rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 + 1, | ||
652 | x + x2 * width , y + y2 * height / 2 - 1); | ||
653 | |||
654 | rb->lcd_drawline(x + x1 * width - 1, y + y1 * height / 2 + 2, | ||
655 | x + x2 * width - 1, y + y2 * height / 2 - 2); | ||
656 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2 + 2, | ||
657 | x + x2 * width + 1, y + y2 * height / 2 - 2); | ||
658 | |||
659 | rb->lcd_drawline(x + x1 * width - 2, y + y1 * height / 2 + 3, | ||
660 | x + x2 * width - 2, y + y2 * height / 2 - 3); | ||
661 | |||
662 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 3, | ||
663 | x + x2 * width + 2, y + y2 * height / 2 - 3); | ||
664 | } | ||
665 | } | ||
666 | |||
667 | /************************************ | ||
668 | * Draws one segment - LCD imitation | ||
669 | ************************************/ | ||
670 | void draw_seg_lcd(int seg, int x, int y, int width, int height) | ||
671 | { | ||
672 | int p1 = seg_points[seg][0]; | ||
673 | int p2 = seg_points[seg][1]; | ||
674 | int x1 = point_coords[p1][0]; | ||
675 | int y1 = point_coords[p1][1]; | ||
676 | int x2 = point_coords[p2][0]; | ||
677 | int y2 = point_coords[p2][1]; | ||
678 | |||
679 | if(seg == 0) | ||
680 | { | ||
681 | rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 - 1, | ||
682 | x + x2 * width, y + y2 * height / 2 - 1); | ||
683 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2, | ||
684 | x + x2 * width - 1, y + y2 * height / 2); | ||
685 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 1, | ||
686 | x + x2 * width - 2, y + y2 * height / 2 + 1); | ||
687 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 + 2, | ||
688 | x + x2 * width - 3, y + y2 * height / 2 + 2); | ||
689 | } | ||
690 | else if(seg == 3) | ||
691 | { | ||
692 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2, | ||
693 | x + x2 * width - 1, y + y2 * height / 2); | ||
694 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 - 1, | ||
695 | x + x2 * width - 2, y + y2 * height / 2 - 1); | ||
696 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 1, | ||
697 | x + x2 * width - 2, y + y2 * height / 2 + 1); | ||
698 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 - 2, | ||
699 | x + x2 * width - 3, y + y2 * height / 2 - 2); | ||
700 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 + 2, | ||
701 | x + x2 * width - 3, y + y2 * height / 2 + 2); | ||
702 | } | ||
703 | else if(seg == 6) | ||
704 | { | ||
705 | rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 + 1, | ||
706 | x + x2 * width, y + y2 * height / 2 + 1); | ||
707 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2, | ||
708 | x + x2 * width - 1, y + y2 * height / 2); | ||
709 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 - 1, | ||
710 | x + x2 * width - 2, y + y2 * height / 2 - 1); | ||
711 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 - 2, | ||
712 | x + x2 * width - 3, y + y2 * height / 2 - 2); | ||
713 | |||
714 | } | ||
715 | else if(seg == 1 || seg == 4) | ||
716 | { | ||
717 | rb->lcd_drawline(x + x1 * width - 1, y + y1 * height / 2, | ||
718 | x + x2 * width - 1, y + y2 * height / 2); | ||
719 | rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 + 1, | ||
720 | x + x2 * width, y + y2 * height / 2 - 1); | ||
721 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2 + 2, | ||
722 | x + x2 * width + 1, y + y2 * height / 2 - 2); | ||
723 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 3, | ||
724 | x + x2 * width + 2, y + y2 * height / 2 - 3); | ||
725 | } | ||
726 | else if(seg == 2 || seg == 5) | ||
727 | { | ||
728 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2, | ||
729 | x + x2 * width + 1, y + y2 * height / 2); | ||
730 | rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 + 1, | ||
731 | x + x2 * width, y + y2 * height / 2 - 1); | ||
732 | rb->lcd_drawline(x + x1 * width - 1, y + y1 * height / 2 + 2, | ||
733 | x + x2 * width - 1, y + y2 * height / 2 - 2); | ||
734 | rb->lcd_drawline(x + x1 * width - 2, y + y1 * height / 2 + 3, | ||
735 | x + x2 * width - 2, y + y2 * height / 2 - 3); | ||
736 | } | ||
737 | } | ||
738 | |||
739 | /****************** | ||
740 | * Draws one digit | ||
741 | ******************/ | ||
742 | void draw_7seg_digit(int digit, int x, int y, int width, int height, bool lcd_display) | ||
743 | { | ||
744 | int i; | ||
745 | int c; | ||
746 | |||
747 | for(i = 0;digit_segs[digit][i] >= 0;i++) | ||
748 | { | ||
749 | c = digit_segs[digit][i]; | ||
750 | |||
751 | if(!lcd_display) | ||
752 | draw_seg_led(c, x, y, width, height); | ||
753 | else | ||
754 | draw_seg_lcd(c, x, y, width, height); | ||
755 | } | ||
756 | } | ||
757 | |||
758 | /****************************************************** | ||
759 | * Draws the entire 7-segment hour-minute time display | ||
760 | ******************************************************/ | ||
761 | void draw_7seg_time(int hour, int minute, int x, int y, int width, int height, | ||
762 | bool colon, bool lcd) | ||
763 | { | ||
764 | int xpos = x; | ||
765 | |||
766 | /* Draw PM indicator */ | ||
767 | if(settings.digital_12h) | ||
768 | { | ||
769 | if(hour > 12) | ||
770 | rb->lcd_bitmap(pm, 97, 55, 15, 8, true); | ||
771 | else | ||
772 | rb->lcd_bitmap(am, 1, 55, 15, 8, true); | ||
773 | } | ||
774 | |||
775 | /* Now change to 12H mode if requested */ | ||
776 | if(settings.digital_12h) | ||
777 | if(hour > 12) | ||
778 | hour -= 12; | ||
779 | |||
780 | draw_7seg_digit(hour / 10, xpos, y, width, height, lcd); | ||
781 | xpos += width + 6; | ||
782 | draw_7seg_digit(hour % 10, xpos, y, width, height, lcd); | ||
783 | xpos += width + 6; | ||
784 | |||
785 | if(colon) | ||
786 | { | ||
787 | rb->lcd_drawline(xpos, y + height/3 + 2, | ||
788 | xpos, y + height/3 + 2); | ||
789 | rb->lcd_drawline(xpos+1, y + height/3 + 1, | ||
790 | xpos+1, y + height/3 + 3); | ||
791 | rb->lcd_drawline(xpos+2, y + height/3, | ||
792 | xpos+2, y + height/3 + 4); | ||
793 | rb->lcd_drawline(xpos+3, y + height/3 + 1, | ||
794 | xpos+3, y + height/3 + 3); | ||
795 | rb->lcd_drawline(xpos+4, y + height/3 + 2, | ||
796 | xpos+4, y + height/3 + 2); | ||
797 | |||
798 | rb->lcd_drawline(xpos, y + height-height/3 + 2, | ||
799 | xpos, y + height-height/3 + 2); | ||
800 | rb->lcd_drawline(xpos+1, y + height-height/3 + 1, | ||
801 | xpos+1, y + height-height/3 + 3); | ||
802 | rb->lcd_drawline(xpos+2, y + height-height/3, | ||
803 | xpos+2, y + height-height/3 + 4); | ||
804 | rb->lcd_drawline(xpos+3, y + height-height/3 + 1, | ||
805 | xpos+3, y + height-height/3 + 3); | ||
806 | rb->lcd_drawline(xpos+4, y + height-height/3 + 2, | ||
807 | xpos+4, y + height-height/3 + 2); | ||
808 | } | ||
809 | |||
810 | xpos += 12; | ||
811 | |||
812 | draw_7seg_digit(minute / 10, xpos, y, width, height, lcd); | ||
813 | xpos += width + 6; | ||
814 | draw_7seg_digit(minute % 10, xpos, y, width, height, lcd); | ||
815 | xpos += width + 6; | ||
816 | } | ||
817 | |||
818 | /************** | ||
819 | * Binary mode | ||
820 | **************/ | ||
821 | void binary(int hour, int minute, int second) | ||
822 | { | ||
823 | /* temporary modifiable versions of ints */ | ||
824 | int temphour = hour; | ||
825 | int tempmin = minute; | ||
826 | int tempsec = second; | ||
827 | |||
828 | rb->lcd_clear_display(); | ||
829 | |||
830 | /***************** | ||
831 | * HOUR | ||
832 | *****************/ | ||
833 | if(temphour >= 32) | ||
834 | { | ||
835 | rb->lcd_bitmap(bitmap_1, 0, 1, 15, 20, true); | ||
836 | temphour -= 32; | ||
837 | } | ||
838 | else | ||
839 | rb->lcd_bitmap(bitmap_0, 0, 1, 15, 20, true); | ||
840 | if(temphour >= 16) | ||
841 | { | ||
842 | rb->lcd_bitmap(bitmap_1, 19, 1, 15, 20, true); | ||
843 | temphour -= 16; | ||
844 | } | ||
845 | else | ||
846 | rb->lcd_bitmap(bitmap_0, 19, 1, 15, 20, true); | ||
847 | if(temphour >= 8) | ||
848 | { | ||
849 | rb->lcd_bitmap(bitmap_1, 38, 1, 15, 20, true); | ||
850 | temphour -= 8; | ||
851 | } | ||
852 | else | ||
853 | rb->lcd_bitmap(bitmap_0, 38, 1, 15, 20, true); | ||
854 | if(temphour >= 4) | ||
855 | { | ||
856 | rb->lcd_bitmap(bitmap_1, 57, 1, 15, 20, true); | ||
857 | temphour -= 4; | ||
858 | } | ||
859 | else | ||
860 | rb->lcd_bitmap(bitmap_0, 57, 1, 15, 20, true); | ||
861 | if(temphour >= 2) | ||
862 | { | ||
863 | rb->lcd_bitmap(bitmap_1, 76, 1, 15, 20, true); | ||
864 | temphour -= 2; | ||
865 | } | ||
866 | else | ||
867 | rb->lcd_bitmap(bitmap_0, 76, 1, 15, 20, true); | ||
868 | if(temphour >= 1) | ||
869 | { | ||
870 | rb->lcd_bitmap(bitmap_1, 95, 1, 15, 20, true); | ||
871 | temphour -= 1; | ||
872 | } | ||
873 | else | ||
874 | rb->lcd_bitmap(bitmap_0, 95, 1, 15, 20, true); | ||
875 | |||
876 | /**************** | ||
877 | * MINUTES | ||
878 | ****************/ | ||
879 | if(tempmin >= 32) | ||
880 | { | ||
881 | rb->lcd_bitmap(bitmap_1, 0, 21, 15, 20, true); | ||
882 | tempmin -= 32; | ||
883 | } | ||
884 | else | ||
885 | rb->lcd_bitmap(bitmap_0, 0, 21, 15, 20, true); | ||
886 | if(tempmin >= 16) | ||
887 | { | ||
888 | rb->lcd_bitmap(bitmap_1, 19, 21, 15, 20, true); | ||
889 | tempmin -= 16; | ||
890 | } | ||
891 | else | ||
892 | rb->lcd_bitmap(bitmap_0, 19, 21, 15, 20, true); | ||
893 | if(tempmin >= 8) | ||
894 | { | ||
895 | rb->lcd_bitmap(bitmap_1, 38, 21, 15, 20, true); | ||
896 | tempmin -= 8; | ||
897 | } | ||
898 | else | ||
899 | rb->lcd_bitmap(bitmap_0, 38, 21, 15, 20, true); | ||
900 | if(tempmin >= 4) | ||
901 | { | ||
902 | rb->lcd_bitmap(bitmap_1, 57, 21, 15, 20, true); | ||
903 | tempmin -= 4; | ||
904 | } | ||
905 | else | ||
906 | rb->lcd_bitmap(bitmap_0, 57, 21, 15, 20, true); | ||
907 | if(tempmin >= 2) | ||
908 | { | ||
909 | rb->lcd_bitmap(bitmap_1, 76, 21, 15, 20, true); | ||
910 | tempmin -= 2; | ||
911 | } | ||
912 | else | ||
913 | rb->lcd_bitmap(bitmap_0, 76, 21, 15, 20, true); | ||
914 | if(tempmin >= 1) | ||
915 | { | ||
916 | rb->lcd_bitmap(bitmap_1, 95, 21, 15, 20, true); | ||
917 | tempmin -= 1; | ||
918 | } | ||
919 | else | ||
920 | rb->lcd_bitmap(bitmap_0, 95, 21, 15, 20, true); | ||
921 | |||
922 | /**************** | ||
923 | * SECONDS | ||
924 | ****************/ | ||
925 | if(tempsec >= 32) | ||
926 | { | ||
927 | rb->lcd_bitmap(bitmap_1, 0, 42, 15, 20, true); | ||
928 | tempsec -= 32; | ||
929 | } | ||
930 | else | ||
931 | rb->lcd_bitmap(bitmap_0, 0, 42, 15, 20, true); | ||
932 | if(tempsec >= 16) | ||
933 | { | ||
934 | rb->lcd_bitmap(bitmap_1, 19, 42, 15, 20, true); | ||
935 | tempsec -= 16; | ||
936 | } | ||
937 | else | ||
938 | rb->lcd_bitmap(bitmap_0, 19, 42, 15, 20, true); | ||
939 | if(tempsec >= 8) | ||
940 | { | ||
941 | rb->lcd_bitmap(bitmap_1, 38, 42, 15, 20, true); | ||
942 | tempsec -= 8; | ||
943 | } | ||
944 | else | ||
945 | rb->lcd_bitmap(bitmap_0, 38, 42, 15, 20, true); | ||
946 | if(tempsec >= 4) | ||
947 | { | ||
948 | rb->lcd_bitmap(bitmap_1, 57, 42, 15, 20, true); | ||
949 | tempsec -= 4; | ||
950 | } | ||
951 | else | ||
952 | rb->lcd_bitmap(bitmap_0, 57, 42, 15, 20, true); | ||
953 | if(tempsec >= 2) | ||
954 | { | ||
955 | rb->lcd_bitmap(bitmap_1, 76, 42, 15, 20, true); | ||
956 | tempsec -= 2; | ||
957 | } | ||
958 | else | ||
959 | rb->lcd_bitmap(bitmap_0, 76, 42, 15, 20, true); | ||
960 | if(tempsec >= 1) | ||
961 | { | ||
962 | rb->lcd_bitmap(bitmap_1, 95, 42, 15, 20, true); | ||
963 | tempsec -= 1; | ||
964 | } | ||
965 | else | ||
966 | rb->lcd_bitmap(bitmap_0, 95, 42, 15, 20, true); | ||
967 | |||
968 | rb->lcd_update(); | ||
969 | } | ||
970 | |||
971 | /***************** | ||
972 | * Shows the logo | ||
973 | *****************/ | ||
974 | void show_logo(bool animate, bool show_clock_text) | ||
975 | { | ||
976 | int x_position; | ||
977 | unsigned char *clogo = 0; | ||
978 | |||
979 | /* decide which logo we're using - usually #4 */ | ||
980 | if(logo == 1) | ||
981 | clogo = (unsigned char *)clocklogo_1; | ||
982 | else if(logo == 2) | ||
983 | clogo = (unsigned char *)clocklogo_2; | ||
984 | else if(logo == 3) | ||
985 | clogo = (unsigned char *)clocklogo_3; | ||
986 | else | ||
987 | clogo = (unsigned char *)clocklogo_4; | ||
988 | |||
989 | /* animate logo */ | ||
990 | if(animate) | ||
991 | { | ||
992 | /* move down the screen */ | ||
993 | for(x_position = 0; x_position <= 25; x_position++) | ||
994 | { | ||
995 | rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); | ||
996 | rb->lcd_clearline(0, x_position/2+38, 111, x_position/2+38); | ||
997 | rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); | ||
998 | if(show_clock_text) | ||
999 | rb->lcd_puts(0, 6, "Clock v2.2"); | ||
1000 | rb->lcd_update(); | ||
1001 | } | ||
1002 | /* bounce back up a little */ | ||
1003 | for(x_position = 25; x_position >= 18; x_position--) | ||
1004 | { | ||
1005 | rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); | ||
1006 | rb->lcd_clearline(0, x_position/2+38, 111, x_position/2+38); | ||
1007 | rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); | ||
1008 | if(show_clock_text) | ||
1009 | rb->lcd_puts(0, 6, "Clock v2.2"); | ||
1010 | rb->lcd_update(); | ||
1011 | } | ||
1012 | /* and go back down again */ | ||
1013 | for(x_position = 18; x_position <= 20; x_position++) | ||
1014 | { | ||
1015 | rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); | ||
1016 | rb->lcd_clearline(0, x_position/2+38, 111, x_position/2+38); | ||
1017 | rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); | ||
1018 | if(show_clock_text) | ||
1019 | rb->lcd_puts(0, 6, "Clock v2.2"); | ||
1020 | rb->lcd_update(); | ||
1021 | } | ||
1022 | } | ||
1023 | else /* don't animate, just show */ | ||
1024 | { | ||
1025 | rb->lcd_bitmap(clogo, 0, 10, 112, 37, true); | ||
1026 | rb->lcd_update(); | ||
1027 | } | ||
1028 | } | ||
1029 | |||
1030 | /********************* | ||
1031 | * Logo flies off lcd | ||
1032 | *********************/ | ||
1033 | void exit_logo(void) | ||
1034 | { | ||
1035 | int x_position; | ||
1036 | |||
1037 | unsigned char *clogo = 0; | ||
1038 | |||
1039 | if(logo == 1) | ||
1040 | clogo = (unsigned char *)clocklogo_1; | ||
1041 | else if(logo == 2) | ||
1042 | clogo = (unsigned char *)clocklogo_2; | ||
1043 | else if(logo == 3) | ||
1044 | clogo = (unsigned char *)clocklogo_3; | ||
1045 | else | ||
1046 | clogo = (unsigned char *)clocklogo_4; | ||
1047 | |||
1048 | /* fly downwards */ | ||
1049 | for(x_position = 20; x_position <= 128; x_position++) | ||
1050 | { | ||
1051 | rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); | ||
1052 | rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); | ||
1053 | rb->lcd_update(); | ||
1054 | } | ||
1055 | } | ||
1056 | |||
1057 | /******************** | ||
1058 | * Rolls the credits | ||
1059 | ********************/ | ||
1060 | /* The following function is pretty confusing, so | ||
1061 | * it's extra well commented. */ | ||
1062 | bool roll_credits(void) | ||
1063 | { | ||
1064 | int j, namepos, jobpos; /* namepos/jobpos are x coords for strings of text */ | ||
1065 | int btn; | ||
1066 | int numnames = 12; /* amount of people in the credits array */ | ||
1067 | int pause; | ||
1068 | |||
1069 | /* used to center the text */ | ||
1070 | char name[20]; | ||
1071 | char job[15]; | ||
1072 | int name_w, name_h; | ||
1073 | int job_w, job_h; | ||
1074 | |||
1075 | /* Shows "[Credits] X/X" */ | ||
1076 | char elapsednames[16]; | ||
1077 | |||
1078 | for(j=0; j < numnames; j++) | ||
1079 | { | ||
1080 | rb->lcd_clear_display(); | ||
1081 | |||
1082 | show_logo(false, false); | ||
1083 | |||
1084 | rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", j+1, numnames); | ||
1085 | rb->lcd_puts(0, 0, elapsednames); | ||
1086 | |||
1087 | /* used to center the text */ | ||
1088 | rb->snprintf(name, sizeof(name), "%s", credits[j]); | ||
1089 | rb->snprintf(job, sizeof(job), "%s", jobs[j]); | ||
1090 | rb->lcd_getstringsize(name, &name_w, &name_h); | ||
1091 | rb->lcd_getstringsize(job, &job_w, &job_h); | ||
1092 | |||
1093 | /* line 1 flies in */ | ||
1094 | for (namepos=0; namepos < LCD_WIDTH/2-name_w/2; namepos++) | ||
1095 | { | ||
1096 | rb->lcd_clearrect(0, 48, 112, 8); /* clear any trails left behind */ | ||
1097 | rb->lcd_putsxy(namepos, 48, name); /* show their name */ | ||
1098 | rb->lcd_update(); | ||
1099 | |||
1100 | /* exit on keypress */ | ||
1101 | btn = rb->button_get(false); | ||
1102 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
1103 | return false; | ||
1104 | } | ||
1105 | |||
1106 | /* now line 2 flies in */ | ||
1107 | for(jobpos=LCD_WIDTH; jobpos > LCD_WIDTH/2-(job_w+2)/2; jobpos--) /* we use (job_w+2) to ensure it fits on the LCD */ | ||
1108 | { | ||
1109 | rb->lcd_clearrect(0, 56, 112, 8); /* clear trails */ | ||
1110 | rb->lcd_putsxy(jobpos, 56, job); /* show their job */ | ||
1111 | rb->lcd_update(); | ||
1112 | |||
1113 | /* exit on keypress */ | ||
1114 | btn = rb->button_get(false); | ||
1115 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
1116 | return false; | ||
1117 | } | ||
1118 | |||
1119 | /* pause (2s) and scan for button presses */ | ||
1120 | for (pause = 0; pause < 10; pause++) | ||
1121 | { | ||
1122 | rb->sleep((HZ*2)/10); /* wait a moment */ | ||
1123 | |||
1124 | btn = rb->button_get(false); | ||
1125 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
1126 | return false; | ||
1127 | } | ||
1128 | |||
1129 | /* fly out both lines at same time */ | ||
1130 | namepos=(LCD_WIDTH/2-name_w/2)+5; | ||
1131 | jobpos=(LCD_WIDTH/2-(job_w+2)/2)-5; | ||
1132 | while(namepos<LCD_WIDTH || jobpos > 0-job_w) | ||
1133 | { | ||
1134 | rb->lcd_clearrect(0, 48, 112, 16); /* clear trails */ | ||
1135 | rb->lcd_putsxy(namepos, 48, name); | ||
1136 | rb->lcd_putsxy(jobpos, 56, job); | ||
1137 | rb->lcd_update(); | ||
1138 | |||
1139 | /* exit on keypress */ | ||
1140 | btn = rb->button_get(false); | ||
1141 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
1142 | return false; | ||
1143 | |||
1144 | namepos++; | ||
1145 | jobpos--; | ||
1146 | } | ||
1147 | |||
1148 | /* pause (.5s) */ | ||
1149 | rb->sleep(HZ/2); | ||
1150 | |||
1151 | /* and scan for button presses */ | ||
1152 | btn = rb->button_get(false); | ||
1153 | if ( (!btn) && (!(btn&BUTTON_REL)) ) | ||
1154 | return false; | ||
1155 | } | ||
1156 | return true; | ||
1157 | } | ||
1158 | |||
1159 | /***************************************** | ||
1160 | * Shows the logo, then rolls the credits | ||
1161 | *****************************************/ | ||
1162 | bool show_credits(void) | ||
1163 | { | ||
1164 | int j = 0; | ||
1165 | int btn; | ||
1166 | |||
1167 | rb->lcd_clear_display(); | ||
1168 | |||
1169 | /* show the logo with an animation and the clock 2.2 text */ | ||
1170 | show_logo(true, true); | ||
1171 | |||
1172 | rb->lcd_puts(0, 7, "Credit Roll..."); | ||
1173 | |||
1174 | rb->lcd_update(); | ||
1175 | |||
1176 | /* pause while button scanning */ | ||
1177 | for (j = 0; j < 10; j++) | ||
1178 | { | ||
1179 | rb->sleep((HZ*2)/10); | ||
1180 | |||
1181 | btn = rb->button_get(false); | ||
1182 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
1183 | return false; | ||
1184 | } | ||
1185 | |||
1186 | /* then roll the credits */ | ||
1187 | roll_credits(); | ||
1188 | |||
1189 | return false; | ||
1190 | } | ||
1191 | |||
1192 | /******************* | ||
1193 | * F1 Screen - HELP | ||
1194 | *******************/ | ||
1195 | bool f1_screen(void) | ||
1196 | { | ||
1197 | done = false; | ||
1198 | |||
1199 | while (!done) | ||
1200 | { | ||
1201 | rb->lcd_clear_display(); | ||
1202 | |||
1203 | /* page one */ | ||
1204 | if(screen == 1) | ||
1205 | { | ||
1206 | rb->lcd_puts(0, 0, "Using Clock v2.2:"); | ||
1207 | rb->lcd_puts(0, 1, "To navigate this"); | ||
1208 | rb->lcd_puts(0, 2, "help, use LEFT and"); | ||
1209 | rb->lcd_puts(0, 3, "RIGHT. F1 returns"); | ||
1210 | rb->lcd_puts(0, 4, "you to the clock."); | ||
1211 | rb->lcd_puts(0, 6, ""); | ||
1212 | rb->lcd_puts(0, 7, "<< ---- 1/9 NEXT >>"); | ||
1213 | } | ||
1214 | else if(screen == 2) | ||
1215 | { | ||
1216 | rb->lcd_puts(0, 0, "At any mode, [F1]"); | ||
1217 | rb->lcd_puts(0, 1, "will show you this"); | ||
1218 | rb->lcd_puts(0, 2, "help screen. [F2]"); | ||
1219 | rb->lcd_puts(0, 3, "will start/stop"); | ||
1220 | rb->lcd_puts(0, 4, "the Counter. Hold"); | ||
1221 | rb->lcd_puts(0, 5, "F2 to reset the"); | ||
1222 | rb->lcd_puts(0, 6, "Counter."); | ||
1223 | rb->lcd_puts(0, 7, "<< BACK 2/9 NEXT >>"); | ||
1224 | } | ||
1225 | else if(screen == 3) | ||
1226 | { | ||
1227 | rb->lcd_puts(0, 0, "At any mode, [F3]"); | ||
1228 | rb->lcd_puts(0, 1, "opens the Options"); | ||
1229 | rb->lcd_puts(0, 2, "screen. In Options"); | ||
1230 | rb->lcd_puts(0, 3, "move the cursor"); | ||
1231 | rb->lcd_puts(0, 4, "with UP/DOWN and"); | ||
1232 | rb->lcd_puts(0, 5, "use PLAY to toggle"); | ||
1233 | rb->lcd_puts(0, 6, "selected option."); | ||
1234 | rb->lcd_puts(0, 7, "<< BACK 3/9 NEXT >>"); | ||
1235 | } | ||
1236 | else if(screen == 4) | ||
1237 | { | ||
1238 | rb->lcd_puts(0, 0, "[ON] at any mode"); | ||
1239 | rb->lcd_puts(0, 1, "will present you"); | ||
1240 | rb->lcd_puts(0, 2, "with a credits roll"); | ||
1241 | rb->lcd_puts(0, 3, "[PLAY] from any"); | ||
1242 | rb->lcd_puts(0, 4, "mode will show the"); | ||
1243 | rb->lcd_puts(0, 5, "MODE SELECTOR. Use"); | ||
1244 | rb->lcd_puts(0, 6, "UP/DOWN to select"); | ||
1245 | rb->lcd_puts(0, 7, "<< BACK 4/9 NEXT >>"); | ||
1246 | } | ||
1247 | else if(screen == 5) | ||
1248 | { | ||
1249 | rb->lcd_puts(0, 0, "a mode and PLAY to"); | ||
1250 | rb->lcd_puts(0, 1, "go to it."); | ||
1251 | rb->lcd_puts(0, 2, "_-=CLOCK MODES=-_"); | ||
1252 | rb->lcd_puts(0, 3, "*ANALOG: Shows a"); | ||
1253 | rb->lcd_puts(0, 4, "small round clock"); | ||
1254 | rb->lcd_puts(0, 5, "in the center of"); | ||
1255 | rb->lcd_puts(0, 6, "LCD. Options appear"); | ||
1256 | rb->lcd_puts(0, 7, "<< BACK 5/9 NEXT >>"); | ||
1257 | } | ||
1258 | else if(screen == 6) | ||
1259 | { | ||
1260 | rb->lcd_puts(0, 0, "around it."); | ||
1261 | rb->lcd_puts(0, 1, "*DIGITAL: Shows an"); | ||
1262 | rb->lcd_puts(0, 2, "LCD imitation with"); | ||
1263 | rb->lcd_puts(0, 3, "virtual 'segments'."); | ||
1264 | rb->lcd_puts(0, 4, "*LCD: Shows another"); | ||
1265 | rb->lcd_puts(0, 5, "imitation of an"); | ||
1266 | rb->lcd_puts(0, 6, "LCD display."); | ||
1267 | rb->lcd_puts(0, 7, "<< BACK 6/9 NEXT >>"); | ||
1268 | } | ||
1269 | else if(screen == 7) | ||
1270 | { | ||
1271 | rb->lcd_puts(0, 0, "*FULLSCREEN: Like"); | ||
1272 | rb->lcd_puts(0, 1, "Analog mode, but"); | ||
1273 | rb->lcd_puts(0, 2, "uses the whole LCD."); | ||
1274 | rb->lcd_puts(0, 3, "Less options are"); | ||
1275 | rb->lcd_puts(0, 4, "available in this"); | ||
1276 | rb->lcd_puts(0, 5, "mode."); | ||
1277 | rb->lcd_puts(0, 6, "*BINARY: Shows a"); | ||
1278 | rb->lcd_puts(0, 7, "<< BACK 7/9 NEXT >>"); | ||
1279 | } | ||
1280 | else if(screen == 8) | ||
1281 | { | ||
1282 | rb->lcd_puts(0, 0, "binary clock. For"); | ||
1283 | rb->lcd_puts(0, 1, "help on reading"); | ||
1284 | rb->lcd_puts(0, 2, "binary, see:"); | ||
1285 | rb->lcd_puts_scroll(0, 3, "http://en.wikipedia.org/wiki/Binary_numeral_system"); | ||
1286 | rb->lcd_puts(0, 4, "_-=OTHER KEYS=-_"); | ||
1287 | rb->lcd_puts(0, 5, "[DWN] will disable"); | ||
1288 | rb->lcd_puts(0, 6, "Rockbox's idle"); | ||
1289 | rb->lcd_puts(0, 7, "<< BACK 8/9 NEXT >>"); | ||
1290 | } | ||
1291 | else if(screen == 9) | ||
1292 | { | ||
1293 | rb->lcd_puts(0, 0, "poweroff feature."); | ||
1294 | rb->lcd_puts(0, 1, "[UP] will reenable"); | ||
1295 | rb->lcd_puts(0, 2, "it. [LEFT] will"); | ||
1296 | rb->lcd_puts(0, 3, "turn off the back-"); | ||
1297 | rb->lcd_puts(0, 4, " light, [RIGHT]"); | ||
1298 | rb->lcd_puts(0, 5, "will turn it on."); | ||
1299 | rb->lcd_puts(0, 6, "[OFF] exits plugin."); | ||
1300 | rb->lcd_puts(0, 7, "<< BACK 9/9 ---- >>"); | ||
1301 | } | ||
1302 | |||
1303 | rb->lcd_update(); | ||
1304 | |||
1305 | switch (rb->button_get(true)) | ||
1306 | { | ||
1307 | case BUTTON_F1: /* exit */ | ||
1308 | case BUTTON_OFF: | ||
1309 | done = true; | ||
1310 | break; | ||
1311 | |||
1312 | case BUTTON_LEFT: | ||
1313 | if(screen > 1) | ||
1314 | screen --; | ||
1315 | break; | ||
1316 | |||
1317 | case BUTTON_RIGHT: | ||
1318 | if(screen < 9) | ||
1319 | screen++; | ||
1320 | break; | ||
1321 | |||
1322 | case SYS_USB_CONNECTED: /* leave for usb */ | ||
1323 | return PLUGIN_USB_CONNECTED; | ||
1324 | rb->usb_screen(); | ||
1325 | break; | ||
1326 | } | ||
1327 | } | ||
1328 | return true; | ||
1329 | } | ||
1330 | |||
1331 | /************************** | ||
1332 | * F2 Screen - Pick a Logo | ||
1333 | * [[ NO LONGER USED ]] | ||
1334 | **************************/ | ||
1335 | void f2_screen(void) | ||
1336 | { | ||
1337 | rb->lcd_clear_display(); | ||
1338 | rb->splash(HZ, true, "LEFT/RIGHT to choose logo"); | ||
1339 | rb->lcd_update(); | ||
1340 | rb->lcd_clear_display(); | ||
1341 | rb->splash(HZ, true, "F2 to select and exit"); | ||
1342 | rb->lcd_update(); | ||
1343 | rb->lcd_clear_display(); | ||
1344 | |||
1345 | /* let's make sure that the logo isn't invalid */ | ||
1346 | if(logo > 4) | ||
1347 | logo = 1; | ||
1348 | |||
1349 | done = false; | ||
1350 | |||
1351 | while(!done) | ||
1352 | { | ||
1353 | show_logo(false, false); | ||
1354 | |||
1355 | rb->lcd_clearrect(0, 48, 112, 16); | ||
1356 | |||
1357 | if(logo == 1) | ||
1358 | { | ||
1359 | rb->lcd_puts(0, 0, "1) 'Default'"); | ||
1360 | rb->lcd_puts(0, 6, "By Zakk Roberts"); | ||
1361 | } | ||
1362 | else if(logo == 2) | ||
1363 | { | ||
1364 | rb->lcd_puts(0, 0, "2) 'Digital'"); | ||
1365 | rb->lcd_puts(0, 6, "By Zakk Roberts"); | ||
1366 | } | ||
1367 | else if(logo == 3) | ||
1368 | { | ||
1369 | rb->lcd_puts(0, 0, "3) 'Electroplate'"); | ||
1370 | rb->lcd_puts(0, 6, "By Adam S. and"); | ||
1371 | rb->lcd_puts(0, 7, "Zakk Roberts"); | ||
1372 | } | ||
1373 | else | ||
1374 | { | ||
1375 | rb->lcd_puts(0, 0, "4) 'Clockbox'"); | ||
1376 | rb->lcd_puts(0, 6, "By Adam S."); | ||
1377 | } | ||
1378 | |||
1379 | rb->lcd_update(); | ||
1380 | |||
1381 | switch(rb->button_get_w_tmo(HZ/4)) | ||
1382 | { | ||
1383 | case BUTTON_F2: | ||
1384 | case BUTTON_OFF: | ||
1385 | done = true; | ||
1386 | break; | ||
1387 | |||
1388 | case BUTTON_RIGHT: | ||
1389 | if(logo < 4) | ||
1390 | logo++; | ||
1391 | break; | ||
1392 | |||
1393 | case BUTTON_LEFT: | ||
1394 | if(logo > 1) | ||
1395 | logo--; | ||
1396 | break; | ||
1397 | } | ||
1398 | } | ||
1399 | } | ||
1400 | |||
1401 | /********************** | ||
1402 | * F3 Screen - OPTIONS | ||
1403 | **********************/ | ||
1404 | bool f3_screen(void) | ||
1405 | { | ||
1406 | done = false; | ||
1407 | |||
1408 | int invert_analog = 1; | ||
1409 | int invert_digital = 1; | ||
1410 | int invert_lcd = 1; | ||
1411 | int invert_fullscreen = 1; | ||
1412 | |||
1413 | while (!done) | ||
1414 | { | ||
1415 | rb->lcd_clear_display(); | ||
1416 | |||
1417 | if(settings.clock == 1) | ||
1418 | { | ||
1419 | rb->lcd_puts(0, 0, "OPTIONS (Analog)"); | ||
1420 | rb->lcd_puts(0, 1, "UP/DOWN & PLAY"); | ||
1421 | rb->lcd_puts(0, 2, "F3/OFF: Done"); | ||
1422 | rb->lcd_puts(2, 4, "Digits"); | ||
1423 | |||
1424 | if(settings.analog_date == 0) | ||
1425 | rb->lcd_puts(2, 5, "Date"); | ||
1426 | else if(settings.analog_date == 1) | ||
1427 | rb->lcd_puts(2, 5, "Date: American"); | ||
1428 | else | ||
1429 | rb->lcd_puts(2, 5, "Date: European"); | ||
1430 | |||
1431 | if(settings.analog_time == 0) | ||
1432 | rb->lcd_puts(2, 6, "Time Readout"); | ||
1433 | else if(settings.analog_time == 1) | ||
1434 | rb->lcd_puts(2, 6, "Time Readout 24h"); | ||
1435 | else | ||
1436 | rb->lcd_puts(2, 6, "Time Readout 12h"); | ||
1437 | |||
1438 | rb->lcd_puts(2, 7, "Second Hand"); | ||
1439 | |||
1440 | /* Draw checkboxes using the new checkbox() function */ | ||
1441 | rb->checkbox(1, 33, 8, 6, settings.analog_digits); | ||
1442 | if(settings.analog_date != 0) | ||
1443 | rb->checkbox(1, 41, 8, 6, true); | ||
1444 | else | ||
1445 | rb->checkbox(1, 41, 8, 6, false); | ||
1446 | rb->checkbox(1, 49, 8, 6, settings.analog_time); | ||
1447 | rb->checkbox(1, 57, 8, 6, settings.analog_secondhand); | ||
1448 | |||
1449 | /* Draw line selector */ | ||
1450 | switch(invert_analog) | ||
1451 | { | ||
1452 | case 1: | ||
1453 | rb->lcd_invertrect(0, 32, 112, 8); break; | ||
1454 | |||
1455 | case 2: | ||
1456 | rb->lcd_invertrect(0, 40, 112, 8); break; | ||
1457 | |||
1458 | case 3: | ||
1459 | rb->lcd_invertrect(0, 48, 112, 8); break; | ||
1460 | |||
1461 | case 4: | ||
1462 | rb->lcd_invertrect(0, 56, 112, 8); break; | ||
1463 | } | ||
1464 | |||
1465 | rb->lcd_update(); | ||
1466 | |||
1467 | switch(rb->button_get_w_tmo(HZ/4)) | ||
1468 | { | ||
1469 | case BUTTON_UP: | ||
1470 | if(invert_analog > 1) | ||
1471 | invert_analog--; | ||
1472 | else | ||
1473 | invert_analog = 4; | ||
1474 | break; | ||
1475 | |||
1476 | case BUTTON_DOWN: | ||
1477 | if(invert_analog < 4) | ||
1478 | invert_analog++; | ||
1479 | else | ||
1480 | invert_analog = 1; | ||
1481 | break; | ||
1482 | |||
1483 | case BUTTON_PLAY: | ||
1484 | if(invert_analog == 1) | ||
1485 | settings.analog_digits = !settings.analog_digits; | ||
1486 | else if(invert_analog == 2) | ||
1487 | { | ||
1488 | if(settings.analog_date < 2) | ||
1489 | settings.analog_date++; | ||
1490 | else | ||
1491 | settings.analog_date = 0; | ||
1492 | } | ||
1493 | else if(invert_analog == 3) | ||
1494 | { | ||
1495 | if(settings.analog_time < 2) | ||
1496 | settings.analog_time++; | ||
1497 | else | ||
1498 | settings.analog_time = 0; | ||
1499 | } | ||
1500 | else | ||
1501 | settings.analog_secondhand = !settings.analog_secondhand; | ||
1502 | break; | ||
1503 | |||
1504 | case BUTTON_F3: | ||
1505 | case BUTTON_OFF: | ||
1506 | done = true; | ||
1507 | break; | ||
1508 | } | ||
1509 | } | ||
1510 | else if(settings.clock == 2) | ||
1511 | { | ||
1512 | rb->lcd_puts(0, 0, "OPTIONS (Digital)"); | ||
1513 | rb->lcd_puts(0, 1, "UP/DOWN & PLAY"); | ||
1514 | rb->lcd_puts(0, 2, "F3/OFF: Done"); | ||
1515 | |||
1516 | if(settings.digital_date == 0) | ||
1517 | rb->lcd_puts(2, 4, "Date"); | ||
1518 | else if(settings.digital_date == 1) | ||
1519 | rb->lcd_puts(2, 4, "Date: American"); | ||
1520 | else | ||
1521 | rb->lcd_puts(2, 4, "Date: European"); | ||
1522 | |||
1523 | if(settings.digital_seconds == 0) | ||
1524 | rb->lcd_puts(2, 5, "Seconds"); | ||
1525 | else if(settings.digital_seconds == 1) | ||
1526 | rb->lcd_puts(2, 5, "Seconds: DIGITAL"); | ||
1527 | else if(settings.digital_seconds == 2) | ||
1528 | rb->lcd_puts(2, 5, "Seconds: BAR"); | ||
1529 | else | ||
1530 | rb->lcd_puts(2, 5, "Seconds: INVERSE"); | ||
1531 | |||
1532 | rb->lcd_puts(2, 6, "Blinking Colon"); | ||
1533 | rb->lcd_puts(2, 7, "12-Hour Format"); | ||
1534 | |||
1535 | /* Draw checkboxes */ | ||
1536 | if(settings.digital_date != 0) | ||
1537 | rb->checkbox(1, 33, 8, 6, true); | ||
1538 | else | ||
1539 | rb->checkbox(1, 33, 8, 6, false); | ||
1540 | if(settings.digital_seconds != 0) | ||
1541 | rb->checkbox(1, 41, 8, 6, true); | ||
1542 | else | ||
1543 | rb->checkbox(1, 41, 8, 6, false); | ||
1544 | rb->checkbox(1, 49, 8, 6, settings.digital_blinkcolon); | ||
1545 | rb->checkbox(1, 57, 8, 6, settings.digital_12h); | ||
1546 | |||
1547 | /* Draw a line selector */ | ||
1548 | switch(invert_digital) | ||
1549 | { | ||
1550 | case 1: | ||
1551 | rb->lcd_invertrect(0, 32, 112, 8); break; | ||
1552 | |||
1553 | case 2: | ||
1554 | rb->lcd_invertrect(0, 40, 112, 8); break; | ||
1555 | |||
1556 | case 3: | ||
1557 | rb->lcd_invertrect(0, 48, 112, 8); break; | ||
1558 | |||
1559 | case 4: | ||
1560 | rb->lcd_invertrect(0, 56, 112, 8); break; | ||
1561 | } | ||
1562 | |||
1563 | rb->lcd_update(); | ||
1564 | |||
1565 | switch(rb->button_get_w_tmo(HZ/4)) | ||
1566 | { | ||
1567 | case BUTTON_UP: | ||
1568 | if(invert_digital == 1) | ||
1569 | invert_digital = 4; | ||
1570 | else | ||
1571 | invert_digital--; | ||
1572 | break; | ||
1573 | |||
1574 | case BUTTON_DOWN: | ||
1575 | if(invert_digital == 4) | ||
1576 | invert_digital = 1; | ||
1577 | else | ||
1578 | invert_digital++; | ||
1579 | break; | ||
1580 | |||
1581 | case BUTTON_PLAY: | ||
1582 | if(invert_digital == 1) | ||
1583 | { | ||
1584 | if(settings.digital_date < 2) | ||
1585 | settings.digital_date++; | ||
1586 | else | ||
1587 | settings.digital_date = 0; | ||
1588 | } | ||
1589 | else if(invert_digital == 2) | ||
1590 | { | ||
1591 | if(settings.digital_seconds < 3) | ||
1592 | settings.digital_seconds++; | ||
1593 | else | ||
1594 | settings.digital_seconds = 0; | ||
1595 | } | ||
1596 | else if(invert_digital == 3) | ||
1597 | settings.digital_blinkcolon = !settings.digital_blinkcolon; | ||
1598 | else | ||
1599 | settings.digital_12h = !settings.digital_12h; | ||
1600 | break; | ||
1601 | |||
1602 | case BUTTON_F3: | ||
1603 | case BUTTON_OFF: | ||
1604 | done = true; | ||
1605 | break; | ||
1606 | } | ||
1607 | } | ||
1608 | else if(settings.clock == 3) | ||
1609 | { | ||
1610 | rb->lcd_puts(0, 0, "OPTIONS (LCD)"); | ||
1611 | rb->lcd_puts(0, 1, "UP/DOWN & PLAY"); | ||
1612 | rb->lcd_puts(0, 2, "F3/OFF: Done"); | ||
1613 | |||
1614 | if(settings.lcd_date == 0) | ||
1615 | rb->lcd_puts(2, 4, "Date"); | ||
1616 | else if(settings.lcd_date == 1) | ||
1617 | rb->lcd_puts(2, 4, "Date: American"); | ||
1618 | else | ||
1619 | rb->lcd_puts(2, 4, "Date: European"); | ||
1620 | |||
1621 | if(settings.lcd_seconds == 0) | ||
1622 | rb->lcd_puts(2, 5, "Seconds"); | ||
1623 | else if(settings.lcd_seconds == 1) | ||
1624 | rb->lcd_puts(2, 5, "Seconds: DIGITAL"); | ||
1625 | else if(settings.lcd_seconds == 2) | ||
1626 | rb->lcd_puts(2, 5, "Seconds: BAR"); | ||
1627 | else | ||
1628 | rb->lcd_puts(2, 5, "Seconds: INVERSE"); | ||
1629 | |||
1630 | rb->lcd_puts(2, 6, "Blinking Colon"); | ||
1631 | rb->lcd_puts(2, 7, "12-Hour Format"); | ||
1632 | |||
1633 | /* Draw checkboxes */ | ||
1634 | if(settings.lcd_date != 0) | ||
1635 | rb->checkbox(1, 33, 8, 6, true); | ||
1636 | else | ||
1637 | rb->checkbox(1, 33, 8, 6, false); | ||
1638 | if(settings.lcd_seconds != 0) | ||
1639 | rb->checkbox(1, 41, 8, 6, true); | ||
1640 | else | ||
1641 | rb->checkbox(1, 41, 8, 6, false); | ||
1642 | rb->checkbox(1, 49, 8, 6, settings.lcd_blinkcolon); | ||
1643 | rb->checkbox(1, 57, 8, 6, settings.lcd_12h); | ||
1644 | |||
1645 | /* Draw a line selector */ | ||
1646 | switch(invert_lcd) | ||
1647 | { | ||
1648 | case 1: | ||
1649 | rb->lcd_invertrect(0, 32, 112, 8); break; | ||
1650 | |||
1651 | case 2: | ||
1652 | rb->lcd_invertrect(0, 40, 112, 8); break; | ||
1653 | |||
1654 | case 3: | ||
1655 | rb->lcd_invertrect(0, 48, 112, 8); break; | ||
1656 | |||
1657 | case 4: | ||
1658 | rb->lcd_invertrect(0, 56, 112, 8); break; | ||
1659 | } | ||
1660 | |||
1661 | rb->lcd_update(); | ||
1662 | |||
1663 | switch(rb->button_get_w_tmo(HZ/4)) | ||
1664 | { | ||
1665 | case BUTTON_UP: | ||
1666 | if(invert_lcd == 1) | ||
1667 | invert_lcd = 4; | ||
1668 | else | ||
1669 | invert_lcd--; | ||
1670 | break; | ||
1671 | |||
1672 | case BUTTON_DOWN: | ||
1673 | if(invert_lcd == 4) | ||
1674 | invert_lcd = 1; | ||
1675 | else | ||
1676 | invert_lcd++; | ||
1677 | break; | ||
1678 | |||
1679 | case BUTTON_PLAY: | ||
1680 | if(invert_lcd == 1) | ||
1681 | { | ||
1682 | if(settings.lcd_date < 2) | ||
1683 | settings.lcd_date++; | ||
1684 | else | ||
1685 | settings.lcd_date = 0; | ||
1686 | } | ||
1687 | else if(invert_lcd == 2) | ||
1688 | { | ||
1689 | if(settings.lcd_seconds < 3) | ||
1690 | settings.lcd_seconds++; | ||
1691 | else | ||
1692 | settings.lcd_seconds = 0; | ||
1693 | } | ||
1694 | else if(invert_lcd == 3) | ||
1695 | settings.lcd_blinkcolon = !settings.lcd_blinkcolon; | ||
1696 | else | ||
1697 | settings.lcd_12h = !settings.lcd_12h; | ||
1698 | break; | ||
1699 | |||
1700 | case BUTTON_F3: | ||
1701 | case BUTTON_OFF: | ||
1702 | done = true; | ||
1703 | break; | ||
1704 | } | ||
1705 | } | ||
1706 | else if(settings.clock == 4) | ||
1707 | { | ||
1708 | rb->lcd_puts(0, 0, "OPTIONS (Full)"); | ||
1709 | rb->lcd_puts(0, 1, "UP/DOWN & PLAY"); | ||
1710 | rb->lcd_puts(0, 2, "F3/OFF: Done"); | ||
1711 | |||
1712 | rb->lcd_puts(2, 4, "Border"); | ||
1713 | rb->lcd_puts(2, 5, "Second Hand"); | ||
1714 | rb->lcd_puts(2, 6, "Invert Seconds"); | ||
1715 | |||
1716 | rb->checkbox(1, 33, 8, 6, settings.fullscreen_border); | ||
1717 | rb->checkbox(1, 41, 8, 6, settings.fullscreen_secondhand); | ||
1718 | rb->checkbox(1, 49, 8, 6, settings.fullscreen_invertseconds); | ||
1719 | |||
1720 | /* Draw a line selector | ||
1721 | * There are 4 values here in case we decide to "up" the amount of settings */ | ||
1722 | switch(invert_fullscreen) | ||
1723 | { | ||
1724 | case 1: | ||
1725 | rb->lcd_invertrect(0, 32, 112, 8); break; | ||
1726 | |||
1727 | case 2: | ||
1728 | rb->lcd_invertrect(0, 40, 112, 8); break; | ||
1729 | |||
1730 | case 3: | ||
1731 | rb->lcd_invertrect(0, 48, 112, 8); break; | ||
1732 | |||
1733 | case 4: | ||
1734 | rb->lcd_invertrect(0, 56, 112, 8); break; | ||
1735 | } | ||
1736 | |||
1737 | rb->lcd_update(); | ||
1738 | |||
1739 | switch(rb->button_get_w_tmo(HZ/4)) | ||
1740 | { | ||
1741 | case BUTTON_UP: | ||
1742 | if(invert_fullscreen == 1) | ||
1743 | invert_fullscreen = 3; | ||
1744 | else | ||
1745 | invert_fullscreen--; | ||
1746 | break; | ||
1747 | |||
1748 | case BUTTON_DOWN: | ||
1749 | if(invert_fullscreen == 3) | ||
1750 | invert_fullscreen = 1; | ||
1751 | else | ||
1752 | invert_fullscreen++; | ||
1753 | break; | ||
1754 | |||
1755 | case BUTTON_PLAY: | ||
1756 | if(invert_fullscreen == 1) | ||
1757 | settings.fullscreen_border = !settings.fullscreen_border; | ||
1758 | else if(invert_fullscreen == 2) | ||
1759 | settings.fullscreen_secondhand = !settings.fullscreen_secondhand; | ||
1760 | else | ||
1761 | settings.fullscreen_invertseconds = !settings.fullscreen_invertseconds; | ||
1762 | break; | ||
1763 | |||
1764 | case BUTTON_F3: | ||
1765 | case BUTTON_OFF: | ||
1766 | done = true; | ||
1767 | break; | ||
1768 | } | ||
1769 | } | ||
1770 | else | ||
1771 | { | ||
1772 | rb->lcd_puts(0, 0, "OPTIONS (Binary)"); | ||
1773 | rb->lcd_puts(0, 1, "UP/DOWN & PLAY"); | ||
1774 | rb->lcd_puts(0, 2, "F3/OFF: Done"); | ||
1775 | |||
1776 | rb->lcd_puts(2, 4, "-- NO OPTIONS --"); | ||
1777 | rb->lcd_puts(1, 6, "F3/OFF to return"); | ||
1778 | |||
1779 | rb->lcd_update(); | ||
1780 | |||
1781 | switch(rb->button_get_w_tmo(HZ/4)) | ||
1782 | { | ||
1783 | |||
1784 | case BUTTON_F3: | ||
1785 | case BUTTON_OFF: | ||
1786 | done = true; | ||
1787 | break; | ||
1788 | } | ||
1789 | } | ||
82 | } | 1790 | } |
83 | /* Else, loading failed */ | 1791 | return true; |
1792 | } | ||
1793 | |||
1794 | /***************************************** | ||
1795 | * Draws the extras, IE border, digits... | ||
1796 | *****************************************/ | ||
1797 | void draw_extras(int year, int day, int month, int hour, int minute, int second) | ||
1798 | { | ||
1799 | char buf[11]; | ||
1800 | int w, h; | ||
1801 | int i; | ||
1802 | int tempyear = 0; | ||
1803 | |||
1804 | struct tm* current_time = rb->get_time(); | ||
1805 | |||
1806 | int fill = seconds112[second]; | ||
1807 | |||
1808 | char moday[8]; | ||
1809 | char dateyr[6]; | ||
1810 | char tmhrmin[7]; | ||
1811 | char tmsec[3]; | ||
1812 | |||
1813 | if(year == 2004) | ||
1814 | tempyear = 04; | ||
1815 | |||
1816 | /* american date readout */ | ||
1817 | if(settings.analog_date == 1) | ||
1818 | rb->snprintf(moday, sizeof(moday), "%02d/%02d", month, day); | ||
84 | else | 1819 | else |
1820 | rb->snprintf(moday, sizeof(moday), "%02d.%02d", day, month); | ||
1821 | rb->snprintf(dateyr, sizeof(dateyr), "%d", year); | ||
1822 | rb->snprintf(tmhrmin, sizeof(tmhrmin), "%02d:%02d", hour, minute); | ||
1823 | rb->snprintf(tmsec, sizeof(tmsec), "%02d", second); | ||
1824 | |||
1825 | /* Analog Extras */ | ||
1826 | if(settings.clock == 1) | ||
1827 | { | ||
1828 | /* DIGITS around the face */ | ||
1829 | if (settings.analog_digits) | ||
1830 | { | ||
1831 | rb->lcd_putsxy((LCD_WIDTH/2)-6, 0, "12"); | ||
1832 | rb->lcd_putsxy(20, (LCD_HEIGHT/2)-4, "9"); | ||
1833 | rb->lcd_putsxy((LCD_WIDTH/2)-4, 56, "6"); | ||
1834 | rb->lcd_putsxy(86, (LCD_HEIGHT/2)-4, "3"); | ||
1835 | } | ||
1836 | |||
1837 | /* Digital readout */ | ||
1838 | if (settings.analog_time != 0) | ||
1839 | { | ||
1840 | /* HH:MM */ | ||
1841 | rb->lcd_putsxy(1, 4, tmhrmin); | ||
1842 | /* SS */ | ||
1843 | rb->lcd_putsxy(10, 12, tmsec); | ||
1844 | |||
1845 | /* AM/PM indicator */ | ||
1846 | if(settings.analog_time == 2) | ||
1847 | { | ||
1848 | if(current_time->tm_hour > 12) /* PM */ | ||
1849 | rb->lcd_bitmap(pm, 96, 1, 15, 8, true); | ||
1850 | else /* AM */ | ||
1851 | rb->lcd_bitmap(am, 96, 1, 15, 8, true); | ||
1852 | } | ||
1853 | } | ||
1854 | |||
1855 | /* Date readout */ | ||
1856 | if(settings.analog_date != 0) | ||
1857 | { | ||
1858 | /* MM-DD (or DD.MM) */ | ||
1859 | rb->lcd_putsxy(1, 48, moday); | ||
1860 | rb->lcd_putsxy(3, 56, dateyr); | ||
1861 | } | ||
1862 | } | ||
1863 | else if(settings.clock == 2) | ||
1864 | { | ||
1865 | /* Date readout */ | ||
1866 | if(settings.digital_date == 1) /* american mode */ | ||
1867 | { | ||
1868 | rb->snprintf(buf, sizeof(buf), "%d/%d/%d", month, day, year); | ||
1869 | rb->lcd_getstringsize(buf, &w, &h); | ||
1870 | rb->lcd_putsxy((LCD_WIDTH/2)-(w/2), 56, buf); | ||
1871 | } | ||
1872 | else if(settings.digital_date == 2) /* european mode */ | ||
1873 | { | ||
1874 | rb->snprintf(buf, sizeof(buf), "%d.%d.%d", day, month, year); | ||
1875 | rb->lcd_getstringsize(buf, &w, &h); | ||
1876 | rb->lcd_putsxy((LCD_WIDTH/2)-(w/2), 56, buf); | ||
1877 | } | ||
1878 | |||
1879 | /* Second readout */ | ||
1880 | if(settings.digital_seconds == 1) | ||
1881 | { | ||
1882 | rb->snprintf(buf, sizeof(buf), "%d", second); | ||
1883 | rb->lcd_getstringsize(buf, &w, &h); | ||
1884 | rb->lcd_putsxy((LCD_WIDTH/2)-(w/2), 5, buf); | ||
1885 | } | ||
1886 | |||
1887 | /* Second progressbar */ | ||
1888 | if(settings.digital_seconds == 2) | ||
1889 | { | ||
1890 | rb->progressbar(0, 0, 112, 4, seconds100[second], 0); | ||
1891 | } | ||
1892 | |||
1893 | /* Invert the whole LCD as the seconds go */ | ||
1894 | if(settings.digital_seconds == 3) | ||
1895 | { | ||
1896 | rb->lcd_invertrect(0, 0, fill, 64); | ||
1897 | } | ||
1898 | } | ||
1899 | else if(settings.clock == 3) /* LCD mode */ | ||
1900 | { | ||
1901 | /* Date readout */ | ||
1902 | if(settings.lcd_date == 1) /* american mode */ | ||
1903 | { | ||
1904 | rb->snprintf(buf, sizeof(buf), "%d/%d/%d", month, day, year); | ||
1905 | rb->lcd_getstringsize(buf, &w, &h); | ||
1906 | rb->lcd_putsxy((LCD_WIDTH/2)-(w/2), 56, buf); | ||
1907 | } | ||
1908 | else if(settings.lcd_date == 2) /* european mode */ | ||
1909 | { | ||
1910 | rb->snprintf(buf, sizeof(buf), "%d.%d.%d", day, month, year); | ||
1911 | rb->lcd_getstringsize(buf, &w, &h); | ||
1912 | rb->lcd_putsxy((LCD_WIDTH/2)-(w/2), 56, buf); | ||
1913 | } | ||
1914 | |||
1915 | /* Second readout */ | ||
1916 | if(settings.lcd_seconds == 1) | ||
1917 | { | ||
1918 | rb->snprintf(buf, sizeof(buf), "%d", second); | ||
1919 | rb->lcd_getstringsize(buf, &w, &h); | ||
1920 | rb->lcd_putsxy((LCD_WIDTH/2)-(w/2), 5, buf); | ||
1921 | } | ||
1922 | |||
1923 | /* Second progressbar */ | ||
1924 | if(settings.lcd_seconds == 2) | ||
1925 | { | ||
1926 | rb->progressbar(0, 0, 112, 4, seconds100[second], 0); | ||
1927 | } | ||
1928 | |||
1929 | /* Invert the whole LCD as the seconds go */ | ||
1930 | if(settings.lcd_seconds == 3) | ||
1931 | { | ||
1932 | rb->lcd_invertrect(0, 0, fill, 64); | ||
1933 | } | ||
1934 | } | ||
1935 | else if(settings.clock == 4) /* Fullscreen mode */ | ||
1936 | { | ||
1937 | if(settings.fullscreen_border) | ||
1938 | { | ||
1939 | /* Draw the circle */ | ||
1940 | for(i=0; i < 60; i+=5) | ||
1941 | { | ||
1942 | rb->lcd_drawpixel(xminute_full[i], | ||
1943 | yminute_full[i]); | ||
1944 | rb->lcd_drawrect(xminute_full[i]-1, | ||
1945 | yminute_full[i]-1, | ||
1946 | 3, 3); | ||
1947 | } | ||
1948 | } | ||
1949 | if(settings.fullscreen_invertseconds) | ||
1950 | { | ||
1951 | rb->lcd_invertrect(0, 0, fill, 64); | ||
1952 | } | ||
1953 | } | ||
1954 | } | ||
1955 | |||
1956 | /**************** | ||
1957 | * Select a mode | ||
1958 | ****************/ | ||
1959 | void select_mode(void) | ||
1960 | { | ||
1961 | done = false; | ||
1962 | |||
1963 | int cursorpos = settings.clock; | ||
1964 | bool a = false; /* (a)nalog */ | ||
1965 | bool d = false; /* (d)igital */ | ||
1966 | bool l = false; /* (l)cd */ | ||
1967 | bool f = false; /* (f)ullscreen */ | ||
1968 | bool b = false; /* (b)inary */ | ||
1969 | |||
1970 | while(!done) | ||
1971 | { | ||
1972 | rb->lcd_clear_display(); | ||
1973 | |||
1974 | rb->lcd_puts(0, 0, "MODE SELECTOR"); | ||
1975 | rb->lcd_puts(2, 1, "Analog"); | ||
1976 | rb->lcd_puts(2, 2, "Digital"); | ||
1977 | rb->lcd_puts(2, 3, "LCD"); | ||
1978 | rb->lcd_puts(2, 4, "Fullscreen"); | ||
1979 | rb->lcd_puts(2, 5, "Binary"); | ||
1980 | rb->lcd_puts(0, 6, "UP/DOWN: Choose"); | ||
1981 | rb->lcd_puts(0, 7, "PLAY:Go|OFF:Cancel"); | ||
1982 | |||
1983 | switch(settings.clock) | ||
1984 | { | ||
1985 | case 1: a=true; d=l=f=b=false; break; | ||
1986 | case 2: d=true; a=l=f=b=false; break; | ||
1987 | case 3: l=true; a=d=f=b=false; break; | ||
1988 | case 4: f=true; a=d=l=b=false; break; | ||
1989 | case 5: b=true; a=d=l=f=false; break; | ||
1990 | } | ||
1991 | |||
1992 | /* draw a checkbox next to current mode */ | ||
1993 | rb->checkbox(1, 9, 8, 6, a); | ||
1994 | rb->checkbox(1, 17, 8, 6, d); | ||
1995 | rb->checkbox(1, 25, 8, 6, l); | ||
1996 | rb->checkbox(1, 33, 8, 6, f); | ||
1997 | rb->checkbox(1, 41, 8, 6, b); | ||
1998 | |||
1999 | /* draw line selector */ | ||
2000 | switch(cursorpos) | ||
2001 | { | ||
2002 | case 1: rb->lcd_invertrect(0, 8, 112, 8); break; | ||
2003 | case 2: rb->lcd_invertrect(0, 16, 112, 8); break; | ||
2004 | case 3: rb->lcd_invertrect(0, 24, 112, 8); break; | ||
2005 | case 4: rb->lcd_invertrect(0, 32, 112, 8); break; | ||
2006 | case 5: rb->lcd_invertrect(0, 40, 112, 8); break; | ||
2007 | } | ||
2008 | |||
2009 | rb->lcd_update(); | ||
2010 | |||
2011 | switch(rb->button_get_w_tmo(HZ/4)) | ||
2012 | { | ||
2013 | case BUTTON_UP: | ||
2014 | if(cursorpos > 1) | ||
2015 | cursorpos--; | ||
2016 | else | ||
2017 | cursorpos = 5; | ||
2018 | break; | ||
2019 | |||
2020 | case BUTTON_DOWN: | ||
2021 | if(cursorpos < 5) | ||
2022 | cursorpos++; | ||
2023 | else | ||
2024 | cursorpos = 1; | ||
2025 | break; | ||
2026 | |||
2027 | case BUTTON_PLAY: | ||
2028 | settings.clock = cursorpos; | ||
2029 | done = true; | ||
2030 | break; | ||
2031 | |||
2032 | case BUTTON_OFF: | ||
2033 | done = true; | ||
2034 | break; | ||
2035 | } | ||
2036 | } | ||
2037 | } | ||
2038 | |||
2039 | void show_counter(void) | ||
2040 | { | ||
2041 | if(counting) | ||
85 | { | 2042 | { |
86 | rb->splash(HZ, true, "Setting load failed, using default settings."); | 2043 | passed_time = *rb->current_tick - start_tick; |
87 | } | 2044 | } |
2045 | else | ||
2046 | passed_time = 0; | ||
2047 | |||
2048 | displayed_value = counter + passed_time; | ||
2049 | displayed_value = displayed_value / HZ; | ||
2050 | |||
2051 | count_s = displayed_value % 60; | ||
2052 | count_m = displayed_value % 3600 / 60; | ||
2053 | count_h = displayed_value / 3600; | ||
2054 | |||
2055 | rb->snprintf(count_text, sizeof(count_text), "%d:%02d:%02d", count_h, count_m, count_s); | ||
2056 | |||
2057 | if(settings.clock == 1) | ||
2058 | rb->lcd_puts(11, 7, count_text); | ||
2059 | else if(settings.clock == 2) | ||
2060 | rb->lcd_putsxy(1, 5, count_text); | ||
2061 | else if(settings.clock == 3) | ||
2062 | rb->lcd_putsxy(1, 5, count_text); | ||
2063 | else if(settings.clock == 4) | ||
2064 | rb->lcd_puts(6, 6, count_text); | ||
88 | } | 2065 | } |
89 | 2066 | ||
2067 | /********************************************************************** | ||
2068 | * Plugin starts here | ||
2069 | **********************************************************************/ | ||
90 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 2070 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
91 | { | 2071 | { |
92 | /* time ints */ | 2072 | /* time ints */ |
@@ -94,6 +2074,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
94 | int hour; | 2074 | int hour; |
95 | int minute; | 2075 | int minute; |
96 | int second; | 2076 | int second; |
2077 | int temphour; | ||
97 | int last_second = -1; | 2078 | int last_second = -1; |
98 | int pos = 0; | 2079 | int pos = 0; |
99 | 2080 | ||
@@ -102,65 +2083,65 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
102 | int day; | 2083 | int day; |
103 | int month; | 2084 | int month; |
104 | 2085 | ||
105 | char moday[6]; | 2086 | /* poweroff activated or not? */ |
106 | char dateyr[5]; | 2087 | bool reset_timer = false; |
107 | char tmhrmin[5]; | ||
108 | char tmsec[2]; | ||
109 | char current_date[12]; | ||
110 | 2088 | ||
111 | struct tm* current_time; | 2089 | struct tm* current_time; |
112 | 2090 | ||
113 | bool exit = false; | ||
114 | bool used = false; | ||
115 | |||
116 | TEST_PLUGIN_API(api); | 2091 | TEST_PLUGIN_API(api); |
117 | (void)parameter; | 2092 | (void)parameter; |
118 | rb = api; | 2093 | rb = api; |
119 | 2094 | ||
120 | /* load settings from disk */ | ||
121 | load_settings(); | 2095 | load_settings(); |
122 | 2096 | ||
123 | rb->lcd_clear_display(); | 2097 | /* universal font */ |
124 | rb->splash(HZ, true, "F1 for INFO"); | 2098 | rb->lcd_setfont(FONT_SYSFIXED); |
2099 | |||
2100 | /* set backlight timeout */ | ||
2101 | rb->backlight_set_timeout(settings.backlight_on); | ||
125 | 2102 | ||
126 | while (!PLUGIN_OK) | 2103 | while (!PLUGIN_OK) |
127 | { | 2104 | { |
128 | /* universal font for better display */ | 2105 | /********************* |
129 | rb->lcd_setfont(FONT_SYSFIXED); | 2106 | * Time info |
130 | 2107 | *********************/ | |
131 | /* start all the clock stuff */ | ||
132 | |||
133 | /* Time info */ | ||
134 | current_time = rb->get_time(); | 2108 | current_time = rb->get_time(); |
135 | hour = current_time->tm_hour; | 2109 | hour = current_time->tm_hour; |
136 | minute = current_time->tm_min; | 2110 | minute = current_time->tm_min; |
137 | second = current_time->tm_sec; | 2111 | second = current_time->tm_sec; |
138 | 2112 | ||
139 | /* Date info */ | 2113 | temphour = hour; |
140 | year = current_time->tm_year+1900; | 2114 | |
2115 | /********************* | ||
2116 | * Date info | ||
2117 | *********************/ | ||
2118 | year = current_time->tm_year + 1900; | ||
141 | day = current_time->tm_mday; | 2119 | day = current_time->tm_mday; |
142 | month = current_time->tm_mon+1; | 2120 | month = current_time->tm_mon + 1; |
2121 | |||
2122 | done = false; | ||
143 | 2123 | ||
144 | if(second != last_second) | 2124 | if(second != last_second) |
145 | { | 2125 | { |
146 | rb->lcd_clear_display(); | 2126 | rb->lcd_clear_display(); |
147 | 2127 | ||
148 | rb->snprintf( moday, 5, "%d/%d", month, day ); | 2128 | show_counter(); |
149 | rb->snprintf( dateyr, 4, "%d", year ); | ||
150 | rb->snprintf( tmhrmin, 5, "%02d:%02d", hour, minute ); | ||
151 | rb->snprintf( tmsec, 2, "%02d", second ); | ||
152 | rb->snprintf( current_date, 12, "%d/%d/%d", month, day, year ); | ||
153 | 2129 | ||
154 | if(settings.analog_clock) | 2130 | /************** |
2131 | * Analog Mode | ||
2132 | **************/ | ||
2133 | if(settings.clock == 1) | ||
155 | { | 2134 | { |
156 | /* Now draw the analog clock */ | ||
157 | pos = 90-second; | ||
158 | if(pos >= 60) | ||
159 | pos -= 60; | ||
160 | |||
161 | /* Second hand */ | 2135 | /* Second hand */ |
162 | rb->lcd_drawline((LCD_WIDTH/2), (LCD_HEIGHT/2), | 2136 | if(settings.analog_secondhand) |
163 | xminute[pos], yminute[pos]); | 2137 | { |
2138 | pos = 90-second; | ||
2139 | if(pos >= 60) | ||
2140 | pos -= 60; | ||
2141 | |||
2142 | rb->lcd_drawline((LCD_WIDTH/2), (LCD_HEIGHT/2), | ||
2143 | xminute[pos], yminute[pos]); | ||
2144 | } | ||
164 | 2145 | ||
165 | pos = 90-minute; | 2146 | pos = 90-minute; |
166 | if(pos >= 60) | 2147 | if(pos >= 60) |
@@ -224,525 +2205,189 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
224 | (LCD_WIDTH/2)+1, (LCD_HEIGHT/2)-3); | 2205 | (LCD_WIDTH/2)+1, (LCD_HEIGHT/2)-3); |
225 | rb->lcd_drawpixel(LCD_WIDTH/2, LCD_HEIGHT/2); | 2206 | rb->lcd_drawpixel(LCD_WIDTH/2, LCD_HEIGHT/2); |
226 | 2207 | ||
227 | /* Draw the digits around the clock */ | ||
228 | if (settings.are_digits_displayed) | ||
229 | { | ||
230 | rb->lcd_putsxy((LCD_WIDTH/2)-6, 1, "12"); | ||
231 | rb->lcd_putsxy(20, (LCD_HEIGHT/2)-4, "9"); | ||
232 | rb->lcd_putsxy((LCD_WIDTH/2)-4, 56, "6"); | ||
233 | rb->lcd_putsxy(86, (LCD_HEIGHT/2)-4, "3"); | ||
234 | } | ||
235 | 2208 | ||
236 | /* Draw digital readout */ | ||
237 | if (settings.is_time_displayed) | ||
238 | { | ||
239 | /* HH:MM */ | ||
240 | rb->lcd_putsxy(1, 4, tmhrmin); | ||
241 | /* SS */ | ||
242 | rb->lcd_putsxy(10, 12, tmsec); | ||
243 | } | ||
244 | } | 2209 | } |
245 | else | 2210 | /*************** |
2211 | * Digital mode | ||
2212 | ***************/ | ||
2213 | else if(settings.clock == 2) | ||
246 | { | 2214 | { |
247 | draw_7seg_time(hour, minute, 8, 16, 16, 32, second & 1); | 2215 | if(settings.digital_blinkcolon) |
2216 | draw_7seg_time(hour, minute, 8, 16, 16, 32, second & 1, false); | ||
2217 | else | ||
2218 | draw_7seg_time(hour, minute, 8, 16, 16, 32, true, false); | ||
248 | } | 2219 | } |
249 | 2220 | /*********** | |
250 | /* Draw the border */ | 2221 | * LCD mode |
251 | if (settings.is_rect_displayed) | 2222 | ***********/ |
2223 | else if(settings.clock == 3) | ||
252 | { | 2224 | { |
253 | rb->lcd_drawrect(0, 0, 112, 64); | 2225 | if(settings.lcd_blinkcolon) |
254 | 2226 | draw_7seg_time(hour, minute, 8, 16, 16, 32, second & 1, true); | |
255 | /* top left corner */ | 2227 | else |
256 | rb->lcd_drawpixel(1, 1); | 2228 | draw_7seg_time(hour, minute, 8, 16, 16, 32, true, true); |
257 | rb->lcd_drawpixel(2, 2); | ||
258 | rb->lcd_drawpixel(1, 2); | ||
259 | rb->lcd_drawpixel(1, 3); | ||
260 | rb->lcd_drawpixel(2, 1); | ||
261 | rb->lcd_drawpixel(3, 1); | ||
262 | |||
263 | /* bottom left corner */ | ||
264 | rb->lcd_drawpixel(1, 62); | ||
265 | rb->lcd_drawpixel(2, 61); | ||
266 | rb->lcd_drawpixel(1, 61); | ||
267 | rb->lcd_drawpixel(1, 60); | ||
268 | rb->lcd_drawpixel(2, 62); | ||
269 | rb->lcd_drawpixel(3, 62); | ||
270 | |||
271 | /* top right corner */ | ||
272 | rb->lcd_drawpixel(110, 1); | ||
273 | rb->lcd_drawpixel(109, 2); | ||
274 | rb->lcd_drawpixel(110, 2); | ||
275 | rb->lcd_drawpixel(110, 3); | ||
276 | rb->lcd_drawpixel(109, 1); | ||
277 | rb->lcd_drawpixel(108, 1); | ||
278 | |||
279 | /* bottom right corner */ | ||
280 | rb->lcd_drawpixel(110, 62); | ||
281 | rb->lcd_drawpixel(109, 61); | ||
282 | rb->lcd_drawpixel(110, 61); | ||
283 | rb->lcd_drawpixel(110, 60); | ||
284 | rb->lcd_drawpixel(109, 62); | ||
285 | rb->lcd_drawpixel(108, 62); | ||
286 | } | 2229 | } |
287 | 2230 | /****************** | |
288 | /* Draw the date */ | 2231 | * Fullscreen mode |
289 | if (settings.is_date_displayed) | 2232 | ******************/ |
2233 | else if(settings.clock == 4) | ||
290 | { | 2234 | { |
291 | if(settings.analog_clock) | 2235 | /* Second hand */ |
2236 | if(settings.fullscreen_secondhand) | ||
292 | { | 2237 | { |
293 | rb->lcd_putsxy(3, 53, moday); | 2238 | pos = 90-second; |
294 | rb->lcd_putsxy(80, 53, dateyr); | 2239 | if(pos >= 60) |
2240 | pos -= 60; | ||
2241 | |||
2242 | rb->lcd_drawline((LCD_WIDTH/2), (LCD_HEIGHT/2), | ||
2243 | xminute_full[pos], yminute_full[pos]); | ||
295 | } | 2244 | } |
296 | else | ||
297 | rb->lcd_putsxy(25, 3, current_date); | ||
298 | } | ||
299 | 2245 | ||
300 | if (settings.is_time_displayed) | 2246 | pos = 90-minute; |
2247 | if(pos >= 60) | ||
2248 | pos -= 60; | ||
2249 | |||
2250 | /* Minute hand, thicker than the second hand */ | ||
2251 | rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, | ||
2252 | xminute_full[pos], yminute_full[pos]); | ||
2253 | rb->lcd_drawline(LCD_WIDTH/2-1, LCD_HEIGHT/2-1, | ||
2254 | xminute_full[pos], yminute_full[pos]); | ||
2255 | rb->lcd_drawline(LCD_WIDTH/2+1, LCD_HEIGHT/2+1, | ||
2256 | xminute_full[pos], yminute_full[pos]); | ||
2257 | rb->lcd_drawline(LCD_WIDTH/2-1, LCD_HEIGHT/2+1, | ||
2258 | xminute_full[pos], yminute_full[pos]); | ||
2259 | rb->lcd_drawline(LCD_WIDTH/2+1, LCD_HEIGHT/2-1, | ||
2260 | xminute_full[pos], yminute_full[pos]); | ||
2261 | |||
2262 | if(hour > 12) | ||
2263 | hour -= 12; | ||
2264 | |||
2265 | hour = hour*5 + minute/12; | ||
2266 | pos = 90-hour; | ||
2267 | if(pos >= 60) | ||
2268 | pos -= 60; | ||
2269 | |||
2270 | /* Hour hand, thick as the minute hand but shorter */ | ||
2271 | rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour_full[pos], yhour_full[pos]); | ||
2272 | rb->lcd_drawline(LCD_WIDTH/2-1, LCD_HEIGHT/2-1, | ||
2273 | xhour_full[pos], yhour_full[pos]); | ||
2274 | rb->lcd_drawline(LCD_WIDTH/2+1, LCD_HEIGHT/2+1, | ||
2275 | xhour_full[pos], yhour_full[pos]); | ||
2276 | rb->lcd_drawline(LCD_WIDTH/2-1, LCD_HEIGHT/2+1, | ||
2277 | xhour_full[pos], yhour_full[pos]); | ||
2278 | rb->lcd_drawline(LCD_WIDTH/2+1, LCD_HEIGHT/2-1, | ||
2279 | xhour_full[pos], yhour_full[pos]); | ||
2280 | |||
2281 | /* Draw the cover over the center */ | ||
2282 | rb->lcd_drawline((LCD_WIDTH/2)-1, (LCD_HEIGHT/2)+3, | ||
2283 | (LCD_WIDTH/2)+1, (LCD_HEIGHT/2)+3); | ||
2284 | rb->lcd_drawline((LCD_WIDTH/2)-3, (LCD_HEIGHT/2)+2, | ||
2285 | (LCD_WIDTH/2)+3, (LCD_HEIGHT/2)+2); | ||
2286 | rb->lcd_drawline((LCD_WIDTH/2)-4, (LCD_HEIGHT/2)+1, | ||
2287 | (LCD_WIDTH/2)+4, (LCD_HEIGHT/2)+1); | ||
2288 | rb->lcd_drawline((LCD_WIDTH/2)-4, LCD_HEIGHT/2, | ||
2289 | (LCD_WIDTH/2)+4, LCD_HEIGHT/2); | ||
2290 | rb->lcd_drawline((LCD_WIDTH/2)-4, (LCD_HEIGHT/2)-1, | ||
2291 | (LCD_WIDTH/2)+4, (LCD_HEIGHT/2)-1); | ||
2292 | rb->lcd_drawline((LCD_WIDTH/2)-3, (LCD_HEIGHT/2)-2, | ||
2293 | (LCD_WIDTH/2)+3, (LCD_HEIGHT/2)-2); | ||
2294 | rb->lcd_drawline((LCD_WIDTH/2)-1, (LCD_HEIGHT/2)-3, | ||
2295 | (LCD_WIDTH/2)+1, (LCD_HEIGHT/2)-3); | ||
2296 | rb->lcd_drawpixel(LCD_WIDTH/2, LCD_HEIGHT/2); | ||
2297 | } | ||
2298 | /************** | ||
2299 | * Binary mode | ||
2300 | **************/ | ||
2301 | else | ||
301 | { | 2302 | { |
302 | if(settings.analog_clock) | 2303 | binary(hour, minute, second); |
303 | { | ||
304 | /* HH:MM */ | ||
305 | rb->lcd_putsxy(1, 4, tmhrmin); | ||
306 | /* SS */ | ||
307 | rb->lcd_putsxy(10, 12, tmsec); | ||
308 | } | ||
309 | else | ||
310 | { | ||
311 | /* Just seconds */ | ||
312 | rb->lcd_putsxy(50, 55, tmsec); | ||
313 | } | ||
314 | } | 2304 | } |
315 | |||
316 | /* Draw all to LCD */ | ||
317 | rb->lcd_update(); | ||
318 | } | 2305 | } |
319 | 2306 | ||
320 | switch (rb->button_get_w_tmo(HZ/6)) | 2307 | if(settings.analog_time == 1 && temphour > 12) |
321 | { | 2308 | temphour += 12; |
322 | /* OFF exits */ | 2309 | |
323 | case BUTTON_OFF: | 2310 | draw_extras(year, day, month, temphour, minute, second); |
2311 | |||
2312 | if(reset_timer) | ||
2313 | rb->reset_poweroff_timer(); | ||
2314 | |||
2315 | rb->lcd_update(); | ||
324 | 2316 | ||
325 | /* Tell the user what's going on */ | 2317 | /************************** |
326 | rb->lcd_clear_display(); | 2318 | * Scan for button presses |
327 | rb->splash(HZ/2, true, "Saving settings..."); | 2319 | **************************/ |
328 | /* Save to disk */ | 2320 | switch (rb->button_get_w_tmo(HZ/10)) |
329 | save_settings(); | 2321 | { |
330 | rb->lcd_clear_display(); | 2322 | case BUTTON_OFF: /* save and exit */ |
331 | rb->splash(HZ, true, "Saved!"); | 2323 | save_settings(); |
332 | /* ...and exit. */ | 2324 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); |
333 | return PLUGIN_OK; | 2325 | return PLUGIN_OK; |
334 | break; | 2326 | break; |
335 | 2327 | ||
336 | /* F1 & OFF exits without saving */ | 2328 | case BUTTON_ON: /* credit roll */ |
337 | case BUTTON_F1 | BUTTON_OFF: | 2329 | show_credits(); |
338 | return PLUGIN_OK; | ||
339 | break; | 2330 | break; |
340 | 2331 | ||
341 | /* F1 screen - plugin info */ | 2332 | case BUTTON_F1: /* help */ |
342 | case BUTTON_F1: | 2333 | f1_screen(); |
343 | while (!exit) | 2334 | break; |
2335 | |||
2336 | case BUTTON_F2: /* start/stop counter */ | ||
2337 | if(settings.clock != 5) | ||
344 | { | 2338 | { |
345 | if(settings.analog_clock) | 2339 | if(counting) |
346 | { | 2340 | { |
347 | rb->lcd_clear_display(); | 2341 | counting = false; |
348 | rb->lcd_puts(0, 0, "F1 > Help"); | 2342 | counter += passed_time; |
349 | rb->lcd_puts(0, 1, "PLAY > Digital"); | ||
350 | rb->lcd_puts(0, 2, "FF > Show Time"); | ||
351 | rb->lcd_puts(0, 3, "DOWN > Border"); | ||
352 | rb->lcd_puts(0, 4, "REW > Digits"); | ||
353 | rb->lcd_puts(0, 5, "UP > Date"); | ||
354 | rb->lcd_puts(0, 6, "OFF > Save & Exit"); | ||
355 | rb->lcd_update(); | ||
356 | } | 2343 | } |
357 | else | 2344 | else |
358 | { | 2345 | { |
359 | rb->lcd_clear_display(); | 2346 | counting = true; |
360 | rb->lcd_puts(0, 0, "F1 > Help"); | 2347 | start_tick = *rb->current_tick; |
361 | rb->lcd_puts(0, 1, "PLAY > Analog"); | ||
362 | rb->lcd_puts(0, 3, "DOWN > Border"); | ||
363 | rb->lcd_puts(0, 4, "UP > Date"); | ||
364 | rb->lcd_puts(0, 5, "FF > Show Seconds"); | ||
365 | rb->lcd_puts(0, 7, "OFF > Save & Exit"); | ||
366 | rb->lcd_update(); | ||
367 | } | ||
368 | |||
369 | switch (rb->button_get(true)) | ||
370 | { | ||
371 | case BUTTON_F1 | BUTTON_REL: | ||
372 | if (used) | ||
373 | exit = true; | ||
374 | used = true; | ||
375 | break; | ||
376 | |||
377 | case BUTTON_OFF: | ||
378 | used = true; | ||
379 | break; | ||
380 | |||
381 | case SYS_USB_CONNECTED: | ||
382 | return PLUGIN_USB_CONNECTED; | ||
383 | rb->usb_screen(); | ||
384 | break; | ||
385 | } | 2348 | } |
386 | } | 2349 | } |
387 | break; | 2350 | break; |
388 | 2351 | ||
389 | /* options screen */ | 2352 | case BUTTON_F2 | BUTTON_REPEAT: /* reset counter */ |
390 | case BUTTON_F3: | 2353 | counter = 0; |
391 | while (!exit) | ||
392 | { | ||
393 | if(settings.analog_clock) | ||
394 | { | ||
395 | rb->lcd_clear_display(); | ||
396 | rb->lcd_putsxy(7, 0, "FF > Show Time"); | ||
397 | rb->lcd_putsxy(7, 10, "DOWN> Show Frame"); | ||
398 | rb->lcd_putsxy(7, 20, "UP > Show Date"); | ||
399 | rb->lcd_putsxy(7, 30, "REW > Show Digits"); | ||
400 | |||
401 | rb->lcd_putsxy(15, 46, "OFF > All OFF"); | ||
402 | rb->lcd_putsxy(17, 56, "ON > All ON"); | ||
403 | |||
404 | rb->lcd_drawline(0, 41, 112, 41); | ||
405 | |||
406 | /* draw checkmarks */ | ||
407 | if(settings.is_time_displayed) | ||
408 | { | ||
409 | rb->lcd_drawline(0, 4, 3, 7); | ||
410 | rb->lcd_drawline(3, 7, 5, 0); | ||
411 | } | ||
412 | if(settings.is_rect_displayed) | ||
413 | { | ||
414 | rb->lcd_drawline(0, 14, 3, 17); | ||
415 | rb->lcd_drawline(3, 17, 5, 10); | ||
416 | } | ||
417 | if(settings.is_date_displayed) | ||
418 | { | ||
419 | rb->lcd_drawline(0, 24, 3, 27); | ||
420 | rb->lcd_drawline(3, 27, 5, 20); | ||
421 | } | ||
422 | if(settings.are_digits_displayed) | ||
423 | { | ||
424 | rb->lcd_drawline(0, 34, 3, 37); | ||
425 | rb->lcd_drawline(3, 37, 5, 30); | ||
426 | } | ||
427 | |||
428 | /* update the LCD after all this madness */ | ||
429 | rb->lcd_update(); | ||
430 | |||
431 | /* ... and finally, setting options from screen: */ | ||
432 | switch (rb->button_get(true)) | ||
433 | { | ||
434 | case BUTTON_F3 | BUTTON_REL: | ||
435 | if (used) | ||
436 | exit = true; | ||
437 | used = true; | ||
438 | break; | ||
439 | |||
440 | case BUTTON_RIGHT: | ||
441 | settings.is_time_displayed = | ||
442 | !settings.is_time_displayed; | ||
443 | break; | ||
444 | |||
445 | case BUTTON_DOWN: | ||
446 | settings.is_rect_displayed = | ||
447 | !settings.is_rect_displayed; | ||
448 | break; | ||
449 | |||
450 | case BUTTON_UP: | ||
451 | settings.is_date_displayed = | ||
452 | !settings.is_date_displayed; | ||
453 | break; | ||
454 | |||
455 | case BUTTON_LEFT: | ||
456 | settings.are_digits_displayed = | ||
457 | !settings.are_digits_displayed; | ||
458 | break; | ||
459 | |||
460 | case BUTTON_ON: | ||
461 | settings.is_time_displayed = true; | ||
462 | settings.is_rect_displayed = true; | ||
463 | settings.is_date_displayed = true; | ||
464 | settings.are_digits_displayed = true; | ||
465 | break; | ||
466 | |||
467 | case BUTTON_OFF: | ||
468 | settings.is_time_displayed = false; | ||
469 | settings.is_rect_displayed = false; | ||
470 | settings.is_date_displayed = false; | ||
471 | settings.are_digits_displayed = false; | ||
472 | break; | ||
473 | |||
474 | case SYS_USB_CONNECTED: | ||
475 | return PLUGIN_USB_CONNECTED; | ||
476 | rb->usb_screen(); | ||
477 | break; | ||
478 | } | ||
479 | } | ||
480 | else /* 7-Segment clock shown, less options */ | ||
481 | { | ||
482 | rb->lcd_clear_display(); | ||
483 | rb->lcd_putsxy(7, 0, "DOWN> Show Frame"); | ||
484 | rb->lcd_putsxy(7, 10, "UP > Show Date"); | ||
485 | rb->lcd_putsxy(7, 20, "FF > Seconds"); | ||
486 | rb->lcd_putsxy(15, 46, "OFF > All OFF"); | ||
487 | rb->lcd_putsxy(17, 56, "ON > All ON"); | ||
488 | rb->lcd_drawline(0, 41, 112, 41); | ||
489 | |||
490 | /* draw checkmarks */ | ||
491 | if(settings.is_rect_displayed) | ||
492 | { | ||
493 | rb->lcd_drawline(0, 4, 3, 7); | ||
494 | rb->lcd_drawline(3, 7, 5, 0); | ||
495 | } | ||
496 | if(settings.is_date_displayed) | ||
497 | { | ||
498 | rb->lcd_drawline(0, 14, 3, 17); | ||
499 | rb->lcd_drawline(3, 17, 5, 10); | ||
500 | } | ||
501 | if(settings.is_time_displayed) | ||
502 | { | ||
503 | rb->lcd_drawline(0, 24, 3, 27); | ||
504 | rb->lcd_drawline(3, 27, 5, 20); | ||
505 | } | ||
506 | |||
507 | /* And finally, update the LCD */ | ||
508 | rb->lcd_update(); | ||
509 | |||
510 | switch (rb->button_get(true)) | ||
511 | { | ||
512 | case BUTTON_F3 | BUTTON_REL: | ||
513 | if (used) | ||
514 | exit = true; | ||
515 | used = true; | ||
516 | break; | ||
517 | |||
518 | case BUTTON_DOWN: | ||
519 | settings.is_rect_displayed = | ||
520 | !settings.is_rect_displayed; | ||
521 | break; | ||
522 | |||
523 | case BUTTON_UP: | ||
524 | settings.is_date_displayed = | ||
525 | !settings.is_date_displayed; | ||
526 | break; | ||
527 | |||
528 | case BUTTON_RIGHT: | ||
529 | settings.is_time_displayed = | ||
530 | !settings.is_time_displayed; | ||
531 | break; | ||
532 | |||
533 | case BUTTON_ON: | ||
534 | settings.is_time_displayed = true; | ||
535 | settings.is_rect_displayed = true; | ||
536 | settings.is_date_displayed = true; | ||
537 | break; | ||
538 | |||
539 | case BUTTON_OFF: | ||
540 | settings.is_time_displayed = false; | ||
541 | settings.is_rect_displayed = false; | ||
542 | settings.is_date_displayed = false; | ||
543 | break; | ||
544 | |||
545 | case SYS_USB_CONNECTED: | ||
546 | return PLUGIN_USB_CONNECTED; | ||
547 | rb->usb_screen(); | ||
548 | break; | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | break; | 2354 | break; |
553 | 2355 | ||
554 | /* Toggle analog/digital */ | 2356 | case BUTTON_F3: /* options */ |
555 | case BUTTON_PLAY: | 2357 | f3_screen(); |
556 | settings.analog_clock = !settings.analog_clock; | ||
557 | break; | 2358 | break; |
558 | 2359 | ||
559 | /* Show time */ | 2360 | case BUTTON_UP: /* enable idle poweroff */ |
560 | case BUTTON_RIGHT: | 2361 | reset_timer = false; |
561 | settings.is_time_displayed = !settings.is_time_displayed; | 2362 | rb->splash(HZ*2, true, "Idle Poweroff ENABLED"); |
562 | break; | 2363 | break; |
563 | 2364 | ||
564 | /* Show border */ | 2365 | case BUTTON_DOWN: /* disable idle poweroff */ |
565 | case BUTTON_DOWN: | 2366 | reset_timer = true; |
566 | settings.is_rect_displayed = !settings.is_rect_displayed ; | 2367 | rb->splash(HZ*2, true, "Idle Poweroff DISABLED"); |
567 | break; | 2368 | break; |
568 | 2369 | ||
569 | /* Show date */ | 2370 | case BUTTON_LEFT: /* backlight off */ |
570 | case BUTTON_UP: | 2371 | settings.backlight_on = false; |
571 | settings.is_date_displayed = !settings.is_date_displayed; | 2372 | rb->splash(HZ, true, "Backlight OFF"); |
2373 | rb->backlight_set_timeout(settings.backlight_on); | ||
572 | break; | 2374 | break; |
573 | 2375 | ||
574 | /* Show digits */ | 2376 | case BUTTON_RIGHT: /* backlight on */ |
575 | case BUTTON_LEFT: | 2377 | settings.backlight_on = true; |
576 | settings.are_digits_displayed = !settings.are_digits_displayed; | 2378 | rb->splash(HZ, true, "Backlight ON"); |
2379 | rb->backlight_set_timeout(settings.backlight_on); | ||
2380 | break; | ||
2381 | |||
2382 | case BUTTON_PLAY: /* select a mode */ | ||
2383 | select_mode(); | ||
577 | break; | 2384 | break; |
578 | 2385 | ||
579 | /* USB plugged? */ | 2386 | case SYS_USB_CONNECTED: /* usb plugged? */ |
580 | case SYS_USB_CONNECTED: | ||
581 | rb->usb_screen(); | 2387 | rb->usb_screen(); |
582 | return PLUGIN_USB_CONNECTED; | 2388 | return PLUGIN_USB_CONNECTED; |
583 | break; | 2389 | break; |
584 | } | 2390 | } |
585 | } | 2391 | } |
586 | } | 2392 | } |
587 | |||
588 | /* 7 Segment LED imitation code by Linus Nielsen Feltzing */ | ||
589 | |||
590 | /* | ||
591 | a 0 b | ||
592 | ######### | ||
593 | # # | ||
594 | # # | ||
595 | 1# #2 | ||
596 | # # | ||
597 | # 3 # | ||
598 | c ######### d | ||
599 | # # | ||
600 | # # | ||
601 | 4# #5 | ||
602 | # # | ||
603 | # 6 # | ||
604 | e ######### f | ||
605 | */ | ||
606 | |||
607 | /* The coordinates of each end point (a-f) of the segment lines (0-6) */ | ||
608 | static unsigned int point_coords[6][2] = | ||
609 | { | ||
610 | {0, 0}, /* a */ | ||
611 | {1, 0}, /* b */ | ||
612 | {0, 1}, /* c */ | ||
613 | {1, 1}, /* d */ | ||
614 | {0, 2}, /* e */ | ||
615 | {1, 2} /* f */ | ||
616 | }; | ||
617 | |||
618 | /* The end points (a-f) for each segment line */ | ||
619 | static unsigned int seg_points[7][2] = | ||
620 | { | ||
621 | {0,1}, /* a to b */ | ||
622 | {0,2}, /* a to c */ | ||
623 | {1,3}, /* b to d */ | ||
624 | {2,3}, /* c to d */ | ||
625 | {2,4}, /* c to e */ | ||
626 | {3,5}, /* d to f */ | ||
627 | {4,5} /* e to f */ | ||
628 | }; | ||
629 | |||
630 | /* Lists that tell which segments (0-6) to enable for each digit (0-9), | ||
631 | the list is terminated with -1 */ | ||
632 | static int digit_segs[10][8] = | ||
633 | { | ||
634 | {0,1,2,4,5,6, -1}, /* 0 */ | ||
635 | {2,5, -1}, /* 1 */ | ||
636 | {0,2,3,4,6, -1}, /* 2 */ | ||
637 | {0,2,3,5,6, -1}, /* 3 */ | ||
638 | {1,2,3,5, -1}, /* 4 */ | ||
639 | {0,1,3,5,6, -1}, /* 5 */ | ||
640 | {0,1,3,4,5,6, -1}, /* 6 */ | ||
641 | {0,2,5, -1}, /* 7 */ | ||
642 | {0,1,2,3,4,5,6, -1}, /* 8 */ | ||
643 | {0,1,2,3,5,6, -1} /* 9 */ | ||
644 | }; | ||
645 | |||
646 | /* Draws one segment */ | ||
647 | void draw_seg(int seg, int x, int y, int width, int height) | ||
648 | { | ||
649 | int p1 = seg_points[seg][0]; | ||
650 | int p2 = seg_points[seg][1]; | ||
651 | int x1 = point_coords[p1][0]; | ||
652 | int y1 = point_coords[p1][1]; | ||
653 | int x2 = point_coords[p2][0]; | ||
654 | int y2 = point_coords[p2][1]; | ||
655 | |||
656 | /* It draws parallel lines of different lengths for thicker segments */ | ||
657 | if(seg == 0 || seg == 3 || seg == 6) | ||
658 | { | ||
659 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2, | ||
660 | x + x2 * width - 1 , y + y2 * height / 2); | ||
661 | |||
662 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 - 1, | ||
663 | x + x2 * width - 2, y + y2 * height / 2 - 1); | ||
664 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 1, | ||
665 | x + x2 * width - 2, y + y2 * height / 2 + 1); | ||
666 | |||
667 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 - 2, | ||
668 | x + x2 * width - 3, y + y2 * height / 2 - 2); | ||
669 | rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 + 2, | ||
670 | x + x2 * width - 3, y + y2 * height / 2 + 2); | ||
671 | } | ||
672 | else | ||
673 | { | ||
674 | rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 + 1, | ||
675 | x + x2 * width , y + y2 * height / 2 - 1); | ||
676 | |||
677 | rb->lcd_drawline(x + x1 * width - 1, y + y1 * height / 2 + 2, | ||
678 | x + x2 * width - 1, y + y2 * height / 2 - 2); | ||
679 | rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2 + 2, | ||
680 | x + x2 * width + 1, y + y2 * height / 2 - 2); | ||
681 | |||
682 | rb->lcd_drawline(x + x1 * width - 2, y + y1 * height / 2 + 3, | ||
683 | x + x2 * width - 2, y + y2 * height / 2 - 3); | ||
684 | |||
685 | rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 3, | ||
686 | x + x2 * width + 2, y + y2 * height / 2 - 3); | ||
687 | } | ||
688 | } | ||
689 | |||
690 | /* Draws one digit */ | ||
691 | void draw_7seg_digit(int digit, int x, int y, int width, int height) | ||
692 | { | ||
693 | int i; | ||
694 | int c; | ||
695 | |||
696 | for(i = 0;digit_segs[digit][i] >= 0;i++) | ||
697 | { | ||
698 | c = digit_segs[digit][i]; | ||
699 | |||
700 | draw_seg(c, x, y, width, height); | ||
701 | } | ||
702 | } | ||
703 | |||
704 | /* Draws the entire 7-segment hour-minute time display */ | ||
705 | void draw_7seg_time(int hour, int minute, int x, int y, int width, int height, | ||
706 | bool colon) | ||
707 | { | ||
708 | int xpos = x; | ||
709 | |||
710 | draw_7seg_digit(hour / 10, xpos, y, width, height); | ||
711 | xpos += width + 6; | ||
712 | draw_7seg_digit(hour % 10, xpos, y, width, height); | ||
713 | xpos += width + 6; | ||
714 | |||
715 | if(colon) | ||
716 | { | ||
717 | rb->lcd_drawline(xpos, y + height/3 + 2, | ||
718 | xpos, y + height/3 + 2); | ||
719 | rb->lcd_drawline(xpos+1, y + height/3 + 1, | ||
720 | xpos+1, y + height/3 + 3); | ||
721 | rb->lcd_drawline(xpos+2, y + height/3, | ||
722 | xpos+2, y + height/3 + 4); | ||
723 | rb->lcd_drawline(xpos+3, y + height/3 + 1, | ||
724 | xpos+3, y + height/3 + 3); | ||
725 | rb->lcd_drawline(xpos+4, y + height/3 + 2, | ||
726 | xpos+4, y + height/3 + 2); | ||
727 | |||
728 | rb->lcd_drawline(xpos, y + height-height/3 + 2, | ||
729 | xpos, y + height-height/3 + 2); | ||
730 | rb->lcd_drawline(xpos+1, y + height-height/3 + 1, | ||
731 | xpos+1, y + height-height/3 + 3); | ||
732 | rb->lcd_drawline(xpos+2, y + height-height/3, | ||
733 | xpos+2, y + height-height/3 + 4); | ||
734 | rb->lcd_drawline(xpos+3, y + height-height/3 + 1, | ||
735 | xpos+3, y + height-height/3 + 3); | ||
736 | rb->lcd_drawline(xpos+4, y + height-height/3 + 2, | ||
737 | xpos+4, y + height-height/3 + 2); | ||
738 | } | ||
739 | |||
740 | xpos += 12; | ||
741 | |||
742 | draw_7seg_digit(minute / 10, xpos, y, width, height); | ||
743 | xpos += width + 6; | ||
744 | draw_7seg_digit(minute % 10, xpos, y, width, height); | ||
745 | xpos += width + 6; | ||
746 | } | ||
747 | |||
748 | #endif | 2393 | #endif |