Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Committer:
shimniok
Date:
Wed Jun 20 14:57:48 2012 +0000
Revision:
0:826c6171fc1b
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:826c6171fc1b 1 #include "Buttons.h"
shimniok 0:826c6171fc1b 2 #include "PinDetect.h"
shimniok 0:826c6171fc1b 3
shimniok 0:826c6171fc1b 4 PinDetect nextButton(p14);
shimniok 0:826c6171fc1b 5 PinDetect selectButton(p16); // Input selectButton
shimniok 0:826c6171fc1b 6 PinDetect prevButton(p15);
shimniok 0:826c6171fc1b 7
shimniok 0:826c6171fc1b 8 Buttons::Buttons(void): which(0), pressed(false)
shimniok 0:826c6171fc1b 9 {
shimniok 0:826c6171fc1b 10 }
shimniok 0:826c6171fc1b 11
shimniok 0:826c6171fc1b 12 void Buttons::init()
shimniok 0:826c6171fc1b 13 {
shimniok 0:826c6171fc1b 14
shimniok 0:826c6171fc1b 15 // Set up button (plugs into two GPIOs, active low
shimniok 0:826c6171fc1b 16 selectButton.mode(PullUp);
shimniok 0:826c6171fc1b 17 selectButton.setSamplesTillAssert(50);
shimniok 0:826c6171fc1b 18 selectButton.setAssertValue(0); // active low logic
shimniok 0:826c6171fc1b 19 selectButton.setSampleFrequency(50); // us
shimniok 0:826c6171fc1b 20 selectButton.attach_asserted( this, &Buttons::selectPressed );
shimniok 0:826c6171fc1b 21
shimniok 0:826c6171fc1b 22 nextButton.mode(PullUp);
shimniok 0:826c6171fc1b 23 nextButton.setSamplesTillAssert(50);
shimniok 0:826c6171fc1b 24 nextButton.setAssertValue(0); // active low logic
shimniok 0:826c6171fc1b 25 nextButton.setSampleFrequency(50); // us
shimniok 0:826c6171fc1b 26 nextButton.attach_asserted( this, &Buttons::nextPressed );
shimniok 0:826c6171fc1b 27
shimniok 0:826c6171fc1b 28 prevButton.mode(PullUp);
shimniok 0:826c6171fc1b 29 prevButton.setSamplesTillAssert(50);
shimniok 0:826c6171fc1b 30 prevButton.setAssertValue(0); // active low logic
shimniok 0:826c6171fc1b 31 prevButton.setSampleFrequency(50); // us
shimniok 0:826c6171fc1b 32 prevButton.attach_asserted( this, &Buttons::prevPressed );
shimniok 0:826c6171fc1b 33 }
shimniok 0:826c6171fc1b 34
shimniok 0:826c6171fc1b 35 void Buttons::nextPressed()
shimniok 0:826c6171fc1b 36 {
shimniok 0:826c6171fc1b 37 pressed = true;
shimniok 0:826c6171fc1b 38 which = NEXT_BUTTON;
shimniok 0:826c6171fc1b 39 }
shimniok 0:826c6171fc1b 40
shimniok 0:826c6171fc1b 41 void Buttons::prevPressed()
shimniok 0:826c6171fc1b 42 {
shimniok 0:826c6171fc1b 43 pressed = true;
shimniok 0:826c6171fc1b 44 which = PREV_BUTTON;
shimniok 0:826c6171fc1b 45 }
shimniok 0:826c6171fc1b 46
shimniok 0:826c6171fc1b 47 void Buttons::selectPressed()
shimniok 0:826c6171fc1b 48 {
shimniok 0:826c6171fc1b 49 pressed = true;
shimniok 0:826c6171fc1b 50 which = SELECT_BUTTON;
shimniok 0:826c6171fc1b 51 }