Input library for the STMstation P.1. Facilitates button state checking and battery voltage checking.

Library to check button states and battery voltage for the STMstation P.1.

/media/uploads/kkado/imgp1229.jpg

See API documentation for detailed information.

Committer:
kkado
Date:
Mon Jul 03 09:24:06 2017 +0000
Revision:
1:8c73c4795f92
Parent:
0:6951d1eef6ad
First public release.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kkado 0:6951d1eef6ad 1 #ifndef STMstation_input_h
kkado 0:6951d1eef6ad 2 #define STMstation_input_h
kkado 0:6951d1eef6ad 3
kkado 0:6951d1eef6ad 4 #include "mbed.h"
kkado 0:6951d1eef6ad 5
kkado 1:8c73c4795f92 6 #define UP_PIN PA_0
kkado 1:8c73c4795f92 7 #define DOWN_PIN PC_3
kkado 1:8c73c4795f92 8 #define LEFT_PIN PC_2
kkado 1:8c73c4795f92 9 #define RIGHT_PIN PA_1
kkado 1:8c73c4795f92 10 #define A_PIN PB_10
kkado 1:8c73c4795f92 11 #define B_PIN PB_12
kkado 1:8c73c4795f92 12 #define X_PIN PB_1
kkado 1:8c73c4795f92 13 #define Y_PIN PB_2
kkado 0:6951d1eef6ad 14 #define START_PIN PB_4
kkado 0:6951d1eef6ad 15 #define SELECT_PIN PB_5
kkado 0:6951d1eef6ad 16
kkado 1:8c73c4795f92 17 #define BAT_PIN PC_0
kkado 1:8c73c4795f92 18
kkado 1:8c73c4795f92 19 /** Input library for the STMstation P.1
kkado 1:8c73c4795f92 20 * Provides information on button states (keydown, keyup, keypress) for each of the
kkado 1:8c73c4795f92 21 * 10 user buttons (up, down, left, right, a, b, x, y, start, select).
kkado 1:8c73c4795f92 22 */
kkado 0:6951d1eef6ad 23 class STMstation_input{
kkado 0:6951d1eef6ad 24 public:
kkado 1:8c73c4795f92 25 ///Create an instance of STMstation_input
kkado 0:6951d1eef6ad 26 STMstation_input();
kkado 0:6951d1eef6ad 27 enum Button {UP, DOWN, LEFT, RIGHT, A, B, X, Y, START, SELECT};
kkado 1:8c73c4795f92 28 ///Update the state of all buttons
kkado 0:6951d1eef6ad 29 void updateButtons();
kkado 1:8c73c4795f92 30 ///Check if a keydown event has occurred
kkado 0:6951d1eef6ad 31 bool keyDown(Button b);
kkado 1:8c73c4795f92 32 ///Check if a keyup event has occurred
kkado 0:6951d1eef6ad 33 bool keyUp(Button b);
kkado 1:8c73c4795f92 34 ///Check if a button is pressed
kkado 0:6951d1eef6ad 35 bool keyPress(Button b);
kkado 1:8c73c4795f92 36 ///Check battery voltage
kkado 1:8c73c4795f92 37 float batCheck();
kkado 0:6951d1eef6ad 38 private:
kkado 0:6951d1eef6ad 39 bool buttonPress[10];
kkado 0:6951d1eef6ad 40 bool buttonDown[10];
kkado 0:6951d1eef6ad 41 bool buttonUp[10];
kkado 0:6951d1eef6ad 42 DigitalIn D_UP, D_DOWN, D_LEFT, D_RIGHT, D_A, D_B, D_X, D_Y, D_START, D_SELECT;
kkado 1:8c73c4795f92 43 AnalogIn bat;
kkado 0:6951d1eef6ad 44 };
kkado 0:6951d1eef6ad 45
kkado 0:6951d1eef6ad 46 #endif