Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Mon Mar 14 02:20:40 2016 +0000
Revision:
108:7415c405ee08
Parent:
107:f9ccffcb84f1
Child:
110:39f22e0c8de4
corrected a buffer overrun in the InsertionSort function of RA8875_Touch.cpp. Thanks to Michael Dinning for reporting it.

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