09-17-2013, 11:55 AM
|
#11 (permalink)
|
MPGuino Supporter
Join Date: Oct 2010
Location: Hungary
Posts: 1,807
iNXS - '10 Opel Zafira 111 Anniversary Suzi - '02 Suzuki Swift GL
Thanks: 830
Thanked 708 Times in 456 Posts
|
I'm working on integrating your code into the 1.86tav MPGuino software. Currently, I'm having issues with getting the software to immediately recognize a keypress. (I am trying to retain long-button-press functionality).
|
|
|
Today
|
|
|
Other popular topics in this forum...
|
|
|
09-17-2013, 04:44 PM
|
#12 (permalink)
|
EcoModding Apprentice
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
|
The keypress should be recognized when the key is released, and returns to "buttonsUp" -- provided it has passed the debounce period (nominally 29ms in the posted code, but a lower value might work too), For a quick keypress, this should appear to be instant, since the timer2 ISR is firing every 1msec. You could probably also trigger it, after passing the LongPress threshold, and not wait for buttonsUp.
The one difference i can think of, is that an extra variable, buttonGood, is now required. It wasn't needed before, because PCINT_vect was detecting pin changes on that port.
|
|
|
09-23-2013, 02:09 PM
|
#13 (permalink)
|
MPGuino Supporter
Join Date: Oct 2010
Location: Hungary
Posts: 1,807
iNXS - '10 Opel Zafira 111 Anniversary Suzi - '02 Suzuki Swift GL
Thanks: 830
Thanked 708 Times in 456 Posts
|
My code has the button detection in the ADC interrupt handler, operating as you had described, nickdigger. My FIR filtering routine and my analog pin channel switching routine were not playing very nicely with each other, which interfered with the analog button signal timing, which caused the software to recognize all keypresses as long keypresses. I stripped out the FIR filter for now. Currently working on reintegrating FIR filtering.
In the meantime, both short- and long-button press functionality is retained.
I got the code to work with a 5 button configuration. This should allow for adding something along the lines of a Parallax 5-position switch.
I also changed the code to more easily accommodate recognizing more than 3 different buttons.
|
|
|
09-23-2013, 05:40 PM
|
#14 (permalink)
|
EcoModding Apprentice
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
|
Maybe you can selectively turn the filter on/off for different ADC channels?
Also, the Arduino code for that Parallax switch indicates they are using 5 digital inputs, not one analog. I haven't taken a closer look at the specs to see if analog output is an option, but their page only mentions "a 10k resistor", which doesn't sound promising.
|
|
|
09-23-2013, 06:03 PM
|
#15 (permalink)
|
MPGuino Supporter
Join Date: Oct 2010
Location: Hungary
Posts: 1,807
iNXS - '10 Opel Zafira 111 Anniversary Suzi - '02 Suzuki Swift GL
Thanks: 830
Thanked 708 Times in 456 Posts
|
Quote:
Originally Posted by nickdigger
Maybe you can selectively turn the filter on/off for different ADC channels?
|
Thought about doing that - that'd introduce more complexity, and I'm not sure if that's such a good thing for an interrupt handler that must fire off fairly quickly. Might do it anyhow, though.
Edit: On second thought, after reviewing the AtMega128/168/328 datasheet, might just abandon the FIR filter altogether.
Quote:
Originally Posted by nickdigger
Also, the Arduino code for that Parallax switch indicates they are using 5 digital inputs, not one analog. I haven't taken a closer look at the specs to see if analog output is an option, but their page only mentions "a 10k resistor", which doesn't sound promising.
|
Looking at the switch hardware in my hands (yes, I bought one from RadioShack), I notice that it has just a bunch of SMT 10k pullup resistors. That's your digital signalling. Remove them, and you have something that is usable. Heck, you might even be able to use the switch without removing the resistors - it'd just be a matter of doing some signal analysis with the pullup resistors added into the analysis.
Last edited by t vago; 09-23-2013 at 06:41 PM..
|
|
|
09-24-2013, 11:04 PM
|
#16 (permalink)
|
MPGuino Supporter
Join Date: Oct 2010
Location: Hungary
Posts: 1,807
iNXS - '10 Opel Zafira 111 Anniversary Suzi - '02 Suzuki Swift GL
Thanks: 830
Thanked 708 Times in 456 Posts
|
Added Parallax 5-position switch support. Since the Parallax 5-position switch does not do simultaneous left + right button presses, I've defined the up position as left + right.
|
|
|
09-25-2013, 05:47 PM
|
#17 (permalink)
|
EcoModding Apprentice
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
|
So the Parallax does have analog output, as well as the 5 digitals? Too bad it costs so much.
|
|
|
09-28-2013, 11:02 AM
|
#18 (permalink)
|
EcoModding Apprentice
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
|
Quote:
Originally Posted by nickdigger
So the Parallax does have analog output, as well as the 5 digitals? Too bad it costs so much.
|
This here is different but cheaper, operation must be same.
5-Way Tactile Breakout Board Jaycon Systems LLC
José Rodrigues
|
|
|
The Following User Says Thank You to josemapiro For This Useful Post:
|
|
09-28-2013, 12:58 PM
|
#19 (permalink)
|
MPGuino Supporter
Join Date: Oct 2010
Location: Hungary
Posts: 1,807
iNXS - '10 Opel Zafira 111 Anniversary Suzi - '02 Suzuki Swift GL
Thanks: 830
Thanked 708 Times in 456 Posts
|
Quote:
Originally Posted by josemapiro
|
And the schematic appears to show exactly the same pull-up resistor configuration as with the Parallax switch. This should work with v1.86tav, with no code modifications.
|
|
|
09-09-2014, 12:43 AM
|
#20 (permalink)
|
EcoModding Lurker
Join Date: Sep 2014
Location: Brishane
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
Hi Just wondering if this thread is still going and if I can ask a question about my car MPGuino Project? ....When I understand things a bit more!
Its about using 5 switches to replace old trip computer in my 1984 car.
current functions are Clock, Range, Trip, Timer, & Reset I'll post a Photo if I'm not Hijacking your thread.
Thanks
|
|
|
|