KSM edits to RA8875

Dependents:   Liz_Test_Code

Committer:
WiredHome
Date:
Sun Feb 24 00:40:00 2019 +0000
Revision:
165:695c24cc5197
Parent:
164:76edd7d9cb68
Child:
166:53fd4a876dac
Initial refactoring to add support for another Cap Sense touch controller - based on the GSL1680.

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