diff options
author | Kevin Ferrare <kevin@rockbox.org> | 2007-07-31 04:59:03 +0000 |
---|---|---|
committer | Kevin Ferrare <kevin@rockbox.org> | 2007-07-31 04:59:03 +0000 |
commit | df4f56b2b0a5343fb40cc749b24897f239c76be7 (patch) | |
tree | f324668f9b4c718649db29b6c7f9025bf115d309 /apps/plugins/clock.c | |
parent | 4e8b171fc4cc3b62a1656ae67e92944ff855dcd3 (diff) | |
download | rockbox-df4f56b2b0a5343fb40cc749b24897f239c76be7.tar.gz rockbox-df4f56b2b0a5343fb40cc749b24897f239c76be7.zip |
plugins code cleanup : moved the duplicated fixed point table loockup based sinus/cosinus functions to fixedpoint.c, removed the bmp size definition in the clock.c|-(useless as the size is already defined in a .h generated with every bitmaps ...)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14087 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/clock.c')
-rw-r--r-- | apps/plugins/clock.c | 188 |
1 files changed, 28 insertions, 160 deletions
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c index f2f6c779f2..8d0efeef43 100644 --- a/apps/plugins/clock.c +++ b/apps/plugins/clock.c | |||
@@ -93,125 +93,38 @@ Original release, featuring analog/digital modes and a few options. | |||
93 | #include "checkbox.h" | 93 | #include "checkbox.h" |
94 | #include "xlcd.h" | 94 | #include "xlcd.h" |
95 | #include "oldmenuapi.h" | 95 | #include "oldmenuapi.h" |
96 | #include "fixedpoint.h" | ||
96 | 97 | ||
97 | PLUGIN_HEADER | 98 | PLUGIN_HEADER |
98 | 99 | ||
99 | /* External bitmap references */ | 100 | /* External bitmap references */ |
100 | extern const fb_data clock_digits[]; | 101 | #include "clock_digits.h" |
101 | extern const fb_data clock_smalldigits[]; | 102 | #include "clock_smalldigits.h" |
102 | extern const fb_data clock_segments[]; | 103 | #include "clock_smallsegments.h" |
103 | extern const fb_data clock_smallsegments[]; | 104 | #include "clock_messages.h" |
104 | extern const fb_data clock_logo[]; | 105 | #include "clock_logo.h" |
105 | extern const fb_data clock_messages[]; | 106 | #include "clock_segments.h" |
106 | extern const fb_data clock_timesup[]; | 107 | |
107 | 108 | /* Bitmap positions/deltas, per LCD size */ | |
108 | /* Bitmap sizes/positions/deltas, per LCD size */ | 109 | #if (LCD_WIDTH >= 112) && (LCD_HEIGHT >= 64) && (LCD_DEPTH >= 1) /* Archos */ |
109 | #if (LCD_WIDTH >= 320) && (LCD_HEIGHT >=240) && (LCD_DEPTH >= 16) /* iPod 5G */ | ||
110 | #define DIGIT_WIDTH 50 | ||
111 | #define DIGIT_HEIGHT 70 | ||
112 | #define SMALLDIGIT_WIDTH 15 | ||
113 | #define SMALLDIGIT_HEIGHT 21 | ||
114 | #define SMALLSEG_WIDTH 15 | ||
115 | #define SMALLSEG_HEIGHT 21 | ||
116 | #define MESSAGE_HEIGHT 40 | ||
117 | #define MESSAGE_WIDTH 320 | ||
118 | #define LOGO_WIDTH 320 | ||
119 | #define LOGO_HEIGHT 160 | ||
120 | #define LCD_OFFSET 1.5 | ||
121 | #define HAND_W 3 | ||
122 | #elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176) && (LCD_DEPTH >= 16) /* H300 */ | ||
123 | #define DIGIT_WIDTH 35 | ||
124 | #define DIGIT_HEIGHT 49 | ||
125 | #define SMALLDIGIT_WIDTH 10 | ||
126 | #define SMALLDIGIT_HEIGHT 14 | ||
127 | #define SMALLSEG_WIDTH 10 | ||
128 | #define SMALLSEG_HEIGHT 14 | ||
129 | #define MESSAGE_HEIGHT 27 | ||
130 | #define MESSAGE_WIDTH 220 | ||
131 | #define LOGO_WIDTH 220 | ||
132 | #define LOGO_HEIGHT 110 | ||
133 | #define LCD_OFFSET 1.5 | ||
134 | #define HAND_W 3 | ||
135 | #elif (LCD_WIDTH >= 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH >=16) /* Nano */ | ||
136 | #define DIGIT_WIDTH 25 | ||
137 | #define DIGIT_HEIGHT 35 | ||
138 | #define SMALLDIGIT_WIDTH 10 | ||
139 | #define SMALLDIGIT_HEIGHT 14 | ||
140 | #define SMALLSEG_WIDTH 10 | ||
141 | #define SMALLSEG_HEIGHT 14 | ||
142 | #define MESSAGE_HEIGHT 22 | ||
143 | #define MESSAGE_WIDTH 176 | ||
144 | #define LOGO_WIDTH 176 | ||
145 | #define LOGO_HEIGHT 88 | ||
146 | #define LCD_OFFSET 1.5 | ||
147 | #define HAND_W 3 | ||
148 | #elif (LCD_WIDTH >= 160) && (LCD_HEIGHT >= 128) && (LCD_DEPTH >=16) /* iAudio, H10 */ | ||
149 | #define DIGIT_WIDTH 25 | ||
150 | #define DIGIT_HEIGHT 35 | ||
151 | #define SMALLDIGIT_WIDTH 10 | ||
152 | #define SMALLDIGIT_HEIGHT 14 | ||
153 | #define SMALLSEG_WIDTH 10 | ||
154 | #define SMALLSEG_HEIGHT 14 | ||
155 | #define MESSAGE_HEIGHT 20 | ||
156 | #define MESSAGE_WIDTH 160 | ||
157 | #define LOGO_WIDTH 160 | ||
158 | #define LOGO_HEIGHT 80 | ||
159 | #define LCD_OFFSET 1.5 | ||
160 | #define HAND_W 3 | ||
161 | #elif (LCD_WIDTH >= 128) && (LCD_HEIGHT >= 128) && (LCD_DEPTH >=16) /* H10 5/6GB */ | ||
162 | #define DIGIT_WIDTH 20 | ||
163 | #define DIGIT_HEIGHT 28 | ||
164 | #define SMALLDIGIT_WIDTH 10 | ||
165 | #define SMALLDIGIT_HEIGHT 14 | ||
166 | #define SMALLSEG_WIDTH 10 | ||
167 | #define SMALLSEG_HEIGHT 14 | ||
168 | #define MESSAGE_HEIGHT 16 | ||
169 | #define MESSAGE_WIDTH 128 | ||
170 | #define LOGO_WIDTH 128 | ||
171 | #define LOGO_HEIGHT 64 | ||
172 | #define LCD_OFFSET 1.5 | ||
173 | #define HAND_W 3 | ||
174 | #elif (LCD_WIDTH >= 160) && (LCD_HEIGHT >= 128) && (LCD_DEPTH >=2) /* iPod 3G, 4G */ | ||
175 | #define DIGIT_WIDTH 25 | ||
176 | #define DIGIT_HEIGHT 35 | ||
177 | #define SMALLDIGIT_WIDTH 10 | ||
178 | #define SMALLDIGIT_HEIGHT 14 | ||
179 | #define SMALLSEG_WIDTH 10 | ||
180 | #define SMALLSEG_HEIGHT 14 | ||
181 | #define MESSAGE_HEIGHT 20 | ||
182 | #define MESSAGE_WIDTH 160 | ||
183 | #define LOGO_WIDTH 160 | ||
184 | #define LOGO_HEIGHT 80 | ||
185 | #define LCD_OFFSET 1.5 | ||
186 | #define HAND_W 3 | ||
187 | #elif (LCD_WIDTH >= 138) && (LCD_HEIGHT >= 110) && (LCD_DEPTH >=2) /* iPod mini */ | ||
188 | #define DIGIT_WIDTH 23 | ||
189 | #define DIGIT_HEIGHT 32 | ||
190 | #define SMALLDIGIT_WIDTH 10 | ||
191 | #define SMALLDIGIT_HEIGHT 14 | ||
192 | #define SMALLSEG_WIDTH 10 | ||
193 | #define SMALLSEG_HEIGHT 14 | ||
194 | #define MESSAGE_HEIGHT 17 | ||
195 | #define MESSAGE_WIDTH 138 | ||
196 | #define LOGO_WIDTH 138 | ||
197 | #define LOGO_HEIGHT 69 | ||
198 | #define LCD_OFFSET 1.5 | ||
199 | #define HAND_W 3 | ||
200 | #elif (LCD_WIDTH >= 112) && (LCD_HEIGHT >= 64) && (LCD_DEPTH >= 1) /* Archos */ | ||
201 | #define DIGIT_WIDTH 16 | ||
202 | #define DIGIT_HEIGHT 20 | ||
203 | #define SMALLDIGIT_WIDTH 8 | ||
204 | #define SMALLDIGIT_HEIGHT 10 | ||
205 | #define SMALLSEG_WIDTH 10 | ||
206 | #define SMALLSEG_HEIGHT 12 | ||
207 | #define MESSAGE_HEIGHT 14 | ||
208 | #define MESSAGE_WIDTH 112 | ||
209 | #define LOGO_WIDTH 112 | ||
210 | #define LOGO_HEIGHT 50 | ||
211 | #define LCD_OFFSET 1 | 110 | #define LCD_OFFSET 1 |
212 | #define HAND_W 2 | 111 | #define HAND_W 2 |
112 | #else | ||
113 | #define LCD_OFFSET 1.5 | ||
114 | #define HAND_W 3 | ||
213 | #endif | 115 | #endif |
214 | 116 | ||
117 | #define DIGIT_WIDTH BMPWIDTH_clock_digits | ||
118 | #define DIGIT_HEIGHT (BMPHEIGHT_clock_digits/15) | ||
119 | #define SMALLDIGIT_WIDTH BMPWIDTH_clock_smalldigits | ||
120 | #define SMALLDIGIT_HEIGHT (BMPHEIGHT_clock_smalldigits/13) | ||
121 | #define SMALLSEG_WIDTH BMPWIDTH_clock_smallsegments | ||
122 | #define SMALLSEG_HEIGHT (BMPHEIGHT_clock_smallsegments/13) | ||
123 | #define MESSAGE_WIDTH BMPWIDTH_clock_messages | ||
124 | #define MESSAGE_HEIGHT (BMPHEIGHT_clock_messages/6) | ||
125 | #define LOGO_WIDTH BMPWIDTH_clock_logo | ||
126 | #define LOGO_HEIGHT BMPHEIGHT_clock_logo | ||
127 | |||
215 | /* Parts of larger bitmaps */ | 128 | /* Parts of larger bitmaps */ |
216 | #define COLON 10 | 129 | #define COLON 10 |
217 | #define DOT_FILLED 11 | 130 | #define DOT_FILLED 11 |
@@ -556,51 +469,6 @@ void reset_settings(void) | |||
556 | settings.plain[plain_blinkcolon] = false; | 469 | settings.plain[plain_blinkcolon] = false; |
557 | } | 470 | } |
558 | 471 | ||
559 | /************************************************ | ||
560 | * Precalculated sine * 16384 (fixed point 18.14) | ||
561 | ***********************************************/ | ||
562 | static const short sin_table[91] = | ||
563 | { | ||
564 | 0, 285, 571, 857, 1142, 1427, 1712, 1996, 2280, 2563, | ||
565 | 2845, 3126, 3406, 3685, 3963, 4240, 4516, 4790, 5062, 5334, | ||
566 | 5603, 5871, 6137, 6401, 6663, 6924, 7182, 7438, 7691, 7943, | ||
567 | 8191, 8438, 8682, 8923, 9161, 9397, 9630, 9860, 10086, 10310, | ||
568 | 10531, 10748, 10963, 11173, 11381, 11585, 11785, 11982, 12175, 12365, | ||
569 | 12550, 12732, 12910, 13084, 13254, 13420, 13582, 13740, 13894, 14043, | ||
570 | 14188, 14329, 14466, 14598, 14725, 14848, 14967, 15081, 15190, 15295, | ||
571 | 15395, 15491, 15582, 15668, 15749, 15825, 15897, 15964, 16025, 16082, | ||
572 | 16135, 16182, 16224, 16261, 16294, 16321, 16344, 16361, 16374, 16381, | ||
573 | 16384 | ||
574 | }; | ||
575 | |||
576 | /******************************* | ||
577 | * Sine function (from plasma.c) | ||
578 | ******************************/ | ||
579 | static short sin(int val) | ||
580 | { | ||
581 | /* value should be between 0 and 360 degree for correct lookup*/ | ||
582 | val%=360; | ||
583 | if(val<0) | ||
584 | val+=360; | ||
585 | |||
586 | /* Speed improvement through successive lookup */ | ||
587 | if (val < 181) | ||
588 | { | ||
589 | if (val < 91) | ||
590 | return (short)sin_table[val]; /* phase 0-90 degree */ | ||
591 | else | ||
592 | return (short)sin_table[180-val]; /* phase 91-180 degree */ | ||
593 | } | ||
594 | else | ||
595 | { | ||
596 | if (val < 271) | ||
597 | return -(short)sin_table[val-180]; /* phase 181-270 degree */ | ||
598 | else | ||
599 | return -(short)sin_table[360-val]; /* phase 270-359 degree */ | ||
600 | } | ||
601 | return 0; | ||
602 | } | ||
603 | |||
604 | /************************************************************** | 472 | /************************************************************** |
605 | * Simple function to check if we're switching to digital mode, | 473 | * Simple function to check if we're switching to digital mode, |
606 | * and if so, set bg/fg colors appropriately. | 474 | * and if so, set bg/fg colors appropriately. |
@@ -812,13 +680,13 @@ void init_clock(void) | |||
812 | 680 | ||
813 | for(i=0; i<ANALOG_VALUES; i++) | 681 | for(i=0; i<ANALOG_VALUES; i++) |
814 | { | 682 | { |
815 | xminute[i] = ((sin(360 * i / ANALOG_VALUES) | 683 | xminute[i] = ((sin_int(360 * i / ANALOG_VALUES) |
816 | * ANALOG_MIN_RADIUS) >> 14) + ANALOG_XCENTER; | 684 | * ANALOG_MIN_RADIUS) >> 14) + ANALOG_XCENTER; |
817 | yminute[i] = ((sin(360*i/ ANALOG_VALUES-90) | 685 | yminute[i] = ((sin_int(360*i/ ANALOG_VALUES-90) |
818 | * ANALOG_MIN_RADIUS) >> 14) + ANALOG_YCENTER; | 686 | * ANALOG_MIN_RADIUS) >> 14) + ANALOG_YCENTER; |
819 | xhour[i] = ((sin(360 * i / ANALOG_VALUES) | 687 | xhour[i] = ((sin_int(360 * i / ANALOG_VALUES) |
820 | * ANALOG_HR_RADIUS) >> 14) + ANALOG_XCENTER; | 688 | * ANALOG_HR_RADIUS) >> 14) + ANALOG_XCENTER; |
821 | yhour[i] = ((sin(360 * i / ANALOG_VALUES-90) | 689 | yhour[i] = ((sin_int(360 * i / ANALOG_VALUES-90) |
822 | * ANALOG_HR_RADIUS) >> 14) + ANALOG_YCENTER; | 690 | * ANALOG_HR_RADIUS) >> 14) + ANALOG_YCENTER; |
823 | 691 | ||
824 | /* Fullscreen initialization */ | 692 | /* Fullscreen initialization */ |