summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-10-28 23:10:45 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-10-28 23:10:45 +0000
commitc4a0d45d36cf093425146c93c25c8f97df87a854 (patch)
treefaf8486c7e296c2272c3b2b277c097ad50ceb695
parent56e75bee23b0458ebe5198912c024475c762c355 (diff)
downloadrockbox-c4a0d45d36cf093425146c93c25c8f97df87a854.zip
rockbox-c4a0d45d36cf093425146c93c25c8f97df87a854.tar.gz
rockbox-c4a0d45d36cf093425146c93c25c8f97df87a854.tar.bz2
rockbox-c4a0d45d36cf093425146c93c25c8f97df87a854.tar.xz
Cleanup of new button reading code. Moved functions for enabling of scanning and the decision to scan or not to button_read_device.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11377 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c2
-rw-r--r--firmware/target/coldfire/iaudio/x5/adc-target.h2
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/adc-x5.c26
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-target.h2
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-x5.c40
-rw-r--r--firmware/target/coldfire/iaudio/x5/pcf50606-x5.c6
6 files changed, 31 insertions, 47 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 712a66c..251d3b3 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1072,7 +1072,7 @@ bool dbg_ports(void)
#ifdef IAUDIO_X5
snprintf(buf, sizeof(buf), "ADC_BUTTONS (%c): %02x",
- adc_get_button_scan_enabled() ? '+' : '-', adc_buttons);
+ button_scan_enabled() ? '+' : '-', adc_buttons);
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "ADC_REMOTE (%c): %02x",
remote_detect() ? '+' : '-', adc_remote);
diff --git a/firmware/target/coldfire/iaudio/x5/adc-target.h b/firmware/target/coldfire/iaudio/x5/adc-target.h
index 51e8536..4081562 100644
--- a/firmware/target/coldfire/iaudio/x5/adc-target.h
+++ b/firmware/target/coldfire/iaudio/x5/adc-target.h
@@ -28,7 +28,5 @@
/* Force a scan now */
unsigned short adc_scan(int channel);
-void adc_enable_button_scan(bool enable);
-bool adc_get_button_scan_enabled(void);
#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c
index c923951..72aec7d 100755
--- a/firmware/target/coldfire/iaudio/x5/adc-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/adc-x5.c
@@ -33,37 +33,11 @@ static const int adcc2_parms[] =
[ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */
};
-/* have buttons scan by default */
-static volatile bool button_scan_on = true;
-
-void adc_enable_button_scan(bool enable)
-{
- button_scan_on = enable;
-}
-
-bool adc_get_button_scan_enabled(void)
-{
- return button_scan_on;
-}
-
unsigned short adc_scan(int channel)
{
int level;
unsigned char data;
- if (channel == ADC_BUTTONS)
- {
- /* no button scan if nothing pushed */
- if (!button_scan_on)
- return adcdata[channel] = 0xff;
- }
- else if (channel == ADC_REMOTE)
- {
- /* no remote scan if not plugged */
- if (GPIO_READ & 0x01000000)
- return adcdata[channel] = 0xff;
- }
-
level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x2f, adcc2_parms[channel]);
diff --git a/firmware/target/coldfire/iaudio/x5/button-target.h b/firmware/target/coldfire/iaudio/x5/button-target.h
index ab6e770..af1088d 100755
--- a/firmware/target/coldfire/iaudio/x5/button-target.h
+++ b/firmware/target/coldfire/iaudio/x5/button-target.h
@@ -29,6 +29,8 @@ bool button_hold(void);
bool remote_button_hold(void);
void button_init_device(void);
int button_read_device(void);
+void button_enable_scan(bool enable);
+bool button_scan_enabled(void);
/* iaudio X5 specific button codes */
diff --git a/firmware/target/coldfire/iaudio/x5/button-x5.c b/firmware/target/coldfire/iaudio/x5/button-x5.c
index 5874e01..7cb86ff 100755
--- a/firmware/target/coldfire/iaudio/x5/button-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/button-x5.c
@@ -16,16 +16,17 @@
* KIND, either express or implied.
*
****************************************************************************/
-
-#include <stdlib.h>
#include "config.h"
-#include "cpu.h"
#include "system.h"
#include "button.h"
-#include "kernel.h"
#include "backlight.h"
#include "adc.h"
-#include "system.h"
+#include "lcd-remote-target.h"
+
+/* have buttons scan by default */
+static bool button_scan_on = true;
+static bool hold_button = false;
+static bool remote_hold_button = false;
void button_init_device(void)
{
@@ -34,24 +35,32 @@ void button_init_device(void)
GPIO_ENABLE &= ~0x0e000000;
}
+void button_enable_scan(bool enable)
+{
+ button_scan_on = enable;
+}
+
+bool button_scan_enabled(void)
+{
+ return button_scan_on;
+}
+
bool button_hold(void)
{
- return (GPIO_READ & 0x08000000)?false:true;
+ return (GPIO_READ & 0x08000000) == 0;
}
bool remote_button_hold(void)
{
- return adc_scan(ADC_REMOTE) < 0x17;
+ return remote_hold_button;
}
int button_read_device(void)
{
- int data;
- int btn = BUTTON_NONE;
- static bool hold_button = false;
- static bool remote_hold_button = false;
+ int btn = BUTTON_NONE;
bool hold_button_old;
bool remote_hold_button_old;
+ int data;
/* normal buttons */
hold_button_old = hold_button;
@@ -63,9 +72,10 @@ int button_read_device(void)
backlight_hold_changed(hold_button);
#endif
- if (!hold_button)
+ if (button_scan_on && !hold_button)
{
data = adc_scan(ADC_BUTTONS);
+
if (data < 0xf0)
{
if(data < 0x7c)
@@ -91,9 +101,9 @@ int button_read_device(void)
}
/* remote buttons */
- remote_hold_button_old = remote_hold_button;
+ data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff;
- data = adc_scan(ADC_REMOTE);
+ remote_hold_button_old = remote_hold_button;
remote_hold_button = data < 0x17;
#ifndef BOOTLOADER
@@ -101,7 +111,7 @@ int button_read_device(void)
remote_backlight_hold_changed(remote_hold_button);
#endif
- if(!remote_hold_button)
+ if (!remote_hold_button)
{
if (data < 0xee)
{
diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
index 8b3655c..3443d1e 100644
--- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
@@ -20,7 +20,7 @@
#include "system.h"
#include "kernel.h"
#include "pcf50606.h"
-#include "adc.h"
+#include "button-target.h"
#include "powermgmt.h"
/* These voltages were determined by measuring the output of the PCF50606
@@ -130,7 +130,7 @@ void GPI0(void)
/* ACDINS/ACDREM */
/* Check if adc_scan should actually scan main buttons or not -
bias towards "yes" out of paranoia. */
- adc_enable_button_scan((data[2] & 0x02) != 0 ||
- (pcf50606_read(0x33) & 0x01) != 0);
+ button_enable_scan((data[2] & 0x02) != 0 ||
+ (pcf50606_read(0x33) & 0x01) != 0);
}
}