A note hitting game for the mbed LPC 1768. User uses a joystick to hit notes as they come down the screen in 3 different lanes.

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player

Nav_Switch.cpp

Committer:
jmpin
Date:
2016-03-17
Revision:
1:94b1ec213686

File content as of revision 1:94b1ec213686:

#include "mbed.h"
#include "Nav_Switch.h"


Nav_Switch::Nav_Switch (PinName up,PinName down,PinName left,PinName right,PinName fire):
    _pins(up, down, left, right, fire)
{
    _pins.mode(PullUp); //needed if pullups not on board or a bare nav switch is used - delete otherwise
    wait(0.001); //delays just a bit for pullups to pull inputs high
}
inline bool Nav_Switch::up()
{
    return !(_pins[0]);
}
inline bool Nav_Switch::down()
{
    return !(_pins[1]);
}
inline bool Nav_Switch::left()
{
    return !(_pins[2]);
}
inline bool Nav_Switch::right()
{
    return !(_pins[3]);
}
bool Nav_Switch::fire()
{
    return !(_pins[4]);
}
int Nav_Switch::read()
{
    return _pins.read();
}
Nav_Switch::operator int()
{
    return _pins.read();
}