2006-08-28 00:01:14 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jens Arnold
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-08-28 00:01:14 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
|
|
#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == ONDIO_PAD) \
|
|
|
|
|| (CONFIG_KEYPAD == IRIVER_H100_PAD)
|
|
|
|
#define SCANRATE_DONE BUTTON_OFF
|
|
|
|
#define SCANRATE_FASTINC BUTTON_UP
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_DOWN
|
|
|
|
#define SCANRATE_INC BUTTON_RIGHT
|
|
|
|
#define SCANRATE_DEC BUTTON_LEFT
|
|
|
|
|
2008-04-07 22:09:14 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) \
|
2008-11-28 00:37:28 +00:00
|
|
|
|| (CONFIG_KEYPAD == MROBE100_PAD) \
|
2009-05-13 08:27:36 +00:00
|
|
|
|| (CONFIG_KEYPAD == SANSA_CLIP_PAD)
|
2007-08-10 10:39:23 +00:00
|
|
|
#define SCANRATE_DONE BUTTON_POWER
|
|
|
|
#define SCANRATE_FASTINC BUTTON_UP
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_DOWN
|
|
|
|
#define SCANRATE_INC BUTTON_RIGHT
|
|
|
|
#define SCANRATE_DEC BUTTON_LEFT
|
|
|
|
|
2009-05-13 08:27:36 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
|
|
|
|
#define SCANRATE_DONE (BUTTON_HOME|BUTTON_REPEAT)
|
|
|
|
#define SCANRATE_FASTINC BUTTON_UP
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_DOWN
|
|
|
|
#define SCANRATE_INC BUTTON_RIGHT
|
|
|
|
#define SCANRATE_DEC BUTTON_LEFT
|
|
|
|
|
2008-03-22 10:24:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
#define SCANRATE_DONE BUTTON_RC_REC
|
|
|
|
#define SCANRATE_FASTINC BUTTON_RC_VOL_UP
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_RC_VOL_DOWN
|
|
|
|
#define SCANRATE_INC BUTTON_RC_FF
|
|
|
|
#define SCANRATE_DEC BUTTON_RC_REW
|
|
|
|
|
2007-07-27 09:57:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
|
|
|
|
|| (CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-08-28 00:01:14 +00:00
|
|
|
#define SCANRATE_DONE BUTTON_MENU
|
|
|
|
#define SCANRATE_FASTINC BUTTON_SCROLL_FWD
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_SCROLL_BACK
|
|
|
|
#define SCANRATE_INC BUTTON_RIGHT
|
|
|
|
#define SCANRATE_DEC BUTTON_LEFT
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
2009-10-03 12:20:56 +00:00
|
|
|
#define SCANRATE_DONE BUTTON_PLAY
|
2009-08-04 03:08:32 +00:00
|
|
|
#define SCANRATE_FASTINC BUTTON_FFWD
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_REW
|
|
|
|
#define SCANRATE_INC BUTTON_UP
|
|
|
|
#define SCANRATE_DEC BUTTON_DOWN
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
#define SCANRATE_DONE BUTTON_PLAY
|
2010-11-02 10:44:34 +00:00
|
|
|
#define SCANRATE_FASTINC BUTTON_FF
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_REW
|
2010-04-26 21:40:00 +00:00
|
|
|
#define SCANRATE_INC BUTTON_VOL_UP
|
|
|
|
#define SCANRATE_DEC BUTTON_VOL_DOWN
|
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
|
|
|
#define SCANRATE_DONE BUTTON_PLAY
|
|
|
|
#define SCANRATE_FASTINC BUTTON_UP
|
|
|
|
#define SCANRATE_FASTDEC BUTTON_DOWN
|
|
|
|
#define SCANRATE_INC BUTTON_FF
|
|
|
|
#define SCANRATE_DEC BUTTON_REW
|
|
|
|
|
2006-08-28 00:01:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Default refresh rates in 1/10 Hz */
|
2008-04-02 22:48:42 +00:00
|
|
|
#if defined ARCHOS_RECORDER || defined ARCHOS_FMRECORDER \
|
|
|
|
|| defined ARCHOS_RECORDERV2 || defined ARCHOS_ONDIOFM \
|
|
|
|
|| defined ARCHOS_ONDIOSP
|
2006-08-28 00:01:14 +00:00
|
|
|
#define DEFAULT_SCAN_RATE 670
|
2008-04-02 22:48:42 +00:00
|
|
|
#elif defined IAUDIO_M3
|
|
|
|
#define DEFAULT_SCAN_RATE 1500
|
2008-03-24 01:03:02 +00:00
|
|
|
#define HORIZ_SCAN /* LCD controller updates the panel sideways */
|
|
|
|
#define NEED_BOOST
|
2010-04-30 14:13:52 +00:00
|
|
|
#elif defined MPIO_HD200
|
|
|
|
#define DEFAULT_SCAN_RATE 1460
|
|
|
|
#define NEED_BOOST
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif defined MPIO_HD300
|
|
|
|
#define DEFAULT_SCAN_RATE 730
|
2008-04-02 22:48:42 +00:00
|
|
|
#elif defined IAUDIO_M5
|
|
|
|
#define DEFAULT_SCAN_RATE 730
|
|
|
|
#elif defined IPOD_1G2G
|
|
|
|
#define DEFAULT_SCAN_RATE 960
|
|
|
|
#elif defined IPOD_MINI2G || defined IPOD_MINI \
|
|
|
|
|| defined IPOD_3G || defined IPOD_4G
|
|
|
|
#define DEFAULT_SCAN_RATE 870
|
|
|
|
#elif defined IRIVER_H100_SERIES
|
|
|
|
#define DEFAULT_SCAN_RATE 700
|
2008-11-28 00:37:28 +00:00
|
|
|
#elif defined SANSA_CLIP
|
|
|
|
#define DEFAULT_SCAN_RATE 780
|
2009-10-03 13:05:13 +00:00
|
|
|
#elif defined SAMSUNG_YH920
|
|
|
|
#define DEFAULT_SCAN_RATE 700
|
2008-03-22 10:24:28 +00:00
|
|
|
#else
|
|
|
|
#define DEFAULT_SCAN_RATE 700
|
|
|
|
#warning Generic default scanrate
|
2006-08-28 00:01:14 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-02 22:48:42 +00:00
|
|
|
#ifdef HORIZ_SCAN
|
2008-03-24 01:03:02 +00:00
|
|
|
#define TEXT_X 0
|
|
|
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
|
|
|
#define BUF_WIDTH ((LCD_WIDTH+7)/8)
|
|
|
|
#define BUF_HEIGHT (LCD_HEIGHT/4)
|
|
|
|
#define TEXT_Y BUF_HEIGHT
|
|
|
|
#else
|
|
|
|
#define BUF_WIDTH (LCD_WIDTH)
|
|
|
|
#define BUF_HEIGHT (LCD_HEIGHT/8/4)
|
|
|
|
#define TEXT_Y (BUF_HEIGHT*8)
|
|
|
|
#endif
|
|
|
|
#else /* !HORIZ_SCAN */
|
|
|
|
#define TEXT_Y 0
|
|
|
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
|
|
|
#define BUF_WIDTH ((LCD_WIDTH+7)/8/4)
|
|
|
|
#define BUF_HEIGHT LCD_HEIGHT
|
|
|
|
#define TEXT_X (BUF_WIDTH*8)
|
|
|
|
#else
|
|
|
|
#define BUF_WIDTH (LCD_WIDTH/4)
|
|
|
|
#define BUF_HEIGHT (LCD_HEIGHT/8)
|
|
|
|
#define TEXT_X BUF_WIDTH
|
|
|
|
#endif
|
|
|
|
#endif /* !HORIZ_SCAN */
|
|
|
|
|
2006-08-28 00:01:14 +00:00
|
|
|
#if defined(CPU_PP) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
|
|
|
#define NEED_BOOST
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static unsigned char bitbuffer[2][BUF_HEIGHT][BUF_WIDTH];
|
|
|
|
static int curbuf = 0;
|
|
|
|
static int scan_rate = DEFAULT_SCAN_RATE;
|
|
|
|
static bool need_refresh = false;
|
|
|
|
|
|
|
|
static void timer_isr(void)
|
|
|
|
{
|
2008-03-24 01:03:02 +00:00
|
|
|
rb->lcd_blit_mono(bitbuffer[curbuf][0], 0, 0, BUF_WIDTH, BUF_HEIGHT, BUF_WIDTH);
|
2006-08-28 00:01:14 +00:00
|
|
|
curbuf = (curbuf + 1) & 1;
|
|
|
|
if (need_refresh)
|
|
|
|
{
|
2008-03-24 01:03:02 +00:00
|
|
|
rb->lcd_update_rect(TEXT_X, TEXT_Y, LCD_WIDTH-TEXT_X, 8);
|
2006-08-28 00:01:14 +00:00
|
|
|
need_refresh = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int plugin_main(void)
|
|
|
|
{
|
|
|
|
int button;
|
|
|
|
bool done = false;
|
|
|
|
bool change = true;
|
|
|
|
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
2008-03-24 01:03:02 +00:00
|
|
|
rb->lcd_putsxy(TEXT_X, TEXT_Y+12, "Adjust Frequ.");
|
|
|
|
rb->lcd_putsxy(TEXT_X, TEXT_Y+20, "so the block");
|
|
|
|
rb->lcd_putsxy(TEXT_X, TEXT_Y+28, "stops moving.");
|
|
|
|
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
|
|
|
|
|| (CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
|
|
|
rb->lcd_putsxy(TEXT_X, TEXT_Y+40, "Scroll: Coarse");
|
|
|
|
#else
|
|
|
|
rb->lcd_putsxy(TEXT_X, TEXT_Y+40, "U/D: Coarse");
|
2006-08-28 00:01:14 +00:00
|
|
|
#endif
|
2008-03-24 01:03:02 +00:00
|
|
|
rb->lcd_putsxy(TEXT_X, TEXT_Y+48, "L/R: Fine");
|
2006-08-28 00:01:14 +00:00
|
|
|
rb->lcd_update();
|
|
|
|
|
|
|
|
rb->memset(bitbuffer[0], 0, sizeof(bitbuffer[0]));
|
|
|
|
rb->memset(bitbuffer[1], 0xff, sizeof(bitbuffer[1]));
|
|
|
|
#ifdef NEED_BOOST
|
|
|
|
rb->cpu_boost(true);
|
|
|
|
#endif
|
|
|
|
/* The actual frequency is twice the displayed value */
|
2009-06-29 14:29:46 +00:00
|
|
|
rb->timer_register(1, NULL, TIMER_FREQ * 5 / scan_rate,
|
2008-04-04 19:38:46 +00:00
|
|
|
timer_isr IF_COP(, CPU));
|
2006-08-28 00:01:14 +00:00
|
|
|
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
if (change)
|
|
|
|
{
|
|
|
|
/* The actual frequency is twice the displayed value */
|
|
|
|
rb->timer_set_period(TIMER_FREQ * 5 / scan_rate);
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(TEXT_X, TEXT_Y, "f: %d.%d Hz", scan_rate / 10,
|
2006-08-28 00:01:14 +00:00
|
|
|
scan_rate % 10);
|
|
|
|
need_refresh = true;
|
|
|
|
change = false;
|
|
|
|
}
|
|
|
|
button = rb->button_get(true);
|
|
|
|
switch (button)
|
|
|
|
{
|
|
|
|
case SCANRATE_FASTINC:
|
|
|
|
case SCANRATE_FASTINC|BUTTON_REPEAT:
|
|
|
|
scan_rate += 10;
|
|
|
|
change = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCANRATE_FASTDEC:
|
|
|
|
case SCANRATE_FASTDEC|BUTTON_REPEAT:
|
|
|
|
scan_rate -= 10;
|
|
|
|
change = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCANRATE_INC:
|
|
|
|
case SCANRATE_INC|BUTTON_REPEAT:
|
|
|
|
scan_rate++;
|
|
|
|
change = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCANRATE_DEC:
|
|
|
|
case SCANRATE_DEC|BUTTON_REPEAT:
|
|
|
|
scan_rate--;
|
|
|
|
change = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCANRATE_DONE:
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rb->timer_unregister();
|
|
|
|
#ifdef NEED_BOOST
|
|
|
|
rb->cpu_boost(false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rb->lcd_setfont(FONT_UI);
|
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* this is the plugin entry point */
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2006-08-28 00:01:14 +00:00
|
|
|
{
|
|
|
|
(void)parameter;
|
|
|
|
return plugin_main();
|
|
|
|
}
|