Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Committer:
WiredHome
Date:
Sun May 15 18:57:06 2016 +0000
Revision:
114:dbfb996bfbf3
Parent:
111:efe436c43aba
Child:
123:2f45e80fec5f
Minor doc changes, and enable the GraphicsDisplay::window( ) to have no parameters to reset the screen size to full.

Who changed what in which revision?

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