
Shows how to use a display and the touch controller. A very basic paint program.
Dependencies: DmTftLibrary mbed
Canvas.h@1:c5ef2d3261d3, 2014-07-04 (annotated)
- Committer:
- displaymodule
- Date:
- Fri Jul 04 10:35:27 2014 +0000
- Revision:
- 1:c5ef2d3261d3
- Parent:
- 0:2ee293544fc1
Misc bugfixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
displaymodule | 0:2ee293544fc1 | 1 | /********************************************************************************************** |
displaymodule | 0:2ee293544fc1 | 2 | Copyright (c) 2014 DisplayModule. All rights reserved. |
displaymodule | 0:2ee293544fc1 | 3 | |
displaymodule | 0:2ee293544fc1 | 4 | Redistribution and use of this source code, part of this source code or any compiled binary |
displaymodule | 0:2ee293544fc1 | 5 | based on this source code is permitted as long as the above copyright notice and following |
displaymodule | 0:2ee293544fc1 | 6 | disclaimer is retained. |
displaymodule | 0:2ee293544fc1 | 7 | |
displaymodule | 0:2ee293544fc1 | 8 | DISCLAIMER: |
displaymodule | 0:2ee293544fc1 | 9 | THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES |
displaymodule | 0:2ee293544fc1 | 10 | NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. |
displaymodule | 0:2ee293544fc1 | 11 | ********************************************************************************************/ |
displaymodule | 0:2ee293544fc1 | 12 | |
displaymodule | 0:2ee293544fc1 | 13 | #ifndef Canvas_h |
displaymodule | 0:2ee293544fc1 | 14 | #define Canvas_h |
displaymodule | 0:2ee293544fc1 | 15 | |
displaymodule | 0:2ee293544fc1 | 16 | #include "DmTftBase.h" |
displaymodule | 0:2ee293544fc1 | 17 | |
displaymodule | 0:2ee293544fc1 | 18 | class Canvas |
displaymodule | 0:2ee293544fc1 | 19 | { |
displaymodule | 0:2ee293544fc1 | 20 | public: |
displaymodule | 0:2ee293544fc1 | 21 | |
displaymodule | 0:2ee293544fc1 | 22 | Canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t fg = WHITE, uint16_t bg = BLACK, uint16_t borderWidth = 0, uint16_t borderColor = WHITE); |
displaymodule | 0:2ee293544fc1 | 23 | |
displaymodule | 0:2ee293544fc1 | 24 | bool isInside(uint16_t x, uint16_t y) { return (x >= _x) && (y >= _y) && (x <= (_x+_width)) && (y <= (_y+_height)); } |
displaymodule | 0:2ee293544fc1 | 25 | |
displaymodule | 0:2ee293544fc1 | 26 | void setColors(uint16_t foreground, uint16_t background) { _fgColor = foreground; _bgColor = background; } |
displaymodule | 0:2ee293544fc1 | 27 | |
displaymodule | 0:2ee293544fc1 | 28 | void setBorder(uint16_t width, uint16_t color); |
displaymodule | 0:2ee293544fc1 | 29 | |
displaymodule | 0:2ee293544fc1 | 30 | void enableBorder(bool enable); |
displaymodule | 0:2ee293544fc1 | 31 | |
displaymodule | 0:2ee293544fc1 | 32 | void draw(DmTftBase* tft); |
displaymodule | 0:2ee293544fc1 | 33 | void drawString(DmTftBase* tft, const char* msg); |
displaymodule | 0:2ee293544fc1 | 34 | |
displaymodule | 0:2ee293544fc1 | 35 | uint16_t x() { return _x; } |
displaymodule | 0:2ee293544fc1 | 36 | uint16_t y() { return _y; } |
displaymodule | 0:2ee293544fc1 | 37 | uint16_t width() { return _width; } |
displaymodule | 0:2ee293544fc1 | 38 | uint16_t height() { return _height; } |
displaymodule | 0:2ee293544fc1 | 39 | |
displaymodule | 0:2ee293544fc1 | 40 | private: |
displaymodule | 0:2ee293544fc1 | 41 | |
displaymodule | 0:2ee293544fc1 | 42 | uint16_t _x, _y, _width, _height, _borderWidth; |
displaymodule | 0:2ee293544fc1 | 43 | uint16_t _fgColor, _bgColor, _borderColor; |
displaymodule | 0:2ee293544fc1 | 44 | bool _borderEnabled; |
displaymodule | 0:2ee293544fc1 | 45 | }; |
displaymodule | 0:2ee293544fc1 | 46 | #endif |
displaymodule | 0:2ee293544fc1 | 47 | |
displaymodule | 0:2ee293544fc1 | 48 | |
displaymodule | 0:2ee293544fc1 | 49 |