A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.
Dependencies: FATFileSystem
Fork of EALib by
TouchPanel.h@4:b32cf4ef45c5, 2013-10-18 (annotated)
- Committer:
- embeddedartists
- Date:
- Fri Oct 18 12:48:58 2013 +0200
- Revision:
- 4:b32cf4ef45c5
- Child:
- 12:15597e45eea0
Added AR1021 touch controller
Added MMA7455 accelerometer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 4:b32cf4ef45c5 | 1 | |
embeddedartists | 4:b32cf4ef45c5 | 2 | #ifndef TOUCHPANEL_H |
embeddedartists | 4:b32cf4ef45c5 | 3 | #define TOUCHPANEL_H |
embeddedartists | 4:b32cf4ef45c5 | 4 | |
embeddedartists | 4:b32cf4ef45c5 | 5 | |
embeddedartists | 4:b32cf4ef45c5 | 6 | /** |
embeddedartists | 4:b32cf4ef45c5 | 7 | * An abstract class that represents touch panels. |
embeddedartists | 4:b32cf4ef45c5 | 8 | */ |
embeddedartists | 4:b32cf4ef45c5 | 9 | class TouchPanel { |
embeddedartists | 4:b32cf4ef45c5 | 10 | public: |
embeddedartists | 4:b32cf4ef45c5 | 11 | |
embeddedartists | 4:b32cf4ef45c5 | 12 | typedef struct { |
embeddedartists | 4:b32cf4ef45c5 | 13 | int32_t x; |
embeddedartists | 4:b32cf4ef45c5 | 14 | int32_t y; |
embeddedartists | 4:b32cf4ef45c5 | 15 | int32_t z; |
embeddedartists | 4:b32cf4ef45c5 | 16 | } touchCoordinate_t; |
embeddedartists | 4:b32cf4ef45c5 | 17 | |
embeddedartists | 4:b32cf4ef45c5 | 18 | |
embeddedartists | 4:b32cf4ef45c5 | 19 | /** |
embeddedartists | 4:b32cf4ef45c5 | 20 | * Initialize the touch controller. This method must be called before |
embeddedartists | 4:b32cf4ef45c5 | 21 | * calibrating or reading data from the controller |
embeddedartists | 4:b32cf4ef45c5 | 22 | * |
embeddedartists | 4:b32cf4ef45c5 | 23 | * @param width the width of the touch panel. This is usually the same as |
embeddedartists | 4:b32cf4ef45c5 | 24 | * the width of the display |
embeddedartists | 4:b32cf4ef45c5 | 25 | * @param height the height of the touch panel. This is usually the same |
embeddedartists | 4:b32cf4ef45c5 | 26 | * as the height of the display. |
embeddedartists | 4:b32cf4ef45c5 | 27 | * |
embeddedartists | 4:b32cf4ef45c5 | 28 | * @return true if the request was successful; otherwise false |
embeddedartists | 4:b32cf4ef45c5 | 29 | */ |
embeddedartists | 4:b32cf4ef45c5 | 30 | virtual bool init(uint16_t width, uint16_t height) = 0; |
embeddedartists | 4:b32cf4ef45c5 | 31 | |
embeddedartists | 4:b32cf4ef45c5 | 32 | /** |
embeddedartists | 4:b32cf4ef45c5 | 33 | * Read coordinates from the touch panel. |
embeddedartists | 4:b32cf4ef45c5 | 34 | * |
embeddedartists | 4:b32cf4ef45c5 | 35 | * @param coord pointer to coordinate object. The read coordinates will be |
embeddedartists | 4:b32cf4ef45c5 | 36 | * written to this object. |
embeddedartists | 4:b32cf4ef45c5 | 37 | */ |
embeddedartists | 4:b32cf4ef45c5 | 38 | virtual bool read(touchCoordinate_t &coord) = 0; |
embeddedartists | 4:b32cf4ef45c5 | 39 | |
embeddedartists | 4:b32cf4ef45c5 | 40 | |
embeddedartists | 4:b32cf4ef45c5 | 41 | /** |
embeddedartists | 4:b32cf4ef45c5 | 42 | * Start to calibrate the display |
embeddedartists | 4:b32cf4ef45c5 | 43 | * |
embeddedartists | 4:b32cf4ef45c5 | 44 | * @return true if the request was successful; otherwise false |
embeddedartists | 4:b32cf4ef45c5 | 45 | */ |
embeddedartists | 4:b32cf4ef45c5 | 46 | virtual bool calibrateStart() = 0; |
embeddedartists | 4:b32cf4ef45c5 | 47 | |
embeddedartists | 4:b32cf4ef45c5 | 48 | /** |
embeddedartists | 4:b32cf4ef45c5 | 49 | * Get the next calibration point. Draw an indicator on the screen |
embeddedartists | 4:b32cf4ef45c5 | 50 | * at the coordinates and ask the user to press/click on the indicator. |
embeddedartists | 4:b32cf4ef45c5 | 51 | * Please note that waitForCalibratePoint() must be called after this |
embeddedartists | 4:b32cf4ef45c5 | 52 | * method. |
embeddedartists | 4:b32cf4ef45c5 | 53 | * |
embeddedartists | 4:b32cf4ef45c5 | 54 | * @param x the x coordinate is written to this argument |
embeddedartists | 4:b32cf4ef45c5 | 55 | * @param y the y coordinate is written to this argument |
embeddedartists | 4:b32cf4ef45c5 | 56 | * |
embeddedartists | 4:b32cf4ef45c5 | 57 | * @return true if the request was successful; otherwise false |
embeddedartists | 4:b32cf4ef45c5 | 58 | */ |
embeddedartists | 4:b32cf4ef45c5 | 59 | virtual bool getNextCalibratePoint(uint16_t* x, uint16_t* y) = 0; |
embeddedartists | 4:b32cf4ef45c5 | 60 | |
embeddedartists | 4:b32cf4ef45c5 | 61 | /** |
embeddedartists | 4:b32cf4ef45c5 | 62 | * Wait for a calibration point to have been pressed and recored. |
embeddedartists | 4:b32cf4ef45c5 | 63 | * This method must be called just after getNextCalibratePoint(). |
embeddedartists | 4:b32cf4ef45c5 | 64 | * |
embeddedartists | 4:b32cf4ef45c5 | 65 | * @param morePoints true is written to this argument if there |
embeddedartists | 4:b32cf4ef45c5 | 66 | * are more calibrations points available; otherwise it will be false |
embeddedartists | 4:b32cf4ef45c5 | 67 | * @param timeout maximum number of milliseconds to wait for |
embeddedartists | 4:b32cf4ef45c5 | 68 | * a calibration point. Set this argument to 0 to wait indefinite. |
embeddedartists | 4:b32cf4ef45c5 | 69 | * |
embeddedartists | 4:b32cf4ef45c5 | 70 | * @return true if the request was successful; otherwise false |
embeddedartists | 4:b32cf4ef45c5 | 71 | */ |
embeddedartists | 4:b32cf4ef45c5 | 72 | virtual bool waitForCalibratePoint(bool* morePoints, uint32_t timeout) = 0; |
embeddedartists | 4:b32cf4ef45c5 | 73 | |
embeddedartists | 4:b32cf4ef45c5 | 74 | |
embeddedartists | 4:b32cf4ef45c5 | 75 | }; |
embeddedartists | 4:b32cf4ef45c5 | 76 | |
embeddedartists | 4:b32cf4ef45c5 | 77 | #endif |