sqefqsdf
Dependencies: C12832 EthernetInterface LM75B mbed-rtos mbed
Fork of app-board-LM75B by
Joystick.h@6:77a4c45f6416, 2017-03-23 (annotated)
- Committer:
- gimohd
- Date:
- Thu Mar 23 12:51:27 2017 +0000
- Revision:
- 6:77a4c45f6416
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gimohd | 6:77a4c45f6416 | 1 | #ifndef Joystick_H |
gimohd | 6:77a4c45f6416 | 2 | #define Joystick_H |
gimohd | 6:77a4c45f6416 | 3 | |
gimohd | 6:77a4c45f6416 | 4 | #include "mbed.h" |
gimohd | 6:77a4c45f6416 | 5 | //Class to control an RGB LED using three PWM pins |
gimohd | 6:77a4c45f6416 | 6 | class Joystick |
gimohd | 6:77a4c45f6416 | 7 | { |
gimohd | 6:77a4c45f6416 | 8 | |
gimohd | 6:77a4c45f6416 | 9 | public: |
gimohd | 6:77a4c45f6416 | 10 | |
gimohd | 6:77a4c45f6416 | 11 | /** |
gimohd | 6:77a4c45f6416 | 12 | * Represents the possible directions of the joystick |
gimohd | 6:77a4c45f6416 | 13 | */ |
gimohd | 6:77a4c45f6416 | 14 | enum Direction { |
gimohd | 6:77a4c45f6416 | 15 | UP, |
gimohd | 6:77a4c45f6416 | 16 | DOWN, |
gimohd | 6:77a4c45f6416 | 17 | LEFT, |
gimohd | 6:77a4c45f6416 | 18 | RIGHT, |
gimohd | 6:77a4c45f6416 | 19 | MIDDLE, |
gimohd | 6:77a4c45f6416 | 20 | NONE |
gimohd | 6:77a4c45f6416 | 21 | }; |
gimohd | 6:77a4c45f6416 | 22 | |
gimohd | 6:77a4c45f6416 | 23 | /** Creates an object of a joystick which can be used to control |
gimohd | 6:77a4c45f6416 | 24 | * |
gimohd | 6:77a4c45f6416 | 25 | * @param up |
gimohd | 6:77a4c45f6416 | 26 | * @param down |
gimohd | 6:77a4c45f6416 | 27 | * @param right |
gimohd | 6:77a4c45f6416 | 28 | * @param right |
gimohd | 6:77a4c45f6416 | 29 | * @param middle |
gimohd | 6:77a4c45f6416 | 30 | * @returns the average temperature in °C |
gimohd | 6:77a4c45f6416 | 31 | */ |
gimohd | 6:77a4c45f6416 | 32 | Joystick(PinName up, PinName down, PinName left, PinName right, PinName middle); |
gimohd | 6:77a4c45f6416 | 33 | |
gimohd | 6:77a4c45f6416 | 34 | /** |
gimohd | 6:77a4c45f6416 | 35 | * The destructor of the Joystick destroying all the DigitalIn objects |
gimohd | 6:77a4c45f6416 | 36 | */ |
gimohd | 6:77a4c45f6416 | 37 | ~Joystick(); |
gimohd | 6:77a4c45f6416 | 38 | |
gimohd | 6:77a4c45f6416 | 39 | /** |
gimohd | 6:77a4c45f6416 | 40 | * Gets the direction the joystick is pressed |
gimohd | 6:77a4c45f6416 | 41 | * |
gimohd | 6:77a4c45f6416 | 42 | * @return the direction of the joystick |
gimohd | 6:77a4c45f6416 | 43 | */ |
gimohd | 6:77a4c45f6416 | 44 | Direction getDirection(); |
gimohd | 6:77a4c45f6416 | 45 | |
gimohd | 6:77a4c45f6416 | 46 | private: |
gimohd | 6:77a4c45f6416 | 47 | DigitalIn * up; |
gimohd | 6:77a4c45f6416 | 48 | DigitalIn * down; |
gimohd | 6:77a4c45f6416 | 49 | DigitalIn * left; |
gimohd | 6:77a4c45f6416 | 50 | DigitalIn * right; |
gimohd | 6:77a4c45f6416 | 51 | DigitalIn * middle; |
gimohd | 6:77a4c45f6416 | 52 | Direction direction; |
gimohd | 6:77a4c45f6416 | 53 | }; |
gimohd | 6:77a4c45f6416 | 54 | |
gimohd | 6:77a4c45f6416 | 55 | #endif |