Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.

Dependencies:   mbed Watchdog SDFileSystem DigoleSerialDisp

Committer:
shimniok
Date:
Fri Nov 30 15:41:05 2018 +0000
Revision:
23:a34af501ea89
Parent:
12:5dfa1ab47838
Disabled PinDetect code (for now); fixed attach() calls in various functions to use new callback class.

Who changed what in which revision?

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