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 ****************************************************************************/
23 #include "lib/pluginlib_actions.h"
25 /* this set the context to use with PLA */
26 static const struct button_mapping
*plugin_contexts
[] = { pla_main_ctx
};
27 #define SCANRATE_QUIT PLA_EXIT
28 #define SCANRATE_QUIT2 PLA_CANCEL
29 #define SCANRATE_FASTINC PLA_UP
30 #define SCANRATE_FASTINC_REPEAT PLA_UP_REPEAT
31 #define SCANRATE_FASTDEC PLA_DOWN
32 #define SCANRATE_FASTDEC_REPEAT PLA_DOWN_REPEAT
34 #ifdef HAVE_SCROLLWHEEL
35 #define SCANRATE_INC PLA_SCROLL_FWD
36 #define SCANRATE_INC_REPEAT PLA_SCROLL_FWD_REPEAT
37 #define SCANRATE_DEC PLA_SCROLL_BACK
38 #define SCANRATE_DEC_REPEAT PLA_SCROLL_BACK_REPEAT
40 #define SCANRATE_INC PLA_RIGHT
41 #define SCANRATE_INC_REPEAT PLA_RIGHT_REPEAT
42 #define SCANRATE_DEC PLA_LEFT
43 #define SCANRATE_DEC_REPEAT PLA_LEFT_REPEAT
44 #endif /*HAVE_SCROLLWHEEL*/
46 /* Default refresh rates in 1/10 Hz */
47 #if defined ARCHOS_RECORDER || defined ARCHOS_FMRECORDER \
48 || defined ARCHOS_RECORDERV2 || defined ARCHOS_ONDIOFM \
49 || defined ARCHOS_ONDIOSP
50 #define DEFAULT_SCAN_RATE 670
51 #elif defined IAUDIO_M3
52 #define DEFAULT_SCAN_RATE 1500
53 #define HORIZ_SCAN /* LCD controller updates the panel sideways */
55 #elif defined MPIO_HD200
56 #define DEFAULT_SCAN_RATE 1460
58 #elif defined MPIO_HD300
59 #define DEFAULT_SCAN_RATE 730
60 #elif defined IAUDIO_M5
61 #define DEFAULT_SCAN_RATE 730
62 #elif defined IPOD_1G2G
63 #define DEFAULT_SCAN_RATE 960
64 #elif defined IPOD_MINI2G || defined IPOD_MINI \
65 || defined IPOD_3G || defined IPOD_4G
66 #define DEFAULT_SCAN_RATE 870
67 #elif defined IRIVER_H100_SERIES
68 #define DEFAULT_SCAN_RATE 700
69 #elif defined SANSA_CLIP
70 #define DEFAULT_SCAN_RATE 780
71 #elif defined SAMSUNG_YH920
72 #define DEFAULT_SCAN_RATE 700
74 #define DEFAULT_SCAN_RATE 700
75 #warning Generic default scanrate
80 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
81 #define BUF_WIDTH ((LCD_WIDTH+7)/8)
82 #define BUF_HEIGHT (LCD_HEIGHT/4)
83 #define TEXT_Y BUF_HEIGHT
85 #define BUF_WIDTH (LCD_WIDTH)
86 #define BUF_HEIGHT (LCD_HEIGHT/8/4)
87 #define TEXT_Y (BUF_HEIGHT*8)
89 #else /* !HORIZ_SCAN */
91 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
92 #define BUF_WIDTH ((LCD_WIDTH+7)/8/4)
93 #define BUF_HEIGHT LCD_HEIGHT
94 #define TEXT_X (BUF_WIDTH*8)
96 #define BUF_WIDTH (LCD_WIDTH/4)
97 #define BUF_HEIGHT (LCD_HEIGHT/8)
98 #define TEXT_X BUF_WIDTH
100 #endif /* !HORIZ_SCAN */
102 #if defined(CPU_PP) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
106 static unsigned char bitbuffer
[2][BUF_HEIGHT
][BUF_WIDTH
];
107 static int curbuf
= 0;
108 static int scan_rate
= DEFAULT_SCAN_RATE
;
109 static bool need_refresh
= false;
111 static void timer_isr(void)
113 rb
->lcd_blit_mono(bitbuffer
[curbuf
][0], 0, 0, BUF_WIDTH
, BUF_HEIGHT
, BUF_WIDTH
);
114 curbuf
= (curbuf
+ 1) & 1;
117 rb
->lcd_update_rect(TEXT_X
, TEXT_Y
, LCD_WIDTH
-TEXT_X
, 8);
118 need_refresh
= false;
122 int plugin_main(void)
128 rb
->lcd_setfont(FONT_SYSFIXED
);
130 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+12, "Adjust Frequ.");
131 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+20, "so the block");
132 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+28, "stops moving.");
133 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
134 || (CONFIG_KEYPAD == IPOD_1G2G_PAD)
135 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+40, "Scroll: Coarse");
137 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+40, "U/D: Coarse");
139 rb
->lcd_putsxy(TEXT_X
, TEXT_Y
+48, "L/R: Fine");
142 rb
->memset(bitbuffer
[0], 0, sizeof(bitbuffer
[0]));
143 rb
->memset(bitbuffer
[1], 0xff, sizeof(bitbuffer
[1]));
147 /* The actual frequency is twice the displayed value */
148 rb
->timer_register(1, NULL
, TIMER_FREQ
* 5 / scan_rate
,
149 timer_isr
IF_COP(, CPU
));
155 /* The actual frequency is twice the displayed value */
156 rb
->timer_set_period(TIMER_FREQ
* 5 / scan_rate
);
157 rb
->lcd_putsxyf(TEXT_X
, TEXT_Y
, "f: %d.%d Hz", scan_rate
/ 10,
162 button
= pluginlib_getaction(TIMEOUT_BLOCK
, plugin_contexts
,
163 ARRAYLEN(plugin_contexts
));
166 case SCANRATE_FASTINC
:
167 case SCANRATE_FASTINC_REPEAT
:
172 case SCANRATE_FASTDEC
:
173 case SCANRATE_FASTDEC_REPEAT
:
179 case SCANRATE_INC_REPEAT
:
185 case SCANRATE_DEC_REPEAT
:
196 rb
->timer_unregister();
198 rb
->cpu_boost(false);
201 rb
->lcd_setfont(FONT_UI
);
207 /* this is the plugin entry point */
208 enum plugin_status
plugin_start(const void* parameter
)
211 return plugin_main();