From 0efdd7a5f74c955d0eb604cd3fef9069be57bcbb Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 27 Jan 2008 21:13:04 +0000 Subject: Use the timeout API as a oneshot for headphone plug debouncing. Set at 1s for now which seems comfortable and was good for meg-fx but target-specific adjustment is easy enough (my 3G hp jack is dead so I can't check that one :( ). Do some minor rearrangements for init safety and consistency. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16178 a1c6a512-1295-4272-9138-f99709370657 --- .../target/arm/s3c2440/gigabeat-fx/button-meg-fx.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'firmware/target/arm/s3c2440/gigabeat-fx') diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c index 4a818d6bfc..a80663d0d6 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c @@ -76,6 +76,16 @@ int button_read_device(void) /* Only one button can be sensed at a time on the remote. */ /* Need to filter the remote button because the ADC is so fast */ remote_adc = adc_read(ADC_HPREMOTE); + + if (remote_adc != ADC_READ_ERROR) + { + /* If there is nothing in the headphone socket, the ADC reads high */ + if (remote_adc < 940) + headphones_detect = true; + else + headphones_detect = false; + } + btn = remote_buttons[(remote_adc + 64) / 128]; if (btn != lastbutton) { @@ -136,14 +146,5 @@ int button_read_device(void) bool headphones_inserted(void) { - unsigned short remote_adc = adc_read(ADC_HPREMOTE); - if (remote_adc != ADC_READ_ERROR) - { - /* If there is nothing in the headphone socket, the ADC reads high */ - if (remote_adc < 940) - headphones_detect = true; - else - headphones_detect = false; - } return headphones_detect; } -- cgit v1.2.3