Gregory Boudreau / Mbed 2 deprecated Lab6_2036_turkey_greg

Dependencies:   4DGL-uLCD-SE PinDetect mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers joystick.cpp Source File

joystick.cpp

00001 #include "mbed.h"
00002 #include "joystick.h"
00003 
00004 
00005 Nav_Switch::Nav_Switch (PinName up,PinName down,PinName left,PinName right,PinName fire):
00006     _pins(up, down, left, right, fire)
00007 {
00008     _pins.mode(PullUp); //needed if pullups not on board or a bare nav switch is used - delete otherwise
00009     wait(0.001); //delays just a bit for pullups to pull inputs high
00010 }
00011 
00012 bool Nav_Switch::up()
00013 {
00014     return !(_pins[0]);
00015 }
00016 bool Nav_Switch::down()
00017 {
00018     return !(_pins[1]);
00019 }
00020 bool Nav_Switch::left()
00021 {
00022     return !(_pins[2]);
00023 }
00024 bool Nav_Switch::right()
00025 {
00026     return !(_pins[3]);
00027 }
00028 bool Nav_Switch::fire()
00029 {
00030     return !(_pins[4]);
00031 }
00032 int Nav_Switch::read()
00033 {
00034     return _pins.read();
00035 }
00036 Nav_Switch::operator int ()
00037 {
00038     return _pins.read();
00039 }