diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-04-13 10:28:06 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-04-13 10:28:06 +0000 |
commit | e5e41c3a82bfd546a686a758ca3a382d0173a3e2 (patch) | |
tree | 1434c0bdb7f52b44db96f87c9a75352110b22174 /firmware/target/arm/as3525/sansa-fuze/button-fuze.c | |
parent | 65aa187aef48191ea2d65e804493a18e9e900da7 (diff) | |
download | rockbox-e5e41c3a82bfd546a686a758ca3a382d0173a3e2.tar.gz rockbox-e5e41c3a82bfd546a686a758ca3a382d0173a3e2.zip |
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
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze/button-fuze.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/button-fuze.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c index f32776f6eb..f532a96431 100644 --- a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c @@ -49,7 +49,7 @@ void button_init_device(void) } #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 */ unsigned wheel_value = 0; @@ -76,7 +76,7 @@ static void scrollwheel(short dbop) { 2, 0, 3, 1 }, /* Clockwise rotation */ { 1, 3, 0, 2 }, /* Counter-clockwise */ }; - wheel_value = dbop & (1<<13|1<<14); + wheel_value = dbop_din & (1<<13|1<<14); wheel_value >>= 13; if (old_wheel_value == wheel_tbl[0][wheel_value]) @@ -90,7 +90,7 @@ static void scrollwheel(short dbop) { /* direction reversals nullify repeats */ wheel_repeat = btn; - repeat = 0; + repeat = counter = 0; } if (btn != BUTTON_NONE) { @@ -139,7 +139,7 @@ static void button_delay(void) while(i--); } -static short button_dbop(void) +short button_read_dbop(void) { /* 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 */ @@ -150,27 +150,24 @@ static short button_dbop(void) old_home_power = (_dbop_din & (1<<15|1<<8)); } - /* Wait for fifo to empty */ - while ((DBOP_STAT & (1<<10)) == 0); - - DBOP_CTRL |= (1<<19); - DBOP_CTRL &= ~(1<<16); /* disable output */ - - DBOP_TIMPOL_01 = 0xe167e167; - DBOP_TIMPOL_23 = 0xe167006e; + /* Set up dbop for input */ + while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */ + DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */ + DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */ + DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ + DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ button_delay(); + DBOP_CTRL |= (1<<15); /* start read */ + while (!(DBOP_STAT & (1<<16))); /* wait for valid data */ - DBOP_CTRL |= (1<<15); /* start read */ - while((DBOP_STAT & (1<<16)) == 0); /* wait for valid data */ - - _dbop_din = DBOP_DIN; /* now read */ + _dbop_din = DBOP_DIN; /* Read dbop data*/ - DBOP_TIMPOL_01 = 0x6e167; - DBOP_TIMPOL_23 = 0xa167e06f; - - DBOP_CTRL |= (1<<16); - DBOP_CTRL &= ~(1<<19); + /* Reset dbop for output */ + DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */ + DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */ + DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */ + DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */ /* write back old values if blocked */ if (old_home_power != -20) @@ -178,6 +175,10 @@ static short button_dbop(void) _dbop_din |= old_home_power & 1<<15; _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; } @@ -233,7 +234,7 @@ static int button_gpio(void) int button_read_device(void) { int btn = BUTTON_NONE; - short dbop = button_dbop(); + short dbop = button_read_dbop(); static unsigned power_counter = 0; /* hold button */ if(dbop & (1<<12)) @@ -244,10 +245,6 @@ int button_read_device(void) else { 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 * you basically always hit power due to the slider mechanism after releasing * hold (wait ~1 sec) */ |