LCD LIB

Dependents:   HagridOS5

Fork of RA8875 by David Smart

Committer:
WiredHome
Date:
Fri Aug 12 11:30:33 2016 +0000
Revision:
131:5bd6ba2ee4a1
Parent:
127:db7f2c704693
Child:
132:a5d7a8541683
Child:
138:61e93bed397e
Added API for BlockMove, and a minor revision to the init to accept a backlight setting directly.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 78:faf49c381591 1 ///
WiredHome 78:faf49c381591 2 /// @mainpage RA8875 Display Controller Driver library
WiredHome 78:faf49c381591 3 ///
WiredHome 78:faf49c381591 4 /// The RA8875 Display controller is a powerful interface for low cost displays. It
WiredHome 78:faf49c381591 5 /// can support displays up to 800 x 600 pixels x 16-bit color. Another common
WiredHome 78:faf49c381591 6 /// implementation is 480 x 272 x 16 with two layers. The two layers can be
WiredHome 78:faf49c381591 7 /// exchanged, or blended in various ways (transparency, OR, AND, and more).
WiredHome 78:faf49c381591 8 /// It includes graphics acceleration capabilities for drawing primitives,
WiredHome 78:faf49c381591 9 /// such as line, rectangle, circles, and more.
WiredHome 78:faf49c381591 10 ///
WiredHome 101:e0aad446094a 11 /// It is not a display for super-fast animations, video, picture frames and so forth,
WiredHome 101:e0aad446094a 12 /// at least when using the SPI ports. Performance has not been evaluated with one
WiredHome 101:e0aad446094a 13 /// of the parallel port options.
WiredHome 101:e0aad446094a 14 ///
WiredHome 78:faf49c381591 15 /// The controller additionally supports backlight control (via PWM), keypad scanning
WiredHome 125:7a0b70f56550 16 /// (for a 4 x 5 matrix) and resistive touch-panel support. Recently support for a
WiredHome 125:7a0b70f56550 17 /// capacitive touch screen was integrated, in a manner that makes the resistive and
WiredHome 125:7a0b70f56550 18 /// capactive interfaces nearly identical.
WiredHome 78:faf49c381591 19 ///
WiredHome 78:faf49c381591 20 /// @section Display_Config Display Configuration
WiredHome 78:faf49c381591 21 ///
WiredHome 78:faf49c381591 22 /// This section details basics for bringing the display online. At a minimum,
WiredHome 78:faf49c381591 23 /// the display is instantiated. After that any of the available commands
WiredHome 78:faf49c381591 24 /// may be issued.
WiredHome 78:faf49c381591 25 ///
WiredHome 78:faf49c381591 26 /// During the instantiation, the display is powered on, cleared, and the backlight
WiredHome 78:faf49c381591 27 /// is energized. Additionally, the keypad and touchscreen features are activated.
WiredHome 78:faf49c381591 28 /// It is important to keep in mind that the keypad had the default mapping, and
WiredHome 78:faf49c381591 29 /// the touchscreen does not have the calibration matrix configured, so additional
WiredHome 78:faf49c381591 30 /// steps may be necessary.
WiredHome 78:faf49c381591 31 ///
WiredHome 78:faf49c381591 32 /// @code
WiredHome 78:faf49c381591 33 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 81:01da2e34283d 34 /// lcd.init();
WiredHome 78:faf49c381591 35 /// lcd.foreground(Blue);
WiredHome 78:faf49c381591 36 /// lcd.line(0,0, 479,271);
WiredHome 78:faf49c381591 37 /// ...
WiredHome 78:faf49c381591 38 /// @endcode
WiredHome 78:faf49c381591 39 ///
WiredHome 78:faf49c381591 40 /// @section Touch_Panel Touch Panel
WiredHome 78:faf49c381591 41 ///
WiredHome 78:faf49c381591 42 /// The supported touch panel interface is for a resistive panel, and is natively
WiredHome 78:faf49c381591 43 /// supported by the RA8875 controller. There are a few steps to enable this interface.
WiredHome 78:faf49c381591 44 ///
WiredHome 78:faf49c381591 45 /// @subsection Touch_Panel_Enable Touch Panel Enable
WiredHome 78:faf49c381591 46 ///
WiredHome 106:c80828f5dea4 47 /// See @ref TouchPanelInit has two forms - fully automatic, and controlled. See the APIs for
WiredHome 78:faf49c381591 48 /// details.
WiredHome 78:faf49c381591 49 ///
WiredHome 78:faf49c381591 50 /// @subsection Touch_Panel_Calibration
WiredHome 78:faf49c381591 51 ///
WiredHome 78:faf49c381591 52 /// The touch panel is not initially calibrated on startup. The application should
WiredHome 78:faf49c381591 53 /// provide a means to activate the calibration process, and that should not require
WiredHome 78:faf49c381591 54 /// the touchscreen as it may not yet be usable. Alternately, a calibration matrix
WiredHome 78:faf49c381591 55 /// can be loaded from non-volatile and installed.
WiredHome 78:faf49c381591 56 ///
WiredHome 78:faf49c381591 57 /// @section Keypad Keypad
WiredHome 78:faf49c381591 58 ///
WiredHome 78:faf49c381591 59 /// The keypad has a default keypad mapping, but there is an API that permits
WiredHome 78:faf49c381591 60 /// installing a custom keymap.
WiredHome 78:faf49c381591 61 ///
WiredHome 101:e0aad446094a 62 /// @todo Add APIs for the 2nd PWM channel, which might be quite useful as a simple
WiredHome 101:e0aad446094a 63 /// beeper.
WiredHome 101:e0aad446094a 64 /// @todo Figure out how to "init()" in the constructor. I ran into some issues if
WiredHome 101:e0aad446094a 65 /// the display was instantiated before main(), and the code would not run,
WiredHome 101:e0aad446094a 66 /// thus the exposure and activation of the init() function. If the constructor
WiredHome 101:e0aad446094a 67 /// was within main(), then it seemed to work as expected.
WiredHome 101:e0aad446094a 68 ///
WiredHome 19:3f82c1161fd2 69 #ifndef RA8875_H
WiredHome 19:3f82c1161fd2 70 #define RA8875_H
WiredHome 19:3f82c1161fd2 71 #include <mbed.h>
WiredHome 19:3f82c1161fd2 72
WiredHome 77:9206c13aa527 73 #include "RA8875_Regs.h"
WiredHome 19:3f82c1161fd2 74 #include "GraphicsDisplay.h"
WiredHome 19:3f82c1161fd2 75
WiredHome 41:2956a0a221e5 76 #define RA8875_DEFAULT_SPI_FREQ 5000000
WiredHome 19:3f82c1161fd2 77
WiredHome 19:3f82c1161fd2 78 // Define this to enable code that monitors the performance of various
WiredHome 19:3f82c1161fd2 79 // graphics commands.
WiredHome 78:faf49c381591 80 //#define PERF_METRICS
WiredHome 19:3f82c1161fd2 81
WiredHome 23:a50ded45dbaf 82 // What better place for some test code than in here and the companion
WiredHome 23:a50ded45dbaf 83 // .cpp file. See also the bottom of this file.
WiredHome 99:66edf771373a 84 //#define TESTENABLE
WiredHome 19:3f82c1161fd2 85
WiredHome 19:3f82c1161fd2 86 /// DOS colors - slightly color enhanced
WiredHome 20:6e2e4a8372eb 87 #define Black (color_t)(RGB(0,0,0))
WiredHome 20:6e2e4a8372eb 88 #define Blue (color_t)(RGB(0,0,187))
WiredHome 20:6e2e4a8372eb 89 #define Green (color_t)(RGB(0,187,0))
WiredHome 20:6e2e4a8372eb 90 #define Cyan (color_t)(RGB(0,187,187))
WiredHome 20:6e2e4a8372eb 91 #define Red (color_t)(RGB(187,0,0))
WiredHome 20:6e2e4a8372eb 92 #define Magenta (color_t)(RGB(187,0,187))
WiredHome 81:01da2e34283d 93 #define Brown (color_t)(RGB(63,63,0))
WiredHome 20:6e2e4a8372eb 94 #define Gray (color_t)(RGB(187,187,187))
WiredHome 20:6e2e4a8372eb 95 #define Charcoal (color_t)(RGB(85,85,85))
WiredHome 62:ba5d33438fda 96 #define BrightBlue (color_t)(RGB(0,0,255))
WiredHome 62:ba5d33438fda 97 #define BrightGreen (color_t)(RGB(0,255,0))
WiredHome 62:ba5d33438fda 98 #define BrightCyan (color_t)(RGB(0,255,255))
WiredHome 62:ba5d33438fda 99 #define BrightRed (color_t)(RGB(255,0,0))
WiredHome 20:6e2e4a8372eb 100 #define Orange (color_t)(RGB(255,85,85))
WiredHome 20:6e2e4a8372eb 101 #define Pink (color_t)(RGB(255,85,255))
WiredHome 81:01da2e34283d 102 #define Yellow (color_t)(RGB(187,187,0))
WiredHome 20:6e2e4a8372eb 103 #define White (color_t)(RGB(255,255,255))
WiredHome 20:6e2e4a8372eb 104
WiredHome 62:ba5d33438fda 105 #define DarkBlue (color_t)(RGB(0,0,63))
WiredHome 62:ba5d33438fda 106 #define DarkGreen (color_t)(RGB(0,63,0))
WiredHome 62:ba5d33438fda 107 #define DarkCyan (color_t)(RGB(0,63,63))
WiredHome 62:ba5d33438fda 108 #define DarkRed (color_t)(RGB(63,0,0))
WiredHome 62:ba5d33438fda 109 #define DarkMagenta (color_t)(RGB(63,0,63))
WiredHome 62:ba5d33438fda 110 #define DarkBrown (color_t)(RGB(63,63,0))
WiredHome 62:ba5d33438fda 111 #define DarkGray (color_t)(RGB(63,63,63))
WiredHome 61:8f3153bf0baa 112
WiredHome 82:f7d300f26540 113 #define min(a,b) ((a<b)?a:b)
WiredHome 82:f7d300f26540 114 #define max(a,b) ((a>b)?a:b)
WiredHome 82:f7d300f26540 115
WiredHome 19:3f82c1161fd2 116
WiredHome 124:1690a7ae871c 117 /// FT5206 definitions follow
WiredHome 124:1690a7ae871c 118 #define FT5206_I2C_FREQUENCY 400000
WiredHome 124:1690a7ae871c 119
WiredHome 124:1690a7ae871c 120 #define FT5206_I2C_ADDRESS 0x38
WiredHome 124:1690a7ae871c 121 #define FT5206_NUMBER_OF_REGISTERS 31 // there are more registers, but this
WiredHome 124:1690a7ae871c 122 // is enough to get all 5 touch coordinates.
WiredHome 124:1690a7ae871c 123
WiredHome 124:1690a7ae871c 124 #define FT5206_NUMBER_OF_TOTAL_REGISTERS 0xFE
WiredHome 124:1690a7ae871c 125
WiredHome 124:1690a7ae871c 126 #define FT5206_DEVICE_MODE 0x00 // Normal, test, etc.
WiredHome 124:1690a7ae871c 127 #define FT5206_GEST_ID 0x01 // Gesture detected
WiredHome 124:1690a7ae871c 128 #define FT5206_TD_STATUS 0x02 // How many points detected (3:0). 1-5 is valid.
WiredHome 124:1690a7ae871c 129
WiredHome 124:1690a7ae871c 130 #define FT5206_TOUCH1_XH 0x03 // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 131 #define FT5206_TOUCH1_XL 0x04
WiredHome 124:1690a7ae871c 132 #define FT5206_TOUCH1_YH 0x05 // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 133 #define FT5206_TOUCH1_YL 0x06
WiredHome 124:1690a7ae871c 134
WiredHome 124:1690a7ae871c 135 #define FT5206_TOUCH2_XH 0x09 // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 136 #define FT5206_TOUCH2_XL 0x0a
WiredHome 124:1690a7ae871c 137 #define FT5206_TOUCH2_YH 0x0b // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 138 #define FT5206_TOUCH2_YL 0x0c
WiredHome 124:1690a7ae871c 139
WiredHome 124:1690a7ae871c 140 #define FT5206_TOUCH3_XH 0x0f // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 141 #define FT5206_TOUCH3_XL 0x10
WiredHome 124:1690a7ae871c 142 #define FT5206_TOUCH3_YH 0x11 // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 143 #define FT5206_TOUCH3_YL 0x12
WiredHome 124:1690a7ae871c 144
WiredHome 124:1690a7ae871c 145 #define FT5206_TOUCH4_XH 0x15 // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 146 #define FT5206_TOUCH4_XL 0x16
WiredHome 124:1690a7ae871c 147 #define FT5206_TOUCH4_YH 0x17 // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 148 #define FT5206_TOUCH4_YL 0x18
WiredHome 124:1690a7ae871c 149
WiredHome 124:1690a7ae871c 150 #define FT5206_TOUCH5_XH 0x1b // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 151 #define FT5206_TOUCH5_XL 0x1c
WiredHome 124:1690a7ae871c 152 #define FT5206_TOUCH5_YH 0x1d // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 153 #define FT5206_TOUCH5_YL 0x1e
WiredHome 124:1690a7ae871c 154
WiredHome 124:1690a7ae871c 155 // For typical usage, the registers listed below are not used.
WiredHome 124:1690a7ae871c 156 #define FT5206_ID_G_THGROUP 0x80 // Valid touching detect threshold
WiredHome 124:1690a7ae871c 157 #define FT5206_ID_G_THPEAK 0x81 // Valid touching peak detect threshold
WiredHome 124:1690a7ae871c 158 #define FT5206_ID_G_THCAL 0x82 // The threshold when calculating the focus of touching
WiredHome 124:1690a7ae871c 159 #define FT5206_ID_G_THWATER 0x83 // The threshold when there is surface water
WiredHome 124:1690a7ae871c 160 #define FT5206_ID_G_THTEMP 0x84 // The threshold of temperature compensation
WiredHome 124:1690a7ae871c 161 #define FT5206_ID_G_CTRL 0x86 // Power control mode
WiredHome 124:1690a7ae871c 162 #define FT5206_ID_G_TIME_ENTER_MONITOR 0x87 // The timer of entering monitor status
WiredHome 124:1690a7ae871c 163 #define FT5206_ID_G_PERIODACTIVE 0x88 // Period Active
WiredHome 124:1690a7ae871c 164 #define FT5206_ID_G_PERIODMONITOR 0x89 // The timer of entering idle while in monitor status
WiredHome 124:1690a7ae871c 165 #define FT5206_ID_G_AUTO_CLB_MODE 0xA0 // Auto calibration mode
WiredHome 124:1690a7ae871c 166
WiredHome 124:1690a7ae871c 167 #define FT5206_TOUCH_LIB_VERSION_H 0xA1 // Firmware Library Version H byte
WiredHome 124:1690a7ae871c 168 #define FT5206_TOUCH_LIB_VERSION_L 0xA2 // Firmware Library Version L byte
WiredHome 124:1690a7ae871c 169 #define FT5206_ID_G_CIPHER 0xA3 // Chip vendor ID
WiredHome 124:1690a7ae871c 170 #define FT5206_G_MODE 0xA4 // The interrupt status to host
WiredHome 124:1690a7ae871c 171 #define FT5206_ID_G_PMODE 0xA5 // Power Consume Mode
WiredHome 124:1690a7ae871c 172 #define FT5206_FIRMID 0xA6 // Firmware ID
WiredHome 124:1690a7ae871c 173 #define FT5206_ID_G_STATE 0xA7 // Running State
WiredHome 124:1690a7ae871c 174 #define FT5206_ID_G_FT5201ID 0xA8 // CTPM Vendor ID
WiredHome 124:1690a7ae871c 175 #define FT5206_ID_G_ERR 0xA9 // Error Code
WiredHome 124:1690a7ae871c 176 #define FT5206_ID_G_CLB 0xAA // Configure TP module during calibration in Test Mode
WiredHome 124:1690a7ae871c 177 #define FT5206_ID_G_B_AREA_TH 0xAE // The threshold of big area
WiredHome 124:1690a7ae871c 178 #define FT5206_LOG_MSG_CNT 0xFE // The log MSG count
WiredHome 124:1690a7ae871c 179 #define FT5206_LOG_CUR_CHA 0xFF // Current character of log message, will point to the next
WiredHome 124:1690a7ae871c 180 // character when one character is read.
WiredHome 124:1690a7ae871c 181 #define FT5206_GEST_ID_MOVE_UP 0x10
WiredHome 124:1690a7ae871c 182 #define FT5206_GEST_ID_MOVE_LEFT 0x14
WiredHome 124:1690a7ae871c 183 #define FT5206_GEST_ID_MOVE_DOWN 0x18
WiredHome 124:1690a7ae871c 184 #define FT5206_GEST_ID_MOVE_RIGHT 0x1c
WiredHome 124:1690a7ae871c 185 #define FT5206_GEST_ID_ZOOM_IN 0x48
WiredHome 124:1690a7ae871c 186 #define FT5206_GEST_ID_ZOOM_OUT 0x49
WiredHome 124:1690a7ae871c 187 #define FT5206_GEST_ID_NO_GESTURE 0x00
WiredHome 124:1690a7ae871c 188
WiredHome 124:1690a7ae871c 189 #define FT5206_EVENT_FLAG_PUT_DOWN 0x00
WiredHome 124:1690a7ae871c 190 #define FT5206_EVENT_FLAG_PUT_UP 0x01
WiredHome 124:1690a7ae871c 191 #define FT5206_EVENT_FLAG_CONTACT 0x02
WiredHome 124:1690a7ae871c 192 #define FT5206_EVENT_FLAG_RESERVED 0x03
WiredHome 124:1690a7ae871c 193
WiredHome 124:1690a7ae871c 194 #define FT5206_ID_G_POLLING_MODE 0x00
WiredHome 124:1690a7ae871c 195 #define FT5206_ID_G_TRIGGER_MODE 0x01
WiredHome 124:1690a7ae871c 196
WiredHome 124:1690a7ae871c 197 #define FT5206_ID_G_PMODE_ACTIVE 0x00
WiredHome 124:1690a7ae871c 198 #define FT5206_ID_G_PMODE_MONITOR 0x01
WiredHome 124:1690a7ae871c 199 #define FT5206_ID_G_PMODE_HIBERNATE 0x03
WiredHome 124:1690a7ae871c 200
WiredHome 124:1690a7ae871c 201 #define FT5206_ID_G_STATE_CONFIGURE 0x00
WiredHome 124:1690a7ae871c 202 #define FT5206_ID_G_STATE_WORK 0x01
WiredHome 124:1690a7ae871c 203 #define FT5206_ID_G_STATE_CALIBRATION 0x02
WiredHome 124:1690a7ae871c 204 #define FT5206_ID_G_STATE_FACTORY 0x03
WiredHome 124:1690a7ae871c 205 #define FT5206_ID_G_STATE_AUTO_CALIBRATION 0x04
WiredHome 124:1690a7ae871c 206 /// end of FT5206 definitions
WiredHome 124:1690a7ae871c 207
WiredHome 124:1690a7ae871c 208
WiredHome 19:3f82c1161fd2 209 //namespace SW_graphics
WiredHome 19:3f82c1161fd2 210 //{
WiredHome 19:3f82c1161fd2 211
WiredHome 96:40b74dd3695b 212 class FPointerDummy; // used by the callback methods.
WiredHome 24:8ca861acf12d 213
WiredHome 21:3c1efb192927 214 /// This is a graphics library for the Raio RA8875 Display Controller chip
WiredHome 21:3c1efb192927 215 /// attached to a 4-wire SPI interface.
WiredHome 21:3c1efb192927 216 ///
WiredHome 56:7a85d226ad0d 217 /// It offers both primitive and high level APIs.
WiredHome 56:7a85d226ad0d 218 ///
WiredHome 21:3c1efb192927 219 /// Central to this API is a coordinate system, where the origin (0,0) is in
WiredHome 56:7a85d226ad0d 220 /// the top-left corner of the display, and the width (x) extends positive to the
WiredHome 56:7a85d226ad0d 221 /// right and the height (y) extends positive toward the bottom.
WiredHome 21:3c1efb192927 222 ///
WiredHome 125:7a0b70f56550 223 /// @note As there are both graphics and text commands, one must take care to use
WiredHome 21:3c1efb192927 224 /// the proper coordinate system for each. Some of the text APIs are in units
WiredHome 29:422616aa04bd 225 /// of column and row, which is measured in character positions (and dependent
WiredHome 56:7a85d226ad0d 226 /// on the font size), where other text APIs permit pixel level positioning.
WiredHome 56:7a85d226ad0d 227 ///
WiredHome 56:7a85d226ad0d 228 /// @code
WiredHome 56:7a85d226ad0d 229 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 230 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 231 ///
WiredHome 56:7a85d226ad0d 232 /// int main()
WiredHome 56:7a85d226ad0d 233 /// {
WiredHome 81:01da2e34283d 234 /// lcd.init();
WiredHome 56:7a85d226ad0d 235 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 236 /// lcd.circle( 400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 237 /// lcd.fillcircle( 400,25, 15, RGB(128,255,128));
WiredHome 56:7a85d226ad0d 238 /// lcd.ellipse( 440,75, 35,20, BrightBlue);
WiredHome 56:7a85d226ad0d 239 /// lcd.fillellipse( 440,75, 25,10, Blue);
WiredHome 56:7a85d226ad0d 240 /// lcd.triangle( 440,100, 475,110, 450,125, Magenta);
WiredHome 56:7a85d226ad0d 241 /// lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
WiredHome 56:7a85d226ad0d 242 /// lcd.rect( 400,130, 475,155, Brown);
WiredHome 56:7a85d226ad0d 243 /// lcd.fillrect( 405,135, 470,150, Pink);
WiredHome 56:7a85d226ad0d 244 /// lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
WiredHome 56:7a85d226ad0d 245 /// lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
WiredHome 56:7a85d226ad0d 246 /// lcd.line( 430,200, 460,230, RGB(0,255,0));
WiredHome 56:7a85d226ad0d 247 /// for (int i=0; i<=30; i+=5)
WiredHome 56:7a85d226ad0d 248 /// lcd.pixel(435+i,200+i, White);
WiredHome 56:7a85d226ad0d 249 /// }
WiredHome 56:7a85d226ad0d 250 /// @endcode
WiredHome 29:422616aa04bd 251 ///
WiredHome 31:c72e12cd5c67 252 /// @todo Add Scroll support for text.
WiredHome 75:ca78388cfd77 253 /// @todo Add Hardware reset signal - but testing to date indicates it is not needed.
WiredHome 44:207594dece70 254 /// @todo Add high level objects - x-y graph, meter, others... but these will
WiredHome 44:207594dece70 255 /// probably be best served in another class, since they may not
WiredHome 44:207594dece70 256 /// be needed for many uses.
WiredHome 21:3c1efb192927 257 ///
WiredHome 19:3f82c1161fd2 258 class RA8875 : public GraphicsDisplay
WiredHome 19:3f82c1161fd2 259 {
WiredHome 19:3f82c1161fd2 260 public:
WiredHome 53:86d24b9480b9 261 /// cursor type to be shown as the text cursor.
WiredHome 53:86d24b9480b9 262 typedef enum
WiredHome 53:86d24b9480b9 263 {
WiredHome 53:86d24b9480b9 264 NOCURSOR, ///< cursor is hidden
WiredHome 53:86d24b9480b9 265 IBEAM, ///< | cursor
WiredHome 53:86d24b9480b9 266 UNDER, ///< _ cursor
WiredHome 53:86d24b9480b9 267 BLOCK ///< Block cursor
WiredHome 53:86d24b9480b9 268 } cursor_t;
WiredHome 53:86d24b9480b9 269
WiredHome 19:3f82c1161fd2 270 /// font type selection.
WiredHome 19:3f82c1161fd2 271 typedef enum
WiredHome 19:3f82c1161fd2 272 {
WiredHome 31:c72e12cd5c67 273 ISO8859_1, ///< ISO8859-1 font
WiredHome 31:c72e12cd5c67 274 ISO8859_2, ///< ISO8859-2 font
WiredHome 31:c72e12cd5c67 275 ISO8859_3, ///< ISO8859-3 font
WiredHome 31:c72e12cd5c67 276 ISO8859_4 ///< ISO8859-4 font
WiredHome 19:3f82c1161fd2 277 } font_t;
WiredHome 19:3f82c1161fd2 278
WiredHome 84:e102021864b5 279 /// display orientation
WiredHome 19:3f82c1161fd2 280 typedef enum
WiredHome 19:3f82c1161fd2 281 {
WiredHome 84:e102021864b5 282 normal, ///< normal (landscape) orientation
WiredHome 84:e102021864b5 283 rotate_0 = normal, ///< alternate to 'normal'
WiredHome 84:e102021864b5 284 rotate_90, ///< rotated clockwise 90 degree
WiredHome 84:e102021864b5 285 rotate_180, ///< rotated (clockwise) 180 degree
WiredHome 84:e102021864b5 286 rotate_270, ///< rotated clockwise 270 degree
WiredHome 84:e102021864b5 287 } orientation_t;
WiredHome 19:3f82c1161fd2 288
WiredHome 19:3f82c1161fd2 289 /// alignment
WiredHome 19:3f82c1161fd2 290 typedef enum
WiredHome 19:3f82c1161fd2 291 {
WiredHome 31:c72e12cd5c67 292 align_none, ///< align - none
WiredHome 31:c72e12cd5c67 293 align_full ///< align - full
WiredHome 19:3f82c1161fd2 294 } alignment_t;
WiredHome 19:3f82c1161fd2 295
WiredHome 127:db7f2c704693 296 /// Font Horizontal Scale factor - 1, 2, 3 4
WiredHome 40:04aa280dfa39 297 typedef int HorizontalScale;
WiredHome 19:3f82c1161fd2 298
WiredHome 127:db7f2c704693 299 /// Font Vertical Scale factor - 1, 2, 3, 4
WiredHome 40:04aa280dfa39 300 typedef int VerticalScale;
WiredHome 19:3f82c1161fd2 301
WiredHome 19:3f82c1161fd2 302 /// Clear screen region
WiredHome 19:3f82c1161fd2 303 typedef enum
WiredHome 19:3f82c1161fd2 304 {
WiredHome 31:c72e12cd5c67 305 FULLWINDOW, ///< Full screen
WiredHome 31:c72e12cd5c67 306 ACTIVEWINDOW ///< active window/region
WiredHome 19:3f82c1161fd2 307 } Region_t;
WiredHome 19:3f82c1161fd2 308
WiredHome 61:8f3153bf0baa 309 /// Set the Layer Display Mode. @ref SetLayerMode
WiredHome 53:86d24b9480b9 310 typedef enum
WiredHome 53:86d24b9480b9 311 {
WiredHome 61:8f3153bf0baa 312 ShowLayer0, ///< Only layer 0 is visible, layer 1 is hidden (default)
WiredHome 56:7a85d226ad0d 313 ShowLayer1, ///< Only layer 1 is visible, layer 0 is hidden
WiredHome 53:86d24b9480b9 314 LightenOverlay, ///< Lighten-overlay mode
WiredHome 53:86d24b9480b9 315 TransparentMode, ///< Transparent mode
WiredHome 53:86d24b9480b9 316 BooleanOR, ///< Boolean OR mode
WiredHome 53:86d24b9480b9 317 BooleanAND, ///< Boolean AND mode
WiredHome 53:86d24b9480b9 318 FloatingWindow ///< Floating Window mode
WiredHome 53:86d24b9480b9 319 } LayerMode_T;
WiredHome 53:86d24b9480b9 320
hexley 54:e117ad10fba6 321 /// Touch Panel modes
hexley 54:e117ad10fba6 322 typedef enum
hexley 54:e117ad10fba6 323 {
hexley 54:e117ad10fba6 324 TP_Auto, ///< Auto touch detection mode
hexley 54:e117ad10fba6 325 TP_Manual, ///< Manual touch detection mode
hexley 54:e117ad10fba6 326 } tpmode_t;
WiredHome 96:40b74dd3695b 327
WiredHome 96:40b74dd3695b 328 /// printscreen callback commands
WiredHome 96:40b74dd3695b 329 typedef enum
WiredHome 96:40b74dd3695b 330 {
WiredHome 96:40b74dd3695b 331 OPEN, ///< command to open the file. cast uint32_t * to the buffer to get the total size to be written.
WiredHome 96:40b74dd3695b 332 WRITE, ///< command to write some data, buffer points to the data and the size is in bytes.
WiredHome 96:40b74dd3695b 333 CLOSE, ///< command to close the file
WiredHome 96:40b74dd3695b 334 } filecmd_t;
WiredHome 96:40b74dd3695b 335
WiredHome 96:40b74dd3695b 336 /// print screen callback
WiredHome 96:40b74dd3695b 337 ///
WiredHome 96:40b74dd3695b 338 /// The special form of the print screen will pass one blob at a time
WiredHome 96:40b74dd3695b 339 /// to the callback. There are basic command declaring that the stream
WiredHome 96:40b74dd3695b 340 /// can be opened, a block written, and the stream closed. There is
WiredHome 96:40b74dd3695b 341 /// also a command to communicate the total size being delivered.
WiredHome 96:40b74dd3695b 342 ///
WiredHome 96:40b74dd3695b 343 /// @code
WiredHome 96:40b74dd3695b 344 /// lcd.PrintScreen(x,y,w,h,callback);
WiredHome 96:40b74dd3695b 345 /// ...
WiredHome 96:40b74dd3695b 346 /// void callback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 347 /// switch(cmd) {
WiredHome 96:40b74dd3695b 348 /// case OPEN:
WiredHome 96:40b74dd3695b 349 /// pc.printf("About to write %u bytes\r\n", *(uint32_t *)buffer);
WiredHome 96:40b74dd3695b 350 /// fh = fopen("file.bmp", "w+b");
WiredHome 96:40b74dd3695b 351 /// break;
WiredHome 96:40b74dd3695b 352 /// case WRITE:
WiredHome 96:40b74dd3695b 353 /// fwrite(buffer, size, fh);
WiredHome 96:40b74dd3695b 354 /// break;
WiredHome 96:40b74dd3695b 355 /// case CLOSE:
WiredHome 96:40b74dd3695b 356 /// fclose(fh);
WiredHome 96:40b74dd3695b 357 /// break;
WiredHome 96:40b74dd3695b 358 /// default:
WiredHome 96:40b74dd3695b 359 /// pc.printf("Unexpected callback %d\r\n", cmd);
WiredHome 96:40b74dd3695b 360 /// break;
WiredHome 96:40b74dd3695b 361 /// }
WiredHome 96:40b74dd3695b 362 /// }
WiredHome 96:40b74dd3695b 363 /// @endcode
WiredHome 96:40b74dd3695b 364 ///
WiredHome 106:c80828f5dea4 365 /// @param cmd is the command to execute. See @ref filecmd_t.
WiredHome 96:40b74dd3695b 366 /// @param buffer is a pointer to the buffer being passed.
WiredHome 96:40b74dd3695b 367 /// @param size is the number of bytes in the buffer.
WiredHome 123:2f45e80fec5f 368 /// @returns the noerror signal.
WiredHome 96:40b74dd3695b 369 ///
WiredHome 96:40b74dd3695b 370 typedef RetCode_t (* PrintCallback_T)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
hexley 54:e117ad10fba6 371
WiredHome 125:7a0b70f56550 372 /// Idle reason provided in the Idle Callback
WiredHome 123:2f45e80fec5f 373 typedef enum {
WiredHome 123:2f45e80fec5f 374 unknown, ///< reason has not been assigned (this should not happen)
WiredHome 123:2f45e80fec5f 375 status_wait, ///< driver is polling the status register while busy
WiredHome 123:2f45e80fec5f 376 command_wait, ///< driver is polling the command register while busy
WiredHome 123:2f45e80fec5f 377 getc_wait, ///< user has called the getc function
WiredHome 123:2f45e80fec5f 378 touch_wait, ///< user has called the touch function
WiredHome 123:2f45e80fec5f 379 touchcal_wait ///< driver is performing a touch calibration
WiredHome 123:2f45e80fec5f 380 } IdleReason_T;
WiredHome 123:2f45e80fec5f 381
WiredHome 123:2f45e80fec5f 382 /// Idle Callback
WiredHome 123:2f45e80fec5f 383 ///
WiredHome 123:2f45e80fec5f 384 /// This defines the interface for an idle callback. That is, when the
WiredHome 125:7a0b70f56550 385 /// driver is held up, pending some event, it can call a previously registered
WiredHome 123:2f45e80fec5f 386 /// idle function. This could be most useful for servicing a watchdog.
WiredHome 123:2f45e80fec5f 387 ///
WiredHome 123:2f45e80fec5f 388 /// The user code, which is notified via this API, can force the idle
WiredHome 123:2f45e80fec5f 389 /// to abort, by returning the external_abort value back to the driver.
WiredHome 125:7a0b70f56550 390 /// It is important to note that the abort could leave the driver in
WiredHome 125:7a0b70f56550 391 /// an undesireable state, so this should be used with care.
WiredHome 125:7a0b70f56550 392 ///
WiredHome 125:7a0b70f56550 393 /// @note Should it be called the BusyCallback? It is true, that it will
WiredHome 125:7a0b70f56550 394 /// call this function when the RA8875 is busy, but this is also
WiredHome 125:7a0b70f56550 395 /// when the CPU is largely idle.
WiredHome 125:7a0b70f56550 396 ///
WiredHome 125:7a0b70f56550 397 /// @code
WiredHome 125:7a0b70f56550 398 /// RetCode_t myIdle_handler(RA8875::IdleReason_T reason)
WiredHome 125:7a0b70f56550 399 /// {
WiredHome 125:7a0b70f56550 400 /// idleFlasher = !idleFlasher;
WiredHome 125:7a0b70f56550 401 /// if (it_has_been_too_long())
WiredHome 125:7a0b70f56550 402 /// return external_abort;
WiredHome 125:7a0b70f56550 403 /// else
WiredHome 125:7a0b70f56550 404 /// return noerror;
WiredHome 125:7a0b70f56550 405 /// }
WiredHome 125:7a0b70f56550 406 /// @endcode
WiredHome 125:7a0b70f56550 407 ///
WiredHome 125:7a0b70f56550 408 /// @param reason informs the callback why it is idle.
WiredHome 123:2f45e80fec5f 409 /// @returns noerror to allow the driver continue waiting.
WiredHome 123:2f45e80fec5f 410 /// @returns external_abort if the pending action should be aborted.
WiredHome 123:2f45e80fec5f 411 ///
WiredHome 125:7a0b70f56550 412 typedef RetCode_t (* IdleCallback_T)(IdleReason_T reason);
WiredHome 123:2f45e80fec5f 413
WiredHome 125:7a0b70f56550 414 /// Basic constructor for a display based on the RAiO RA8875
WiredHome 125:7a0b70f56550 415 /// display controller, which can be used with no touchscreen,
WiredHome 125:7a0b70f56550 416 /// or the RA8875 managed resistive touchscreen.
WiredHome 124:1690a7ae871c 417 ///
WiredHome 124:1690a7ae871c 418 /// This constructor differs from the alternate by supportting
WiredHome 124:1690a7ae871c 419 /// either No Touch Screen, or the RA8875 built-in resistive
WiredHome 125:7a0b70f56550 420 /// touch screen. If the application requires the use of the
WiredHome 125:7a0b70f56550 421 /// capacitive touchscreen, the alternate constructor should
WiredHome 125:7a0b70f56550 422 /// be used.
WiredHome 19:3f82c1161fd2 423 ///
WiredHome 61:8f3153bf0baa 424 /// This configures the registers and calls the @ref init method.
WiredHome 61:8f3153bf0baa 425 ///
WiredHome 56:7a85d226ad0d 426 /// @code
WiredHome 56:7a85d226ad0d 427 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 428 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 429 ///
WiredHome 56:7a85d226ad0d 430 /// int main()
WiredHome 56:7a85d226ad0d 431 /// {
WiredHome 81:01da2e34283d 432 /// lcd.init();
WiredHome 56:7a85d226ad0d 433 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 434 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 435 /// }
WiredHome 56:7a85d226ad0d 436 /// @endcode
WiredHome 56:7a85d226ad0d 437 ///
WiredHome 72:ecffe56af969 438 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 72:ecffe56af969 439 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 72:ecffe56af969 440 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 72:ecffe56af969 441 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 442 /// active low chip select for the display controller.
WiredHome 72:ecffe56af969 443 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 444 /// active low reset input on the display controller -
WiredHome 19:3f82c1161fd2 445 /// but this is not currently used.
WiredHome 72:ecffe56af969 446 /// @param[in] name is a text name for this object, which will permit
WiredHome 72:ecffe56af969 447 /// capturing stdout to puts() and printf() directly to it.
WiredHome 19:3f82c1161fd2 448 ///
WiredHome 124:1690a7ae871c 449 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 124:1690a7ae871c 450 const char * name = "lcd");
WiredHome 124:1690a7ae871c 451
WiredHome 124:1690a7ae871c 452
WiredHome 124:1690a7ae871c 453 /// Constructor for a display based on the RAiO RA8875
WiredHome 124:1690a7ae871c 454 /// display controller (use for TouchScreen: Capacitive only)
WiredHome 124:1690a7ae871c 455 ///
WiredHome 124:1690a7ae871c 456 /// This constructor differs from the alternate by including support
WiredHome 124:1690a7ae871c 457 /// for the Capactive Touch screen.
WiredHome 124:1690a7ae871c 458 ///
WiredHome 125:7a0b70f56550 459 /// @code
WiredHome 125:7a0b70f56550 460 /// #include "RA8875.h"
WiredHome 125:7a0b70f56550 461 /// RA8875 lcd(p5, p6, p7, p12, NC, p9,p10,p13, "tft");
WiredHome 125:7a0b70f56550 462 ///
WiredHome 125:7a0b70f56550 463 /// int main()
WiredHome 125:7a0b70f56550 464 /// {
WiredHome 125:7a0b70f56550 465 /// lcd.init();
WiredHome 125:7a0b70f56550 466 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 125:7a0b70f56550 467 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 125:7a0b70f56550 468 /// TouchCode_t tp = lcd.TouchPanelReadable();
WiredHome 125:7a0b70f56550 469 /// if (tp == touch)
WiredHome 125:7a0b70f56550 470 /// ...
WiredHome 125:7a0b70f56550 471 /// }
WiredHome 125:7a0b70f56550 472 /// @endcode
WiredHome 125:7a0b70f56550 473 ///
WiredHome 124:1690a7ae871c 474 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 124:1690a7ae871c 475 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 124:1690a7ae871c 476 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 124:1690a7ae871c 477 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 124:1690a7ae871c 478 /// active low chip select for the display controller.
WiredHome 124:1690a7ae871c 479 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 124:1690a7ae871c 480 /// active low reset input on the display controller -
WiredHome 124:1690a7ae871c 481 /// but this is not currently used.
WiredHome 124:1690a7ae871c 482 /// @param[in] sda is the I2C Serial Data pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 483 /// @param[in] scl is the I2C Serial Clock pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 484 /// @param[in] irq is the Interrupt Request pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 485 /// @param[in] name is a text name for this object, which will permit
WiredHome 124:1690a7ae871c 486 /// capturing stdout to puts() and printf() directly to it.
WiredHome 124:1690a7ae871c 487 ///
WiredHome 124:1690a7ae871c 488 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 124:1690a7ae871c 489 PinName sda, PinName scl, PinName irq, const char * name = "lcd");
WiredHome 124:1690a7ae871c 490
WiredHome 19:3f82c1161fd2 491
WiredHome 45:679c2fb8480c 492 // Destructor doesn't have much to do as this would typically be created
WiredHome 45:679c2fb8480c 493 // at startup, and not at runtime.
WiredHome 19:3f82c1161fd2 494 //~RA8875();
WiredHome 19:3f82c1161fd2 495
WiredHome 79:544eb4964795 496 /// Initialize the driver.
WiredHome 79:544eb4964795 497 ///
WiredHome 106:c80828f5dea4 498 /// The RA8875 can scale to 800x600, and it supports 8 or 16-bit color. It also supports
WiredHome 106:c80828f5dea4 499 /// layers, but it cannot support layers at the maximum color and screen size. When configured
WiredHome 106:c80828f5dea4 500 /// under 800x600, it will support both 16-bit and 2 layers. But at 800x600, it can
WiredHome 106:c80828f5dea4 501 /// support either 16-bit color, or 2 layers, but not both.
WiredHome 106:c80828f5dea4 502 ///
WiredHome 81:01da2e34283d 503 /// @param[in] width in pixels to configure the display for. This parameter is optional
WiredHome 81:01da2e34283d 504 /// and the default is 480.
WiredHome 81:01da2e34283d 505 /// @param[in] height in pixels to configure the display for. This parameter is optional
WiredHome 81:01da2e34283d 506 /// and the default is 272.
WiredHome 81:01da2e34283d 507 /// @param[in] color_bpp can be either 8 or 16, but must be consistent
WiredHome 81:01da2e34283d 508 /// with the width and height parameters. This parameter is optional
WiredHome 81:01da2e34283d 509 /// and the default is 16.
WiredHome 131:5bd6ba2ee4a1 510 /// @param[in] poweron defines if the display should be initialized into the power-on or off state.
WiredHome 131:5bd6ba2ee4a1 511 /// If power is non-zero(on), the backlight is set to this vale. This parameter is optional
WiredHome 131:5bd6ba2ee4a1 512 /// and the default is 255 (on and full brightness). See @ref Power.
WiredHome 81:01da2e34283d 513 /// @param[in] keypadon defines if the keypad support should be enabled. This parameter is optional
WiredHome 106:c80828f5dea4 514 /// and the default is true (enabled). See @ref KeypadInit.
WiredHome 124:1690a7ae871c 515 /// @param[in] touchscreeenon defines if the touchscreen support should be enabled.
WiredHome 124:1690a7ae871c 516 /// This parameter is optional and the default is true (enabled). See @ref TouchPanelInit.\\
WiredHome 124:1690a7ae871c 517 /// - If the constructor was called with support for the capacitive driver, this
WiredHome 124:1690a7ae871c 518 /// parameter causes the driver to initialize.
WiredHome 124:1690a7ae871c 519 /// - If the constructor was called without support for the capacitive driver, this
WiredHome 124:1690a7ae871c 520 /// parameter is used to enable and initialize the resistive touchscreen driver.
WiredHome 106:c80828f5dea4 521 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 79:544eb4964795 522 ///
WiredHome 81:01da2e34283d 523 RetCode_t init(int width = 480, int height = 272, int color_bpp = 16,
WiredHome 131:5bd6ba2ee4a1 524 uint8_t poweron = 255, bool keypadon = true, bool touchscreeenon = true);
WiredHome 124:1690a7ae871c 525
WiredHome 125:7a0b70f56550 526
WiredHome 79:544eb4964795 527 /// Get a pointer to the error code.
WiredHome 79:544eb4964795 528 ///
WiredHome 79:544eb4964795 529 /// This method returns a pointer to a text string that matches the
WiredHome 106:c80828f5dea4 530 /// code. See @ref RetCode_t.
WiredHome 79:544eb4964795 531 ///
WiredHome 79:544eb4964795 532 /// @param[in] code is the return value from RetCode_t to look up.
WiredHome 79:544eb4964795 533 /// @returns a pointer to the text message representing code. If code
WiredHome 79:544eb4964795 534 /// is not a valid value, then it returns the text for bad_parameter;
WiredHome 125:7a0b70f56550 535 ///
WiredHome 79:544eb4964795 536 const char * GetErrorMessage(RetCode_t code);
WiredHome 79:544eb4964795 537
WiredHome 79:544eb4964795 538
WiredHome 50:2c4f474a2453 539 /// Select the drawing layer for subsequent commands.
WiredHome 43:3becae133285 540 ///
WiredHome 43:3becae133285 541 /// If the screen configuration is 480 x 272, or if it is 800 x 480
WiredHome 43:3becae133285 542 /// and 8-bit color, the the display supports two layers, which can
WiredHome 43:3becae133285 543 /// be independently drawn on and shown. Additionally, complex
WiredHome 43:3becae133285 544 /// operations involving both layers are permitted.
WiredHome 43:3becae133285 545 ///
WiredHome 56:7a85d226ad0d 546 /// @code
WiredHome 56:7a85d226ad0d 547 /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
WiredHome 56:7a85d226ad0d 548 /// lcd.rect(400,130, 475,155,Brown);
WiredHome 56:7a85d226ad0d 549 /// lcd.SelectDrawingLayer(1);
WiredHome 56:7a85d226ad0d 550 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 551 /// wait(1);
WiredHome 56:7a85d226ad0d 552 /// lcd.SetLayerMode(ShowLayer1);
WiredHome 56:7a85d226ad0d 553 /// @endcode
WiredHome 56:7a85d226ad0d 554 ///
WiredHome 61:8f3153bf0baa 555 /// @attention The user manual refers to Layer 1 and Layer 2, however the
WiredHome 61:8f3153bf0baa 556 /// actual register values are value 0 and 1. This API as well as
WiredHome 61:8f3153bf0baa 557 /// others that reference the layers use the values 0 and 1 for
WiredHome 61:8f3153bf0baa 558 /// cleaner iteration in the code.
WiredHome 43:3becae133285 559 ///
WiredHome 72:ecffe56af969 560 /// @param[in] layer is 0 or 1 to select the layer for subsequent
WiredHome 61:8f3153bf0baa 561 /// commands.
WiredHome 106:c80828f5dea4 562 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 43:3becae133285 563 ///
WiredHome 50:2c4f474a2453 564 RetCode_t SelectDrawingLayer(uint16_t layer);
WiredHome 125:7a0b70f56550 565
WiredHome 43:3becae133285 566
WiredHome 61:8f3153bf0baa 567 /// Get the currently active drawing layer.
WiredHome 61:8f3153bf0baa 568 ///
WiredHome 61:8f3153bf0baa 569 /// This returns a value, 0 or 1, based on the screen configuration
WiredHome 61:8f3153bf0baa 570 /// and the currently active drawing layer.
WiredHome 61:8f3153bf0baa 571 ///
WiredHome 61:8f3153bf0baa 572 /// @code
WiredHome 61:8f3153bf0baa 573 /// uint16_t prevLayer = lcd.GetDrawingLayer();
WiredHome 61:8f3153bf0baa 574 /// lcd.SelectDrawingLayer(x);
WiredHome 61:8f3153bf0baa 575 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 61:8f3153bf0baa 576 /// lcd.SelectDrawingLayer(prevLayer);
WiredHome 61:8f3153bf0baa 577 /// @endcode
WiredHome 61:8f3153bf0baa 578 ///
WiredHome 61:8f3153bf0baa 579 /// @attention The user manual refers to Layer 1 and Layer 2, however the
WiredHome 61:8f3153bf0baa 580 /// actual register values are value 0 and 1. This API as well as
WiredHome 61:8f3153bf0baa 581 /// others that reference the layers use the values 0 and 1 for
WiredHome 61:8f3153bf0baa 582 /// cleaner iteration in the code.
WiredHome 61:8f3153bf0baa 583 ///
WiredHome 61:8f3153bf0baa 584 /// @returns the current drawing layer; 0 or 1.
WiredHome 61:8f3153bf0baa 585 ///
WiredHome 61:8f3153bf0baa 586 uint16_t GetDrawingLayer(void);
WiredHome 125:7a0b70f56550 587
WiredHome 61:8f3153bf0baa 588
WiredHome 44:207594dece70 589 /// Set the Layer presentation mode.
WiredHome 44:207594dece70 590 ///
WiredHome 44:207594dece70 591 /// This sets the presentation mode for layers, and permits showing
WiredHome 44:207594dece70 592 /// a single layer, or applying a mode where the two layers
WiredHome 44:207594dece70 593 /// are combined using one of the hardware methods.
WiredHome 44:207594dece70 594 ///
WiredHome 61:8f3153bf0baa 595 /// Refer to the RA8875 data sheet for full details.
WiredHome 61:8f3153bf0baa 596 ///
WiredHome 56:7a85d226ad0d 597 /// @code
WiredHome 56:7a85d226ad0d 598 /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
WiredHome 56:7a85d226ad0d 599 /// lcd.rect(400,130, 475,155,Brown);
WiredHome 56:7a85d226ad0d 600 /// lcd.SelectDrawingLayer(1);
WiredHome 56:7a85d226ad0d 601 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 602 /// wait(1);
WiredHome 56:7a85d226ad0d 603 /// lcd.SetLayerMode(ShowLayer1);
WiredHome 56:7a85d226ad0d 604 /// @endcode
WiredHome 56:7a85d226ad0d 605 ///
WiredHome 72:ecffe56af969 606 /// @param[in] mode sets the mode in the Layer Transparency Register.
WiredHome 106:c80828f5dea4 607 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 44:207594dece70 608 ///
WiredHome 53:86d24b9480b9 609 RetCode_t SetLayerMode(LayerMode_T mode);
WiredHome 125:7a0b70f56550 610
WiredHome 44:207594dece70 611
WiredHome 82:f7d300f26540 612 /// Get the Layer presentation mode.
WiredHome 82:f7d300f26540 613 ///
WiredHome 106:c80828f5dea4 614 /// This gets the current layer mode. See @ref LayerMode_T.
WiredHome 82:f7d300f26540 615 ///
WiredHome 82:f7d300f26540 616 /// @returns layer mode.
WiredHome 82:f7d300f26540 617 ///
WiredHome 82:f7d300f26540 618 LayerMode_T GetLayerMode(void);
WiredHome 125:7a0b70f56550 619
WiredHome 82:f7d300f26540 620
WiredHome 44:207594dece70 621 /// Set the layer transparency for each layer.
WiredHome 44:207594dece70 622 ///
WiredHome 44:207594dece70 623 /// Set the transparency, where the range of values is
WiredHome 44:207594dece70 624 /// from zero (fully visible) to eight (fully transparent).
WiredHome 44:207594dece70 625 /// The input value is automatically limited to this range.
WiredHome 44:207594dece70 626 ///
WiredHome 56:7a85d226ad0d 627 /// @code
WiredHome 56:7a85d226ad0d 628 /// // draw something on each layer, then step-fade across
WiredHome 56:7a85d226ad0d 629 /// display.SetLayerMode(RA8875::TransparentMode);
WiredHome 56:7a85d226ad0d 630 /// for (i=0; i<=8; i++) {
WiredHome 56:7a85d226ad0d 631 /// display.SetLayerTransparency(i, 8-i);
WiredHome 56:7a85d226ad0d 632 /// wait_ms(200);
WiredHome 56:7a85d226ad0d 633 /// }
WiredHome 56:7a85d226ad0d 634 /// @endcode
WiredHome 56:7a85d226ad0d 635 ///
WiredHome 72:ecffe56af969 636 /// @param[in] layer1 sets the layer 1 transparency.
WiredHome 72:ecffe56af969 637 /// @param[in] layer2 sets the layer 2 transparency.
WiredHome 106:c80828f5dea4 638 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 44:207594dece70 639 ///
WiredHome 44:207594dece70 640 RetCode_t SetLayerTransparency(uint8_t layer1, uint8_t layer2);
WiredHome 125:7a0b70f56550 641
WiredHome 44:207594dece70 642
WiredHome 53:86d24b9480b9 643 /// Set the background color register used for transparency.
WiredHome 53:86d24b9480b9 644 ///
WiredHome 53:86d24b9480b9 645 /// This command sets the background color registers that are used
WiredHome 53:86d24b9480b9 646 /// in the transparent color operations involving the layers.
WiredHome 53:86d24b9480b9 647 ///
WiredHome 72:ecffe56af969 648 /// @param[in] color is optional and expressed in 16-bit format. If not
WiredHome 53:86d24b9480b9 649 /// supplied, a default of Black is used.
WiredHome 106:c80828f5dea4 650 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 53:86d24b9480b9 651 ///
WiredHome 53:86d24b9480b9 652 RetCode_t SetBackgroundTransparencyColor(color_t color = RGB(0,0,0));
hexley 54:e117ad10fba6 653
WiredHome 73:f22a18707b5e 654
WiredHome 73:f22a18707b5e 655 /// Get the background color value used for transparency.
WiredHome 73:f22a18707b5e 656 ///
WiredHome 73:f22a18707b5e 657 /// This command reads the background color registers that define
WiredHome 73:f22a18707b5e 658 /// the transparency color for operations involving layers.
WiredHome 73:f22a18707b5e 659 ///
WiredHome 73:f22a18707b5e 660 /// @returns the color.
WiredHome 73:f22a18707b5e 661 ///
WiredHome 73:f22a18707b5e 662 color_t GetBackgroundTransparencyColor(void);
WiredHome 73:f22a18707b5e 663
WiredHome 125:7a0b70f56550 664
hexley 54:e117ad10fba6 665 /// Initialize theTouch Panel controller with default values
hexley 54:e117ad10fba6 666 ///
WiredHome 78:faf49c381591 667 /// This activates the simplified touch panel init, which may work for
WiredHome 78:faf49c381591 668 /// most uses. The alternate API is available if fine-grained control
WiredHome 124:1690a7ae871c 669 /// of the numerous settings of the resistive panel is needed.
WiredHome 78:faf49c381591 670 ///
WiredHome 106:c80828f5dea4 671 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 56:7a85d226ad0d 672 ///
hexley 54:e117ad10fba6 673 RetCode_t TouchPanelInit(void);
hexley 54:e117ad10fba6 674
WiredHome 125:7a0b70f56550 675
hexley 54:e117ad10fba6 676 /// Initialize the Touch Panel controller with detailed settings.
hexley 54:e117ad10fba6 677 ///
WiredHome 78:faf49c381591 678 /// This is the detailed touch panel init, which provides the ability
WiredHome 124:1690a7ae871c 679 /// to set nearly every option.
WiredHome 124:1690a7ae871c 680 ///
WiredHome 124:1690a7ae871c 681 /// @note If the capacitive touch panel was constructed, this behaves
WiredHome 124:1690a7ae871c 682 /// the same as the simplified version.
WiredHome 78:faf49c381591 683 ///
hexley 54:e117ad10fba6 684 /// @param[in] bTpEnable Touch Panel enable/disable control:
hexley 54:e117ad10fba6 685 /// - TP_ENABLE: enable the touch panel
hexley 54:e117ad10fba6 686 /// - TP_DISABLE: disable the touch panel
WiredHome 56:7a85d226ad0d 687 /// @param[in] bTpAutoManual Touch Panel operating mode:
hexley 54:e117ad10fba6 688 /// - TP_MODE_AUTO: automatic capture
hexley 54:e117ad10fba6 689 /// - TP_MODE_MANUAL: manual capture
WiredHome 56:7a85d226ad0d 690 /// @param[in] bTpDebounce Debounce circuit enable for touch panel interrupt:
hexley 54:e117ad10fba6 691 /// - TP_DEBOUNCE_OFF: disable the debounce circuit
hexley 54:e117ad10fba6 692 /// - TP_DEBOUNCE_ON: enable the debounce circuit
WiredHome 56:7a85d226ad0d 693 /// @param[in] bTpManualMode When Manual Mode is selected, this sets the mode:
hexley 54:e117ad10fba6 694 /// - TP_MANUAL_IDLE: touch panel is idle
hexley 54:e117ad10fba6 695 /// - TP_MANUAL_WAIT: wait for touch panel event
hexley 54:e117ad10fba6 696 /// - TP_MANUAL_LATCH_X: latch X data
hexley 54:e117ad10fba6 697 /// - TP_MANUAL_LATCH_Y: latch Y data
WiredHome 56:7a85d226ad0d 698 /// @param[in] bTpAdcClkDiv Sets the ADC clock as a fraction of the System CLK:
hexley 54:e117ad10fba6 699 /// - TP_ADC_CLKDIV_1: Use CLK
hexley 54:e117ad10fba6 700 /// - TP_ADC_CLKDIV_2: Use CLK/2
hexley 54:e117ad10fba6 701 /// - TP_ADC_CLKDIV_4: Use CLK/4
hexley 54:e117ad10fba6 702 /// - TP_ADC_CLKDIV_8: Use CLK/8
hexley 54:e117ad10fba6 703 /// - TP_ADC_CLKDIV_16: Use CLK/16
hexley 54:e117ad10fba6 704 /// - TP_ADC_CLKDIV_32: Use CLK/32
hexley 54:e117ad10fba6 705 /// - TP_ADC_CLKDIV_64: Use CLK/64
hexley 54:e117ad10fba6 706 /// - TP_ADC_CLKDIV_128: Use CLK/128
WiredHome 56:7a85d226ad0d 707 /// @param[in] bTpAdcSampleTime Touch Panel sample time delay before ADC data is ready:
hexley 54:e117ad10fba6 708 /// - TP_ADC_SAMPLE_512_CLKS: Wait 512 system clocks
hexley 54:e117ad10fba6 709 /// - TP_ADC_SAMPLE_1024_CLKS: Wait 1024 system clocks
hexley 54:e117ad10fba6 710 /// - TP_ADC_SAMPLE_2048_CLKS: Wait 2048 system clocks
hexley 54:e117ad10fba6 711 /// - TP_ADC_SAMPLE_4096_CLKS: Wait 4096 system clocks
hexley 54:e117ad10fba6 712 /// - TP_ADC_SAMPLE_8192_CLKS: Wait 8192 system clocks
hexley 54:e117ad10fba6 713 /// - TP_ADC_SAMPLE_16384_CLKS: Wait 16384 system clocks
hexley 54:e117ad10fba6 714 /// - TP_ADC_SAMPLE_32768_CLKS: Wait 32768 system clocks
hexley 54:e117ad10fba6 715 /// - TP_ADC_SAMPLE_65536_CLKS: Wait 65536 system clocks
WiredHome 106:c80828f5dea4 716 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 56:7a85d226ad0d 717 ///
WiredHome 78:faf49c381591 718 RetCode_t TouchPanelInit(uint8_t bTpEnable, uint8_t bTpAutoManual, uint8_t bTpDebounce,
WiredHome 78:faf49c381591 719 uint8_t bTpManualMode, uint8_t bTpAdcClkDiv, uint8_t bTpAdcSampleTime);
WiredHome 53:86d24b9480b9 720
WiredHome 123:2f45e80fec5f 721
WiredHome 123:2f45e80fec5f 722 /// Get the screen calibrated point of touch.
WiredHome 123:2f45e80fec5f 723 ///
WiredHome 123:2f45e80fec5f 724 /// This method determines if there is a touch and if so it will provide
WiredHome 123:2f45e80fec5f 725 /// the screen-relative touch coordinates. This method can be used in
WiredHome 123:2f45e80fec5f 726 /// a manner similar to Serial.readable(), to determine if there was a
WiredHome 123:2f45e80fec5f 727 /// touch and indicate that - but not care about the coordinates. Alternately,
WiredHome 123:2f45e80fec5f 728 /// if a valid pointer to a point_t is provided, then if a touch is detected
WiredHome 123:2f45e80fec5f 729 /// the point_t will be populated with data.
WiredHome 123:2f45e80fec5f 730 ///
WiredHome 123:2f45e80fec5f 731 /// @code
WiredHome 123:2f45e80fec5f 732 /// Timer t;
WiredHome 123:2f45e80fec5f 733 /// t.start();
WiredHome 123:2f45e80fec5f 734 /// do {
WiredHome 123:2f45e80fec5f 735 /// point_t point = {0, 0};
WiredHome 123:2f45e80fec5f 736 /// if (display.TouchPanelReadable(&point)) {
WiredHome 123:2f45e80fec5f 737 /// display.pixel(point, Red);
WiredHome 123:2f45e80fec5f 738 /// }
WiredHome 123:2f45e80fec5f 739 /// } while (t.read_ms() < 30000);
WiredHome 123:2f45e80fec5f 740 /// @endcode
WiredHome 123:2f45e80fec5f 741 ///
WiredHome 123:2f45e80fec5f 742 /// @param[out] TouchPoint is a pointer to a point_t, which is set as the touch point, if a touch is registered.
WiredHome 123:2f45e80fec5f 743 /// @returns a value indicating the state of the touch,
WiredHome 123:2f45e80fec5f 744 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 123:2f45e80fec5f 745 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 123:2f45e80fec5f 746 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 747 /// - held: held after touch, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 748 /// - release: indicates a release, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 749 ///
WiredHome 123:2f45e80fec5f 750 TouchCode_t TouchPanelReadable(point_t * TouchPoint = NULL);
WiredHome 123:2f45e80fec5f 751
WiredHome 125:7a0b70f56550 752
WiredHome 124:1690a7ae871c 753 /// Get the reported touch gesture, if any.
WiredHome 124:1690a7ae871c 754 ///
WiredHome 124:1690a7ae871c 755 /// If it could detect a gesture, it will return a value based on
WiredHome 124:1690a7ae871c 756 /// the interpreted gesture.\\
WiredHome 124:1690a7ae871c 757 ///
WiredHome 124:1690a7ae871c 758 /// Valid gesture values are:
WiredHome 124:1690a7ae871c 759 /// @li 0x00 No gesture
WiredHome 124:1690a7ae871c 760 /// @li 0x10 Move up
WiredHome 124:1690a7ae871c 761 /// @li 0x14 Move left
WiredHome 124:1690a7ae871c 762 /// @li 0x18 Move down
WiredHome 124:1690a7ae871c 763 /// @li 0x1C Move right
WiredHome 124:1690a7ae871c 764 /// @li 0x48 Zoom in
WiredHome 124:1690a7ae871c 765 /// @li 0x49 Zoom out
WiredHome 124:1690a7ae871c 766 ///
WiredHome 124:1690a7ae871c 767 /// @returns gesture information.
WiredHome 124:1690a7ae871c 768 ///
WiredHome 124:1690a7ae871c 769 uint8_t TouchGesture(void) { return gesture; }
WiredHome 124:1690a7ae871c 770
WiredHome 123:2f45e80fec5f 771
WiredHome 124:1690a7ae871c 772 /// Get the count of registered touches.
WiredHome 124:1690a7ae871c 773 ///
WiredHome 124:1690a7ae871c 774 /// @returns count of touch points to communicate; 0 to 5.
WiredHome 124:1690a7ae871c 775 ///
WiredHome 124:1690a7ae871c 776 int TouchCount(void) { return numberOfTouchPoints; }
WiredHome 125:7a0b70f56550 777
WiredHome 124:1690a7ae871c 778
WiredHome 124:1690a7ae871c 779 /// Get the count of possible touch channels.
WiredHome 124:1690a7ae871c 780 ///
WiredHome 124:1690a7ae871c 781 /// @returns count of touch channels supported by the hardware.
WiredHome 124:1690a7ae871c 782 ///
WiredHome 124:1690a7ae871c 783 int TouchChannels(void);
WiredHome 125:7a0b70f56550 784
WiredHome 124:1690a7ae871c 785
WiredHome 124:1690a7ae871c 786 /// Get the Touch ID value for a specified touch channel.
WiredHome 124:1690a7ae871c 787 ///
WiredHome 124:1690a7ae871c 788 /// Touch ID is a tracking number based on the order of the touch
WiredHome 124:1690a7ae871c 789 /// detections. The first touch is ID 0, the next is ID 1, and
WiredHome 124:1690a7ae871c 790 /// so on. If the first touch is lifted (no touch), the touch count
WiredHome 124:1690a7ae871c 791 /// decrements, and the remaining touch is communicated on
WiredHome 124:1690a7ae871c 792 /// touch channel zero, even as the Touch ID remains as originally
WiredHome 124:1690a7ae871c 793 /// reported (1 in this example). In this way, it is easy to track
WiredHome 124:1690a7ae871c 794 /// a specific touch.\\
WiredHome 124:1690a7ae871c 795 ///
WiredHome 124:1690a7ae871c 796 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 797 /// presently reported as touched.
WiredHome 124:1690a7ae871c 798 ///
WiredHome 124:1690a7ae871c 799 /// @param[in] channel is the touch channel, from 0 to 4, or 0 to getTouchCount()-1
WiredHome 124:1690a7ae871c 800 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 801 /// @returns the touch ID, or 15 if you get the ID for an untouched channel.
WiredHome 124:1690a7ae871c 802 /// @returns 0 if an invalid channel is queried.
WiredHome 124:1690a7ae871c 803 ///
WiredHome 124:1690a7ae871c 804 uint8_t TouchID(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].touchID : touchInfo[0].touchID; }
WiredHome 125:7a0b70f56550 805
WiredHome 124:1690a7ae871c 806
WiredHome 124:1690a7ae871c 807 /// Get the Touch Code for a touch channel.
WiredHome 124:1690a7ae871c 808 ///
WiredHome 124:1690a7ae871c 809 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 810 /// presently reported as touched.
WiredHome 124:1690a7ae871c 811 ///
WiredHome 124:1690a7ae871c 812 /// @param[in] channel is the touch channel, from 0 to 4, or 0 to getTouchCount()-1
WiredHome 124:1690a7ae871c 813 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 814 /// @returns the touch code (@ref TouchCode_t).
WiredHome 124:1690a7ae871c 815 /// @returns channel 0 information if an invalid channel is queried.
WiredHome 124:1690a7ae871c 816 ///
WiredHome 124:1690a7ae871c 817 TouchCode_t TouchCode(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].touchCode : touchInfo[0].touchCode; }
WiredHome 124:1690a7ae871c 818
WiredHome 125:7a0b70f56550 819
WiredHome 124:1690a7ae871c 820 /// Get the coordinates for a touch channel.
WiredHome 124:1690a7ae871c 821 ///
WiredHome 124:1690a7ae871c 822 /// This returns the (X,Y) coordinates for a touch channel.
WiredHome 124:1690a7ae871c 823 ///\\
WiredHome 124:1690a7ae871c 824 ///
WiredHome 124:1690a7ae871c 825 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 826 /// presently reported as touched.
WiredHome 124:1690a7ae871c 827 ///
WiredHome 124:1690a7ae871c 828 /// @param[in] channel is an optional touch channel, from 0 to 4, or 0 to getTouchCount()-1.
WiredHome 124:1690a7ae871c 829 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 830 /// @returns the coordinates as a point_t structure.
WiredHome 124:1690a7ae871c 831 /// @returns channel 0 information if an invalid channel is queried.
WiredHome 124:1690a7ae871c 832 ///
WiredHome 124:1690a7ae871c 833 point_t TouchCoordinates(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].coordinates : touchInfo[0].coordinates; }
WiredHome 125:7a0b70f56550 834
WiredHome 131:5bd6ba2ee4a1 835
WiredHome 79:544eb4964795 836 /// Poll the TouchPanel and on a touch event return the a to d filtered x, y coordinates.
hexley 54:e117ad10fba6 837 ///
WiredHome 78:faf49c381591 838 /// This method reads the touch controller, which has a 10-bit range for each the
WiredHome 79:544eb4964795 839 /// x and the y axis.
WiredHome 79:544eb4964795 840 ///
WiredHome 79:544eb4964795 841 /// @note The returned values are not in display (pixel) units but are in analog to
WiredHome 79:544eb4964795 842 /// digital converter units.
WiredHome 78:faf49c381591 843 ///
WiredHome 131:5bd6ba2ee4a1 844 /// @note This API is usually not needed and is likely to be deprecated.
WiredHome 131:5bd6ba2ee4a1 845 /// See @ref TouchPanelComputeCalibration.
WiredHome 106:c80828f5dea4 846 /// See @ref TouchPanelReadable.
WiredHome 78:faf49c381591 847 ///
WiredHome 79:544eb4964795 848 /// @param[out] x is the x scale a/d value.
WiredHome 79:544eb4964795 849 /// @param[out] y is the y scale a/d value.
WiredHome 83:7bad0068cca0 850 /// @returns a value indicating the state of the touch,
WiredHome 83:7bad0068cca0 851 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 852 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 853 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 83:7bad0068cca0 854 /// - held: held after touch, touch coordinates are returned.
WiredHome 83:7bad0068cca0 855 /// - release: indicates a release, touch coordinates are returned.
WiredHome 56:7a85d226ad0d 856 ///
WiredHome 83:7bad0068cca0 857 TouchCode_t TouchPanelA2DFiltered(int *x, int *y);
hexley 54:e117ad10fba6 858
WiredHome 125:7a0b70f56550 859
WiredHome 79:544eb4964795 860 /// Poll the TouchPanel and on a touch event return the a to d raw x, y coordinates.
hexley 54:e117ad10fba6 861 ///
WiredHome 78:faf49c381591 862 /// This method reads the touch controller, which has a 10-bit range for each the
WiredHome 78:faf49c381591 863 /// x and the y axis. A number of samples of the raw data are taken, filtered,
WiredHome 79:544eb4964795 864 /// and the results are returned.
WiredHome 78:faf49c381591 865 ///
WiredHome 79:544eb4964795 866 /// @note The returned values are not in display (pixel) units but are in analog to
WiredHome 79:544eb4964795 867 /// digital converter units.
WiredHome 79:544eb4964795 868 ///
WiredHome 131:5bd6ba2ee4a1 869 /// @note This API is usually not needed and is likely to be deprecated.
WiredHome 131:5bd6ba2ee4a1 870 /// See @ref TouchPanelComputeCalibration.
WiredHome 106:c80828f5dea4 871 /// See @ref TouchPanelReadable.
WiredHome 78:faf49c381591 872 ///
WiredHome 79:544eb4964795 873 /// @param[out] x is the x scale a/d value.
WiredHome 79:544eb4964795 874 /// @param[out] y is the y scale a/d value.
WiredHome 83:7bad0068cca0 875 /// @returns a value indicating the state of the touch,
WiredHome 83:7bad0068cca0 876 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 877 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 878 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 83:7bad0068cca0 879 /// - held: held after touch, touch coordinates are returned.
WiredHome 83:7bad0068cca0 880 /// - release: indicates a release, touch coordinates are returned.
WiredHome 83:7bad0068cca0 881 ///
WiredHome 83:7bad0068cca0 882 TouchCode_t TouchPanelA2DRaw(int *x, int *y);
WiredHome 125:7a0b70f56550 883
WiredHome 83:7bad0068cca0 884
WiredHome 85:022bba13c5c4 885 /// Wait for a touch panel touch and return it.
WiredHome 85:022bba13c5c4 886 ///
WiredHome 85:022bba13c5c4 887 /// This method is similar to Serial.getc() in that it will wait for a touch
WiredHome 85:022bba13c5c4 888 /// and then return. In order to extract the coordinates of the touch, a
WiredHome 85:022bba13c5c4 889 /// valid pointer to a point_t must be provided.
WiredHome 85:022bba13c5c4 890 ///
WiredHome 85:022bba13c5c4 891 /// @note There is no timeout on this function, so its use is not recommended.
WiredHome 85:022bba13c5c4 892 ///
WiredHome 85:022bba13c5c4 893 /// @code
WiredHome 85:022bba13c5c4 894 /// Timer t;
WiredHome 85:022bba13c5c4 895 /// t.start();
WiredHome 85:022bba13c5c4 896 /// do {
WiredHome 85:022bba13c5c4 897 /// point_t point = {0, 0};
WiredHome 85:022bba13c5c4 898 /// display.TouchPanelGet(&point); // hangs here until touch
WiredHome 85:022bba13c5c4 899 /// display.pixel(point, Red);
WiredHome 85:022bba13c5c4 900 /// } while (t.read_ms() < 30000);
WiredHome 85:022bba13c5c4 901 /// @endcode
WiredHome 85:022bba13c5c4 902 ///
WiredHome 85:022bba13c5c4 903 /// @param[out] TouchPoint is the touch point, if a touch is registered.
WiredHome 85:022bba13c5c4 904 /// @returns a value indicating the state of the touch,
WiredHome 85:022bba13c5c4 905 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 85:022bba13c5c4 906 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 85:022bba13c5c4 907 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 85:022bba13c5c4 908 /// - held: held after touch, touch coordinates are returned.
WiredHome 85:022bba13c5c4 909 /// - release: indicates a release, touch coordinates are returned.
WiredHome 85:022bba13c5c4 910 ///
WiredHome 85:022bba13c5c4 911 TouchCode_t TouchPanelGet(point_t * TouchPoint);
WiredHome 85:022bba13c5c4 912
WiredHome 83:7bad0068cca0 913
WiredHome 77:9206c13aa527 914 /// Calibrate the touch panel.
WiredHome 77:9206c13aa527 915 ///
WiredHome 77:9206c13aa527 916 /// This method accepts two lists - one list is target points in ,
WiredHome 77:9206c13aa527 917 /// display coordinates and the other is a lit of raw touch coordinate
WiredHome 77:9206c13aa527 918 /// values. It generates a calibration matrix for later use. This
WiredHome 77:9206c13aa527 919 /// matrix is also accessible to the calling API, which may store
WiredHome 77:9206c13aa527 920 /// the matrix in persistent memory and then install the calibration
WiredHome 77:9206c13aa527 921 /// matrix on the next power cycle. By doing so, it can avoid the
WiredHome 77:9206c13aa527 922 /// need to calibrate on every power cycle.
WiredHome 77:9206c13aa527 923 ///
WiredHome 81:01da2e34283d 924 /// @note The methods "TouchPanelComputeCalibration", "TouchPanelReadable", and
WiredHome 77:9206c13aa527 925 /// indirectly the "TouchPanelSetMatrix" methods are all derived
WiredHome 77:9206c13aa527 926 /// from a program by Carlos E. Vidales. See the copyright note
WiredHome 77:9206c13aa527 927 /// for further details. See also the article
WiredHome 77:9206c13aa527 928 /// http://www.embedded.com/design/system-integration/4023968/How-To-Calibrate-Touch-Screens
WiredHome 77:9206c13aa527 929 ///
WiredHome 77:9206c13aa527 930 /// @copyright Copyright (c) 2001, Carlos E. Vidales. All rights reserved.
WiredHome 78:faf49c381591 931 /// This sample program was written and put in the public domain
WiredHome 78:faf49c381591 932 /// by Carlos E. Vidales. The program is provided "as is"
WiredHome 78:faf49c381591 933 /// without warranty of any kind, either expressed or implied.
WiredHome 78:faf49c381591 934 /// If you choose to use the program within your own products
WiredHome 78:faf49c381591 935 /// you do so at your own risk, and assume the responsibility
WiredHome 78:faf49c381591 936 /// for servicing, repairing or correcting the program should
WiredHome 78:faf49c381591 937 /// it prove defective in any manner.
WiredHome 78:faf49c381591 938 /// You may copy and distribute the program's source code in any
WiredHome 78:faf49c381591 939 /// medium, provided that you also include in each copy an
WiredHome 78:faf49c381591 940 /// appropriate copyright notice and disclaimer of warranty.
WiredHome 78:faf49c381591 941 /// You may also modify this program and distribute copies of
WiredHome 78:faf49c381591 942 /// it provided that you include prominent notices stating
WiredHome 78:faf49c381591 943 /// that you changed the file(s) and the date of any change,
WiredHome 78:faf49c381591 944 /// and that you do not charge any royalties or licenses for
WiredHome 78:faf49c381591 945 /// its use.
WiredHome 77:9206c13aa527 946 ///
WiredHome 77:9206c13aa527 947 /// @param[in] display is a pointer to a set of 3 points, which
WiredHome 77:9206c13aa527 948 /// are in display units of measure. These are the targets
WiredHome 77:9206c13aa527 949 /// the calibration was aiming for.
WiredHome 77:9206c13aa527 950 /// @param[in] screen is a pointer to a set of 3 points, which
WiredHome 77:9206c13aa527 951 /// are in touchscreen units of measure. These are the
WiredHome 77:9206c13aa527 952 /// registered touches.
WiredHome 77:9206c13aa527 953 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 77:9206c13aa527 954 /// as a result of the calibration. This can be saved in
WiredHome 77:9206c13aa527 955 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 106:c80828f5dea4 956 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 77:9206c13aa527 957 ///
WiredHome 81:01da2e34283d 958 RetCode_t TouchPanelComputeCalibration(point_t display[3], point_t screen[3], tpMatrix_t * matrix);
WiredHome 81:01da2e34283d 959
WiredHome 81:01da2e34283d 960
WiredHome 81:01da2e34283d 961 /// Perform the touch panel calibration process.
WiredHome 81:01da2e34283d 962 ///
WiredHome 81:01da2e34283d 963 /// This method provides the easy "shortcut" to calibrating the touch panel.
WiredHome 81:01da2e34283d 964 /// The process will automatically generate the calibration points, present
WiredHome 81:01da2e34283d 965 /// the targets on-screen, detect the touches, compute the calibration
WiredHome 81:01da2e34283d 966 /// matrix, and optionally provide the calibration matrix to the calling code
WiredHome 81:01da2e34283d 967 /// for persistence in non-volatile memory.
WiredHome 81:01da2e34283d 968 ///
WiredHome 81:01da2e34283d 969 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 81:01da2e34283d 970 /// as a result of the calibration. This can be saved in
WiredHome 81:01da2e34283d 971 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 106:c80828f5dea4 972 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 973 ///
WiredHome 85:022bba13c5c4 974 RetCode_t TouchPanelCalibrate(tpMatrix_t * matrix = NULL);
WiredHome 81:01da2e34283d 975
WiredHome 125:7a0b70f56550 976
WiredHome 81:01da2e34283d 977 /// Perform the touch panel calibration process.
WiredHome 81:01da2e34283d 978 ///
WiredHome 81:01da2e34283d 979 /// This method provides the easy "shortcut" to calibrating the touch panel.
WiredHome 81:01da2e34283d 980 /// The process will automatically generate the calibration points, present
WiredHome 81:01da2e34283d 981 /// the targets on-screen, detect the touches, compute the calibration
WiredHome 81:01da2e34283d 982 /// matrix, and optionally provide the calibration matrix to the calling code
WiredHome 81:01da2e34283d 983 /// for persistence in non-volatile memory.
WiredHome 81:01da2e34283d 984 ///
WiredHome 81:01da2e34283d 985 /// @param[in] msg is a text message to present on the screen during the
WiredHome 81:01da2e34283d 986 /// calibration process.
WiredHome 81:01da2e34283d 987 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 81:01da2e34283d 988 /// as a result of the calibration. This can be saved in
WiredHome 81:01da2e34283d 989 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 88:bfddef6ec836 990 /// @param[in] maxwait_s is the maximum number of seconds to wait for a touch
WiredHome 88:bfddef6ec836 991 /// calibration. If no touch panel installed, it then reports
WiredHome 88:bfddef6ec836 992 /// touch_cal_timeout.
WiredHome 106:c80828f5dea4 993 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 994 ///
WiredHome 88:bfddef6ec836 995 RetCode_t TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix = NULL, int maxwait_s = 15);
WiredHome 77:9206c13aa527 996
WiredHome 125:7a0b70f56550 997
WiredHome 77:9206c13aa527 998 /// Set the calibration matrix for the touch panel.
WiredHome 77:9206c13aa527 999 ///
WiredHome 77:9206c13aa527 1000 /// This method is used to set the calibration matrix for the touch panel. After
WiredHome 106:c80828f5dea4 1001 /// performing the calibration (See @ref TouchPanelComputeCalibration), the matrix can be stored.
WiredHome 77:9206c13aa527 1002 /// On a subsequence power cycle, the matrix may be restored from non-volatile and
WiredHome 77:9206c13aa527 1003 /// passed in to this method. It will then be held to perform the corrections when
WiredHome 77:9206c13aa527 1004 /// reading the touch panel point.
WiredHome 77:9206c13aa527 1005 ///
WiredHome 78:faf49c381591 1006 /// @code
WiredHome 78:faf49c381591 1007 /// FILE * fh = fopen("/local/tpmatrix.cfg", "r");
WiredHome 78:faf49c381591 1008 /// if (fh) {
WiredHome 78:faf49c381591 1009 /// tpMatrix_t matrix;
WiredHome 78:faf49c381591 1010 /// if (fread(fh, &matrix, sizeof(tpMatrix_t))) {
WiredHome 78:faf49c381591 1011 /// lcd.TouchPanelSetMatrix(&matrix);
WiredHome 78:faf49c381591 1012 /// }
WiredHome 78:faf49c381591 1013 /// fclose(fh);
WiredHome 78:faf49c381591 1014 /// }
WiredHome 78:faf49c381591 1015 /// @endcode
WiredHome 78:faf49c381591 1016 ///
WiredHome 77:9206c13aa527 1017 /// @param[in] matrix is a pointer to the touch panel calibration matrix.
WiredHome 106:c80828f5dea4 1018 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 77:9206c13aa527 1019 ///
WiredHome 77:9206c13aa527 1020 RetCode_t TouchPanelSetMatrix(tpMatrix_t * matrix);
WiredHome 78:faf49c381591 1021
WiredHome 125:7a0b70f56550 1022
WiredHome 75:ca78388cfd77 1023 #if 0
hexley 54:e117ad10fba6 1024 /// Append interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 1025 ///
hexley 54:e117ad10fba6 1026 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 1027 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 1028 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 1029 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 1030 /// - RA8875_INT_BTE: BTE process complete interrupt
hexley 54:e117ad10fba6 1031 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
WiredHome 56:7a85d226ad0d 1032 /// @param[in] fptr is a callback function to handle the interrupt event.
WiredHome 56:7a85d226ad0d 1033 /// @returns none
hexley 54:e117ad10fba6 1034 ///
hexley 54:e117ad10fba6 1035 void AppendISR(uint8_t bISRType, void(*fptr)(void));
hexley 54:e117ad10fba6 1036
hexley 54:e117ad10fba6 1037 /// Unappend interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 1038 ///
hexley 54:e117ad10fba6 1039 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 1040 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 1041 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 1042 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 1043 /// - RA8875_INT_BTE: BTE process complete interrupt
hexley 54:e117ad10fba6 1044 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
hexley 54:e117ad10fba6 1045 /// @return none
hexley 54:e117ad10fba6 1046 ///
hexley 54:e117ad10fba6 1047 void UnAppendISR(uint8_t bISRType);
WiredHome 75:ca78388cfd77 1048 #endif
WiredHome 77:9206c13aa527 1049
WiredHome 125:7a0b70f56550 1050
WiredHome 71:dcac8efd842d 1051 /// Initialize the keypad interface on the RA8875 controller.
WiredHome 71:dcac8efd842d 1052 ///
WiredHome 71:dcac8efd842d 1053 /// Enables the keypad subsystem. It will scan the 4 x 5 matrix
WiredHome 131:5bd6ba2ee4a1 1054 /// and make available key presses.
WiredHome 71:dcac8efd842d 1055 ///
WiredHome 71:dcac8efd842d 1056 /// @note See section 5-13 of RAIO RA8875 data sheet for more details.
WiredHome 125:7a0b70f56550 1057 /// @note When using the display from buy-display.com, be sure that
WiredHome 71:dcac8efd842d 1058 /// the option for the keypad is configured on the hardware.
WiredHome 71:dcac8efd842d 1059 ///
WiredHome 71:dcac8efd842d 1060 /// All parameters are optional.
WiredHome 76:c981284eb513 1061 /// @param[in] scanEnable when true, enables the key scan function (default: true).
WiredHome 76:c981284eb513 1062 /// @param[in] longDetect when true, additionally enables the long key held detection (default: false).
WiredHome 71:dcac8efd842d 1063 /// @param[in] sampleTime setting (range: 0 - 3, default: 0).
WiredHome 71:dcac8efd842d 1064 /// @param[in] scanFrequency setting (range: 0 - 7, default: 0).
WiredHome 71:dcac8efd842d 1065 /// @param[in] longTimeAdjustment (range: 0 - 3, default: 0).
WiredHome 76:c981284eb513 1066 /// @param[in] interruptEnable when true, enables interrupts from keypress (default: false).
WiredHome 76:c981284eb513 1067 /// @param[in] wakeupEnable when true, activates the wakeup function (default: false).
WiredHome 71:dcac8efd842d 1068 ///
WiredHome 106:c80828f5dea4 1069 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 71:dcac8efd842d 1070 ///
WiredHome 71:dcac8efd842d 1071 RetCode_t KeypadInit(bool scanEnable = true, bool longDetect = false,
WiredHome 71:dcac8efd842d 1072 uint8_t sampleTime = 0, uint8_t scanFrequency = 0,
WiredHome 71:dcac8efd842d 1073 uint8_t longTimeAdjustment = 0,
WiredHome 71:dcac8efd842d 1074 bool interruptEnable = false, bool wakeupEnable = false);
WiredHome 71:dcac8efd842d 1075
WiredHome 125:7a0b70f56550 1076
WiredHome 75:ca78388cfd77 1077 /// Create Key Code definitions for the key matrix.
WiredHome 75:ca78388cfd77 1078 ///
WiredHome 75:ca78388cfd77 1079 /// This API provides a table of 22 key-code assignments for the matrix of keys.
WiredHome 75:ca78388cfd77 1080 /// This can be used to translate the keys 1 - 20 into some other value, as
WiredHome 75:ca78388cfd77 1081 /// well as to communicate the "no key" (zero) and "error state" (21).
WiredHome 75:ca78388cfd77 1082 ///
WiredHome 75:ca78388cfd77 1083 /// In this way, a keypad could easily emulate a piece of a keyboard, transforming
WiredHome 75:ca78388cfd77 1084 /// 0 - 20 into the values 0, '0', '1', '2', '3', '4', '5', '6', '7', '8',
WiredHome 125:7a0b70f56550 1085 /// '9', '+', '-', '*' , '/', '=', '(bs)', '(cr)', and so on...
WiredHome 75:ca78388cfd77 1086 ///
WiredHome 75:ca78388cfd77 1087 /// @code
WiredHome 75:ca78388cfd77 1088 /// // Return Value by Row, Column Example reassignment
WiredHome 75:ca78388cfd77 1089 /// // Column 0 1 2 3 4
WiredHome 75:ca78388cfd77 1090 /// // +-------------------------+ +-------------------------+
WiredHome 76:c981284eb513 1091 /// // Row 0 | 1 2 3 4 5 | | '7' '8' '9' ',' '<-' |
WiredHome 75:ca78388cfd77 1092 /// // 1 | 6 7 8 9 10 | | '4' '5' '6' '/' '-' |
WiredHome 75:ca78388cfd77 1093 /// // 2 | 11 12 13 14 15 | | '1' '2' '3' '*' '+' |
WiredHome 76:c981284eb513 1094 /// // 3 | 16 17 18 19 20 | | '0' '.' '(' ')' '\n' |
WiredHome 75:ca78388cfd77 1095 /// // +-------------------------+ +-------------------------+
WiredHome 75:ca78388cfd77 1096 /// // Return value 0 = No Key pressed
WiredHome 75:ca78388cfd77 1097 /// // Return value 21 = Error
WiredHome 77:9206c13aa527 1098 /// const uint8_t CodeList[22] =
WiredHome 77:9206c13aa527 1099 /// {0, '7', '8', '9', ',', '\h',
WiredHome 77:9206c13aa527 1100 /// '4', '5', '6', '/', '-',
WiredHome 77:9206c13aa527 1101 /// '1', '2', '3', '*', '+',
WiredHome 77:9206c13aa527 1102 /// '0', '.', '(', ')', '\n',
WiredHome 77:9206c13aa527 1103 /// '\x1b'};
WiredHome 77:9206c13aa527 1104 /// lcd.SetKeyMap(CodeList);
WiredHome 75:ca78388cfd77 1105 /// @endcode
WiredHome 75:ca78388cfd77 1106 ///
WiredHome 75:ca78388cfd77 1107 /// @param[in] CodeList is a pointer to an always available byte-array
WiredHome 75:ca78388cfd77 1108 /// where the first 22 bytes are used as the transformation
WiredHome 75:ca78388cfd77 1109 /// from raw code to your reassigned value.
WiredHome 75:ca78388cfd77 1110 /// If CodeList is NULL, the original raw value key map is
WiredHome 75:ca78388cfd77 1111 /// restored.
WiredHome 75:ca78388cfd77 1112 /// @returns noerror.
WiredHome 75:ca78388cfd77 1113 ///
WiredHome 75:ca78388cfd77 1114 RetCode_t SetKeyMap(const uint8_t * CodeList = NULL);
WiredHome 75:ca78388cfd77 1115
WiredHome 125:7a0b70f56550 1116
WiredHome 71:dcac8efd842d 1117 /// Determine if a key has been hit
WiredHome 71:dcac8efd842d 1118 ///
WiredHome 71:dcac8efd842d 1119 /// @returns true if a key has been hit
WiredHome 71:dcac8efd842d 1120 ///
WiredHome 75:ca78388cfd77 1121 bool readable();
WiredHome 71:dcac8efd842d 1122
WiredHome 125:7a0b70f56550 1123
WiredHome 71:dcac8efd842d 1124 /// Blocking read of the keypad.
WiredHome 71:dcac8efd842d 1125 ///
WiredHome 125:7a0b70f56550 1126 /// @note: This is a blocking read, so it is important to first call _kbhit()
WiredHome 71:dcac8efd842d 1127 /// to avoid hanging your processes.
WiredHome 71:dcac8efd842d 1128 ///
WiredHome 71:dcac8efd842d 1129 /// A keypad connected to the RA8875 is connected in a matrix of 4 rows and 5 columns.
WiredHome 75:ca78388cfd77 1130 /// When pressed, this method will return a code in the range of 1 through 20, reserving
WiredHome 75:ca78388cfd77 1131 /// the value 0 to indicate that no key is pressed.
WiredHome 71:dcac8efd842d 1132 ///
WiredHome 71:dcac8efd842d 1133 /// Additionally, if configured to detect a "long press", bit 7 will be set to indicate
WiredHome 71:dcac8efd842d 1134 /// this. In this situation, first a "normal press" would be detected and signaled and
WiredHome 71:dcac8efd842d 1135 /// soon after that a "long press" of the same key would be detected and communicated.
WiredHome 71:dcac8efd842d 1136 ///
WiredHome 75:ca78388cfd77 1137 /// @return 8-bit where bit 7 indicates a long press. The remaining bits indicate the
WiredHome 75:ca78388cfd77 1138 /// keypress using 0 = no key pressed, 1 - 20 = the key pressed.
WiredHome 71:dcac8efd842d 1139 ///
WiredHome 75:ca78388cfd77 1140 uint8_t getc();
WiredHome 75:ca78388cfd77 1141
WiredHome 82:f7d300f26540 1142
WiredHome 82:f7d300f26540 1143 /// Determine if a point is within a rectangle.
WiredHome 82:f7d300f26540 1144 ///
WiredHome 82:f7d300f26540 1145 /// @param[in] rect is a rectangular region to use.
WiredHome 82:f7d300f26540 1146 /// @param[in] p is a point to analyze to see if it is within the rect.
WiredHome 82:f7d300f26540 1147 /// @returns true if p is within rect.
WiredHome 82:f7d300f26540 1148 ///
WiredHome 82:f7d300f26540 1149 bool Intersect(rect_t rect, point_t p);
WiredHome 82:f7d300f26540 1150
WiredHome 131:5bd6ba2ee4a1 1151 /// Determine if a rectangle intersects another rectangle.
WiredHome 131:5bd6ba2ee4a1 1152 ///
WiredHome 131:5bd6ba2ee4a1 1153 /// @param[in] rect1 is a rectangular region.
WiredHome 131:5bd6ba2ee4a1 1154 /// @param[in] rect2 is a second rectangular region.
WiredHome 131:5bd6ba2ee4a1 1155 /// @returns true if rect1 and rect2 intersect.
WiredHome 131:5bd6ba2ee4a1 1156 ///
WiredHome 131:5bd6ba2ee4a1 1157 bool Intersect(rect_t rect1, rect_t rect2);
WiredHome 82:f7d300f26540 1158
WiredHome 38:38d503b4fad6 1159 /// Write a command to the display with a word of data.
WiredHome 38:38d503b4fad6 1160 ///
WiredHome 38:38d503b4fad6 1161 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 1162 ///
WiredHome 72:ecffe56af969 1163 /// @param[in] command is the command to write.
WiredHome 72:ecffe56af969 1164 /// @param[in] data is data to be written to the command register.
WiredHome 106:c80828f5dea4 1165 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 38:38d503b4fad6 1166 ///
WiredHome 38:38d503b4fad6 1167 RetCode_t WriteCommandW(uint8_t command, uint16_t data);
WiredHome 38:38d503b4fad6 1168
WiredHome 125:7a0b70f56550 1169
WiredHome 19:3f82c1161fd2 1170 /// Write a command to the display
WiredHome 19:3f82c1161fd2 1171 ///
WiredHome 19:3f82c1161fd2 1172 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1173 ///
WiredHome 72:ecffe56af969 1174 /// @param[in] command is the command to write.
WiredHome 72:ecffe56af969 1175 /// @param[in] data is optional data to be written to the command register
WiredHome 19:3f82c1161fd2 1176 /// and only occurs if the data is in the range [0 - 0xFF].
WiredHome 106:c80828f5dea4 1177 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1178 ///
WiredHome 32:0e4f2ae512e2 1179 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
WiredHome 125:7a0b70f56550 1180
WiredHome 19:3f82c1161fd2 1181
WiredHome 38:38d503b4fad6 1182 /// Write a data word to the display
WiredHome 38:38d503b4fad6 1183 ///
WiredHome 38:38d503b4fad6 1184 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 1185 ///
WiredHome 72:ecffe56af969 1186 /// @param[in] data is the data to write.
WiredHome 106:c80828f5dea4 1187 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 38:38d503b4fad6 1188 ///
WiredHome 38:38d503b4fad6 1189 RetCode_t WriteDataW(uint16_t data);
WiredHome 125:7a0b70f56550 1190
WiredHome 38:38d503b4fad6 1191
WiredHome 19:3f82c1161fd2 1192 /// Write a data byte to the display
WiredHome 19:3f82c1161fd2 1193 ///
WiredHome 19:3f82c1161fd2 1194 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1195 ///
WiredHome 72:ecffe56af969 1196 /// @param[in] data is the data to write.
WiredHome 106:c80828f5dea4 1197 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1198 ///
WiredHome 32:0e4f2ae512e2 1199 virtual RetCode_t WriteData(unsigned char data);
WiredHome 125:7a0b70f56550 1200
WiredHome 19:3f82c1161fd2 1201
WiredHome 19:3f82c1161fd2 1202 /// Read a command register
WiredHome 19:3f82c1161fd2 1203 ///
WiredHome 72:ecffe56af969 1204 /// @param[in] command is the command register to read.
WiredHome 19:3f82c1161fd2 1205 /// @returns the value read from the register.
WiredHome 19:3f82c1161fd2 1206 ///
WiredHome 19:3f82c1161fd2 1207 unsigned char ReadCommand(unsigned char command);
WiredHome 19:3f82c1161fd2 1208
WiredHome 125:7a0b70f56550 1209
WiredHome 41:2956a0a221e5 1210 /// Read a data byte from the display
WiredHome 19:3f82c1161fd2 1211 ///
WiredHome 19:3f82c1161fd2 1212 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1213 ///
WiredHome 19:3f82c1161fd2 1214 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 1215 ///
WiredHome 19:3f82c1161fd2 1216 unsigned char ReadData(void);
WiredHome 125:7a0b70f56550 1217
WiredHome 19:3f82c1161fd2 1218
WiredHome 41:2956a0a221e5 1219 /// Read a word from the display
WiredHome 41:2956a0a221e5 1220 ///
WiredHome 41:2956a0a221e5 1221 /// This is a high level command, and may invoke several primitives.
WiredHome 41:2956a0a221e5 1222 ///
WiredHome 41:2956a0a221e5 1223 /// @returns data that was read.
WiredHome 41:2956a0a221e5 1224 ///
WiredHome 41:2956a0a221e5 1225 uint16_t ReadDataW(void);
WiredHome 41:2956a0a221e5 1226
WiredHome 125:7a0b70f56550 1227
WiredHome 19:3f82c1161fd2 1228 /// Read the display status
WiredHome 19:3f82c1161fd2 1229 ///
WiredHome 19:3f82c1161fd2 1230 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1231 ///
WiredHome 19:3f82c1161fd2 1232 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 1233 ///
WiredHome 19:3f82c1161fd2 1234 unsigned char ReadStatus(void);
WiredHome 19:3f82c1161fd2 1235
WiredHome 125:7a0b70f56550 1236
WiredHome 19:3f82c1161fd2 1237 /// get the width in pixels of the currently active font
WiredHome 19:3f82c1161fd2 1238 ///
WiredHome 19:3f82c1161fd2 1239 /// @returns font width in pixels.
WiredHome 19:3f82c1161fd2 1240 ///
WiredHome 37:f19b7e7449dc 1241 dim_t fontwidth(void);
WiredHome 19:3f82c1161fd2 1242
WiredHome 125:7a0b70f56550 1243
WiredHome 19:3f82c1161fd2 1244 /// get the height in pixels of the currently active font
WiredHome 19:3f82c1161fd2 1245 ///
WiredHome 19:3f82c1161fd2 1246 /// @returns font height in pixels.
WiredHome 19:3f82c1161fd2 1247 ///
WiredHome 37:f19b7e7449dc 1248 dim_t fontheight(void);
WiredHome 125:7a0b70f56550 1249
WiredHome 19:3f82c1161fd2 1250
WiredHome 19:3f82c1161fd2 1251 /// get the number of colums based on the currently active font
WiredHome 19:3f82c1161fd2 1252 ///
WiredHome 19:3f82c1161fd2 1253 /// @returns number of columns.
WiredHome 19:3f82c1161fd2 1254 ///
WiredHome 19:3f82c1161fd2 1255 virtual int columns(void);
WiredHome 19:3f82c1161fd2 1256
WiredHome 125:7a0b70f56550 1257
WiredHome 19:3f82c1161fd2 1258 /// get the number of rows based on the currently active font
WiredHome 19:3f82c1161fd2 1259 ///
WiredHome 19:3f82c1161fd2 1260 /// @returns number of rows.
WiredHome 19:3f82c1161fd2 1261 ///
WiredHome 19:3f82c1161fd2 1262 virtual int rows(void);
WiredHome 19:3f82c1161fd2 1263
WiredHome 125:7a0b70f56550 1264
WiredHome 19:3f82c1161fd2 1265 /// get the screen width in pixels
WiredHome 19:3f82c1161fd2 1266 ///
WiredHome 19:3f82c1161fd2 1267 /// @returns screen width in pixels.
WiredHome 19:3f82c1161fd2 1268 ///
WiredHome 38:38d503b4fad6 1269 virtual dim_t width(void);
WiredHome 19:3f82c1161fd2 1270
WiredHome 125:7a0b70f56550 1271
WiredHome 19:3f82c1161fd2 1272 /// get the screen height in pixels
WiredHome 19:3f82c1161fd2 1273 ///
WiredHome 19:3f82c1161fd2 1274 /// @returns screen height in pixels.
WiredHome 19:3f82c1161fd2 1275 ///
WiredHome 38:38d503b4fad6 1276 virtual dim_t height(void);
WiredHome 19:3f82c1161fd2 1277
WiredHome 125:7a0b70f56550 1278
WiredHome 43:3becae133285 1279 /// get the color depth in bits per pixel.
WiredHome 43:3becae133285 1280 ///
WiredHome 43:3becae133285 1281 /// @returns 8 or 16 only.
WiredHome 43:3becae133285 1282 ///
WiredHome 43:3becae133285 1283 virtual dim_t color_bpp(void);
WiredHome 43:3becae133285 1284
WiredHome 19:3f82c1161fd2 1285 /// Set cursor position based on the current font size.
WiredHome 19:3f82c1161fd2 1286 ///
WiredHome 72:ecffe56af969 1287 /// @param[in] column is the horizontal position in character positions
WiredHome 72:ecffe56af969 1288 /// @param[in] row is the vertical position in character positions
WiredHome 106:c80828f5dea4 1289 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1290 ///
WiredHome 37:f19b7e7449dc 1291 virtual RetCode_t locate(textloc_t column, textloc_t row);
WiredHome 19:3f82c1161fd2 1292
WiredHome 125:7a0b70f56550 1293
WiredHome 19:3f82c1161fd2 1294 /// Prepare the controller to write text to the screen by positioning
WiredHome 19:3f82c1161fd2 1295 /// the cursor.
WiredHome 19:3f82c1161fd2 1296 ///
WiredHome 56:7a85d226ad0d 1297 /// @code
WiredHome 56:7a85d226ad0d 1298 /// lcd.SetTextCursor(100, 25);
WiredHome 56:7a85d226ad0d 1299 /// lcd.puts("Hello");
WiredHome 56:7a85d226ad0d 1300 /// @endcode
WiredHome 56:7a85d226ad0d 1301 ///
WiredHome 72:ecffe56af969 1302 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1303 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 106:c80828f5dea4 1304 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1305 ///
WiredHome 37:f19b7e7449dc 1306 RetCode_t SetTextCursor(loc_t x, loc_t y);
WiredHome 29:422616aa04bd 1307
WiredHome 125:7a0b70f56550 1308
WiredHome 103:7e0464ca6c5c 1309 /// Prepare the controller to write text to the screen by positioning
WiredHome 103:7e0464ca6c5c 1310 /// the cursor.
WiredHome 103:7e0464ca6c5c 1311 ///
WiredHome 103:7e0464ca6c5c 1312 /// @code
WiredHome 103:7e0464ca6c5c 1313 /// point_t point = {100, 25};
WiredHome 103:7e0464ca6c5c 1314 /// lcd.SetTextCursor(point);
WiredHome 103:7e0464ca6c5c 1315 /// lcd.puts("Hello");
WiredHome 103:7e0464ca6c5c 1316 /// @endcode
WiredHome 103:7e0464ca6c5c 1317 ///
WiredHome 103:7e0464ca6c5c 1318 /// @param[in] p is the x:y point in pixels from the top-left.
WiredHome 106:c80828f5dea4 1319 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 103:7e0464ca6c5c 1320 ///
WiredHome 103:7e0464ca6c5c 1321 RetCode_t SetTextCursor(point_t p);
WiredHome 103:7e0464ca6c5c 1322
WiredHome 125:7a0b70f56550 1323
WiredHome 37:f19b7e7449dc 1324 /// Get the current cursor position in pixels.
WiredHome 37:f19b7e7449dc 1325 ///
WiredHome 56:7a85d226ad0d 1326 /// @code
WiredHome 56:7a85d226ad0d 1327 /// point_t point = GetTextCursor();
WiredHome 56:7a85d226ad0d 1328 /// if (point.x > 100 && point.y > 150)
WiredHome 56:7a85d226ad0d 1329 /// //...
WiredHome 56:7a85d226ad0d 1330 /// @endcode
WiredHome 56:7a85d226ad0d 1331 ///
WiredHome 37:f19b7e7449dc 1332 /// @returns cursor position.
WiredHome 37:f19b7e7449dc 1333 ///
WiredHome 37:f19b7e7449dc 1334 point_t GetTextCursor(void);
WiredHome 37:f19b7e7449dc 1335
WiredHome 125:7a0b70f56550 1336
WiredHome 29:422616aa04bd 1337 /// Get the current cursor horizontal position in pixels.
WiredHome 29:422616aa04bd 1338 ///
WiredHome 29:422616aa04bd 1339 /// @returns cursor position horizontal offset.
WiredHome 29:422616aa04bd 1340 ///
WiredHome 37:f19b7e7449dc 1341 loc_t GetTextCursor_X(void);
WiredHome 29:422616aa04bd 1342
WiredHome 125:7a0b70f56550 1343
WiredHome 29:422616aa04bd 1344 /// Get the current cursor vertical position in pixels.
WiredHome 29:422616aa04bd 1345 ///
WiredHome 29:422616aa04bd 1346 /// @returns cursor position vertical offset.
WiredHome 29:422616aa04bd 1347 ///
WiredHome 37:f19b7e7449dc 1348 loc_t GetTextCursor_Y(void);
WiredHome 29:422616aa04bd 1349
WiredHome 125:7a0b70f56550 1350
WiredHome 23:a50ded45dbaf 1351 /// Configure additional Cursor Control settings.
WiredHome 23:a50ded45dbaf 1352 ///
WiredHome 23:a50ded45dbaf 1353 /// This API lets you modify other cursor control settings;
WiredHome 23:a50ded45dbaf 1354 /// Cursor visible/hidden, Cursor blink/normal,
WiredHome 23:a50ded45dbaf 1355 /// Cursor I-Beam/underscore/box.
WiredHome 23:a50ded45dbaf 1356 ///
WiredHome 72:ecffe56af969 1357 /// @param[in] cursor can be set to NOCURSOR (default), IBEAM,
WiredHome 24:8ca861acf12d 1358 /// UNDER, or BLOCK.
WiredHome 72:ecffe56af969 1359 /// @param[in] blink can be set to true or false (default false)
WiredHome 106:c80828f5dea4 1360 /// @returns success/failure code. See @ref RetCode_t
WiredHome 23:a50ded45dbaf 1361 ///
WiredHome 24:8ca861acf12d 1362 RetCode_t SetTextCursorControl(cursor_t cursor = NOCURSOR, bool blink = false);
WiredHome 125:7a0b70f56550 1363
WiredHome 23:a50ded45dbaf 1364
WiredHome 98:ecebed9b80b2 1365 /// Select the built-in ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 1366 ///
WiredHome 19:3f82c1161fd2 1367 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 1368 ///
WiredHome 125:7a0b70f56550 1369 /// @note This only modifies the choice of font from the RA8875 internal
WiredHome 98:ecebed9b80b2 1370 /// fonts.
WiredHome 98:ecebed9b80b2 1371 ///
WiredHome 72:ecffe56af969 1372 /// @param[in] font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 1373 ///
WiredHome 19:3f82c1161fd2 1374 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1375 /// the command is not executed.
WiredHome 106:c80828f5dea4 1376 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1377 ///
WiredHome 19:3f82c1161fd2 1378 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 19:3f82c1161fd2 1379
WiredHome 125:7a0b70f56550 1380
WiredHome 84:e102021864b5 1381 /// Sets the display orientation.
WiredHome 84:e102021864b5 1382 ///
WiredHome 84:e102021864b5 1383 /// @note This command does not let you "merge" text onto an existing
WiredHome 84:e102021864b5 1384 /// image, since it reuses the memory for the new orientation.
WiredHome 84:e102021864b5 1385 /// Therefore, it is recommended that you issue a cls() prior
WiredHome 84:e102021864b5 1386 /// to sending text to the screen, or you end with a blended
WiredHome 84:e102021864b5 1387 /// image that is probably not as intended.
WiredHome 84:e102021864b5 1388 ///
WiredHome 125:7a0b70f56550 1389 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1390 ///
WiredHome 84:e102021864b5 1391 /// @code
WiredHome 84:e102021864b5 1392 /// lcd.cls();
WiredHome 84:e102021864b5 1393 /// lcd.SetOrientation(RA8875::normal);
WiredHome 84:e102021864b5 1394 /// lcd.puts(30,30, "Normal Landscape");
WiredHome 84:e102021864b5 1395 /// wait_ms(2500);
WiredHome 84:e102021864b5 1396 ///
WiredHome 84:e102021864b5 1397 /// lcd.cls();
WiredHome 84:e102021864b5 1398 /// lcd.SetOrientation(RA8875::rotate_90);
WiredHome 84:e102021864b5 1399 /// lcd.puts(30,30, "Rotated 90 Text\r\n");
WiredHome 84:e102021864b5 1400 /// wait_ms(2500);
WiredHome 84:e102021864b5 1401 ///
WiredHome 84:e102021864b5 1402 /// lcd.cls();
WiredHome 84:e102021864b5 1403 /// lcd.SetOrientation(RA8875::rotate_180);
WiredHome 84:e102021864b5 1404 /// lcd.puts(30,30, "Rotated 180 Text\r\n");
WiredHome 84:e102021864b5 1405 /// wait_ms(2500);
WiredHome 84:e102021864b5 1406 ///
WiredHome 84:e102021864b5 1407 /// lcd.cls();
WiredHome 84:e102021864b5 1408 /// lcd.SetOrientation(RA8875::rotate_270);
WiredHome 84:e102021864b5 1409 /// lcd.puts(30,30, "Rotated 270 Text\r\n");
WiredHome 84:e102021864b5 1410 /// wait_ms(2500);
WiredHome 84:e102021864b5 1411 /// @endcode
WiredHome 84:e102021864b5 1412 ///
WiredHome 84:e102021864b5 1413 /// @param[in] angle defaults to normal, but can be rotated
WiredHome 84:e102021864b5 1414 /// - normal | rotate_0
WiredHome 84:e102021864b5 1415 /// - rotate_90 (clockwise)
WiredHome 84:e102021864b5 1416 /// - rotate_180
WiredHome 84:e102021864b5 1417 /// - rotate_270 (clockwise)
WiredHome 106:c80828f5dea4 1418 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 84:e102021864b5 1419 ///
WiredHome 84:e102021864b5 1420 RetCode_t SetOrientation(orientation_t angle = normal);
WiredHome 84:e102021864b5 1421
WiredHome 125:7a0b70f56550 1422
WiredHome 19:3f82c1161fd2 1423 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 1424 ///
WiredHome 19:3f82c1161fd2 1425 /// This command lets you make several modifications to any text that
WiredHome 56:7a85d226ad0d 1426 /// will be written to the screen.
WiredHome 19:3f82c1161fd2 1427 ///
WiredHome 125:7a0b70f56550 1428 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1429 ///
WiredHome 19:3f82c1161fd2 1430 /// Options can be combined:
WiredHome 19:3f82c1161fd2 1431 /// Default:
WiredHome 19:3f82c1161fd2 1432 /// @li Full alignment disabled,
WiredHome 19:3f82c1161fd2 1433 /// @li Font with Background color,
WiredHome 84:e102021864b5 1434 /// @li Font in normal orientiation, or rotated 90, 180, or 270 clockwise,
WiredHome 84:e102021864b5 1435 /// @li Horizontal scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1436 /// @li Vertical scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1437 ///
WiredHome 84:e102021864b5 1438 /// @note alignment is a special mode for the fonts, when mixing half and
WiredHome 84:e102021864b5 1439 /// full fonts on one presentation. 'align_full' starts each full
WiredHome 84:e102021864b5 1440 /// character on an even alignment. See section 7-4-7 of the RA8875
WiredHome 84:e102021864b5 1441 /// specification.
WiredHome 19:3f82c1161fd2 1442 ///
WiredHome 72:ecffe56af969 1443 /// @param[in] fillit defaults to FILL, but can be NOFILL
WiredHome 72:ecffe56af969 1444 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1445 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1446 /// @param[in] vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1447 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1448 /// @param[in] alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 1449 /// align_full.
WiredHome 19:3f82c1161fd2 1450 ///
WiredHome 19:3f82c1161fd2 1451 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1452 /// the command is not executed.
WiredHome 106:c80828f5dea4 1453 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1454 ///
WiredHome 19:3f82c1161fd2 1455 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 19:3f82c1161fd2 1456 HorizontalScale hScale = 1,
WiredHome 19:3f82c1161fd2 1457 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 1458 alignment_t alignment = align_none);
WiredHome 19:3f82c1161fd2 1459
WiredHome 125:7a0b70f56550 1460
WiredHome 98:ecebed9b80b2 1461 /// Control the font size of the RA8875 internal fonts.
WiredHome 19:3f82c1161fd2 1462 ///
WiredHome 19:3f82c1161fd2 1463 /// This command lets you set the font enlargement for both horizontal
WiredHome 19:3f82c1161fd2 1464 /// and vertical, independent of the rotation, background, and
WiredHome 106:c80828f5dea4 1465 /// alignment. See @ref SetTextFontControl.
WiredHome 19:3f82c1161fd2 1466 ///
WiredHome 125:7a0b70f56550 1467 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1468 ///
WiredHome 72:ecffe56af969 1469 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1470 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1471 /// @param[in] vScale is an optional parameter that defaults to the hScale value,
WiredHome 40:04aa280dfa39 1472 /// but can be 1, 2, 3, or 4, and scales the font size by this amount.
WiredHome 40:04aa280dfa39 1473 ///
WiredHome 40:04aa280dfa39 1474 /// @code
WiredHome 40:04aa280dfa39 1475 /// lcd.SetTextFontSize(2); // Set the font to 2x normal size
WiredHome 56:7a85d226ad0d 1476 /// lcd.puts("Two times");
WiredHome 40:04aa280dfa39 1477 /// lcd.SetTextFontSize(2,3); // Set the font to 2x Width and 3x Height
WiredHome 56:7a85d226ad0d 1478 /// lcd.puts("2*2 3*h");
WiredHome 40:04aa280dfa39 1479 /// lcd.SetTextFontSize(); // Restore to normal size in both dimensions
WiredHome 56:7a85d226ad0d 1480 /// lcd.puts("normal");
WiredHome 40:04aa280dfa39 1481 /// @endcode
WiredHome 19:3f82c1161fd2 1482 ///
WiredHome 19:3f82c1161fd2 1483 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1484 /// the command is not executed.
WiredHome 106:c80828f5dea4 1485 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1486 ///
WiredHome 40:04aa280dfa39 1487 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
WiredHome 127:db7f2c704693 1488
WiredHome 127:db7f2c704693 1489
WiredHome 127:db7f2c704693 1490 /// Get the text font size of the RA8875 internal fonts.
WiredHome 127:db7f2c704693 1491 ///
WiredHome 127:db7f2c704693 1492 /// This command lets you retrieve the current settings for the font
WiredHome 127:db7f2c704693 1493 /// horizontal and vertical scale factors. The return value is
WiredHome 127:db7f2c704693 1494 /// one of the scale factors 1, 2, 3, or 4.
WiredHome 127:db7f2c704693 1495 ///
WiredHome 127:db7f2c704693 1496 /// @param[out] hScale is a pointer to memory where the horizontal scale factor
WiredHome 127:db7f2c704693 1497 /// will be written. If the pointer is null, that item will be ignored.
WiredHome 127:db7f2c704693 1498 /// @param[out] vScale is a pointer to memory where the vertical scale factor
WiredHome 127:db7f2c704693 1499 /// will be written. If the pointer is null, that item will be ignored.
WiredHome 127:db7f2c704693 1500 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 127:db7f2c704693 1501 ///
WiredHome 127:db7f2c704693 1502 RetCode_t GetTextFontSize(HorizontalScale * hScale, VerticalScale * vScale);
WiredHome 125:7a0b70f56550 1503
WiredHome 19:3f82c1161fd2 1504 /// put a character on the screen.
WiredHome 19:3f82c1161fd2 1505 ///
WiredHome 72:ecffe56af969 1506 /// @param[in] c is the character.
WiredHome 19:3f82c1161fd2 1507 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 1508 ///
WiredHome 19:3f82c1161fd2 1509 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 1510
WiredHome 125:7a0b70f56550 1511
WiredHome 19:3f82c1161fd2 1512 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 1513 ///
WiredHome 56:7a85d226ad0d 1514 /// @code
WiredHome 56:7a85d226ad0d 1515 /// lcd.puts("Test STring");
WiredHome 56:7a85d226ad0d 1516 /// @endcode
WiredHome 56:7a85d226ad0d 1517 ///
WiredHome 72:ecffe56af969 1518 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 1519 ///
WiredHome 19:3f82c1161fd2 1520 void puts(const char * string);
WiredHome 125:7a0b70f56550 1521
WiredHome 19:3f82c1161fd2 1522
WiredHome 19:3f82c1161fd2 1523 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 1524 ///
WiredHome 56:7a85d226ad0d 1525 /// @code
WiredHome 56:7a85d226ad0d 1526 /// lcd.puts(10,25, "Test STring");
WiredHome 56:7a85d226ad0d 1527 /// @endcode
WiredHome 56:7a85d226ad0d 1528 ///
WiredHome 72:ecffe56af969 1529 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1530 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 72:ecffe56af969 1531 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 1532 ///
WiredHome 37:f19b7e7449dc 1533 void puts(loc_t x, loc_t y, const char * string);
WiredHome 19:3f82c1161fd2 1534
WiredHome 125:7a0b70f56550 1535
WiredHome 19:3f82c1161fd2 1536 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 1537 /// the memory cursor.
WiredHome 19:3f82c1161fd2 1538 ///
WiredHome 72:ecffe56af969 1539 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1540 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 106:c80828f5dea4 1541 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1542 ///
WiredHome 37:f19b7e7449dc 1543 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y);
WiredHome 125:7a0b70f56550 1544
WiredHome 19:3f82c1161fd2 1545
WiredHome 41:2956a0a221e5 1546 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 1547 /// the memory read cursor.
WiredHome 41:2956a0a221e5 1548 ///
WiredHome 72:ecffe56af969 1549 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1550 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 106:c80828f5dea4 1551 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 41:2956a0a221e5 1552 ///
WiredHome 41:2956a0a221e5 1553 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1554
WiredHome 125:7a0b70f56550 1555
WiredHome 111:efe436c43aba 1556 /// Set the window, constraining where items are written to the screen.
WiredHome 111:efe436c43aba 1557 ///
WiredHome 111:efe436c43aba 1558 /// After setting the window, text and graphics are constrained to this
WiredHome 111:efe436c43aba 1559 /// window. Text will wrap from the right edge back to the left and down
WiredHome 111:efe436c43aba 1560 /// one row and from the bottom to the top. Graphics drawing will be clipped
WiredHome 111:efe436c43aba 1561 /// at the edge of the window.
WiredHome 111:efe436c43aba 1562 ///
WiredHome 111:efe436c43aba 1563 /// @note If the initial text write is outside the window, it will be shown
WiredHome 111:efe436c43aba 1564 /// where the cursor position it. Once the write hits the right edge of
WiredHome 111:efe436c43aba 1565 /// the defined window, it will then wrap back to the left edge. Once it
WiredHome 111:efe436c43aba 1566 /// hits the bottom, it wraps to the top of the window. For this reason,
WiredHome 111:efe436c43aba 1567 /// it is common to set the text cursor to the window.
WiredHome 19:3f82c1161fd2 1568 ///
WiredHome 111:efe436c43aba 1569 /// @code
WiredHome 111:efe436c43aba 1570 /// rect_t r = {10,10, 90,90};
WiredHome 111:efe436c43aba 1571 /// lcd.window(r);
WiredHome 111:efe436c43aba 1572 /// lcd.SetTextCursor(r.p1.x, r.p1.y);
WiredHome 111:efe436c43aba 1573 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 111:efe436c43aba 1574 /// lcd.window(); restore to full screen
WiredHome 111:efe436c43aba 1575 /// @endcode
WiredHome 111:efe436c43aba 1576 ///
WiredHome 111:efe436c43aba 1577 /// @param[in] r is the rect_t used to set the window.
WiredHome 111:efe436c43aba 1578 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 111:efe436c43aba 1579 ///
WiredHome 111:efe436c43aba 1580 virtual RetCode_t window(rect_t r);
WiredHome 111:efe436c43aba 1581
WiredHome 125:7a0b70f56550 1582
WiredHome 111:efe436c43aba 1583 /// Set the window, constraining where items are written to the screen.
WiredHome 111:efe436c43aba 1584 ///
WiredHome 111:efe436c43aba 1585 /// After setting the window, text and graphics are constrained to this
WiredHome 111:efe436c43aba 1586 /// window. Text will wrap from the right edge back to the left and down
WiredHome 111:efe436c43aba 1587 /// one row and from the bottom to the top. Graphics drawing will be clipped
WiredHome 111:efe436c43aba 1588 /// at the edge of the window.
WiredHome 111:efe436c43aba 1589 ///
WiredHome 114:dbfb996bfbf3 1590 /// @note if no parameters are provided, it restores the window to full screen.
WiredHome 114:dbfb996bfbf3 1591 ///
WiredHome 111:efe436c43aba 1592 /// @note If the initial text write is outside the window, it will be shown
WiredHome 111:efe436c43aba 1593 /// where the cursor position it. Once the write hits the right edge of
WiredHome 111:efe436c43aba 1594 /// the defined window, it will then wrap back to the left edge. Once it
WiredHome 111:efe436c43aba 1595 /// hits the bottom, it wraps to the top of the window. For this reason,
WiredHome 111:efe436c43aba 1596 /// it is common to set the text cursor to the window.
WiredHome 19:3f82c1161fd2 1597 ///
WiredHome 56:7a85d226ad0d 1598 /// @code
WiredHome 56:7a85d226ad0d 1599 /// lcd.window(10,10, 80,80);
WiredHome 111:efe436c43aba 1600 /// lcd.SetTextCursor(10,10);
WiredHome 56:7a85d226ad0d 1601 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 111:efe436c43aba 1602 /// lcd.window(); restore to full screen
WiredHome 56:7a85d226ad0d 1603 /// @endcode
WiredHome 56:7a85d226ad0d 1604 ///
WiredHome 72:ecffe56af969 1605 /// @param[in] x is the left edge in pixels.
WiredHome 72:ecffe56af969 1606 /// @param[in] y is the top edge in pixels.
WiredHome 72:ecffe56af969 1607 /// @param[in] width is the window width in pixels.
WiredHome 72:ecffe56af969 1608 /// @param[in] height is the window height in pixels.
WiredHome 106:c80828f5dea4 1609 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1610 ///
WiredHome 111:efe436c43aba 1611 virtual RetCode_t window(loc_t x = 0, loc_t y = 0, dim_t width = (dim_t)-1, dim_t height = (dim_t)-1);
WiredHome 19:3f82c1161fd2 1612
WiredHome 125:7a0b70f56550 1613
WiredHome 61:8f3153bf0baa 1614 /// Clear either the specified layer, or the active layer.
WiredHome 19:3f82c1161fd2 1615 ///
WiredHome 61:8f3153bf0baa 1616 /// The behavior is to clear the whole screen for the specified
WiredHome 61:8f3153bf0baa 1617 /// layer. When not specified, the active drawing layer is cleared.
WiredHome 61:8f3153bf0baa 1618 /// This command can also be used to specifically clear either,
WiredHome 106:c80828f5dea4 1619 /// or both layers. See @ref clsw().
WiredHome 19:3f82c1161fd2 1620 ///
WiredHome 56:7a85d226ad0d 1621 /// @code
WiredHome 56:7a85d226ad0d 1622 /// lcd.cls();
WiredHome 56:7a85d226ad0d 1623 /// @endcode
WiredHome 56:7a85d226ad0d 1624 ///
WiredHome 72:ecffe56af969 1625 /// @param[in] layers is optional. If not provided, the active layer
WiredHome 61:8f3153bf0baa 1626 /// is cleared. If bit 0 is set, layer 0 is cleared, if bit
WiredHome 61:8f3153bf0baa 1627 /// 1 is set, layer 1 is cleared. If both are set, both layers
WiredHome 61:8f3153bf0baa 1628 /// are cleared. Any other value does not cause an action.
WiredHome 61:8f3153bf0baa 1629 ///
WiredHome 106:c80828f5dea4 1630 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1631 ///
WiredHome 61:8f3153bf0baa 1632 virtual RetCode_t cls(uint16_t layers = 0);
WiredHome 125:7a0b70f56550 1633
WiredHome 19:3f82c1161fd2 1634
WiredHome 19:3f82c1161fd2 1635 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 1636 ///
WiredHome 19:3f82c1161fd2 1637 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 1638 /// parameter, the action can be restricted to the active window, which
WiredHome 106:c80828f5dea4 1639 /// can be set with the See @ref window method.
WiredHome 19:3f82c1161fd2 1640 ///
WiredHome 56:7a85d226ad0d 1641 /// @code
WiredHome 56:7a85d226ad0d 1642 /// lcd.window(20,20, 40,10);
WiredHome 56:7a85d226ad0d 1643 /// lcd.clsw();
WiredHome 56:7a85d226ad0d 1644 /// @endcode
WiredHome 56:7a85d226ad0d 1645 ///
WiredHome 72:ecffe56af969 1646 /// @param[in] region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 1647 /// or may be set to ACTIVEWINDOW.
WiredHome 106:c80828f5dea4 1648 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1649 ///
WiredHome 19:3f82c1161fd2 1650 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 1651
WiredHome 125:7a0b70f56550 1652
WiredHome 19:3f82c1161fd2 1653 /// Set the background color.
WiredHome 19:3f82c1161fd2 1654 ///
WiredHome 72:ecffe56af969 1655 /// @param[in] color is expressed in 16-bit format.
WiredHome 106:c80828f5dea4 1656 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1657 ///
WiredHome 19:3f82c1161fd2 1658 virtual RetCode_t background(color_t color);
WiredHome 125:7a0b70f56550 1659
WiredHome 19:3f82c1161fd2 1660
WiredHome 19:3f82c1161fd2 1661 /// Set the background color.
WiredHome 19:3f82c1161fd2 1662 ///
WiredHome 72:ecffe56af969 1663 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 1664 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 1665 /// @param[in] b is the blue element of the color.
WiredHome 106:c80828f5dea4 1666 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1667 ///
WiredHome 19:3f82c1161fd2 1668 virtual RetCode_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 1669
WiredHome 125:7a0b70f56550 1670
WiredHome 19:3f82c1161fd2 1671 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 1672 ///
WiredHome 72:ecffe56af969 1673 /// @param[in] color is expressed in 16-bit format.
WiredHome 106:c80828f5dea4 1674 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1675 ///
WiredHome 19:3f82c1161fd2 1676 virtual RetCode_t foreground(color_t color);
WiredHome 19:3f82c1161fd2 1677
WiredHome 125:7a0b70f56550 1678
WiredHome 19:3f82c1161fd2 1679 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 1680 ///
WiredHome 72:ecffe56af969 1681 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 1682 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 1683 /// @param[in] b is the blue element of the color.
WiredHome 106:c80828f5dea4 1684 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1685 ///
WiredHome 37:f19b7e7449dc 1686 virtual RetCode_t foreground(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 1687
WiredHome 125:7a0b70f56550 1688
WiredHome 19:3f82c1161fd2 1689 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 1690 ///
WiredHome 19:3f82c1161fd2 1691 /// @returns the current foreground color.
WiredHome 19:3f82c1161fd2 1692 ///
WiredHome 37:f19b7e7449dc 1693 color_t GetForeColor(void);
WiredHome 87:ee2240581aa7 1694
WiredHome 125:7a0b70f56550 1695
WiredHome 87:ee2240581aa7 1696 /// Draw a pixel in the specified color.
WiredHome 87:ee2240581aa7 1697 ///
WiredHome 87:ee2240581aa7 1698 /// @note Unlike many other operations, this does not
WiredHome 87:ee2240581aa7 1699 /// set the forecolor!
WiredHome 87:ee2240581aa7 1700 ///
WiredHome 87:ee2240581aa7 1701 /// @param[in] p is the point_t defining the location.
WiredHome 106:c80828f5dea4 1702 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 87:ee2240581aa7 1703 ///
WiredHome 87:ee2240581aa7 1704 virtual RetCode_t pixel(point_t p, color_t color);
WiredHome 87:ee2240581aa7 1705
WiredHome 125:7a0b70f56550 1706
WiredHome 87:ee2240581aa7 1707 /// Draw a pixel in the current foreground color.
WiredHome 87:ee2240581aa7 1708 ///
WiredHome 87:ee2240581aa7 1709 /// @param[in] p is the point_t defining the location.
WiredHome 106:c80828f5dea4 1710 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 87:ee2240581aa7 1711 ///
WiredHome 87:ee2240581aa7 1712 virtual RetCode_t pixel(point_t p);
WiredHome 125:7a0b70f56550 1713
WiredHome 19:3f82c1161fd2 1714
WiredHome 19:3f82c1161fd2 1715 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 1716 ///
WiredHome 41:2956a0a221e5 1717 /// @note Unlike many other operations, this does not
WiredHome 41:2956a0a221e5 1718 /// set the forecolor!
WiredHome 19:3f82c1161fd2 1719 ///
WiredHome 72:ecffe56af969 1720 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1721 /// @param[in] y is the vertical offset to this pixel.
WiredHome 72:ecffe56af969 1722 /// @param[in] color defines the color for the pixel.
WiredHome 106:c80828f5dea4 1723 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1724 ///
WiredHome 37:f19b7e7449dc 1725 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color);
WiredHome 19:3f82c1161fd2 1726
WiredHome 125:7a0b70f56550 1727
WiredHome 19:3f82c1161fd2 1728 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 1729 ///
WiredHome 72:ecffe56af969 1730 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1731 /// @param[in] y is the veritical offset to this pixel.
WiredHome 106:c80828f5dea4 1732 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1733 ///
WiredHome 37:f19b7e7449dc 1734 virtual RetCode_t pixel(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 1735
WiredHome 125:7a0b70f56550 1736
WiredHome 41:2956a0a221e5 1737 /// Get a pixel from the display.
WiredHome 41:2956a0a221e5 1738 ///
WiredHome 72:ecffe56af969 1739 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1740 /// @param[in] y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 1741 /// @returns the pixel. see @color_t
WiredHome 41:2956a0a221e5 1742 ///
WiredHome 41:2956a0a221e5 1743 virtual color_t getPixel(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1744
WiredHome 125:7a0b70f56550 1745
WiredHome 41:2956a0a221e5 1746 /// Write a stream of pixels to the display.
WiredHome 41:2956a0a221e5 1747 ///
WiredHome 72:ecffe56af969 1748 /// @param[in] p is a pointer to a color_t array to write.
WiredHome 72:ecffe56af969 1749 /// @param[in] count is the number of pixels to write.
WiredHome 72:ecffe56af969 1750 /// @param[in] x is the horizontal position on the display.
WiredHome 72:ecffe56af969 1751 /// @param[in] y is the vertical position on the display.
WiredHome 106:c80828f5dea4 1752 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 41:2956a0a221e5 1753 ///
WiredHome 41:2956a0a221e5 1754 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1755
WiredHome 125:7a0b70f56550 1756
WiredHome 41:2956a0a221e5 1757 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 1758 ///
WiredHome 72:ecffe56af969 1759 /// @param[in] p is a pointer to a color_t array to accept the stream.
WiredHome 72:ecffe56af969 1760 /// @param[in] count is the number of pixels to read.
WiredHome 72:ecffe56af969 1761 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1762 /// @param[in] y is the vertical offset to this pixel.
WiredHome 106:c80828f5dea4 1763 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 41:2956a0a221e5 1764 ///
WiredHome 41:2956a0a221e5 1765 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 131:5bd6ba2ee4a1 1766
WiredHome 131:5bd6ba2ee4a1 1767
WiredHome 109:7b94f06f085b 1768 /// Write a boolean stream to the display.
WiredHome 109:7b94f06f085b 1769 ///
WiredHome 109:7b94f06f085b 1770 /// This takes a bit stream in memory and using the current color settings
WiredHome 109:7b94f06f085b 1771 /// it will stream it to the display. Along the way, each bit is translated
WiredHome 109:7b94f06f085b 1772 /// to either the foreground or background color value and then that pixel
WiredHome 109:7b94f06f085b 1773 /// is pushed onward.
WiredHome 109:7b94f06f085b 1774 ///
WiredHome 109:7b94f06f085b 1775 /// This is similar, but different, to the @ref pixelStream API, which is
WiredHome 109:7b94f06f085b 1776 /// given a stream of color values.
WiredHome 109:7b94f06f085b 1777 ///
WiredHome 109:7b94f06f085b 1778 /// @param[in] x is the horizontal position on the display.
WiredHome 109:7b94f06f085b 1779 /// @param[in] y is the vertical position on the display.
WiredHome 109:7b94f06f085b 1780 /// @param[in] w is the width of the rectangular region to fill.
WiredHome 109:7b94f06f085b 1781 /// @param[in] h is the height of the rectangular region to fill.
WiredHome 109:7b94f06f085b 1782 /// @param[in] boolStream is the inline memory image from which to extract
WiredHome 109:7b94f06f085b 1783 /// the bitstream.
WiredHome 109:7b94f06f085b 1784 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 109:7b94f06f085b 1785 ///
WiredHome 109:7b94f06f085b 1786 virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream);
WiredHome 125:7a0b70f56550 1787
WiredHome 109:7b94f06f085b 1788
WiredHome 19:3f82c1161fd2 1789 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 1790 ///
WiredHome 19:3f82c1161fd2 1791 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1792 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1793 ///
WiredHome 83:7bad0068cca0 1794 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 1795 /// @param[in] p2 is the point to end the line.
WiredHome 83:7bad0068cca0 1796 /// @param[in] color defines the foreground color.
WiredHome 106:c80828f5dea4 1797 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 1798 ///
WiredHome 83:7bad0068cca0 1799 RetCode_t line(point_t p1, point_t p2, color_t color);
WiredHome 83:7bad0068cca0 1800
WiredHome 125:7a0b70f56550 1801
WiredHome 83:7bad0068cca0 1802 /// Draw a line
WiredHome 83:7bad0068cca0 1803 ///
WiredHome 83:7bad0068cca0 1804 /// Draws a line using the foreground color setting.
WiredHome 83:7bad0068cca0 1805 ///
WiredHome 83:7bad0068cca0 1806 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 1807 /// @param[in] p2 is the point to end the line.
WiredHome 106:c80828f5dea4 1808 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 1809 ///
WiredHome 83:7bad0068cca0 1810 RetCode_t line(point_t p1, point_t p2);
WiredHome 125:7a0b70f56550 1811
WiredHome 83:7bad0068cca0 1812
WiredHome 83:7bad0068cca0 1813 /// Draw a line in the specified color
WiredHome 83:7bad0068cca0 1814 ///
WiredHome 83:7bad0068cca0 1815 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 1816 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 1817 ///
WiredHome 72:ecffe56af969 1818 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1819 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1820 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1821 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1822 /// @param[in] color defines the foreground color.
WiredHome 106:c80828f5dea4 1823 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1824 ///
WiredHome 56:7a85d226ad0d 1825 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color);
WiredHome 19:3f82c1161fd2 1826
WiredHome 125:7a0b70f56550 1827
WiredHome 19:3f82c1161fd2 1828 /// Draw a line
WiredHome 19:3f82c1161fd2 1829 ///
WiredHome 19:3f82c1161fd2 1830 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 1831 ///
WiredHome 72:ecffe56af969 1832 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1833 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1834 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1835 /// @param[in] y2 is the vertical end of the line.
WiredHome 106:c80828f5dea4 1836 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1837 ///
WiredHome 37:f19b7e7449dc 1838 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2);
WiredHome 19:3f82c1161fd2 1839
WiredHome 125:7a0b70f56550 1840
WiredHome 19:3f82c1161fd2 1841 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 1842 ///
WiredHome 19:3f82c1161fd2 1843 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1844 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1845 ///
WiredHome 81:01da2e34283d 1846 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 1847 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1848 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 1849 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 1850 ///
WiredHome 82:f7d300f26540 1851 RetCode_t rect(rect_t rect, color_t color, fill_t fillit = NOFILL);
WiredHome 81:01da2e34283d 1852
WiredHome 125:7a0b70f56550 1853
WiredHome 125:7a0b70f56550 1854 /// Draw a filled rectangle in the specified color
WiredHome 81:01da2e34283d 1855 ///
WiredHome 81:01da2e34283d 1856 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 1857 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 1858 ///
WiredHome 81:01da2e34283d 1859 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 1860 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1861 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 1862 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 1863 ///
WiredHome 81:01da2e34283d 1864 RetCode_t fillrect(rect_t rect, color_t color, fill_t fillit = FILL);
WiredHome 81:01da2e34283d 1865
WiredHome 125:7a0b70f56550 1866
WiredHome 81:01da2e34283d 1867 /// Draw a rectangle in the specified color
WiredHome 81:01da2e34283d 1868 ///
WiredHome 81:01da2e34283d 1869 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 1870 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 1871 ///
WiredHome 72:ecffe56af969 1872 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1873 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1874 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1875 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1876 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1877 /// @param[in] fillit is optional to FILL the rectangle. default is FILL.
WiredHome 106:c80828f5dea4 1878 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1879 ///
WiredHome 37:f19b7e7449dc 1880 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 1881 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1882
WiredHome 125:7a0b70f56550 1883
WiredHome 19:3f82c1161fd2 1884 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 1885 ///
WiredHome 19:3f82c1161fd2 1886 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1887 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1888 ///
WiredHome 72:ecffe56af969 1889 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1890 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1891 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1892 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1893 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1894 /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 106:c80828f5dea4 1895 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1896 ///
WiredHome 37:f19b7e7449dc 1897 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 1898 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1899
WiredHome 125:7a0b70f56550 1900
WiredHome 19:3f82c1161fd2 1901 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 1902 ///
WiredHome 19:3f82c1161fd2 1903 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 1904 ///
WiredHome 72:ecffe56af969 1905 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1906 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1907 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1908 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1909 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 1910 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1911 ///
WiredHome 37:f19b7e7449dc 1912 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 1913 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1914
WiredHome 125:7a0b70f56550 1915
WiredHome 19:3f82c1161fd2 1916 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 1917 ///
WiredHome 21:3c1efb192927 1918 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 1919 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 1920 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 1921 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 1922 ///
WiredHome 19:3f82c1161fd2 1923 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1924 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1925 ///
WiredHome 72:ecffe56af969 1926 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 1927 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 1928 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 1929 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 1930 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1931 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1932 /// is returned.
WiredHome 72:ecffe56af969 1933 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1934 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1935 /// is returned.
WiredHome 72:ecffe56af969 1936 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1937 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 1938 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1939 ///
WiredHome 37:f19b7e7449dc 1940 RetCode_t fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1941 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1942
WiredHome 125:7a0b70f56550 1943
WiredHome 107:f9ccffcb84f1 1944 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 107:f9ccffcb84f1 1945 ///
WiredHome 107:f9ccffcb84f1 1946 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 107:f9ccffcb84f1 1947 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 107:f9ccffcb84f1 1948 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 107:f9ccffcb84f1 1949 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 107:f9ccffcb84f1 1950 ///
WiredHome 107:f9ccffcb84f1 1951 /// @note As a side effect, this changes the current
WiredHome 107:f9ccffcb84f1 1952 /// foreground color for subsequent operations.
WiredHome 107:f9ccffcb84f1 1953 ///
WiredHome 107:f9ccffcb84f1 1954 /// @param[in] r is the rectangle to draw.
WiredHome 107:f9ccffcb84f1 1955 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 1956 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 1957 /// is returned.
WiredHome 107:f9ccffcb84f1 1958 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 1959 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 1960 /// is returned.
WiredHome 107:f9ccffcb84f1 1961 /// @param[in] color defines the foreground color.
WiredHome 107:f9ccffcb84f1 1962 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 107:f9ccffcb84f1 1963 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 107:f9ccffcb84f1 1964 ///
WiredHome 107:f9ccffcb84f1 1965 RetCode_t fillroundrect(rect_t r,
WiredHome 107:f9ccffcb84f1 1966 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 107:f9ccffcb84f1 1967
WiredHome 125:7a0b70f56550 1968
WiredHome 107:f9ccffcb84f1 1969 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 107:f9ccffcb84f1 1970 ///
WiredHome 107:f9ccffcb84f1 1971 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 107:f9ccffcb84f1 1972 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 107:f9ccffcb84f1 1973 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 107:f9ccffcb84f1 1974 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 107:f9ccffcb84f1 1975 ///
WiredHome 107:f9ccffcb84f1 1976 /// @note As a side effect, this changes the current
WiredHome 107:f9ccffcb84f1 1977 /// foreground color for subsequent operations.
WiredHome 107:f9ccffcb84f1 1978 ///
WiredHome 107:f9ccffcb84f1 1979 /// @param[in] r is the rectangle to draw.
WiredHome 107:f9ccffcb84f1 1980 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 1981 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 1982 /// is returned.
WiredHome 107:f9ccffcb84f1 1983 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 1984 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 1985 /// is returned.
WiredHome 107:f9ccffcb84f1 1986 /// @param[in] color defines the foreground color.
WiredHome 107:f9ccffcb84f1 1987 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 107:f9ccffcb84f1 1988 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 107:f9ccffcb84f1 1989 ///
WiredHome 107:f9ccffcb84f1 1990 RetCode_t roundrect(rect_t r,
WiredHome 107:f9ccffcb84f1 1991 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 107:f9ccffcb84f1 1992
WiredHome 125:7a0b70f56550 1993
WiredHome 19:3f82c1161fd2 1994 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 1995 ///
WiredHome 21:3c1efb192927 1996 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 1997 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 1998 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 1999 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 2000 ///
WiredHome 19:3f82c1161fd2 2001 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2002 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2003 ///
WiredHome 72:ecffe56af969 2004 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2005 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2006 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2007 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2008 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2009 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2010 /// is returned.
WiredHome 72:ecffe56af969 2011 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2012 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2013 /// is returned.
WiredHome 72:ecffe56af969 2014 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2015 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2016 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2017 ///
WiredHome 37:f19b7e7449dc 2018 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2019 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2020
WiredHome 125:7a0b70f56550 2021
WiredHome 19:3f82c1161fd2 2022 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 2023 ///
WiredHome 21:3c1efb192927 2024 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2025 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2026 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2027 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 2028 ///
WiredHome 72:ecffe56af969 2029 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2030 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2031 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2032 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2033 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2034 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2035 /// is returned.
WiredHome 72:ecffe56af969 2036 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2037 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2038 /// is returned.
WiredHome 72:ecffe56af969 2039 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2040 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2041 ///
WiredHome 37:f19b7e7449dc 2042 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2043 dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2044
WiredHome 125:7a0b70f56550 2045
WiredHome 19:3f82c1161fd2 2046 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 2047 ///
WiredHome 19:3f82c1161fd2 2048 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2049 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2050 ///
WiredHome 72:ecffe56af969 2051 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2052 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2053 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2054 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2055 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2056 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2057 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2058 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2059 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2060 ///
WiredHome 37:f19b7e7449dc 2061 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2062 loc_t x3, loc_t y3, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2063
WiredHome 125:7a0b70f56550 2064
WiredHome 19:3f82c1161fd2 2065 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 2066 ///
WiredHome 19:3f82c1161fd2 2067 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2068 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2069 ///
WiredHome 72:ecffe56af969 2070 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2071 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2072 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2073 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2074 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2075 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2076 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2077 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2078 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2079 ///
WiredHome 37:f19b7e7449dc 2080 RetCode_t filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2081 loc_t x3, loc_t y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2082
WiredHome 125:7a0b70f56550 2083
WiredHome 19:3f82c1161fd2 2084 /// Draw a triangle
WiredHome 19:3f82c1161fd2 2085 ///
WiredHome 19:3f82c1161fd2 2086 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2087 ///
WiredHome 72:ecffe56af969 2088 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2089 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2090 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2091 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2092 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2093 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2094 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2095 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2096 ///
WiredHome 37:f19b7e7449dc 2097 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2098 loc_t x3, loc_t y3, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2099
WiredHome 83:7bad0068cca0 2100
WiredHome 83:7bad0068cca0 2101 /// Draw a circle using the specified color.
WiredHome 83:7bad0068cca0 2102 ///
WiredHome 83:7bad0068cca0 2103 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2104 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2105 ///
WiredHome 83:7bad0068cca0 2106 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2107 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 2108 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2109 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2110 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 2111 ///
WiredHome 83:7bad0068cca0 2112 RetCode_t circle(point_t p, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 2113
WiredHome 125:7a0b70f56550 2114
WiredHome 83:7bad0068cca0 2115 /// Draw a filled circle using the specified color.
WiredHome 83:7bad0068cca0 2116 ///
WiredHome 83:7bad0068cca0 2117 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2118 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2119 ///
WiredHome 83:7bad0068cca0 2120 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2121 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 2122 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2123 /// @param[in] fillit is optional to FILL the circle. default is FILL.
WiredHome 106:c80828f5dea4 2124 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 2125 ///
WiredHome 83:7bad0068cca0 2126 RetCode_t fillcircle(point_t p, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 83:7bad0068cca0 2127
WiredHome 125:7a0b70f56550 2128
WiredHome 83:7bad0068cca0 2129 /// Draw a circle.
WiredHome 83:7bad0068cca0 2130 ///
WiredHome 83:7bad0068cca0 2131 /// Draws a circle using the foreground color setting.
WiredHome 83:7bad0068cca0 2132 ///
WiredHome 83:7bad0068cca0 2133 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2134 /// @param[in] radius defines the size of the circle.
WiredHome 125:7a0b70f56550 2135 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2136 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 2137 ///
WiredHome 83:7bad0068cca0 2138 RetCode_t circle(point_t p, dim_t radius, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 2139
WiredHome 125:7a0b70f56550 2140
WiredHome 19:3f82c1161fd2 2141 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 2142 ///
WiredHome 19:3f82c1161fd2 2143 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2144 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2145 ///
WiredHome 72:ecffe56af969 2146 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2147 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2148 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 2149 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2150 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2151 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2152 ///
WiredHome 37:f19b7e7449dc 2153 RetCode_t circle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2154
WiredHome 125:7a0b70f56550 2155
WiredHome 19:3f82c1161fd2 2156 /// Draw a filled circle using the specified color.
WiredHome 19:3f82c1161fd2 2157 ///
WiredHome 19:3f82c1161fd2 2158 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2159 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2160 ///
WiredHome 72:ecffe56af969 2161 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2162 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2163 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 2164 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2165 /// @param[in] fillit is optional to FILL the circle. default is FILL.
WiredHome 106:c80828f5dea4 2166 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2167 ///
WiredHome 37:f19b7e7449dc 2168 RetCode_t fillcircle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2169
WiredHome 125:7a0b70f56550 2170
WiredHome 19:3f82c1161fd2 2171 /// Draw a circle.
WiredHome 19:3f82c1161fd2 2172 ///
WiredHome 19:3f82c1161fd2 2173 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2174 ///
WiredHome 72:ecffe56af969 2175 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2176 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2177 /// @param[in] radius defines the size of the circle.
WiredHome 125:7a0b70f56550 2178 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2179 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2180 ///
WiredHome 37:f19b7e7449dc 2181 RetCode_t circle(loc_t x, loc_t y, dim_t radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2182
WiredHome 19:3f82c1161fd2 2183 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 2184 ///
WiredHome 19:3f82c1161fd2 2185 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2186 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2187 ///
WiredHome 72:ecffe56af969 2188 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2189 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2190 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2191 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2192 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2193 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 106:c80828f5dea4 2194 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2195 ///
WiredHome 37:f19b7e7449dc 2196 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 19:3f82c1161fd2 2197 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2198
WiredHome 125:7a0b70f56550 2199
WiredHome 25:9556a3a9b7cc 2200 /// Draw a filled Ellipse using the specified color
WiredHome 25:9556a3a9b7cc 2201 ///
WiredHome 25:9556a3a9b7cc 2202 /// @note As a side effect, this changes the current
WiredHome 25:9556a3a9b7cc 2203 /// foreground color for subsequent operations.
WiredHome 25:9556a3a9b7cc 2204 ///
WiredHome 72:ecffe56af969 2205 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2206 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2207 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2208 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2209 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2210 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 106:c80828f5dea4 2211 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 25:9556a3a9b7cc 2212 ///
WiredHome 37:f19b7e7449dc 2213 RetCode_t fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 25:9556a3a9b7cc 2214 color_t color, fill_t fillit = FILL);
WiredHome 25:9556a3a9b7cc 2215
WiredHome 125:7a0b70f56550 2216
WiredHome 19:3f82c1161fd2 2217 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 2218 ///
WiredHome 19:3f82c1161fd2 2219 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 2220 ///
WiredHome 72:ecffe56af969 2221 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2222 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2223 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2224 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2225 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 106:c80828f5dea4 2226 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2227 ///
WiredHome 37:f19b7e7449dc 2228 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2229
WiredHome 125:7a0b70f56550 2230
WiredHome 131:5bd6ba2ee4a1 2231
WiredHome 131:5bd6ba2ee4a1 2232 /// Block Move
WiredHome 131:5bd6ba2ee4a1 2233 ///
WiredHome 131:5bd6ba2ee4a1 2234 /// The Block Move API activates the RA8875 Block Transfer Engine. Due to the complex
WiredHome 131:5bd6ba2ee4a1 2235 /// set of possible operations, the user should read the related sections of the
WiredHome 131:5bd6ba2ee4a1 2236 /// RA8875 user manual.
WiredHome 131:5bd6ba2ee4a1 2237 ///
WiredHome 131:5bd6ba2ee4a1 2238 /// Some operations may require that other registers are configured, such as the
WiredHome 131:5bd6ba2ee4a1 2239 /// foreground and background color registers, and others. Those must be set
WiredHome 131:5bd6ba2ee4a1 2240 /// outside of this API.
WiredHome 131:5bd6ba2ee4a1 2241 ///
WiredHome 131:5bd6ba2ee4a1 2242 /// @param[in] dstLayer layer [5B.7]. layer value is 0 or 1 repreenting layer 1 and 2.
WiredHome 131:5bd6ba2ee4a1 2243 /// @param[in] dstDataSelect [50.5] defines the destination data type 0: block, 1: linear.
WiredHome 131:5bd6ba2ee4a1 2244 /// @param[in] dstPoint [58-5B] is a point_t defining the destination coordinate.
WiredHome 131:5bd6ba2ee4a1 2245 /// @param[in] srcLayer layer [57.7]. layer value is 0 or 1 repreenting layer 1 and 2.
WiredHome 131:5bd6ba2ee4a1 2246 /// @param[in] srcDataSelect [50.6] defines the source data type 0: block, 1: linear.
WiredHome 131:5bd6ba2ee4a1 2247 /// @param[in] srcPoint [54-57] is a point_t defining the source coordinate.
WiredHome 131:5bd6ba2ee4a1 2248 /// @param[in] bte_width [5C-5D]. operation width.
WiredHome 131:5bd6ba2ee4a1 2249 /// @param[in] bte_height [5E-5F]. operation height.
WiredHome 131:5bd6ba2ee4a1 2250 /// @param[in] bte_op_code [51.3-0] defines the raster operation function
WiredHome 131:5bd6ba2ee4a1 2251 /// (write/read/move/...)
WiredHome 131:5bd6ba2ee4a1 2252 /// @param[in] bte_rop_code [51.7-4] defines what type of BTE operation to perform
WiredHome 131:5bd6ba2ee4a1 2253 /// (what is placed at the destination)
WiredHome 131:5bd6ba2ee4a1 2254 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 131:5bd6ba2ee4a1 2255 ///
WiredHome 131:5bd6ba2ee4a1 2256 RetCode_t BlockMove(uint8_t dstLayer, uint8_t dstDataSelect, point_t dstPoint,
WiredHome 131:5bd6ba2ee4a1 2257 uint8_t srcLayer, uint8_t srcDataSelect, point_t srcPoint,
WiredHome 131:5bd6ba2ee4a1 2258 uint16_t bte_width, uint16_t bte_height,
WiredHome 131:5bd6ba2ee4a1 2259 uint8_t bte_op_code, uint8_t bte_rop_code);
WiredHome 131:5bd6ba2ee4a1 2260
WiredHome 131:5bd6ba2ee4a1 2261
WiredHome 19:3f82c1161fd2 2262 /// Control display power
WiredHome 19:3f82c1161fd2 2263 ///
WiredHome 72:ecffe56af969 2264 /// @param[in] on when set to true will turn on the display, when false it is turned off.
WiredHome 106:c80828f5dea4 2265 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2266 ///
WiredHome 19:3f82c1161fd2 2267 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 2268
WiredHome 125:7a0b70f56550 2269
WiredHome 19:3f82c1161fd2 2270 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 2271 ///
WiredHome 106:c80828f5dea4 2272 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2273 ///
WiredHome 19:3f82c1161fd2 2274 RetCode_t Reset(void);
WiredHome 19:3f82c1161fd2 2275
WiredHome 125:7a0b70f56550 2276
WiredHome 19:3f82c1161fd2 2277 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 2278 ///
WiredHome 19:3f82c1161fd2 2279 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 2280 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 2281 ///
WiredHome 72:ecffe56af969 2282 /// @param[in] brightness ranges from 0 (off) to 255 (full on)
WiredHome 106:c80828f5dea4 2283 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2284 ///
WiredHome 131:5bd6ba2ee4a1 2285 RetCode_t Backlight_u8(uint8_t brightness);
WiredHome 125:7a0b70f56550 2286
WiredHome 19:3f82c1161fd2 2287
WiredHome 86:e86b355940f4 2288 /// Get backlight brightness.
WiredHome 86:e86b355940f4 2289 ///
WiredHome 86:e86b355940f4 2290 /// @returns backlight setting from 0 (off) to 255 (full on).
WiredHome 86:e86b355940f4 2291 ///
WiredHome 86:e86b355940f4 2292 uint8_t GetBacklight_u8(void);
WiredHome 86:e86b355940f4 2293
WiredHome 19:3f82c1161fd2 2294 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 2295 ///
WiredHome 19:3f82c1161fd2 2296 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 2297 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 2298 ///
WiredHome 72:ecffe56af969 2299 /// @param[in] brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 106:c80828f5dea4 2300 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2301 ///
WiredHome 19:3f82c1161fd2 2302 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 2303
WiredHome 125:7a0b70f56550 2304
WiredHome 86:e86b355940f4 2305 /// Get backlight brightness.
WiredHome 86:e86b355940f4 2306 ///
WiredHome 86:e86b355940f4 2307 /// @returns backlight setting from 0 (off) to 1.0 (full on).
WiredHome 86:e86b355940f4 2308 ///
WiredHome 86:e86b355940f4 2309 float GetBacklight(void);
WiredHome 86:e86b355940f4 2310
WiredHome 125:7a0b70f56550 2311
WiredHome 98:ecebed9b80b2 2312 /// Select a User Font for all subsequent text.
WiredHome 98:ecebed9b80b2 2313 ///
WiredHome 98:ecebed9b80b2 2314 /// @note Tool to create the fonts is accessible from its creator
WiredHome 98:ecebed9b80b2 2315 /// available at http://www.mikroe.com.
WiredHome 98:ecebed9b80b2 2316 /// For version 1.2.0.0, choose the "Export for TFT and new GLCD"
WiredHome 98:ecebed9b80b2 2317 /// format.
WiredHome 98:ecebed9b80b2 2318 ///
WiredHome 98:ecebed9b80b2 2319 /// @param[in] font is a pointer to a specially formed font resource.
WiredHome 98:ecebed9b80b2 2320 /// @returns error code.
WiredHome 98:ecebed9b80b2 2321 ///
WiredHome 98:ecebed9b80b2 2322 virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
WiredHome 98:ecebed9b80b2 2323
WiredHome 127:db7f2c704693 2324 /// Get the currently selected user font.
WiredHome 127:db7f2c704693 2325 ///
WiredHome 127:db7f2c704693 2326 /// @returns a pointer to the font, or null, if no user font is selected.
WiredHome 127:db7f2c704693 2327 ///
WiredHome 127:db7f2c704693 2328 virtual const uint8_t * GetUserFont(void) { return font; }
WiredHome 19:3f82c1161fd2 2329
WiredHome 19:3f82c1161fd2 2330 /// Get the RGB value for a DOS color.
WiredHome 19:3f82c1161fd2 2331 ///
WiredHome 125:7a0b70f56550 2332 /// @code
WiredHome 125:7a0b70f56550 2333 /// color_t color = DOSColor(12);
WiredHome 125:7a0b70f56550 2334 /// @endcode
WiredHome 125:7a0b70f56550 2335 ///
WiredHome 72:ecffe56af969 2336 /// @param[in] i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 2337 /// @returns the RGB color of the selected index, or 0
WiredHome 19:3f82c1161fd2 2338 /// if the index is out of bounds.
WiredHome 19:3f82c1161fd2 2339 ///
WiredHome 19:3f82c1161fd2 2340 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 2341
WiredHome 125:7a0b70f56550 2342
WiredHome 19:3f82c1161fd2 2343 /// Get the color name (string) for a DOS color.
WiredHome 19:3f82c1161fd2 2344 ///
WiredHome 125:7a0b70f56550 2345 /// @code
WiredHome 125:7a0b70f56550 2346 /// printf("color is %s\n", DOSColorNames(12));
WiredHome 125:7a0b70f56550 2347 /// @endcode
WiredHome 125:7a0b70f56550 2348 ///
WiredHome 72:ecffe56af969 2349 /// @param[in] i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 2350 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 2351 /// or NULL if the index is out of bounds.
WiredHome 19:3f82c1161fd2 2352 ///
WiredHome 19:3f82c1161fd2 2353 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 2354
WiredHome 125:7a0b70f56550 2355
WiredHome 55:dfbabef7003e 2356 /// Advanced method indicating the start of a graphics stream.
WiredHome 55:dfbabef7003e 2357 ///
WiredHome 55:dfbabef7003e 2358 /// This is called prior to a stream of pixel data being sent.
WiredHome 55:dfbabef7003e 2359 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 2360 /// class in order to prepare the hardware to accept the streaming
WiredHome 55:dfbabef7003e 2361 /// data.
WiredHome 55:dfbabef7003e 2362 ///
WiredHome 106:c80828f5dea4 2363 /// Following this command, a series of See @ref _putp() commands can
WiredHome 55:dfbabef7003e 2364 /// be used to send individual pixels to the screen.
WiredHome 55:dfbabef7003e 2365 ///
WiredHome 106:c80828f5dea4 2366 /// To conclude the graphics stream, See @ref _EndGraphicsStream should
WiredHome 55:dfbabef7003e 2367 /// be callled.
WiredHome 55:dfbabef7003e 2368 ///
WiredHome 55:dfbabef7003e 2369 /// @returns error code.
WiredHome 55:dfbabef7003e 2370 ///
WiredHome 55:dfbabef7003e 2371 virtual RetCode_t _StartGraphicsStream(void);
WiredHome 125:7a0b70f56550 2372
WiredHome 55:dfbabef7003e 2373
WiredHome 55:dfbabef7003e 2374 /// Advanced method to put a single color pixel to the screen.
WiredHome 55:dfbabef7003e 2375 ///
WiredHome 55:dfbabef7003e 2376 /// This method may be called as many times as necessary after
WiredHome 106:c80828f5dea4 2377 /// See @ref _StartGraphicsStream() is called, and it should be followed
WiredHome 55:dfbabef7003e 2378 /// by _EndGraphicsStream.
WiredHome 55:dfbabef7003e 2379 ///
WiredHome 125:7a0b70f56550 2380 /// @code
WiredHome 125:7a0b70f56550 2381 /// _putp(DOSColor(12));
WiredHome 125:7a0b70f56550 2382 /// @endcode
WiredHome 125:7a0b70f56550 2383 ///
WiredHome 72:ecffe56af969 2384 /// @param[in] pixel is a color value to be put on the screen.
WiredHome 55:dfbabef7003e 2385 /// @returns error code.
WiredHome 55:dfbabef7003e 2386 ///
WiredHome 55:dfbabef7003e 2387 virtual RetCode_t _putp(color_t pixel);
WiredHome 125:7a0b70f56550 2388
WiredHome 55:dfbabef7003e 2389
WiredHome 55:dfbabef7003e 2390 /// Advanced method indicating the end of a graphics stream.
WiredHome 55:dfbabef7003e 2391 ///
WiredHome 55:dfbabef7003e 2392 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 55:dfbabef7003e 2393 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 2394 /// class in order to stop the hardware from accept the streaming
WiredHome 55:dfbabef7003e 2395 /// data.
WiredHome 55:dfbabef7003e 2396 ///
WiredHome 55:dfbabef7003e 2397 /// @returns error code.
WiredHome 55:dfbabef7003e 2398 ///
WiredHome 55:dfbabef7003e 2399 virtual RetCode_t _EndGraphicsStream(void);
WiredHome 19:3f82c1161fd2 2400
WiredHome 125:7a0b70f56550 2401
WiredHome 57:bd53a9e165a1 2402 /// Set the SPI port frequency (in Hz).
WiredHome 57:bd53a9e165a1 2403 ///
WiredHome 66:468a11f05580 2404 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 66:468a11f05580 2405 /// its capabilities. The RA8875 can accept writes via SPI faster
WiredHome 66:468a11f05580 2406 /// than a read can be performed. The frequency set by this API
WiredHome 66:468a11f05580 2407 /// is for the SPI writes. It will automatically reduce the SPI
WiredHome 66:468a11f05580 2408 /// clock rate when a read is performed, and restore it for the
WiredHome 68:ab08efabfc88 2409 /// next write. Alternately, the 2nd parameters permits setting
WiredHome 68:ab08efabfc88 2410 /// the read speed rather than letting it compute it automatically.
WiredHome 57:bd53a9e165a1 2411 ///
WiredHome 66:468a11f05580 2412 /// @note The primary effect of this is to recover more CPU cycles
WiredHome 66:468a11f05580 2413 /// for your application code. Keep in mind that when more than
WiredHome 66:468a11f05580 2414 /// one command is sent to the display controller, that it
WiredHome 66:468a11f05580 2415 /// will wait for the controller to finish the prior command.
WiredHome 66:468a11f05580 2416 /// In this case, the performance is limited by the RA8875.
WiredHome 57:bd53a9e165a1 2417 ///
WiredHome 72:ecffe56af969 2418 /// @param[in] Hz is the frequency in Hz, tested range includes the
WiredHome 66:468a11f05580 2419 /// range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
WiredHome 66:468a11f05580 2420 /// outside this range will be accepted, but operation may
WiredHome 76:c981284eb513 2421 /// be unreliable. This depends partially on your hardware design
WiredHome 76:c981284eb513 2422 /// and the wires connecting the display module.
WiredHome 76:c981284eb513 2423 /// The default value is 5,000,000, which should work for most
WiredHome 76:c981284eb513 2424 /// applications as a starting point.
WiredHome 72:ecffe56af969 2425 /// @param[in] Hz2 is an optional parameter and will set the read
WiredHome 68:ab08efabfc88 2426 /// speed independently of the write speed.
WiredHome 106:c80828f5dea4 2427 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 57:bd53a9e165a1 2428 ///
WiredHome 68:ab08efabfc88 2429 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ, unsigned long Hz2 = 0);
WiredHome 125:7a0b70f56550 2430
WiredHome 125:7a0b70f56550 2431
WiredHome 72:ecffe56af969 2432 /// This method captures the specified area as a 24-bit bitmap file.
WiredHome 72:ecffe56af969 2433 ///
WiredHome 72:ecffe56af969 2434 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 2435 /// 24-bit format.
WiredHome 72:ecffe56af969 2436 ///
WiredHome 73:f22a18707b5e 2437 /// This method will interrogate the current display setting and
WiredHome 73:f22a18707b5e 2438 /// create a bitmap based on those settings. For instance, if
WiredHome 73:f22a18707b5e 2439 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 73:f22a18707b5e 2440 /// if there is some other operation in effect (transparent mode).
WiredHome 73:f22a18707b5e 2441 ///
WiredHome 72:ecffe56af969 2442 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 2443 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 2444 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 2445 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 2446 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 72:ecffe56af969 2447 /// @return success or error code.
WiredHome 72:ecffe56af969 2448 ///
WiredHome 72:ecffe56af969 2449 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP);
WiredHome 125:7a0b70f56550 2450
WiredHome 72:ecffe56af969 2451
WiredHome 96:40b74dd3695b 2452 /// This method captures the specified area as a 24-bit bitmap file
WiredHome 96:40b74dd3695b 2453 /// and delivers it to the previously attached callback.
WiredHome 96:40b74dd3695b 2454 ///
WiredHome 96:40b74dd3695b 2455 /// Even though this is a 16-bit display, the stored image is in
WiredHome 96:40b74dd3695b 2456 /// 24-bit format.
WiredHome 96:40b74dd3695b 2457 ///
WiredHome 96:40b74dd3695b 2458 /// This method will interrogate the current display setting and
WiredHome 96:40b74dd3695b 2459 /// create a bitmap based on those settings. For instance, if
WiredHome 96:40b74dd3695b 2460 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 96:40b74dd3695b 2461 /// if there is some other operation in effect (transparent mode), it
WiredHome 96:40b74dd3695b 2462 /// will return the blended image.
WiredHome 96:40b74dd3695b 2463 ///
WiredHome 96:40b74dd3695b 2464 /// @param[in] x is the left edge of the region to capture
WiredHome 96:40b74dd3695b 2465 /// @param[in] y is the top edge of the region to capture
WiredHome 96:40b74dd3695b 2466 /// @param[in] w is the width of the region to capture
WiredHome 96:40b74dd3695b 2467 /// @param[in] h is the height of the region to capture.
WiredHome 96:40b74dd3695b 2468 /// @return success or error code.
WiredHome 96:40b74dd3695b 2469 ///
WiredHome 96:40b74dd3695b 2470 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h);
WiredHome 125:7a0b70f56550 2471
WiredHome 96:40b74dd3695b 2472
WiredHome 96:40b74dd3695b 2473 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 2474 ///
WiredHome 96:40b74dd3695b 2475 /// This method attaches a simple c-compatible callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 2476 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 2477 /// BMP file to be created is passed to this callback.
WiredHome 96:40b74dd3695b 2478 ///
WiredHome 123:2f45e80fec5f 2479 /// @param callback is the optional callback function. Without a callback function
WiredHome 123:2f45e80fec5f 2480 /// it will unregister the handler.
WiredHome 96:40b74dd3695b 2481 ///
WiredHome 123:2f45e80fec5f 2482 void AttachPrintHandler(PrintCallback_T callback = NULL) { c_callback = callback; }
WiredHome 96:40b74dd3695b 2483
WiredHome 125:7a0b70f56550 2484
WiredHome 96:40b74dd3695b 2485 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 2486 ///
WiredHome 96:40b74dd3695b 2487 /// This method attaches a c++ class method as a callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 2488 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 2489 /// BMP file to be created is passed to this callback.
WiredHome 96:40b74dd3695b 2490 ///
WiredHome 96:40b74dd3695b 2491 /// @param object is the class hosting the callback function.
WiredHome 102:fc60bfa0199f 2492 /// @param method is the callback method in the object to activate.
WiredHome 96:40b74dd3695b 2493 ///
WiredHome 96:40b74dd3695b 2494 template <class T>
WiredHome 102:fc60bfa0199f 2495 void AttachPrintHandler(T *object, RetCode_t (T::*method)(void)) {
WiredHome 102:fc60bfa0199f 2496 obj_callback = (FPointerDummy *)object;
WiredHome 108:7415c405ee08 2497 method_callback = (uint32_t (FPointerDummy::*)(uint32_t, uint8_t *, uint16_t))method;
WiredHome 96:40b74dd3695b 2498 }
WiredHome 96:40b74dd3695b 2499
WiredHome 125:7a0b70f56550 2500
WiredHome 72:ecffe56af969 2501 /// This method captures the specified area as a 24-bit bitmap file,
WiredHome 72:ecffe56af969 2502 /// including the option of layer selection.
WiredHome 72:ecffe56af969 2503 ///
WiredHome 125:7a0b70f56550 2504 /// @note This method is deprecated as the alternate PrintScreen API
WiredHome 74:686faa218914 2505 /// automatically examines the display layer configuration.
WiredHome 74:686faa218914 2506 /// Therefore, calls to this API will ignore the layer parameter
WiredHome 74:686faa218914 2507 /// and automatically execute the other method.
WiredHome 74:686faa218914 2508 ///
WiredHome 72:ecffe56af969 2509 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 2510 /// 24-bit format.
WiredHome 72:ecffe56af969 2511 ///
WiredHome 72:ecffe56af969 2512 /// @param[in] layer is 0 or 1 to select the layer to extract.
WiredHome 72:ecffe56af969 2513 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 2514 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 2515 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 2516 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 2517 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 72:ecffe56af969 2518 /// @return success or error code.
WiredHome 72:ecffe56af969 2519 ///
WiredHome 72:ecffe56af969 2520 RetCode_t PrintScreen(uint16_t layer, loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP);
WiredHome 125:7a0b70f56550 2521
WiredHome 72:ecffe56af969 2522
WiredHome 123:2f45e80fec5f 2523 /// idle callback registration.
WiredHome 123:2f45e80fec5f 2524 ///
WiredHome 125:7a0b70f56550 2525 /// This method attaches a simple c-compatible callback of type IdleCallback_T.
WiredHome 123:2f45e80fec5f 2526 /// Then, at any time when the display driver is waiting, it will call the
WiredHome 123:2f45e80fec5f 2527 /// registered function. This is probably most useful if you want to service
WiredHome 123:2f45e80fec5f 2528 /// a watchdog, when you may have called an API that will "hang" waiting
WiredHome 123:2f45e80fec5f 2529 /// on the user.
WiredHome 123:2f45e80fec5f 2530 ///
WiredHome 123:2f45e80fec5f 2531 /// @param callback is the idle callback function. Without a callback function
WiredHome 123:2f45e80fec5f 2532 /// it will unregister the handler.
WiredHome 123:2f45e80fec5f 2533 ///
WiredHome 123:2f45e80fec5f 2534 void AttachIdleHandler(IdleCallback_T callback = NULL) { idle_callback = callback; }
WiredHome 57:bd53a9e165a1 2535
WiredHome 19:3f82c1161fd2 2536 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 2537 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 2538 void ClearPerformance();
WiredHome 19:3f82c1161fd2 2539
WiredHome 66:468a11f05580 2540 /// Count idle time.
WiredHome 66:468a11f05580 2541 ///
WiredHome 72:ecffe56af969 2542 /// @param[in] t is the amount of idle time to accumulate.
WiredHome 66:468a11f05580 2543 ///
WiredHome 66:468a11f05580 2544 void CountIdleTime(uint32_t t);
WiredHome 66:468a11f05580 2545
WiredHome 19:3f82c1161fd2 2546 /// Report the performance metrics for drawing functions using
WiredHome 41:2956a0a221e5 2547 /// the available serial channel.
WiredHome 41:2956a0a221e5 2548 ///
WiredHome 72:ecffe56af969 2549 /// @param[in,out] pc is the serial channel to write to.
WiredHome 41:2956a0a221e5 2550 ///
WiredHome 41:2956a0a221e5 2551 void ReportPerformance(Serial & pc);
WiredHome 19:3f82c1161fd2 2552 #endif
WiredHome 19:3f82c1161fd2 2553
hexley 54:e117ad10fba6 2554
WiredHome 19:3f82c1161fd2 2555 private:
WiredHome 124:1690a7ae871c 2556 /// Touch panel parameters - common to both resistive and capacitive
WiredHome 124:1690a7ae871c 2557
WiredHome 124:1690a7ae871c 2558 /// Data type to indicate which TP, if any, is in use.
WiredHome 124:1690a7ae871c 2559 typedef enum {
WiredHome 124:1690a7ae871c 2560 TP_NONE, ///< no touch panel in use
WiredHome 124:1690a7ae871c 2561 TP_RES, ///< resistive touch panel using RA8875
WiredHome 124:1690a7ae871c 2562 TP_CAP, ///< capacitive touch panel using FT5206
WiredHome 124:1690a7ae871c 2563 } WhichTP_T;
WiredHome 124:1690a7ae871c 2564
WiredHome 124:1690a7ae871c 2565 /// boolean flag set true when using Capacitive touch panel, and false
WiredHome 124:1690a7ae871c 2566 /// for resistive.
WiredHome 124:1690a7ae871c 2567 WhichTP_T useTouchPanel; ///< Indicates which TP is selected for use.
WiredHome 124:1690a7ae871c 2568
WiredHome 124:1690a7ae871c 2569 /// Touch State used by TouchPanelReadable. See @ref TouchCode_t.
WiredHome 124:1690a7ae871c 2570 TouchCode_t touchState;
WiredHome 124:1690a7ae871c 2571
WiredHome 124:1690a7ae871c 2572 ////////////////// Start of Capacitive Touch Panel parameters
WiredHome 124:1690a7ae871c 2573
WiredHome 124:1690a7ae871c 2574 uint8_t getTouchPositions(void);
WiredHome 124:1690a7ae871c 2575 void TouchPanelISR(void);
WiredHome 124:1690a7ae871c 2576 uint16_t numberOfTouchPoints;
WiredHome 124:1690a7ae871c 2577 uint8_t gesture; ///< Holds the reported gesture information.
WiredHome 124:1690a7ae871c 2578
WiredHome 124:1690a7ae871c 2579 /// Touch Information data structure
WiredHome 124:1690a7ae871c 2580 typedef struct {
WiredHome 124:1690a7ae871c 2581 uint8_t touchID; ///< Contains the touch ID, which is the "order" of touch, from 0 to n-1
WiredHome 124:1690a7ae871c 2582 TouchCode_t touchCode; ///< Contains the touch code; no_touch, touch, held, release
WiredHome 124:1690a7ae871c 2583 point_t coordinates; ///< Contains the X,Y coordinate of the touch
WiredHome 124:1690a7ae871c 2584 } touchInfo_T;
WiredHome 124:1690a7ae871c 2585
WiredHome 124:1690a7ae871c 2586 touchInfo_T touchInfo[5]; /// Contains the actual touch information in an array from 0 to n-1
WiredHome 124:1690a7ae871c 2587
WiredHome 124:1690a7ae871c 2588 InterruptIn * m_irq;
WiredHome 124:1690a7ae871c 2589 I2C * m_i2c;
WiredHome 124:1690a7ae871c 2590 int m_addr;
WiredHome 124:1690a7ae871c 2591 uint8_t data[2];
WiredHome 124:1690a7ae871c 2592
WiredHome 124:1690a7ae871c 2593 bool panelTouched;
WiredHome 124:1690a7ae871c 2594 void writeRegister8(uint8_t reg, uint8_t val);
WiredHome 124:1690a7ae871c 2595 uint8_t readRegister8(uint8_t reg);
WiredHome 124:1690a7ae871c 2596
WiredHome 124:1690a7ae871c 2597
WiredHome 124:1690a7ae871c 2598 ////////////////// Start of Resistive Touch Panel parameters
WiredHome 124:1690a7ae871c 2599
WiredHome 124:1690a7ae871c 2600 /// Resistive Touch Panel register name definitions
WiredHome 77:9206c13aa527 2601 #define TPCR0 0x70
WiredHome 77:9206c13aa527 2602 #define TPCR1 0x71
WiredHome 77:9206c13aa527 2603 #define TPXH 0x72
WiredHome 77:9206c13aa527 2604 #define TPYH 0x73
WiredHome 77:9206c13aa527 2605 #define TPXYL 0x74
WiredHome 77:9206c13aa527 2606 #define INTC1 0xF0
WiredHome 77:9206c13aa527 2607 #define INTC2 0xF1
hexley 54:e117ad10fba6 2608
hexley 54:e117ad10fba6 2609 /// Specify the default settings for the Touch Panel, where different from the chip defaults
WiredHome 77:9206c13aa527 2610 #define TP_MODE_DEFAULT TP_MODE_AUTO
WiredHome 77:9206c13aa527 2611 #define TP_DEBOUNCE_DEFAULT TP_DEBOUNCE_ON
WiredHome 77:9206c13aa527 2612 #define TP_ADC_CLKDIV_DEFAULT TP_ADC_CLKDIV_8
hexley 54:e117ad10fba6 2613
WiredHome 77:9206c13aa527 2614 #define TP_ADC_SAMPLE_DEFAULT_CLKS TP_ADC_SAMPLE_8192_CLKS
hexley 54:e117ad10fba6 2615
hexley 54:e117ad10fba6 2616 /// Other Touch Panel params
WiredHome 77:9206c13aa527 2617 #define TPBUFSIZE 16 // Depth of the averaging buffers for x and y data
hexley 54:e117ad10fba6 2618
WiredHome 83:7bad0068cca0 2619 // Needs both a ticker and a timer. (could have created a timer from the ticker, but this is easier).
WiredHome 83:7bad0068cca0 2620 // on a touch, the timer is reset.
WiredHome 83:7bad0068cca0 2621 // the ticker monitors the timer to see if it has been a long time since
WiredHome 83:7bad0068cca0 2622 // a touch, and if so, it then clears the sample counter so it doesn't get partial old
WiredHome 83:7bad0068cca0 2623 // and partial new.
WiredHome 83:7bad0068cca0 2624
WiredHome 83:7bad0068cca0 2625 /// Touch Panel ticker
WiredHome 83:7bad0068cca0 2626 Ticker touchTicker;
WiredHome 83:7bad0068cca0 2627
WiredHome 83:7bad0068cca0 2628 /// Touch Panel timer
WiredHome 83:7bad0068cca0 2629 Timer touchTimer;
WiredHome 83:7bad0068cca0 2630
WiredHome 83:7bad0068cca0 2631 /// keeps track of which sample we're collecting to filter out the noise.
WiredHome 83:7bad0068cca0 2632 int touchSample;
WiredHome 83:7bad0068cca0 2633
WiredHome 83:7bad0068cca0 2634 /// Private function for touch ticker callback.
WiredHome 83:7bad0068cca0 2635 void _TouchTicker(void);
WiredHome 83:7bad0068cca0 2636
WiredHome 77:9206c13aa527 2637 /// Touch Panel calibration matrix.
WiredHome 77:9206c13aa527 2638 tpMatrix_t tpMatrix;
hexley 54:e117ad10fba6 2639
WiredHome 124:1690a7ae871c 2640 ////////////////// End of Touch Panel parameters
WiredHome 124:1690a7ae871c 2641
WiredHome 124:1690a7ae871c 2642
WiredHome 29:422616aa04bd 2643 /// Internal function to put a character using the built-in (internal) font engine
WiredHome 29:422616aa04bd 2644 ///
WiredHome 101:e0aad446094a 2645 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 2646 /// @returns the character put.
WiredHome 29:422616aa04bd 2647 ///
WiredHome 29:422616aa04bd 2648 int _internal_putc(int c);
WiredHome 29:422616aa04bd 2649
WiredHome 29:422616aa04bd 2650 /// Internal function to put a character using the external font engine
WiredHome 29:422616aa04bd 2651 ///
WiredHome 101:e0aad446094a 2652 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 2653 /// @returns the character put.
WiredHome 29:422616aa04bd 2654 ///
WiredHome 29:422616aa04bd 2655 int _external_putc(int c);
WiredHome 29:422616aa04bd 2656
WiredHome 101:e0aad446094a 2657 /// Internal function to get the actual width of a character when using the external font engine
WiredHome 101:e0aad446094a 2658 ///
WiredHome 101:e0aad446094a 2659 /// @param[in] c is the character to get the width.
WiredHome 101:e0aad446094a 2660 /// @returns the width in pixels of the character. zero if not found.
WiredHome 101:e0aad446094a 2661 ///
WiredHome 101:e0aad446094a 2662 int _external_getCharWidth(int c);
WiredHome 101:e0aad446094a 2663
WiredHome 105:4f116006ba1f 2664 /// Convert a 16-bit color value to an 8-bit value
WiredHome 105:4f116006ba1f 2665 ///
WiredHome 105:4f116006ba1f 2666 /// @param[in] c16 is the 16-bit color value to convert.
WiredHome 105:4f116006ba1f 2667 /// @returns 8-bit color value.
WiredHome 105:4f116006ba1f 2668 ///
WiredHome 105:4f116006ba1f 2669 uint8_t _cvt16to8(color_t c16);
WiredHome 105:4f116006ba1f 2670
WiredHome 105:4f116006ba1f 2671 /// Convert an 8-bit color value to a 16-bit value
WiredHome 105:4f116006ba1f 2672 ///
WiredHome 105:4f116006ba1f 2673 /// @param[in] c8 is the 8-bit color value to convert.
WiredHome 105:4f116006ba1f 2674 /// @returns 16-bit color value.
WiredHome 105:4f116006ba1f 2675 ///
WiredHome 105:4f116006ba1f 2676 color_t _cvt8to16(uint8_t c8);
WiredHome 105:4f116006ba1f 2677
WiredHome 19:3f82c1161fd2 2678 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 2679 ///
WiredHome 72:ecffe56af969 2680 /// @param[in] chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 2681 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 2682 /// the pin selection is the invert of this.
WiredHome 106:c80828f5dea4 2683 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2684 ///
WiredHome 79:544eb4964795 2685 RetCode_t _select(bool chipsel);
WiredHome 19:3f82c1161fd2 2686
WiredHome 66:468a11f05580 2687 /// Wait while the status register indicates the controller is busy.
WiredHome 66:468a11f05580 2688 ///
WiredHome 72:ecffe56af969 2689 /// @param[in] mask is the mask of bits to monitor.
WiredHome 66:468a11f05580 2690 /// @returns true if a normal exit.
WiredHome 66:468a11f05580 2691 /// @returns false if a timeout exit.
WiredHome 66:468a11f05580 2692 ///
WiredHome 66:468a11f05580 2693 bool _WaitWhileBusy(uint8_t mask);
WiredHome 66:468a11f05580 2694
WiredHome 66:468a11f05580 2695 /// Wait while the the register anded with the mask is true.
WiredHome 66:468a11f05580 2696 ///
WiredHome 72:ecffe56af969 2697 /// @param[in] reg is the register to monitor
WiredHome 72:ecffe56af969 2698 /// @param[in] mask is the bit mask to monitor
WiredHome 66:468a11f05580 2699 /// @returns true if it was a normal exit
WiredHome 66:468a11f05580 2700 /// @returns false if it was a timeout that caused the exit.
WiredHome 66:468a11f05580 2701 ///
WiredHome 66:468a11f05580 2702 bool _WaitWhileReg(uint8_t reg, uint8_t mask);
WiredHome 66:468a11f05580 2703
WiredHome 68:ab08efabfc88 2704 /// set the spi port to either the write or the read speed.
WiredHome 68:ab08efabfc88 2705 ///
WiredHome 68:ab08efabfc88 2706 /// This is a private API used to toggle between the write
WiredHome 68:ab08efabfc88 2707 /// and the read speed for the SPI port to the RA8875, since
WiredHome 68:ab08efabfc88 2708 /// it can accept writes faster than reads.
WiredHome 68:ab08efabfc88 2709 ///
WiredHome 72:ecffe56af969 2710 /// @param[in] writeSpeed when true selects the write frequency,
WiredHome 68:ab08efabfc88 2711 /// and when false it selects the read frequency.
WiredHome 68:ab08efabfc88 2712 ///
WiredHome 68:ab08efabfc88 2713 void _setWriteSpeed(bool writeSpeed);
WiredHome 68:ab08efabfc88 2714
WiredHome 19:3f82c1161fd2 2715 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 2716 ///
WiredHome 72:ecffe56af969 2717 /// @param[in] data is the value to write.
WiredHome 19:3f82c1161fd2 2718 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 2719 /// in while shifting out.
WiredHome 19:3f82c1161fd2 2720 ///
WiredHome 79:544eb4964795 2721 unsigned char _spiwrite(unsigned char data);
WiredHome 19:3f82c1161fd2 2722
WiredHome 19:3f82c1161fd2 2723 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 2724 ///
WiredHome 19:3f82c1161fd2 2725 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 2726 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 2727 ///
WiredHome 19:3f82c1161fd2 2728 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 2729 /// in while shifting out.
WiredHome 19:3f82c1161fd2 2730 ///
WiredHome 79:544eb4964795 2731 unsigned char _spiread();
WiredHome 19:3f82c1161fd2 2732
WiredHome 75:ca78388cfd77 2733 const uint8_t * pKeyMap;
WiredHome 75:ca78388cfd77 2734
WiredHome 19:3f82c1161fd2 2735 SPI spi; ///< spi port
WiredHome 68:ab08efabfc88 2736 bool spiWriteSpeed; ///< indicates if the current mode is write or read
WiredHome 68:ab08efabfc88 2737 unsigned long spiwritefreq; ///< saved write freq
WiredHome 66:468a11f05580 2738 unsigned long spireadfreq; ///< saved read freq
WiredHome 19:3f82c1161fd2 2739 DigitalOut cs; ///< chip select pin, assumed active low
WiredHome 19:3f82c1161fd2 2740 DigitalOut res; ///< reset pin, assumed active low
WiredHome 90:d113d71ae4f0 2741
WiredHome 105:4f116006ba1f 2742 // display metrics to avoid lengthy spi read queries
WiredHome 105:4f116006ba1f 2743 uint8_t screenbpp; ///< configured bits per pixel
WiredHome 90:d113d71ae4f0 2744 dim_t screenwidth; ///< configured screen width
WiredHome 90:d113d71ae4f0 2745 dim_t screenheight; ///< configured screen height
WiredHome 111:efe436c43aba 2746 rect_t windowrect; ///< window commands are held here for speed of access
WiredHome 90:d113d71ae4f0 2747 bool portraitmode; ///< set true when in portrait mode (w,h are reversed)
WiredHome 90:d113d71ae4f0 2748
WiredHome 19:3f82c1161fd2 2749 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 98:ecebed9b80b2 2750 uint8_t extFontHeight; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 2751 uint8_t extFontWidth; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 2752
WiredHome 90:d113d71ae4f0 2753 loc_t cursor_x, cursor_y; ///< used for external fonts only
WiredHome 19:3f82c1161fd2 2754
WiredHome 19:3f82c1161fd2 2755 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 2756 typedef enum
WiredHome 19:3f82c1161fd2 2757 {
WiredHome 19:3f82c1161fd2 2758 PRF_CLS,
WiredHome 41:2956a0a221e5 2759 PRF_DRAWPIXEL,
WiredHome 41:2956a0a221e5 2760 PRF_PIXELSTREAM,
WiredHome 109:7b94f06f085b 2761 PRF_BOOLSTREAM,
WiredHome 41:2956a0a221e5 2762 PRF_READPIXEL,
WiredHome 41:2956a0a221e5 2763 PRF_READPIXELSTREAM,
WiredHome 19:3f82c1161fd2 2764 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 2765 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 2766 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 2767 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 2768 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 2769 PRF_DRAWELLIPSE,
WiredHome 131:5bd6ba2ee4a1 2770 PRF_BLOCKMOVE,
WiredHome 19:3f82c1161fd2 2771 METRICCOUNT
WiredHome 19:3f82c1161fd2 2772 } method_e;
WiredHome 19:3f82c1161fd2 2773 unsigned long metrics[METRICCOUNT];
WiredHome 75:ca78388cfd77 2774 unsigned long idletime_usec;
WiredHome 19:3f82c1161fd2 2775 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 2776 Timer performance;
WiredHome 19:3f82c1161fd2 2777 #endif
WiredHome 96:40b74dd3695b 2778
WiredHome 96:40b74dd3695b 2779 RetCode_t _printCallback(RA8875::filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 2780
WiredHome 96:40b74dd3695b 2781 FILE * _printFH; ///< PrintScreen file handle
WiredHome 96:40b74dd3695b 2782
WiredHome 96:40b74dd3695b 2783 RetCode_t privateCallback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 2784 if (c_callback != NULL) {
WiredHome 96:40b74dd3695b 2785 return (*c_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 2786 }
WiredHome 96:40b74dd3695b 2787 else {
WiredHome 96:40b74dd3695b 2788 if (obj_callback != NULL && method_callback != NULL) {
WiredHome 96:40b74dd3695b 2789 return (obj_callback->*method_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 2790 }
WiredHome 96:40b74dd3695b 2791 }
WiredHome 96:40b74dd3695b 2792 return noerror;
WiredHome 96:40b74dd3695b 2793 }
WiredHome 96:40b74dd3695b 2794
WiredHome 96:40b74dd3695b 2795 RetCode_t (* c_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 2796 FPointerDummy *obj_callback;
WiredHome 96:40b74dd3695b 2797 RetCode_t (FPointerDummy::*method_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 123:2f45e80fec5f 2798 RetCode_t (* idle_callback)(IdleReason_T reason);
WiredHome 19:3f82c1161fd2 2799 };
WiredHome 19:3f82c1161fd2 2800
WiredHome 96:40b74dd3695b 2801
WiredHome 19:3f82c1161fd2 2802 //} // namespace
WiredHome 19:3f82c1161fd2 2803
WiredHome 19:3f82c1161fd2 2804 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 2805
WiredHome 23:a50ded45dbaf 2806
WiredHome 23:a50ded45dbaf 2807 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 2808 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 2809 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 2810 // / / / / / / / /
WiredHome 23:a50ded45dbaf 2811 // / / / /___ / /__________ / /
WiredHome 23:a50ded45dbaf 2812 // / / / ____/ /__________ / / /
WiredHome 23:a50ded45dbaf 2813 // / / / / / / / /
WiredHome 23:a50ded45dbaf 2814 // / / / /__________ ___________/ / / /
WiredHome 23:a50ded45dbaf 2815 // /__/ /_____________/ /_____________/ /__/
WiredHome 23:a50ded45dbaf 2816
WiredHome 23:a50ded45dbaf 2817 #include "WebColors.h"
WiredHome 23:a50ded45dbaf 2818 #include <algorithm>
WiredHome 23:a50ded45dbaf 2819
WiredHome 23:a50ded45dbaf 2820 extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 2821
WiredHome 23:a50ded45dbaf 2822 /// This activates a small set of tests for the graphics library.
WiredHome 23:a50ded45dbaf 2823 ///
WiredHome 23:a50ded45dbaf 2824 /// Call this API and pass it the reference to the display class.
WiredHome 23:a50ded45dbaf 2825 /// It will then run a series of tests. It accepts interaction via
WiredHome 23:a50ded45dbaf 2826 /// stdin to switch from automatic test mode to manual, run a specific
WiredHome 23:a50ded45dbaf 2827 /// test, or to exit the test mode.
WiredHome 23:a50ded45dbaf 2828 ///
WiredHome 72:ecffe56af969 2829 /// @param[in] lcd is a reference to the display class.
WiredHome 72:ecffe56af969 2830 /// @param[in] pc is a reference to a serial interface, typically the USB to PC.
WiredHome 23:a50ded45dbaf 2831 ///
WiredHome 23:a50ded45dbaf 2832 void RunTestSet(RA8875 & lcd, Serial & pc);
WiredHome 23:a50ded45dbaf 2833
WiredHome 23:a50ded45dbaf 2834
WiredHome 23:a50ded45dbaf 2835 // To enable the test code, uncomment this section, or copy the
WiredHome 23:a50ded45dbaf 2836 // necessary pieces to your "main()".
WiredHome 23:a50ded45dbaf 2837 //
WiredHome 23:a50ded45dbaf 2838 // #include "mbed.h"
WiredHome 23:a50ded45dbaf 2839 // #include "RA8875.h"
WiredHome 23:a50ded45dbaf 2840 // RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 23:a50ded45dbaf 2841 // Serial pc(USBTX, USBRX);
WiredHome 23:a50ded45dbaf 2842 // extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 2843 // int main()
WiredHome 23:a50ded45dbaf 2844 // {
WiredHome 23:a50ded45dbaf 2845 // pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 23:a50ded45dbaf 2846 // pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 23:a50ded45dbaf 2847 //
WiredHome 23:a50ded45dbaf 2848 // pc.printf("Turning on display\r\n");
WiredHome 101:e0aad446094a 2849 // lcd.init();
WiredHome 23:a50ded45dbaf 2850 // lcd.Reset();
WiredHome 23:a50ded45dbaf 2851 // lcd.Power(true); // display power is on, but the backlight is independent
WiredHome 23:a50ded45dbaf 2852 // lcd.Backlight(0.5);
WiredHome 23:a50ded45dbaf 2853 // RunTestSet(lcd, pc);
WiredHome 23:a50ded45dbaf 2854 // }
WiredHome 23:a50ded45dbaf 2855
WiredHome 23:a50ded45dbaf 2856 #endif // TESTENABLE
WiredHome 23:a50ded45dbaf 2857
WiredHome 56:7a85d226ad0d 2858 #endif