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_FF
73 #define SCANRATE_FASTDEC BUTTON_REW
74 #define SCANRATE_INC BUTTON_VOL_UP
75 #define SCANRATE_DEC BUTTON_VOL_DOWN
77 #elif CONFIG_KEYPAD == MPIO_HD300_PAD
78 #define SCANRATE_DONE BUTTON_PLAY
79 #define SCANRATE_FASTINC BUTTON_UP
80 #define SCANRATE_FASTDEC BUTTON_DOWN
81 #define SCANRATE_INC BUTTON_FF
82 #define SCANRATE_DEC BUTTON_REW
86 /* Default refresh rates in 1/10 Hz */
87 #if defined ARCHOS_RECORDER || defined ARCHOS_FMRECORDER \
88 || defined ARCHOS_RECORDERV2 || defined ARCHOS_ONDIOFM \
89 || defined ARCHOS_ONDIOSP
90 #define DEFAULT_SCAN_RATE 670
91 #elif defined IAUDIO_M3
92 #define DEFAULT_SCAN_RATE 1500
93 #define HORIZ_SCAN /* LCD controller updates the panel sideways */
95 #elif defined MPIO_HD200
96 #define DEFAULT_SCAN_RATE 1460
98 #elif defined MPIO_HD300
99 #define DEFAULT_SCAN_RATE 730
100 #elif defined IAUDIO_M5
101 #define DEFAULT_SCAN_RATE 730
102 #elif defined IPOD_1G2G
103 #define DEFAULT_SCAN_RATE 960
104 #elif defined IPOD_MINI2G || defined IPOD_MINI \
105 || defined IPOD_3G || defined IPOD_4G
106 #define DEFAULT_SCAN_RATE 870
107 #elif defined IRIVER_H100_SERIES
108 #define DEFAULT_SCAN_RATE 700
109 #elif defined SANSA_CLIP
110 #define DEFAULT_SCAN_RATE 780
111 #elif defined SAMSUNG_YH920
112 #define DEFAULT_SCAN_RATE 700
114 #define DEFAULT_SCAN_RATE 700
115 #warning Generic default scanrate
120 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
121 #define BUF_WIDTH ((LCD_WIDTH+7)/8)
122 #define BUF_HEIGHT (LCD_HEIGHT/4)
123 #define TEXT_Y BUF_HEIGHT
125 #define BUF_WIDTH (LCD_WIDTH)
126 #define BUF_HEIGHT (LCD_HEIGHT/8/4)
127 #define TEXT_Y (BUF_HEIGHT*8)
129 #else /* !HORIZ_SCAN */
131 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
132 #define BUF_WIDTH ((LCD_WIDTH+7)/8/4)
133 #define BUF_HEIGHT LCD_HEIGHT
134 #define TEXT_X (BUF_WIDTH*8)
136 #define BUF_WIDTH (LCD_WIDTH/4)
137 #define BUF_HEIGHT (LCD_HEIGHT/8)
138 #define TEXT_X BUF_WIDTH
140 #endif /* !HORIZ_SCAN */
142 #if defined(CPU_PP) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
146 static unsigned char bitbuffer
[2][BUF_HEIGHT
][BUF_WIDTH
];
147 static int curbuf
= 0;
148 static int scan_rate
= DEFAULT_SCAN_RATE
;
149 static bool need_refresh
= false;
151 static void timer_isr(void)
153 rb
->lcd_blit_mono(bitbuffer
[curbuf
][0], 0, 0, BUF_WIDTH
, BUF_HEIGHT
, BUF_WIDTH
);
154 curbuf
= (curbuf
+ 1) & 1;
157 rb
->lcd_update_rect(TEXT_X
, TEXT_Y
, LCD_WIDTH
-TEXT_X
, 8);
158 need_refresh
= false;
162 int plugin_main(void)
168 rb
->lcd_setfont(FONT_SYSFIXED
);
170 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+12, "Adjust Frequ.");
171 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+20, "so the block");
172 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+28, "stops moving.");
173 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
174 || (CONFIG_KEYPAD == IPOD_1G2G_PAD)
175 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+40, "Scroll: Coarse");
177 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+40, "U/D: Coarse");
179 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+48, "L/R: Fine");
182 rb
->memset(bitbuffer
[0], 0, sizeof(bitbuffer
[0]));
183 rb
->memset(bitbuffer
[1], 0xff, sizeof(bitbuffer
[1]));
187 /* The actual frequency is twice the displayed value */
188 rb
->timer_register(1, NULL
, TIMER_FREQ
* 5 / scan_rate
,
189 timer_isr
IF_COP(, CPU
));
195 /* The actual frequency is twice the displayed value */
196 rb
->timer_set_period(TIMER_FREQ
* 5 / scan_rate
);
197 rb
->lcd_putsxyf(TEXT_X
, TEXT_Y
, "f: %d.%d Hz", scan_rate
/ 10,
202 button
= rb
->button_get(true);
205 case SCANRATE_FASTINC
:
206 case SCANRATE_FASTINC
|BUTTON_REPEAT
:
211 case SCANRATE_FASTDEC
:
212 case SCANRATE_FASTDEC
|BUTTON_REPEAT
:
218 case SCANRATE_INC
|BUTTON_REPEAT
:
224 case SCANRATE_DEC
|BUTTON_REPEAT
:
234 rb
->timer_unregister();
236 rb
->cpu_boost(false);
239 rb
->lcd_setfont(FONT_UI
);
245 /* this is the plugin entry point */
246 enum plugin_status
plugin_start(const void* parameter
)
249 return plugin_main();