KSM edits to RA8875

Dependents:   Liz_Test_Code

Committer:
WiredHome
Date:
Sun Feb 07 23:18:01 2016 +0000
Revision:
103:7e0464ca6c5c
Parent:
102:fc60bfa0199f
Child:
105:4f116006ba1f
Added missing APIs for Get/SetTextCursor using point_t.; Fixed a defect in touch; if no point was requested, just polling for touch-state, it would return the no calibration value during a touch.

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