FS#10120 - fuze/e200v2: poll the wheel more often (every 5ms). This makes the scrollwheel behavior nearly perfect (decent acceleration, no direction changes if you turn to fast).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20699 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
65aa187aef
commit
e5e41c3a82
3 changed files with 55 additions and 32 deletions
|
@ -24,12 +24,29 @@
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "timer-target.h"
|
#include "timer-target.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SCROLLWHEEL
|
||||||
|
/* The scrollwheel is polled every 5 ms (the tick tasks only every 10) */
|
||||||
|
extern void button_read_dbop(void);
|
||||||
|
static volatile int poll_scrollwheel = 0;
|
||||||
|
|
||||||
|
void INT_TIMER2(void)
|
||||||
|
{
|
||||||
|
if (!poll_scrollwheel)
|
||||||
|
call_tick_tasks(); /* Run through the list of tick tasks */
|
||||||
|
else
|
||||||
|
button_read_dbop();
|
||||||
|
|
||||||
|
poll_scrollwheel ^= 1;
|
||||||
|
TIMER2_INTCLR = 0; /* clear interrupt */
|
||||||
|
}
|
||||||
|
#else
|
||||||
void INT_TIMER2(void)
|
void INT_TIMER2(void)
|
||||||
{
|
{
|
||||||
call_tick_tasks(); /* Run through the list of tick tasks */
|
call_tick_tasks(); /* Run through the list of tick tasks */
|
||||||
|
|
||||||
TIMER2_INTCLR = 0; /* clear interrupt */
|
TIMER2_INTCLR = 0; /* clear interrupt */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tick_start(unsigned int interval_in_ms)
|
void tick_start(unsigned int interval_in_ms)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +54,11 @@ void tick_start(unsigned int interval_in_ms)
|
||||||
int prescale = 1;
|
int prescale = 1;
|
||||||
int cycles = TIMER_FREQ / 1000 * interval_in_ms;
|
int cycles = TIMER_FREQ / 1000 * interval_in_ms;
|
||||||
|
|
||||||
|
#ifdef HAVE_SCROLLWHEEL
|
||||||
|
/* let the timer interrupt twice as often for the scrollwheel polling */
|
||||||
|
cycles >>= 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
while(cycles > 0x10000)
|
while(cycles > 0x10000)
|
||||||
{
|
{
|
||||||
phi++;
|
phi++;
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool button_hold(void)
|
||||||
return hold_button;
|
return hold_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clickwheel(unsigned int wheel_value)
|
static void scrollwheel(short dbop_din)
|
||||||
{
|
{
|
||||||
static const unsigned char wheel_tbl[2][4] =
|
static const unsigned char wheel_tbl[2][4] =
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,10 @@ void clickwheel(unsigned int wheel_value)
|
||||||
|
|
||||||
/* did the wheel value change? */
|
/* did the wheel value change? */
|
||||||
unsigned int btn = BUTTON_NONE;
|
unsigned int btn = BUTTON_NONE;
|
||||||
|
|
||||||
|
unsigned wheel_value = dbop_din & (1<<13|1<<14);
|
||||||
|
wheel_value >>= 13;
|
||||||
|
|
||||||
if (old_wheel_value == wheel_tbl[0][wheel_value])
|
if (old_wheel_value == wheel_tbl[0][wheel_value])
|
||||||
btn = BUTTON_SCROLL_FWD;
|
btn = BUTTON_SCROLL_FWD;
|
||||||
else if (old_wheel_value == wheel_tbl[1][wheel_value])
|
else if (old_wheel_value == wheel_tbl[1][wheel_value])
|
||||||
|
@ -178,7 +182,7 @@ void clickwheel(unsigned int wheel_value)
|
||||||
old_wheel_value = wheel_value;
|
old_wheel_value = wheel_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static short read_dbop(void)
|
short button_read_dbop(void)
|
||||||
{
|
{
|
||||||
/*write a red pixel */
|
/*write a red pixel */
|
||||||
if (!lcd_button_support())
|
if (!lcd_button_support())
|
||||||
|
@ -186,7 +190,7 @@ static short read_dbop(void)
|
||||||
|
|
||||||
/* Set up dbop for input */
|
/* Set up dbop for input */
|
||||||
while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */
|
while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */
|
||||||
DBOP_CTRL |= (1<<19);
|
DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */
|
||||||
DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
|
DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
|
||||||
DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
|
DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
|
||||||
DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
|
DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
|
||||||
|
@ -200,8 +204,9 @@ static short read_dbop(void)
|
||||||
DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
|
DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
|
||||||
DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
|
DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
|
||||||
DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
|
DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
|
||||||
DBOP_CTRL &= ~(1<<19);
|
DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */
|
||||||
|
|
||||||
|
scrollwheel(_dbop_din);
|
||||||
return _dbop_din;
|
return _dbop_din;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +222,7 @@ int button_read_device(void)
|
||||||
{
|
{
|
||||||
int btn = BUTTON_NONE;
|
int btn = BUTTON_NONE;
|
||||||
/* read buttons from dbop */
|
/* read buttons from dbop */
|
||||||
short dbop = read_dbop();
|
short dbop = button_read_dbop();
|
||||||
|
|
||||||
/* hold button */
|
/* hold button */
|
||||||
if(dbop & (1<<12))
|
if(dbop & (1<<12))
|
||||||
|
@ -239,7 +244,6 @@ int button_read_device(void)
|
||||||
/* handle wheel */
|
/* handle wheel */
|
||||||
int wheel_value = dbop & (1<<13|1<<14);
|
int wheel_value = dbop & (1<<13|1<<14);
|
||||||
wheel_value >>= 13;
|
wheel_value >>= 13;
|
||||||
clickwheel(wheel_value);
|
|
||||||
|
|
||||||
/* Set afsel, so that we can read our buttons */
|
/* Set afsel, so that we can read our buttons */
|
||||||
GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
|
GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
|
||||||
|
|
|
@ -49,7 +49,7 @@ void button_init_device(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL)
|
#if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL)
|
||||||
static void scrollwheel(short dbop)
|
static void scrollwheel(short dbop_din)
|
||||||
{
|
{
|
||||||
/* current wheel values, parsed from dbop and the resulting button */
|
/* current wheel values, parsed from dbop and the resulting button */
|
||||||
unsigned wheel_value = 0;
|
unsigned wheel_value = 0;
|
||||||
|
@ -76,7 +76,7 @@ static void scrollwheel(short dbop)
|
||||||
{ 2, 0, 3, 1 }, /* Clockwise rotation */
|
{ 2, 0, 3, 1 }, /* Clockwise rotation */
|
||||||
{ 1, 3, 0, 2 }, /* Counter-clockwise */
|
{ 1, 3, 0, 2 }, /* Counter-clockwise */
|
||||||
};
|
};
|
||||||
wheel_value = dbop & (1<<13|1<<14);
|
wheel_value = dbop_din & (1<<13|1<<14);
|
||||||
wheel_value >>= 13;
|
wheel_value >>= 13;
|
||||||
|
|
||||||
if (old_wheel_value == wheel_tbl[0][wheel_value])
|
if (old_wheel_value == wheel_tbl[0][wheel_value])
|
||||||
|
@ -90,7 +90,7 @@ static void scrollwheel(short dbop)
|
||||||
{
|
{
|
||||||
/* direction reversals nullify repeats */
|
/* direction reversals nullify repeats */
|
||||||
wheel_repeat = btn;
|
wheel_repeat = btn;
|
||||||
repeat = 0;
|
repeat = counter = 0;
|
||||||
}
|
}
|
||||||
if (btn != BUTTON_NONE)
|
if (btn != BUTTON_NONE)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,7 @@ static void button_delay(void)
|
||||||
while(i--);
|
while(i--);
|
||||||
}
|
}
|
||||||
|
|
||||||
static short button_dbop(void)
|
short button_read_dbop(void)
|
||||||
{
|
{
|
||||||
/* skip home and power reading if lcd_button_support was blocked,
|
/* skip home and power reading if lcd_button_support was blocked,
|
||||||
* since the dbop bit 15 is invalid then, and use the old value instead */
|
* since the dbop bit 15 is invalid then, and use the old value instead */
|
||||||
|
@ -150,27 +150,24 @@ static short button_dbop(void)
|
||||||
old_home_power = (_dbop_din & (1<<15|1<<8));
|
old_home_power = (_dbop_din & (1<<15|1<<8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for fifo to empty */
|
/* Set up dbop for input */
|
||||||
while ((DBOP_STAT & (1<<10)) == 0);
|
while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */
|
||||||
|
DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */
|
||||||
DBOP_CTRL |= (1<<19);
|
DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
|
||||||
DBOP_CTRL &= ~(1<<16); /* disable output */
|
DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
|
||||||
|
DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
|
||||||
DBOP_TIMPOL_01 = 0xe167e167;
|
|
||||||
DBOP_TIMPOL_23 = 0xe167006e;
|
|
||||||
|
|
||||||
button_delay();
|
button_delay();
|
||||||
|
DBOP_CTRL |= (1<<15); /* start read */
|
||||||
|
while (!(DBOP_STAT & (1<<16))); /* wait for valid data */
|
||||||
|
|
||||||
DBOP_CTRL |= (1<<15); /* start read */
|
_dbop_din = DBOP_DIN; /* Read dbop data*/
|
||||||
while((DBOP_STAT & (1<<16)) == 0); /* wait for valid data */
|
|
||||||
|
|
||||||
_dbop_din = DBOP_DIN; /* now read */
|
/* Reset dbop for output */
|
||||||
|
DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
|
||||||
DBOP_TIMPOL_01 = 0x6e167;
|
DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
|
||||||
DBOP_TIMPOL_23 = 0xa167e06f;
|
DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
|
||||||
|
DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */
|
||||||
DBOP_CTRL |= (1<<16);
|
|
||||||
DBOP_CTRL &= ~(1<<19);
|
|
||||||
|
|
||||||
/* write back old values if blocked */
|
/* write back old values if blocked */
|
||||||
if (old_home_power != -20)
|
if (old_home_power != -20)
|
||||||
|
@ -178,6 +175,10 @@ static short button_dbop(void)
|
||||||
_dbop_din |= old_home_power & 1<<15;
|
_dbop_din |= old_home_power & 1<<15;
|
||||||
_dbop_din &= 0xfeff|(old_home_power & 1<<8);
|
_dbop_din &= 0xfeff|(old_home_power & 1<<8);
|
||||||
}
|
}
|
||||||
|
#if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER)
|
||||||
|
/* read wheel on bit 13 & 14, but sent to the button queue seperately */
|
||||||
|
scrollwheel(_dbop_din);
|
||||||
|
#endif
|
||||||
return _dbop_din;
|
return _dbop_din;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ static int button_gpio(void)
|
||||||
int button_read_device(void)
|
int button_read_device(void)
|
||||||
{
|
{
|
||||||
int btn = BUTTON_NONE;
|
int btn = BUTTON_NONE;
|
||||||
short dbop = button_dbop();
|
short dbop = button_read_dbop();
|
||||||
static unsigned power_counter = 0;
|
static unsigned power_counter = 0;
|
||||||
/* hold button */
|
/* hold button */
|
||||||
if(dbop & (1<<12))
|
if(dbop & (1<<12))
|
||||||
|
@ -244,10 +245,6 @@ int button_read_device(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hold_button = false;
|
hold_button = false;
|
||||||
#if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER)
|
|
||||||
/* read wheel on bit 13 & 14, but sent to the button queue seperately */
|
|
||||||
scrollwheel(dbop);
|
|
||||||
#endif
|
|
||||||
/* read power on bit 8, but not if hold button was just released, since
|
/* read power on bit 8, but not if hold button was just released, since
|
||||||
* you basically always hit power due to the slider mechanism after releasing
|
* you basically always hit power due to the slider mechanism after releasing
|
||||||
* hold (wait ~1 sec) */
|
* hold (wait ~1 sec) */
|
||||||
|
|
Loading…
Reference in a new issue