1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Jens Arnold
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == ONDIO_PAD) \
25 || (CONFIG_KEYPAD == IRIVER_H100_PAD)
26 #define SCANRATE_DONE BUTTON_OFF
27 #define SCANRATE_FASTINC BUTTON_UP
28 #define SCANRATE_FASTDEC BUTTON_DOWN
29 #define SCANRATE_INC BUTTON_RIGHT
30 #define SCANRATE_DEC BUTTON_LEFT
32 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) \
33 || (CONFIG_KEYPAD == MROBE100_PAD) \
34 || (CONFIG_KEYPAD == SANSA_CLIP_PAD)
35 #define SCANRATE_DONE BUTTON_POWER
36 #define SCANRATE_FASTINC BUTTON_UP
37 #define SCANRATE_FASTDEC BUTTON_DOWN
38 #define SCANRATE_INC BUTTON_RIGHT
39 #define SCANRATE_DEC BUTTON_LEFT
41 #elif CONFIG_KEYPAD == SANSA_FUZE_PAD
42 #define SCANRATE_DONE (BUTTON_HOME|BUTTON_REPEAT)
43 #define SCANRATE_FASTINC BUTTON_UP
44 #define SCANRATE_FASTDEC BUTTON_DOWN
45 #define SCANRATE_INC BUTTON_RIGHT
46 #define SCANRATE_DEC BUTTON_LEFT
48 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
49 #define SCANRATE_DONE BUTTON_RC_REC
50 #define SCANRATE_FASTINC BUTTON_RC_VOL_UP
51 #define SCANRATE_FASTDEC BUTTON_RC_VOL_DOWN
52 #define SCANRATE_INC BUTTON_RC_FF
53 #define SCANRATE_DEC BUTTON_RC_REW
55 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
56 || (CONFIG_KEYPAD == IPOD_1G2G_PAD)
57 #define SCANRATE_DONE BUTTON_MENU
58 #define SCANRATE_FASTINC BUTTON_SCROLL_FWD
59 #define SCANRATE_FASTDEC BUTTON_SCROLL_BACK
60 #define SCANRATE_INC BUTTON_RIGHT
61 #define SCANRATE_DEC BUTTON_LEFT
63 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
64 #define SCANRATE_DONE BUTTON_PLAY
65 #define SCANRATE_FASTINC BUTTON_FFWD
66 #define SCANRATE_FASTDEC BUTTON_REW
67 #define SCANRATE_INC BUTTON_UP
68 #define SCANRATE_DEC BUTTON_DOWN
70 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
71 #define SCANRATE_DONE BUTTON_PLAY
72 #define SCANRATE_FASTINC BUTTON_NEXT
73 #define SCANRATE_FASTDEC BUTTON_PREV
74 #define SCANRATE_INC BUTTON_VOL_UP
75 #define SCANRATE_DEC BUTTON_VOL_DOWN
79 /* Default refresh rates in 1/10 Hz */
80 #if defined ARCHOS_RECORDER || defined ARCHOS_FMRECORDER \
81 || defined ARCHOS_RECORDERV2 || defined ARCHOS_ONDIOFM \
82 || defined ARCHOS_ONDIOSP
83 #define DEFAULT_SCAN_RATE 670
84 #elif defined IAUDIO_M3
85 #define DEFAULT_SCAN_RATE 1500
86 #define HORIZ_SCAN /* LCD controller updates the panel sideways */
88 #elif defined MPIO_HD200
89 #define DEFAULT_SCAN_RATE 1460
91 #elif defined IAUDIO_M5
92 #define DEFAULT_SCAN_RATE 730
93 #elif defined IPOD_1G2G
94 #define DEFAULT_SCAN_RATE 960
95 #elif defined IPOD_MINI2G || defined IPOD_MINI \
96 || defined IPOD_3G || defined IPOD_4G
97 #define DEFAULT_SCAN_RATE 870
98 #elif defined IRIVER_H100_SERIES
99 #define DEFAULT_SCAN_RATE 700
100 #elif defined SANSA_CLIP
101 #define DEFAULT_SCAN_RATE 780
102 #elif defined SAMSUNG_YH920
103 #define DEFAULT_SCAN_RATE 700
105 #define DEFAULT_SCAN_RATE 700
106 #warning Generic default scanrate
111 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
112 #define BUF_WIDTH ((LCD_WIDTH+7)/8)
113 #define BUF_HEIGHT (LCD_HEIGHT/4)
114 #define TEXT_Y BUF_HEIGHT
116 #define BUF_WIDTH (LCD_WIDTH)
117 #define BUF_HEIGHT (LCD_HEIGHT/8/4)
118 #define TEXT_Y (BUF_HEIGHT*8)
120 #else /* !HORIZ_SCAN */
122 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
123 #define BUF_WIDTH ((LCD_WIDTH+7)/8/4)
124 #define BUF_HEIGHT LCD_HEIGHT
125 #define TEXT_X (BUF_WIDTH*8)
127 #define BUF_WIDTH (LCD_WIDTH/4)
128 #define BUF_HEIGHT (LCD_HEIGHT/8)
129 #define TEXT_X BUF_WIDTH
131 #endif /* !HORIZ_SCAN */
133 #if defined(CPU_PP) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
137 static unsigned char bitbuffer
[2][BUF_HEIGHT
][BUF_WIDTH
];
138 static int curbuf
= 0;
139 static int scan_rate
= DEFAULT_SCAN_RATE
;
140 static bool need_refresh
= false;
142 static void timer_isr(void)
144 rb
->lcd_blit_mono(bitbuffer
[curbuf
][0], 0, 0, BUF_WIDTH
, BUF_HEIGHT
, BUF_WIDTH
);
145 curbuf
= (curbuf
+ 1) & 1;
148 rb
->lcd_update_rect(TEXT_X
, TEXT_Y
, LCD_WIDTH
-TEXT_X
, 8);
149 need_refresh
= false;
153 int plugin_main(void)
159 rb
->lcd_setfont(FONT_SYSFIXED
);
161 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+12, "Adjust Frequ.");
162 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+20, "so the block");
163 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+28, "stops moving.");
164 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
165 || (CONFIG_KEYPAD == IPOD_1G2G_PAD)
166 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+40, "Scroll: Coarse");
168 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+40, "U/D: Coarse");
170 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+48, "L/R: Fine");
173 rb
->memset(bitbuffer
[0], 0, sizeof(bitbuffer
[0]));
174 rb
->memset(bitbuffer
[1], 0xff, sizeof(bitbuffer
[1]));
178 /* The actual frequency is twice the displayed value */
179 rb
->timer_register(1, NULL
, TIMER_FREQ
* 5 / scan_rate
,
180 timer_isr
IF_COP(, CPU
));
186 /* The actual frequency is twice the displayed value */
187 rb
->timer_set_period(TIMER_FREQ
* 5 / scan_rate
);
188 rb
->lcd_putsxyf(TEXT_X
, TEXT_Y
, "f: %d.%d Hz", scan_rate
/ 10,
193 button
= rb
->button_get(true);
196 case SCANRATE_FASTINC
:
197 case SCANRATE_FASTINC
|BUTTON_REPEAT
:
202 case SCANRATE_FASTDEC
:
203 case SCANRATE_FASTDEC
|BUTTON_REPEAT
:
209 case SCANRATE_INC
|BUTTON_REPEAT
:
215 case SCANRATE_DEC
|BUTTON_REPEAT
:
225 rb
->timer_unregister();
227 rb
->cpu_boost(false);
230 rb
->lcd_setfont(FONT_UI
);
236 /* this is the plugin entry point */
237 enum plugin_status
plugin_start(const void* parameter
)
240 return plugin_main();