Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE PinDetect mbed
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 }
Generated on Tue Nov 22 2022 16:42:34 by
1.7.2