LCD LIB

Dependents:   HagridOS5

Fork of RA8875 by David Smart

Committer:
WiredHome
Date:
Sat Jan 23 16:58:54 2016 +0000
Revision:
102:fc60bfa0199f
Parent:
101:e0aad446094a
Child:
103:7e0464ca6c5c
Small change to the color and the on-screen sample.

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 85:022bba13c5c4 582 /// @param[out] TouchPoint is 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 37:f19b7e7449dc 987 /// Get the current cursor position in pixels.
WiredHome 37:f19b7e7449dc 988 ///
WiredHome 56:7a85d226ad0d 989 /// @code
WiredHome 56:7a85d226ad0d 990 /// point_t point = GetTextCursor();
WiredHome 56:7a85d226ad0d 991 /// if (point.x > 100 && point.y > 150)
WiredHome 56:7a85d226ad0d 992 /// //...
WiredHome 56:7a85d226ad0d 993 /// @endcode
WiredHome 56:7a85d226ad0d 994 ///
WiredHome 37:f19b7e7449dc 995 /// @returns cursor position.
WiredHome 37:f19b7e7449dc 996 ///
WiredHome 37:f19b7e7449dc 997 point_t GetTextCursor(void);
WiredHome 37:f19b7e7449dc 998
WiredHome 29:422616aa04bd 999 /// Get the current cursor horizontal position in pixels.
WiredHome 29:422616aa04bd 1000 ///
WiredHome 29:422616aa04bd 1001 /// @returns cursor position horizontal offset.
WiredHome 29:422616aa04bd 1002 ///
WiredHome 37:f19b7e7449dc 1003 loc_t GetTextCursor_X(void);
WiredHome 29:422616aa04bd 1004
WiredHome 29:422616aa04bd 1005 /// Get the current cursor vertical position in pixels.
WiredHome 29:422616aa04bd 1006 ///
WiredHome 29:422616aa04bd 1007 /// @returns cursor position vertical offset.
WiredHome 29:422616aa04bd 1008 ///
WiredHome 37:f19b7e7449dc 1009 loc_t GetTextCursor_Y(void);
WiredHome 29:422616aa04bd 1010
WiredHome 23:a50ded45dbaf 1011 /// Configure additional Cursor Control settings.
WiredHome 23:a50ded45dbaf 1012 ///
WiredHome 23:a50ded45dbaf 1013 /// This API lets you modify other cursor control settings;
WiredHome 23:a50ded45dbaf 1014 /// Cursor visible/hidden, Cursor blink/normal,
WiredHome 23:a50ded45dbaf 1015 /// Cursor I-Beam/underscore/box.
WiredHome 23:a50ded45dbaf 1016 ///
WiredHome 72:ecffe56af969 1017 /// @param[in] cursor can be set to NOCURSOR (default), IBEAM,
WiredHome 24:8ca861acf12d 1018 /// UNDER, or BLOCK.
WiredHome 72:ecffe56af969 1019 /// @param[in] blink can be set to true or false (default false)
WiredHome 23:a50ded45dbaf 1020 /// @returns success/failure code. @see RetCode_t
WiredHome 23:a50ded45dbaf 1021 ///
WiredHome 24:8ca861acf12d 1022 RetCode_t SetTextCursorControl(cursor_t cursor = NOCURSOR, bool blink = false);
WiredHome 23:a50ded45dbaf 1023
WiredHome 98:ecebed9b80b2 1024 /// Select the built-in ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 1025 ///
WiredHome 19:3f82c1161fd2 1026 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 1027 ///
WiredHome 98:ecebed9b80b2 1028 /// @caution This only modifies the choice of font from the RA8875 internal
WiredHome 98:ecebed9b80b2 1029 /// fonts.
WiredHome 98:ecebed9b80b2 1030 ///
WiredHome 72:ecffe56af969 1031 /// @param[in] font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 1032 ///
WiredHome 19:3f82c1161fd2 1033 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1034 /// the command is not executed.
WiredHome 19:3f82c1161fd2 1035 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1036 ///
WiredHome 19:3f82c1161fd2 1037 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 19:3f82c1161fd2 1038
WiredHome 84:e102021864b5 1039 /// Sets the display orientation.
WiredHome 84:e102021864b5 1040 ///
WiredHome 84:e102021864b5 1041 /// @note This command does not let you "merge" text onto an existing
WiredHome 84:e102021864b5 1042 /// image, since it reuses the memory for the new orientation.
WiredHome 84:e102021864b5 1043 /// Therefore, it is recommended that you issue a cls() prior
WiredHome 84:e102021864b5 1044 /// to sending text to the screen, or you end with a blended
WiredHome 84:e102021864b5 1045 /// image that is probably not as intended.
WiredHome 84:e102021864b5 1046 ///
WiredHome 98:ecebed9b80b2 1047 /// @caution This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1048 ///
WiredHome 84:e102021864b5 1049 /// @code
WiredHome 84:e102021864b5 1050 /// lcd.cls();
WiredHome 84:e102021864b5 1051 /// lcd.SetOrientation(RA8875::normal);
WiredHome 84:e102021864b5 1052 /// lcd.puts(30,30, "Normal Landscape");
WiredHome 84:e102021864b5 1053 /// wait_ms(2500);
WiredHome 84:e102021864b5 1054 ///
WiredHome 84:e102021864b5 1055 /// lcd.cls();
WiredHome 84:e102021864b5 1056 /// lcd.SetOrientation(RA8875::rotate_90);
WiredHome 84:e102021864b5 1057 /// lcd.puts(30,30, "Rotated 90 Text\r\n");
WiredHome 84:e102021864b5 1058 /// wait_ms(2500);
WiredHome 84:e102021864b5 1059 ///
WiredHome 84:e102021864b5 1060 /// lcd.cls();
WiredHome 84:e102021864b5 1061 /// lcd.SetOrientation(RA8875::rotate_180);
WiredHome 84:e102021864b5 1062 /// lcd.puts(30,30, "Rotated 180 Text\r\n");
WiredHome 84:e102021864b5 1063 /// wait_ms(2500);
WiredHome 84:e102021864b5 1064 ///
WiredHome 84:e102021864b5 1065 /// lcd.cls();
WiredHome 84:e102021864b5 1066 /// lcd.SetOrientation(RA8875::rotate_270);
WiredHome 84:e102021864b5 1067 /// lcd.puts(30,30, "Rotated 270 Text\r\n");
WiredHome 84:e102021864b5 1068 /// wait_ms(2500);
WiredHome 84:e102021864b5 1069 /// @endcode
WiredHome 84:e102021864b5 1070 ///
WiredHome 84:e102021864b5 1071 /// @param[in] angle defaults to normal, but can be rotated
WiredHome 84:e102021864b5 1072 /// - normal | rotate_0
WiredHome 84:e102021864b5 1073 /// - rotate_90 (clockwise)
WiredHome 84:e102021864b5 1074 /// - rotate_180
WiredHome 84:e102021864b5 1075 /// - rotate_270 (clockwise)
WiredHome 84:e102021864b5 1076 /// @returns success/failure code. @see RetCode_t.
WiredHome 84:e102021864b5 1077 ///
WiredHome 84:e102021864b5 1078 RetCode_t SetOrientation(orientation_t angle = normal);
WiredHome 84:e102021864b5 1079
WiredHome 19:3f82c1161fd2 1080 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 1081 ///
WiredHome 19:3f82c1161fd2 1082 /// This command lets you make several modifications to any text that
WiredHome 56:7a85d226ad0d 1083 /// will be written to the screen.
WiredHome 19:3f82c1161fd2 1084 ///
WiredHome 98:ecebed9b80b2 1085 /// @caution This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1086 ///
WiredHome 19:3f82c1161fd2 1087 /// Options can be combined:
WiredHome 19:3f82c1161fd2 1088 /// Default:
WiredHome 19:3f82c1161fd2 1089 /// @li Full alignment disabled,
WiredHome 19:3f82c1161fd2 1090 /// @li Font with Background color,
WiredHome 84:e102021864b5 1091 /// @li Font in normal orientiation, or rotated 90, 180, or 270 clockwise,
WiredHome 84:e102021864b5 1092 /// @li Horizontal scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1093 /// @li Vertical scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1094 ///
WiredHome 84:e102021864b5 1095 /// @note alignment is a special mode for the fonts, when mixing half and
WiredHome 84:e102021864b5 1096 /// full fonts on one presentation. 'align_full' starts each full
WiredHome 84:e102021864b5 1097 /// character on an even alignment. See section 7-4-7 of the RA8875
WiredHome 84:e102021864b5 1098 /// specification.
WiredHome 19:3f82c1161fd2 1099 ///
WiredHome 72:ecffe56af969 1100 /// @param[in] fillit defaults to FILL, but can be NOFILL
WiredHome 72:ecffe56af969 1101 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1102 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1103 /// @param[in] vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1104 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1105 /// @param[in] alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 1106 /// align_full.
WiredHome 19:3f82c1161fd2 1107 ///
WiredHome 19:3f82c1161fd2 1108 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1109 /// the command is not executed.
WiredHome 19:3f82c1161fd2 1110 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1111 ///
WiredHome 19:3f82c1161fd2 1112 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 19:3f82c1161fd2 1113 HorizontalScale hScale = 1,
WiredHome 19:3f82c1161fd2 1114 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 1115 alignment_t alignment = align_none);
WiredHome 19:3f82c1161fd2 1116
WiredHome 98:ecebed9b80b2 1117 /// Control the font size of the RA8875 internal fonts.
WiredHome 19:3f82c1161fd2 1118 ///
WiredHome 19:3f82c1161fd2 1119 /// This command lets you set the font enlargement for both horizontal
WiredHome 19:3f82c1161fd2 1120 /// and vertical, independent of the rotation, background, and
WiredHome 19:3f82c1161fd2 1121 /// alignment. @see SetTextFontControl.
WiredHome 19:3f82c1161fd2 1122 ///
WiredHome 98:ecebed9b80b2 1123 /// @caution This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1124 ///
WiredHome 72:ecffe56af969 1125 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1126 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1127 /// @param[in] vScale is an optional parameter that defaults to the hScale value,
WiredHome 40:04aa280dfa39 1128 /// but can be 1, 2, 3, or 4, and scales the font size by this amount.
WiredHome 40:04aa280dfa39 1129 ///
WiredHome 40:04aa280dfa39 1130 /// @code
WiredHome 40:04aa280dfa39 1131 /// lcd.SetTextFontSize(2); // Set the font to 2x normal size
WiredHome 56:7a85d226ad0d 1132 /// lcd.puts("Two times");
WiredHome 40:04aa280dfa39 1133 /// lcd.SetTextFontSize(2,3); // Set the font to 2x Width and 3x Height
WiredHome 56:7a85d226ad0d 1134 /// lcd.puts("2*2 3*h");
WiredHome 40:04aa280dfa39 1135 /// lcd.SetTextFontSize(); // Restore to normal size in both dimensions
WiredHome 56:7a85d226ad0d 1136 /// lcd.puts("normal");
WiredHome 40:04aa280dfa39 1137 /// @endcode
WiredHome 19:3f82c1161fd2 1138 ///
WiredHome 19:3f82c1161fd2 1139 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1140 /// the command is not executed.
WiredHome 19:3f82c1161fd2 1141 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1142 ///
WiredHome 40:04aa280dfa39 1143 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
WiredHome 19:3f82c1161fd2 1144
WiredHome 19:3f82c1161fd2 1145 /// put a character on the screen.
WiredHome 19:3f82c1161fd2 1146 ///
WiredHome 72:ecffe56af969 1147 /// @param[in] c is the character.
WiredHome 19:3f82c1161fd2 1148 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 1149 ///
WiredHome 19:3f82c1161fd2 1150 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 1151
WiredHome 19:3f82c1161fd2 1152 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 1153 ///
WiredHome 56:7a85d226ad0d 1154 /// @code
WiredHome 56:7a85d226ad0d 1155 /// lcd.puts("Test STring");
WiredHome 56:7a85d226ad0d 1156 /// @endcode
WiredHome 56:7a85d226ad0d 1157 ///
WiredHome 72:ecffe56af969 1158 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 1159 ///
WiredHome 19:3f82c1161fd2 1160 void puts(const char * string);
WiredHome 19:3f82c1161fd2 1161
WiredHome 19:3f82c1161fd2 1162 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 1163 ///
WiredHome 56:7a85d226ad0d 1164 /// @code
WiredHome 56:7a85d226ad0d 1165 /// lcd.puts(10,25, "Test STring");
WiredHome 56:7a85d226ad0d 1166 /// @endcode
WiredHome 56:7a85d226ad0d 1167 ///
WiredHome 72:ecffe56af969 1168 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1169 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 72:ecffe56af969 1170 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 1171 ///
WiredHome 37:f19b7e7449dc 1172 void puts(loc_t x, loc_t y, const char * string);
WiredHome 19:3f82c1161fd2 1173
WiredHome 19:3f82c1161fd2 1174 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 1175 /// the memory cursor.
WiredHome 19:3f82c1161fd2 1176 ///
WiredHome 72:ecffe56af969 1177 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1178 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 1179 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1180 ///
WiredHome 37:f19b7e7449dc 1181 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 1182
WiredHome 41:2956a0a221e5 1183 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 1184 /// the memory read cursor.
WiredHome 41:2956a0a221e5 1185 ///
WiredHome 72:ecffe56af969 1186 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1187 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 41:2956a0a221e5 1188 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 1189 ///
WiredHome 41:2956a0a221e5 1190 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1191
WiredHome 19:3f82c1161fd2 1192 /// Set the window, which controls where items are written to the screen.
WiredHome 19:3f82c1161fd2 1193 ///
WiredHome 19:3f82c1161fd2 1194 /// When something hits the window width, it wraps back to the left side
WiredHome 19:3f82c1161fd2 1195 /// and down a row. If the initial write is outside the window, it will
WiredHome 19:3f82c1161fd2 1196 /// be captured into the window when it crosses a boundary.
WiredHome 19:3f82c1161fd2 1197 ///
WiredHome 56:7a85d226ad0d 1198 /// @code
WiredHome 56:7a85d226ad0d 1199 /// lcd.window(10,10, 80,80);
WiredHome 56:7a85d226ad0d 1200 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 56:7a85d226ad0d 1201 /// @endcode
WiredHome 56:7a85d226ad0d 1202 ///
WiredHome 72:ecffe56af969 1203 /// @param[in] x is the left edge in pixels.
WiredHome 72:ecffe56af969 1204 /// @param[in] y is the top edge in pixels.
WiredHome 72:ecffe56af969 1205 /// @param[in] width is the window width in pixels.
WiredHome 72:ecffe56af969 1206 /// @param[in] height is the window height in pixels.
WiredHome 19:3f82c1161fd2 1207 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1208 ///
WiredHome 37:f19b7e7449dc 1209 virtual RetCode_t window(loc_t x, loc_t y, dim_t width, dim_t height);
WiredHome 19:3f82c1161fd2 1210
WiredHome 61:8f3153bf0baa 1211 /// Clear either the specified layer, or the active layer.
WiredHome 19:3f82c1161fd2 1212 ///
WiredHome 61:8f3153bf0baa 1213 /// The behavior is to clear the whole screen for the specified
WiredHome 61:8f3153bf0baa 1214 /// layer. When not specified, the active drawing layer is cleared.
WiredHome 61:8f3153bf0baa 1215 /// This command can also be used to specifically clear either,
WiredHome 61:8f3153bf0baa 1216 /// or both layers. @see clsw().
WiredHome 19:3f82c1161fd2 1217 ///
WiredHome 56:7a85d226ad0d 1218 /// @code
WiredHome 56:7a85d226ad0d 1219 /// lcd.cls();
WiredHome 56:7a85d226ad0d 1220 /// @endcode
WiredHome 56:7a85d226ad0d 1221 ///
WiredHome 72:ecffe56af969 1222 /// @param[in] layers is optional. If not provided, the active layer
WiredHome 61:8f3153bf0baa 1223 /// is cleared. If bit 0 is set, layer 0 is cleared, if bit
WiredHome 61:8f3153bf0baa 1224 /// 1 is set, layer 1 is cleared. If both are set, both layers
WiredHome 61:8f3153bf0baa 1225 /// are cleared. Any other value does not cause an action.
WiredHome 61:8f3153bf0baa 1226 ///
WiredHome 19:3f82c1161fd2 1227 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1228 ///
WiredHome 61:8f3153bf0baa 1229 virtual RetCode_t cls(uint16_t layers = 0);
WiredHome 19:3f82c1161fd2 1230
WiredHome 19:3f82c1161fd2 1231 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 1232 ///
WiredHome 19:3f82c1161fd2 1233 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 1234 /// parameter, the action can be restricted to the active window, which
WiredHome 32:0e4f2ae512e2 1235 /// can be set with the @see window method.
WiredHome 19:3f82c1161fd2 1236 ///
WiredHome 56:7a85d226ad0d 1237 /// @code
WiredHome 56:7a85d226ad0d 1238 /// lcd.window(20,20, 40,10);
WiredHome 56:7a85d226ad0d 1239 /// lcd.clsw();
WiredHome 56:7a85d226ad0d 1240 /// @endcode
WiredHome 56:7a85d226ad0d 1241 ///
WiredHome 72:ecffe56af969 1242 /// @param[in] region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 1243 /// or may be set to ACTIVEWINDOW.
WiredHome 19:3f82c1161fd2 1244 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1245 ///
WiredHome 19:3f82c1161fd2 1246 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 1247
WiredHome 19:3f82c1161fd2 1248 /// Set the background color.
WiredHome 19:3f82c1161fd2 1249 ///
WiredHome 72:ecffe56af969 1250 /// @param[in] color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 1251 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1252 ///
WiredHome 19:3f82c1161fd2 1253 virtual RetCode_t background(color_t color);
WiredHome 19:3f82c1161fd2 1254
WiredHome 19:3f82c1161fd2 1255 /// Set the background color.
WiredHome 19:3f82c1161fd2 1256 ///
WiredHome 72:ecffe56af969 1257 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 1258 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 1259 /// @param[in] b is the blue element of the color.
WiredHome 19:3f82c1161fd2 1260 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1261 ///
WiredHome 19:3f82c1161fd2 1262 virtual RetCode_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 1263
WiredHome 19:3f82c1161fd2 1264 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 1265 ///
WiredHome 72:ecffe56af969 1266 /// @param[in] color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 1267 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1268 ///
WiredHome 19:3f82c1161fd2 1269 virtual RetCode_t foreground(color_t color);
WiredHome 19:3f82c1161fd2 1270
WiredHome 19:3f82c1161fd2 1271 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 1272 ///
WiredHome 72:ecffe56af969 1273 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 1274 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 1275 /// @param[in] b is the blue element of the color.
WiredHome 19:3f82c1161fd2 1276 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1277 ///
WiredHome 37:f19b7e7449dc 1278 virtual RetCode_t foreground(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 1279
WiredHome 19:3f82c1161fd2 1280 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 1281 ///
WiredHome 19:3f82c1161fd2 1282 /// @returns the current foreground color.
WiredHome 19:3f82c1161fd2 1283 ///
WiredHome 37:f19b7e7449dc 1284 color_t GetForeColor(void);
WiredHome 87:ee2240581aa7 1285
WiredHome 87:ee2240581aa7 1286 /// Draw a pixel in the specified color.
WiredHome 87:ee2240581aa7 1287 ///
WiredHome 87:ee2240581aa7 1288 /// @note Unlike many other operations, this does not
WiredHome 87:ee2240581aa7 1289 /// set the forecolor!
WiredHome 87:ee2240581aa7 1290 ///
WiredHome 87:ee2240581aa7 1291 /// @param[in] p is the point_t defining the location.
WiredHome 87:ee2240581aa7 1292 /// @returns success/failure code. @see RetCode_t.
WiredHome 87:ee2240581aa7 1293 ///
WiredHome 87:ee2240581aa7 1294 virtual RetCode_t pixel(point_t p, color_t color);
WiredHome 87:ee2240581aa7 1295
WiredHome 87:ee2240581aa7 1296 /// Draw a pixel in the current foreground color.
WiredHome 87:ee2240581aa7 1297 ///
WiredHome 87:ee2240581aa7 1298 /// @param[in] p is the point_t defining the location.
WiredHome 87:ee2240581aa7 1299 /// @returns success/failure code. @see RetCode_t.
WiredHome 87:ee2240581aa7 1300 ///
WiredHome 87:ee2240581aa7 1301 virtual RetCode_t pixel(point_t p);
WiredHome 19:3f82c1161fd2 1302
WiredHome 19:3f82c1161fd2 1303 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 1304 ///
WiredHome 41:2956a0a221e5 1305 /// @note Unlike many other operations, this does not
WiredHome 41:2956a0a221e5 1306 /// set the forecolor!
WiredHome 19:3f82c1161fd2 1307 ///
WiredHome 72:ecffe56af969 1308 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1309 /// @param[in] y is the vertical offset to this pixel.
WiredHome 72:ecffe56af969 1310 /// @param[in] color defines the color for the pixel.
WiredHome 19:3f82c1161fd2 1311 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1312 ///
WiredHome 37:f19b7e7449dc 1313 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color);
WiredHome 19:3f82c1161fd2 1314
WiredHome 19:3f82c1161fd2 1315 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 1316 ///
WiredHome 72:ecffe56af969 1317 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1318 /// @param[in] y is the veritical offset to this pixel.
WiredHome 19:3f82c1161fd2 1319 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1320 ///
WiredHome 37:f19b7e7449dc 1321 virtual RetCode_t pixel(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 1322
WiredHome 41:2956a0a221e5 1323 /// Get a pixel from the display.
WiredHome 41:2956a0a221e5 1324 ///
WiredHome 72:ecffe56af969 1325 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1326 /// @param[in] y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 1327 /// @returns the pixel. see @color_t
WiredHome 41:2956a0a221e5 1328 ///
WiredHome 41:2956a0a221e5 1329 virtual color_t getPixel(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1330
WiredHome 41:2956a0a221e5 1331 /// Write a stream of pixels to the display.
WiredHome 41:2956a0a221e5 1332 ///
WiredHome 72:ecffe56af969 1333 /// @param[in] p is a pointer to a color_t array to write.
WiredHome 72:ecffe56af969 1334 /// @param[in] count is the number of pixels to write.
WiredHome 72:ecffe56af969 1335 /// @param[in] x is the horizontal position on the display.
WiredHome 72:ecffe56af969 1336 /// @param[in] y is the vertical position on the display.
WiredHome 41:2956a0a221e5 1337 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 1338 ///
WiredHome 41:2956a0a221e5 1339 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1340
WiredHome 41:2956a0a221e5 1341 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 1342 ///
WiredHome 72:ecffe56af969 1343 /// @param[in] p is a pointer to a color_t array to accept the stream.
WiredHome 72:ecffe56af969 1344 /// @param[in] count is the number of pixels to read.
WiredHome 72:ecffe56af969 1345 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1346 /// @param[in] y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 1347 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 1348 ///
WiredHome 41:2956a0a221e5 1349 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1350
WiredHome 19:3f82c1161fd2 1351 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 1352 ///
WiredHome 19:3f82c1161fd2 1353 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1354 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1355 ///
WiredHome 83:7bad0068cca0 1356 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 1357 /// @param[in] p2 is the point to end the line.
WiredHome 83:7bad0068cca0 1358 /// @param[in] color defines the foreground color.
WiredHome 83:7bad0068cca0 1359 /// @returns success/failure code. @see RetCode_t.
WiredHome 83:7bad0068cca0 1360 ///
WiredHome 83:7bad0068cca0 1361 RetCode_t line(point_t p1, point_t p2, color_t color);
WiredHome 83:7bad0068cca0 1362
WiredHome 83:7bad0068cca0 1363 /// Draw a line
WiredHome 83:7bad0068cca0 1364 ///
WiredHome 83:7bad0068cca0 1365 /// Draws a line using the foreground color setting.
WiredHome 83:7bad0068cca0 1366 ///
WiredHome 83:7bad0068cca0 1367 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 1368 /// @param[in] p2 is the point to end the line.
WiredHome 83:7bad0068cca0 1369 /// @returns success/failure code. @see RetCode_t.
WiredHome 83:7bad0068cca0 1370 ///
WiredHome 83:7bad0068cca0 1371 RetCode_t line(point_t p1, point_t p2);
WiredHome 83:7bad0068cca0 1372
WiredHome 83:7bad0068cca0 1373 /// Draw a line in the specified color
WiredHome 83:7bad0068cca0 1374 ///
WiredHome 83:7bad0068cca0 1375 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 1376 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 1377 ///
WiredHome 72:ecffe56af969 1378 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1379 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1380 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1381 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1382 /// @param[in] color defines the foreground color.
WiredHome 19:3f82c1161fd2 1383 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1384 ///
WiredHome 56:7a85d226ad0d 1385 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color);
WiredHome 19:3f82c1161fd2 1386
WiredHome 19:3f82c1161fd2 1387 /// Draw a line
WiredHome 19:3f82c1161fd2 1388 ///
WiredHome 19:3f82c1161fd2 1389 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 1390 ///
WiredHome 72:ecffe56af969 1391 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1392 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1393 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1394 /// @param[in] y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 1395 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1396 ///
WiredHome 37:f19b7e7449dc 1397 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2);
WiredHome 19:3f82c1161fd2 1398
WiredHome 19:3f82c1161fd2 1399 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 1400 ///
WiredHome 19:3f82c1161fd2 1401 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1402 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1403 ///
WiredHome 81:01da2e34283d 1404 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 1405 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1406 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 81:01da2e34283d 1407 /// @returns success/failure code. @see RetCode_t.
WiredHome 81:01da2e34283d 1408 ///
WiredHome 82:f7d300f26540 1409 RetCode_t rect(rect_t rect, color_t color, fill_t fillit = NOFILL);
WiredHome 81:01da2e34283d 1410
WiredHome 81:01da2e34283d 1411 /// Draw a filled rectangle in the specified color
WiredHome 81:01da2e34283d 1412 ///
WiredHome 81:01da2e34283d 1413 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 1414 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 1415 ///
WiredHome 81:01da2e34283d 1416 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 1417 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1418 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 81:01da2e34283d 1419 /// @returns success/failure code. @see RetCode_t.
WiredHome 81:01da2e34283d 1420 ///
WiredHome 81:01da2e34283d 1421 RetCode_t fillrect(rect_t rect, color_t color, fill_t fillit = FILL);
WiredHome 81:01da2e34283d 1422
WiredHome 81:01da2e34283d 1423 /// Draw a rectangle in the specified color
WiredHome 81:01da2e34283d 1424 ///
WiredHome 81:01da2e34283d 1425 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 1426 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 1427 ///
WiredHome 72:ecffe56af969 1428 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1429 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1430 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1431 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1432 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1433 /// @param[in] fillit is optional to FILL the rectangle. default is FILL.
WiredHome 19:3f82c1161fd2 1434 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1435 ///
WiredHome 37:f19b7e7449dc 1436 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 1437 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1438
WiredHome 19:3f82c1161fd2 1439 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 1440 ///
WiredHome 19:3f82c1161fd2 1441 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1442 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1443 ///
WiredHome 72:ecffe56af969 1444 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1445 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1446 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1447 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1448 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1449 /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 19:3f82c1161fd2 1450 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1451 ///
WiredHome 37:f19b7e7449dc 1452 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 1453 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1454
WiredHome 19:3f82c1161fd2 1455 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 1456 ///
WiredHome 19:3f82c1161fd2 1457 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 1458 ///
WiredHome 72:ecffe56af969 1459 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1460 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1461 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1462 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1463 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1464 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1465 ///
WiredHome 37:f19b7e7449dc 1466 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 1467 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1468
WiredHome 19:3f82c1161fd2 1469 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 1470 ///
WiredHome 21:3c1efb192927 1471 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 1472 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 1473 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 1474 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 1475 ///
WiredHome 19:3f82c1161fd2 1476 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1477 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1478 ///
WiredHome 72:ecffe56af969 1479 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 1480 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 1481 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 1482 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 1483 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1484 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1485 /// is returned.
WiredHome 72:ecffe56af969 1486 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1487 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1488 /// is returned.
WiredHome 72:ecffe56af969 1489 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1490 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1491 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1492 ///
WiredHome 37:f19b7e7449dc 1493 RetCode_t fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1494 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1495
WiredHome 19:3f82c1161fd2 1496 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 1497 ///
WiredHome 21:3c1efb192927 1498 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 1499 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 1500 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 1501 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 1502 ///
WiredHome 19:3f82c1161fd2 1503 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1504 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1505 ///
WiredHome 72:ecffe56af969 1506 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 1507 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 1508 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 1509 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 1510 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1511 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1512 /// is returned.
WiredHome 72:ecffe56af969 1513 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1514 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1515 /// is returned.
WiredHome 72:ecffe56af969 1516 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1517 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1518 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1519 ///
WiredHome 37:f19b7e7449dc 1520 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1521 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1522
WiredHome 19:3f82c1161fd2 1523 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 1524 ///
WiredHome 21:3c1efb192927 1525 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 1526 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 1527 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 1528 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 1529 ///
WiredHome 72:ecffe56af969 1530 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 1531 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 1532 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 1533 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 1534 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1535 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1536 /// is returned.
WiredHome 72:ecffe56af969 1537 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 1538 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 1539 /// is returned.
WiredHome 72:ecffe56af969 1540 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1541 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1542 ///
WiredHome 37:f19b7e7449dc 1543 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1544 dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1545
WiredHome 19:3f82c1161fd2 1546 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 1547 ///
WiredHome 19:3f82c1161fd2 1548 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1549 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1550 ///
WiredHome 72:ecffe56af969 1551 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 1552 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 1553 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 1554 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 1555 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 1556 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 1557 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1558 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1559 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1560 ///
WiredHome 37:f19b7e7449dc 1561 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1562 loc_t x3, loc_t y3, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1563
WiredHome 19:3f82c1161fd2 1564 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 1565 ///
WiredHome 19:3f82c1161fd2 1566 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1567 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1568 ///
WiredHome 72:ecffe56af969 1569 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 1570 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 1571 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 1572 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 1573 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 1574 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 1575 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1576 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1577 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1578 ///
WiredHome 37:f19b7e7449dc 1579 RetCode_t filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1580 loc_t x3, loc_t y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1581
WiredHome 19:3f82c1161fd2 1582 /// Draw a triangle
WiredHome 19:3f82c1161fd2 1583 ///
WiredHome 19:3f82c1161fd2 1584 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 1585 ///
WiredHome 72:ecffe56af969 1586 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 1587 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 1588 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 1589 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 1590 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 1591 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 1592 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1593 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1594 ///
WiredHome 37:f19b7e7449dc 1595 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1596 loc_t x3, loc_t y3, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1597
WiredHome 83:7bad0068cca0 1598
WiredHome 83:7bad0068cca0 1599 /// Draw a circle using the specified color.
WiredHome 83:7bad0068cca0 1600 ///
WiredHome 83:7bad0068cca0 1601 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 1602 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 1603 ///
WiredHome 83:7bad0068cca0 1604 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 1605 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 1606 /// @param[in] color defines the foreground color.
WiredHome 83:7bad0068cca0 1607 /// @returns success/failure code. @see RetCode_t.
WiredHome 83:7bad0068cca0 1608 ///
WiredHome 83:7bad0068cca0 1609 RetCode_t circle(point_t p, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 1610
WiredHome 83:7bad0068cca0 1611 /// Draw a filled circle using the specified color.
WiredHome 83:7bad0068cca0 1612 ///
WiredHome 83:7bad0068cca0 1613 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 1614 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 1615 ///
WiredHome 83:7bad0068cca0 1616 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 1617 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 1618 /// @param[in] color defines the foreground color.
WiredHome 83:7bad0068cca0 1619 /// @returns success/failure code. @see RetCode_t.
WiredHome 83:7bad0068cca0 1620 ///
WiredHome 83:7bad0068cca0 1621 RetCode_t fillcircle(point_t p, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 83:7bad0068cca0 1622
WiredHome 83:7bad0068cca0 1623 /// Draw a circle.
WiredHome 83:7bad0068cca0 1624 ///
WiredHome 83:7bad0068cca0 1625 /// Draws a circle using the foreground color setting.
WiredHome 83:7bad0068cca0 1626 ///
WiredHome 83:7bad0068cca0 1627 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 1628 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 1629 /// @returns success/failure code. @see RetCode_t.
WiredHome 83:7bad0068cca0 1630 ///
WiredHome 83:7bad0068cca0 1631 RetCode_t circle(point_t p, dim_t radius, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 1632
WiredHome 19:3f82c1161fd2 1633 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 1634 ///
WiredHome 19:3f82c1161fd2 1635 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1636 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1637 ///
WiredHome 72:ecffe56af969 1638 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 1639 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 1640 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 1641 /// @param[in] color defines the foreground color.
WiredHome 19:3f82c1161fd2 1642 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1643 ///
WiredHome 37:f19b7e7449dc 1644 RetCode_t circle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1645
WiredHome 19:3f82c1161fd2 1646 /// Draw a filled circle using the specified color.
WiredHome 19:3f82c1161fd2 1647 ///
WiredHome 19:3f82c1161fd2 1648 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1649 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1650 ///
WiredHome 72:ecffe56af969 1651 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 1652 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 1653 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 1654 /// @param[in] color defines the foreground color.
WiredHome 19:3f82c1161fd2 1655 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1656 ///
WiredHome 37:f19b7e7449dc 1657 RetCode_t fillcircle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1658
WiredHome 19:3f82c1161fd2 1659 /// Draw a circle.
WiredHome 19:3f82c1161fd2 1660 ///
WiredHome 19:3f82c1161fd2 1661 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 1662 ///
WiredHome 72:ecffe56af969 1663 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 1664 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 1665 /// @param[in] radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 1666 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1667 ///
WiredHome 37:f19b7e7449dc 1668 RetCode_t circle(loc_t x, loc_t y, dim_t radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1669
WiredHome 19:3f82c1161fd2 1670 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 1671 ///
WiredHome 19:3f82c1161fd2 1672 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1673 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1674 ///
WiredHome 72:ecffe56af969 1675 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 1676 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 1677 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 1678 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 1679 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1680 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 1681 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1682 ///
WiredHome 37:f19b7e7449dc 1683 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 19:3f82c1161fd2 1684 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1685
WiredHome 25:9556a3a9b7cc 1686 /// Draw a filled Ellipse using the specified color
WiredHome 25:9556a3a9b7cc 1687 ///
WiredHome 25:9556a3a9b7cc 1688 /// @note As a side effect, this changes the current
WiredHome 25:9556a3a9b7cc 1689 /// foreground color for subsequent operations.
WiredHome 25:9556a3a9b7cc 1690 ///
WiredHome 72:ecffe56af969 1691 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 1692 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 1693 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 1694 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 1695 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 1696 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 25:9556a3a9b7cc 1697 /// @returns success/failure code. @see RetCode_t.
WiredHome 25:9556a3a9b7cc 1698 ///
WiredHome 37:f19b7e7449dc 1699 RetCode_t fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 25:9556a3a9b7cc 1700 color_t color, fill_t fillit = FILL);
WiredHome 25:9556a3a9b7cc 1701
WiredHome 19:3f82c1161fd2 1702 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 1703 ///
WiredHome 19:3f82c1161fd2 1704 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 1705 ///
WiredHome 72:ecffe56af969 1706 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 1707 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 1708 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 1709 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 1710 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 1711 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1712 ///
WiredHome 37:f19b7e7449dc 1713 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1714
WiredHome 19:3f82c1161fd2 1715 /// Control display power
WiredHome 19:3f82c1161fd2 1716 ///
WiredHome 72:ecffe56af969 1717 /// @param[in] on when set to true will turn on the display, when false it is turned off.
WiredHome 19:3f82c1161fd2 1718 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1719 ///
WiredHome 19:3f82c1161fd2 1720 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 1721
WiredHome 19:3f82c1161fd2 1722 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 1723 ///
WiredHome 19:3f82c1161fd2 1724 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1725 ///
WiredHome 19:3f82c1161fd2 1726 RetCode_t Reset(void);
WiredHome 19:3f82c1161fd2 1727
WiredHome 19:3f82c1161fd2 1728 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 1729 ///
WiredHome 19:3f82c1161fd2 1730 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 1731 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 1732 ///
WiredHome 72:ecffe56af969 1733 /// @param[in] brightness ranges from 0 (off) to 255 (full on)
WiredHome 19:3f82c1161fd2 1734 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1735 ///
WiredHome 19:3f82c1161fd2 1736 RetCode_t Backlight_u8(unsigned char brightness);
WiredHome 19:3f82c1161fd2 1737
WiredHome 86:e86b355940f4 1738 /// Get backlight brightness.
WiredHome 86:e86b355940f4 1739 ///
WiredHome 86:e86b355940f4 1740 /// @returns backlight setting from 0 (off) to 255 (full on).
WiredHome 86:e86b355940f4 1741 ///
WiredHome 86:e86b355940f4 1742 uint8_t GetBacklight_u8(void);
WiredHome 86:e86b355940f4 1743
WiredHome 19:3f82c1161fd2 1744 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 1745 ///
WiredHome 19:3f82c1161fd2 1746 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 1747 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 1748 ///
WiredHome 72:ecffe56af969 1749 /// @param[in] brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 19:3f82c1161fd2 1750 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1751 ///
WiredHome 19:3f82c1161fd2 1752 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 1753
WiredHome 86:e86b355940f4 1754 /// Get backlight brightness.
WiredHome 86:e86b355940f4 1755 ///
WiredHome 86:e86b355940f4 1756 /// @returns backlight setting from 0 (off) to 1.0 (full on).
WiredHome 86:e86b355940f4 1757 ///
WiredHome 86:e86b355940f4 1758 float GetBacklight(void);
WiredHome 86:e86b355940f4 1759
WiredHome 98:ecebed9b80b2 1760 /// Select a User Font for all subsequent text.
WiredHome 98:ecebed9b80b2 1761 ///
WiredHome 98:ecebed9b80b2 1762 /// @note Tool to create the fonts is accessible from its creator
WiredHome 98:ecebed9b80b2 1763 /// available at http://www.mikroe.com.
WiredHome 98:ecebed9b80b2 1764 /// For version 1.2.0.0, choose the "Export for TFT and new GLCD"
WiredHome 98:ecebed9b80b2 1765 /// format.
WiredHome 98:ecebed9b80b2 1766 ///
WiredHome 98:ecebed9b80b2 1767 /// @param[in] font is a pointer to a specially formed font resource.
WiredHome 98:ecebed9b80b2 1768 /// @returns error code.
WiredHome 98:ecebed9b80b2 1769 ///
WiredHome 98:ecebed9b80b2 1770 virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
WiredHome 98:ecebed9b80b2 1771
WiredHome 98:ecebed9b80b2 1772 typedef uint8_t byte;
WiredHome 19:3f82c1161fd2 1773
WiredHome 19:3f82c1161fd2 1774 /// Get the RGB value for a DOS color.
WiredHome 19:3f82c1161fd2 1775 ///
WiredHome 72:ecffe56af969 1776 /// @param[in] i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 1777 /// @returns the RGB color of the selected index, or 0
WiredHome 19:3f82c1161fd2 1778 /// if the index is out of bounds.
WiredHome 19:3f82c1161fd2 1779 ///
WiredHome 19:3f82c1161fd2 1780 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 1781
WiredHome 19:3f82c1161fd2 1782 /// Get the color name (string) for a DOS color.
WiredHome 19:3f82c1161fd2 1783 ///
WiredHome 72:ecffe56af969 1784 /// @param[in] i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 1785 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 1786 /// or NULL if the index is out of bounds.
WiredHome 19:3f82c1161fd2 1787 ///
WiredHome 19:3f82c1161fd2 1788 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 1789
WiredHome 55:dfbabef7003e 1790 /// Advanced method indicating the start of a graphics stream.
WiredHome 55:dfbabef7003e 1791 ///
WiredHome 55:dfbabef7003e 1792 /// This is called prior to a stream of pixel data being sent.
WiredHome 55:dfbabef7003e 1793 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 1794 /// class in order to prepare the hardware to accept the streaming
WiredHome 55:dfbabef7003e 1795 /// data.
WiredHome 55:dfbabef7003e 1796 ///
WiredHome 55:dfbabef7003e 1797 /// Following this command, a series of @see _putp() commands can
WiredHome 55:dfbabef7003e 1798 /// be used to send individual pixels to the screen.
WiredHome 55:dfbabef7003e 1799 ///
WiredHome 55:dfbabef7003e 1800 /// To conclude the graphics stream, @see _EndGraphicsStream should
WiredHome 55:dfbabef7003e 1801 /// be callled.
WiredHome 55:dfbabef7003e 1802 ///
WiredHome 55:dfbabef7003e 1803 /// @returns error code.
WiredHome 55:dfbabef7003e 1804 ///
WiredHome 55:dfbabef7003e 1805 virtual RetCode_t _StartGraphicsStream(void);
WiredHome 55:dfbabef7003e 1806
WiredHome 55:dfbabef7003e 1807 /// Advanced method to put a single color pixel to the screen.
WiredHome 55:dfbabef7003e 1808 ///
WiredHome 55:dfbabef7003e 1809 /// This method may be called as many times as necessary after
WiredHome 55:dfbabef7003e 1810 /// @see _StartGraphicsStream() is called, and it should be followed
WiredHome 55:dfbabef7003e 1811 /// by _EndGraphicsStream.
WiredHome 55:dfbabef7003e 1812 ///
WiredHome 72:ecffe56af969 1813 /// @param[in] pixel is a color value to be put on the screen.
WiredHome 55:dfbabef7003e 1814 /// @returns error code.
WiredHome 55:dfbabef7003e 1815 ///
WiredHome 55:dfbabef7003e 1816 virtual RetCode_t _putp(color_t pixel);
WiredHome 55:dfbabef7003e 1817
WiredHome 55:dfbabef7003e 1818 /// Advanced method indicating the end of a graphics stream.
WiredHome 55:dfbabef7003e 1819 ///
WiredHome 55:dfbabef7003e 1820 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 55:dfbabef7003e 1821 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 1822 /// class in order to stop the hardware from accept the streaming
WiredHome 55:dfbabef7003e 1823 /// data.
WiredHome 55:dfbabef7003e 1824 ///
WiredHome 55:dfbabef7003e 1825 /// @returns error code.
WiredHome 55:dfbabef7003e 1826 ///
WiredHome 55:dfbabef7003e 1827 virtual RetCode_t _EndGraphicsStream(void);
WiredHome 19:3f82c1161fd2 1828
WiredHome 57:bd53a9e165a1 1829 /// Set the SPI port frequency (in Hz).
WiredHome 57:bd53a9e165a1 1830 ///
WiredHome 66:468a11f05580 1831 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 66:468a11f05580 1832 /// its capabilities. The RA8875 can accept writes via SPI faster
WiredHome 66:468a11f05580 1833 /// than a read can be performed. The frequency set by this API
WiredHome 66:468a11f05580 1834 /// is for the SPI writes. It will automatically reduce the SPI
WiredHome 66:468a11f05580 1835 /// clock rate when a read is performed, and restore it for the
WiredHome 68:ab08efabfc88 1836 /// next write. Alternately, the 2nd parameters permits setting
WiredHome 68:ab08efabfc88 1837 /// the read speed rather than letting it compute it automatically.
WiredHome 57:bd53a9e165a1 1838 ///
WiredHome 66:468a11f05580 1839 /// @note The primary effect of this is to recover more CPU cycles
WiredHome 66:468a11f05580 1840 /// for your application code. Keep in mind that when more than
WiredHome 66:468a11f05580 1841 /// one command is sent to the display controller, that it
WiredHome 66:468a11f05580 1842 /// will wait for the controller to finish the prior command.
WiredHome 66:468a11f05580 1843 /// In this case, the performance is limited by the RA8875.
WiredHome 57:bd53a9e165a1 1844 ///
WiredHome 72:ecffe56af969 1845 /// @param[in] Hz is the frequency in Hz, tested range includes the
WiredHome 66:468a11f05580 1846 /// range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
WiredHome 66:468a11f05580 1847 /// outside this range will be accepted, but operation may
WiredHome 76:c981284eb513 1848 /// be unreliable. This depends partially on your hardware design
WiredHome 76:c981284eb513 1849 /// and the wires connecting the display module.
WiredHome 76:c981284eb513 1850 /// The default value is 5,000,000, which should work for most
WiredHome 76:c981284eb513 1851 /// applications as a starting point.
WiredHome 72:ecffe56af969 1852 /// @param[in] Hz2 is an optional parameter and will set the read
WiredHome 68:ab08efabfc88 1853 /// speed independently of the write speed.
WiredHome 57:bd53a9e165a1 1854 /// @returns success/failure code. @see RetCode_t.
WiredHome 57:bd53a9e165a1 1855 ///
WiredHome 68:ab08efabfc88 1856 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ, unsigned long Hz2 = 0);
WiredHome 57:bd53a9e165a1 1857
WiredHome 72:ecffe56af969 1858 /// This method captures the specified area as a 24-bit bitmap file.
WiredHome 72:ecffe56af969 1859 ///
WiredHome 72:ecffe56af969 1860 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 1861 /// 24-bit format.
WiredHome 72:ecffe56af969 1862 ///
WiredHome 73:f22a18707b5e 1863 /// This method will interrogate the current display setting and
WiredHome 73:f22a18707b5e 1864 /// create a bitmap based on those settings. For instance, if
WiredHome 73:f22a18707b5e 1865 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 73:f22a18707b5e 1866 /// if there is some other operation in effect (transparent mode).
WiredHome 73:f22a18707b5e 1867 ///
WiredHome 72:ecffe56af969 1868 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 1869 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 1870 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 1871 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 1872 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 72:ecffe56af969 1873 /// @return success or error code.
WiredHome 72:ecffe56af969 1874 ///
WiredHome 72:ecffe56af969 1875 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP);
WiredHome 72:ecffe56af969 1876
WiredHome 96:40b74dd3695b 1877 /// This method captures the specified area as a 24-bit bitmap file
WiredHome 96:40b74dd3695b 1878 /// and delivers it to the previously attached callback.
WiredHome 96:40b74dd3695b 1879 ///
WiredHome 96:40b74dd3695b 1880 /// Even though this is a 16-bit display, the stored image is in
WiredHome 96:40b74dd3695b 1881 /// 24-bit format.
WiredHome 96:40b74dd3695b 1882 ///
WiredHome 96:40b74dd3695b 1883 /// This method will interrogate the current display setting and
WiredHome 96:40b74dd3695b 1884 /// create a bitmap based on those settings. For instance, if
WiredHome 96:40b74dd3695b 1885 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 96:40b74dd3695b 1886 /// if there is some other operation in effect (transparent mode), it
WiredHome 96:40b74dd3695b 1887 /// will return the blended image.
WiredHome 96:40b74dd3695b 1888 ///
WiredHome 96:40b74dd3695b 1889 /// @param[in] x is the left edge of the region to capture
WiredHome 96:40b74dd3695b 1890 /// @param[in] y is the top edge of the region to capture
WiredHome 96:40b74dd3695b 1891 /// @param[in] w is the width of the region to capture
WiredHome 96:40b74dd3695b 1892 /// @param[in] h is the height of the region to capture.
WiredHome 96:40b74dd3695b 1893 /// @return success or error code.
WiredHome 96:40b74dd3695b 1894 ///
WiredHome 96:40b74dd3695b 1895 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h);
WiredHome 96:40b74dd3695b 1896
WiredHome 96:40b74dd3695b 1897 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 1898 ///
WiredHome 96:40b74dd3695b 1899 /// This method attaches a simple c-compatible callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 1900 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 1901 /// BMP file to be created is passed to this callback.
WiredHome 96:40b74dd3695b 1902 ///
WiredHome 96:40b74dd3695b 1903 /// @param callback is the callback function.
WiredHome 96:40b74dd3695b 1904 ///
WiredHome 96:40b74dd3695b 1905 void AttachPrintHandler(PrintCallback_T callback) { c_callback = callback; }
WiredHome 96:40b74dd3695b 1906
WiredHome 96:40b74dd3695b 1907 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 1908 ///
WiredHome 96:40b74dd3695b 1909 /// This method attaches a c++ class method as a callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 1910 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 1911 /// BMP file to be created is passed to this callback.
WiredHome 96:40b74dd3695b 1912 ///
WiredHome 96:40b74dd3695b 1913 /// @param object is the class hosting the callback function.
WiredHome 102:fc60bfa0199f 1914 /// @param method is the callback method in the object to activate.
WiredHome 96:40b74dd3695b 1915 ///
WiredHome 96:40b74dd3695b 1916 template <class T>
WiredHome 102:fc60bfa0199f 1917 void AttachPrintHandler(T *object, RetCode_t (T::*method)(void)) {
WiredHome 102:fc60bfa0199f 1918 obj_callback = (FPointerDummy *)object;
WiredHome 96:40b74dd3695b 1919 method_callback = (uint32_t (FPointerDummy::*)(uint32_t))method;
WiredHome 96:40b74dd3695b 1920 }
WiredHome 96:40b74dd3695b 1921
WiredHome 72:ecffe56af969 1922 /// This method captures the specified area as a 24-bit bitmap file,
WiredHome 72:ecffe56af969 1923 /// including the option of layer selection.
WiredHome 72:ecffe56af969 1924 ///
WiredHome 74:686faa218914 1925 /// @caution This method is deprecated as the alternate PrintScreen API
WiredHome 74:686faa218914 1926 /// automatically examines the display layer configuration.
WiredHome 74:686faa218914 1927 /// Therefore, calls to this API will ignore the layer parameter
WiredHome 74:686faa218914 1928 /// and automatically execute the other method.
WiredHome 74:686faa218914 1929 ///
WiredHome 72:ecffe56af969 1930 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 1931 /// 24-bit format.
WiredHome 72:ecffe56af969 1932 ///
WiredHome 72:ecffe56af969 1933 /// @param[in] layer is 0 or 1 to select the layer to extract.
WiredHome 72:ecffe56af969 1934 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 1935 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 1936 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 1937 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 1938 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 72:ecffe56af969 1939 /// @return success or error code.
WiredHome 72:ecffe56af969 1940 ///
WiredHome 72:ecffe56af969 1941 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 1942
WiredHome 57:bd53a9e165a1 1943
WiredHome 19:3f82c1161fd2 1944 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 1945 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 1946 void ClearPerformance();
WiredHome 19:3f82c1161fd2 1947
WiredHome 66:468a11f05580 1948 /// Count idle time.
WiredHome 66:468a11f05580 1949 ///
WiredHome 72:ecffe56af969 1950 /// @param[in] t is the amount of idle time to accumulate.
WiredHome 66:468a11f05580 1951 ///
WiredHome 66:468a11f05580 1952 void CountIdleTime(uint32_t t);
WiredHome 66:468a11f05580 1953
WiredHome 19:3f82c1161fd2 1954 /// Report the performance metrics for drawing functions using
WiredHome 41:2956a0a221e5 1955 /// the available serial channel.
WiredHome 41:2956a0a221e5 1956 ///
WiredHome 72:ecffe56af969 1957 /// @param[in,out] pc is the serial channel to write to.
WiredHome 41:2956a0a221e5 1958 ///
WiredHome 41:2956a0a221e5 1959 void ReportPerformance(Serial & pc);
WiredHome 19:3f82c1161fd2 1960 #endif
WiredHome 19:3f82c1161fd2 1961
hexley 54:e117ad10fba6 1962
WiredHome 19:3f82c1161fd2 1963 private:
hexley 54:e117ad10fba6 1964 /// Touch Panel register name definitions
WiredHome 77:9206c13aa527 1965 #define TPCR0 0x70
WiredHome 77:9206c13aa527 1966 #define TPCR1 0x71
WiredHome 77:9206c13aa527 1967 #define TPXH 0x72
WiredHome 77:9206c13aa527 1968 #define TPYH 0x73
WiredHome 77:9206c13aa527 1969 #define TPXYL 0x74
WiredHome 77:9206c13aa527 1970 #define INTC1 0xF0
WiredHome 77:9206c13aa527 1971 #define INTC2 0xF1
hexley 54:e117ad10fba6 1972
hexley 54:e117ad10fba6 1973 /// Specify the default settings for the Touch Panel, where different from the chip defaults
WiredHome 77:9206c13aa527 1974 #define TP_MODE_DEFAULT TP_MODE_AUTO
WiredHome 77:9206c13aa527 1975 #define TP_DEBOUNCE_DEFAULT TP_DEBOUNCE_ON
WiredHome 77:9206c13aa527 1976 #define TP_ADC_CLKDIV_DEFAULT TP_ADC_CLKDIV_8
hexley 54:e117ad10fba6 1977
WiredHome 77:9206c13aa527 1978 #define TP_ADC_SAMPLE_DEFAULT_CLKS TP_ADC_SAMPLE_8192_CLKS
hexley 54:e117ad10fba6 1979
hexley 54:e117ad10fba6 1980 /// Other Touch Panel params
WiredHome 77:9206c13aa527 1981 #define TPBUFSIZE 16 // Depth of the averaging buffers for x and y data
hexley 54:e117ad10fba6 1982
WiredHome 83:7bad0068cca0 1983 // Needs both a ticker and a timer. (could have created a timer from the ticker, but this is easier).
WiredHome 83:7bad0068cca0 1984 // on a touch, the timer is reset.
WiredHome 83:7bad0068cca0 1985 // the ticker monitors the timer to see if it has been a long time since
WiredHome 83:7bad0068cca0 1986 // a touch, and if so, it then clears the sample counter so it doesn't get partial old
WiredHome 83:7bad0068cca0 1987 // and partial new.
WiredHome 83:7bad0068cca0 1988
WiredHome 83:7bad0068cca0 1989 /// Touch State used by TouchPanelReadable. @see TouchCode_t.
WiredHome 83:7bad0068cca0 1990 TouchCode_t touchState;
WiredHome 83:7bad0068cca0 1991
WiredHome 83:7bad0068cca0 1992 /// Touch Panel ticker
WiredHome 83:7bad0068cca0 1993 Ticker touchTicker;
WiredHome 83:7bad0068cca0 1994
WiredHome 83:7bad0068cca0 1995 /// Touch Panel timer
WiredHome 83:7bad0068cca0 1996 Timer touchTimer;
WiredHome 83:7bad0068cca0 1997
WiredHome 83:7bad0068cca0 1998 /// keeps track of which sample we're collecting to filter out the noise.
WiredHome 83:7bad0068cca0 1999 int touchSample;
WiredHome 83:7bad0068cca0 2000
WiredHome 83:7bad0068cca0 2001 /// Private function for touch ticker callback.
WiredHome 83:7bad0068cca0 2002 void _TouchTicker(void);
WiredHome 83:7bad0068cca0 2003
WiredHome 77:9206c13aa527 2004 /// Touch Panel calibration matrix.
WiredHome 77:9206c13aa527 2005 tpMatrix_t tpMatrix;
hexley 54:e117ad10fba6 2006
WiredHome 29:422616aa04bd 2007 /// Internal function to put a character using the built-in (internal) font engine
WiredHome 29:422616aa04bd 2008 ///
WiredHome 101:e0aad446094a 2009 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 2010 /// @returns the character put.
WiredHome 29:422616aa04bd 2011 ///
WiredHome 29:422616aa04bd 2012 int _internal_putc(int c);
WiredHome 29:422616aa04bd 2013
WiredHome 29:422616aa04bd 2014 /// Internal function to put a character using the external font engine
WiredHome 29:422616aa04bd 2015 ///
WiredHome 101:e0aad446094a 2016 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 2017 /// @returns the character put.
WiredHome 29:422616aa04bd 2018 ///
WiredHome 29:422616aa04bd 2019 int _external_putc(int c);
WiredHome 29:422616aa04bd 2020
WiredHome 101:e0aad446094a 2021 /// Internal function to get the actual width of a character when using the external font engine
WiredHome 101:e0aad446094a 2022 ///
WiredHome 101:e0aad446094a 2023 /// @param[in] c is the character to get the width.
WiredHome 101:e0aad446094a 2024 /// @returns the width in pixels of the character. zero if not found.
WiredHome 101:e0aad446094a 2025 ///
WiredHome 101:e0aad446094a 2026 int _external_getCharWidth(int c);
WiredHome 101:e0aad446094a 2027
WiredHome 19:3f82c1161fd2 2028 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 2029 ///
WiredHome 72:ecffe56af969 2030 /// @param[in] chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 2031 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 2032 /// the pin selection is the invert of this.
WiredHome 19:3f82c1161fd2 2033 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 2034 ///
WiredHome 79:544eb4964795 2035 RetCode_t _select(bool chipsel);
WiredHome 19:3f82c1161fd2 2036
WiredHome 66:468a11f05580 2037 /// Wait while the status register indicates the controller is busy.
WiredHome 66:468a11f05580 2038 ///
WiredHome 72:ecffe56af969 2039 /// @param[in] mask is the mask of bits to monitor.
WiredHome 66:468a11f05580 2040 /// @returns true if a normal exit.
WiredHome 66:468a11f05580 2041 /// @returns false if a timeout exit.
WiredHome 66:468a11f05580 2042 ///
WiredHome 66:468a11f05580 2043 bool _WaitWhileBusy(uint8_t mask);
WiredHome 66:468a11f05580 2044
WiredHome 66:468a11f05580 2045 /// Wait while the the register anded with the mask is true.
WiredHome 66:468a11f05580 2046 ///
WiredHome 72:ecffe56af969 2047 /// @param[in] reg is the register to monitor
WiredHome 72:ecffe56af969 2048 /// @param[in] mask is the bit mask to monitor
WiredHome 66:468a11f05580 2049 /// @returns true if it was a normal exit
WiredHome 66:468a11f05580 2050 /// @returns false if it was a timeout that caused the exit.
WiredHome 66:468a11f05580 2051 ///
WiredHome 66:468a11f05580 2052 bool _WaitWhileReg(uint8_t reg, uint8_t mask);
WiredHome 66:468a11f05580 2053
WiredHome 68:ab08efabfc88 2054 /// set the spi port to either the write or the read speed.
WiredHome 68:ab08efabfc88 2055 ///
WiredHome 68:ab08efabfc88 2056 /// This is a private API used to toggle between the write
WiredHome 68:ab08efabfc88 2057 /// and the read speed for the SPI port to the RA8875, since
WiredHome 68:ab08efabfc88 2058 /// it can accept writes faster than reads.
WiredHome 68:ab08efabfc88 2059 ///
WiredHome 72:ecffe56af969 2060 /// @param[in] writeSpeed when true selects the write frequency,
WiredHome 68:ab08efabfc88 2061 /// and when false it selects the read frequency.
WiredHome 68:ab08efabfc88 2062 ///
WiredHome 68:ab08efabfc88 2063 void _setWriteSpeed(bool writeSpeed);
WiredHome 68:ab08efabfc88 2064
WiredHome 19:3f82c1161fd2 2065 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 2066 ///
WiredHome 72:ecffe56af969 2067 /// @param[in] data is the value to write.
WiredHome 19:3f82c1161fd2 2068 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 2069 /// in while shifting out.
WiredHome 19:3f82c1161fd2 2070 ///
WiredHome 79:544eb4964795 2071 unsigned char _spiwrite(unsigned char data);
WiredHome 19:3f82c1161fd2 2072
WiredHome 19:3f82c1161fd2 2073 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 2074 ///
WiredHome 19:3f82c1161fd2 2075 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 2076 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 2077 ///
WiredHome 19:3f82c1161fd2 2078 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 2079 /// in while shifting out.
WiredHome 19:3f82c1161fd2 2080 ///
WiredHome 79:544eb4964795 2081 unsigned char _spiread();
WiredHome 19:3f82c1161fd2 2082
WiredHome 75:ca78388cfd77 2083 const uint8_t * pKeyMap;
WiredHome 75:ca78388cfd77 2084
WiredHome 19:3f82c1161fd2 2085 SPI spi; ///< spi port
WiredHome 68:ab08efabfc88 2086 bool spiWriteSpeed; ///< indicates if the current mode is write or read
WiredHome 68:ab08efabfc88 2087 unsigned long spiwritefreq; ///< saved write freq
WiredHome 66:468a11f05580 2088 unsigned long spireadfreq; ///< saved read freq
WiredHome 19:3f82c1161fd2 2089 DigitalOut cs; ///< chip select pin, assumed active low
WiredHome 19:3f82c1161fd2 2090 DigitalOut res; ///< reset pin, assumed active low
WiredHome 90:d113d71ae4f0 2091
WiredHome 90:d113d71ae4f0 2092 dim_t screenwidth; ///< configured screen width
WiredHome 90:d113d71ae4f0 2093 dim_t screenheight; ///< configured screen height
WiredHome 90:d113d71ae4f0 2094 bool portraitmode; ///< set true when in portrait mode (w,h are reversed)
WiredHome 90:d113d71ae4f0 2095
WiredHome 19:3f82c1161fd2 2096 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 98:ecebed9b80b2 2097 uint8_t extFontHeight; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 2098 uint8_t extFontWidth; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 2099
WiredHome 90:d113d71ae4f0 2100 loc_t cursor_x, cursor_y; ///< used for external fonts only
WiredHome 19:3f82c1161fd2 2101
WiredHome 19:3f82c1161fd2 2102 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 2103 typedef enum
WiredHome 19:3f82c1161fd2 2104 {
WiredHome 19:3f82c1161fd2 2105 PRF_CLS,
WiredHome 41:2956a0a221e5 2106 PRF_DRAWPIXEL,
WiredHome 41:2956a0a221e5 2107 PRF_PIXELSTREAM,
WiredHome 41:2956a0a221e5 2108 PRF_READPIXEL,
WiredHome 41:2956a0a221e5 2109 PRF_READPIXELSTREAM,
WiredHome 19:3f82c1161fd2 2110 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 2111 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 2112 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 2113 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 2114 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 2115 PRF_DRAWELLIPSE,
WiredHome 19:3f82c1161fd2 2116 METRICCOUNT
WiredHome 19:3f82c1161fd2 2117 } method_e;
WiredHome 19:3f82c1161fd2 2118 unsigned long metrics[METRICCOUNT];
WiredHome 75:ca78388cfd77 2119 unsigned long idletime_usec;
WiredHome 19:3f82c1161fd2 2120 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 2121 Timer performance;
WiredHome 19:3f82c1161fd2 2122 #endif
WiredHome 96:40b74dd3695b 2123
WiredHome 96:40b74dd3695b 2124 RetCode_t _printCallback(RA8875::filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 2125
WiredHome 96:40b74dd3695b 2126 FILE * _printFH; ///< PrintScreen file handle
WiredHome 96:40b74dd3695b 2127
WiredHome 96:40b74dd3695b 2128 RetCode_t privateCallback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 2129 if (c_callback != NULL) {
WiredHome 96:40b74dd3695b 2130 return (*c_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 2131 }
WiredHome 96:40b74dd3695b 2132 else {
WiredHome 96:40b74dd3695b 2133 if (obj_callback != NULL && method_callback != NULL) {
WiredHome 96:40b74dd3695b 2134 return (obj_callback->*method_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 2135 }
WiredHome 96:40b74dd3695b 2136 }
WiredHome 96:40b74dd3695b 2137 return noerror;
WiredHome 96:40b74dd3695b 2138 }
WiredHome 96:40b74dd3695b 2139
WiredHome 96:40b74dd3695b 2140 RetCode_t (* c_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 2141 FPointerDummy *obj_callback;
WiredHome 96:40b74dd3695b 2142 RetCode_t (FPointerDummy::*method_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 19:3f82c1161fd2 2143 };
WiredHome 19:3f82c1161fd2 2144
WiredHome 96:40b74dd3695b 2145
WiredHome 19:3f82c1161fd2 2146 //} // namespace
WiredHome 19:3f82c1161fd2 2147
WiredHome 19:3f82c1161fd2 2148 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 2149
WiredHome 23:a50ded45dbaf 2150
WiredHome 23:a50ded45dbaf 2151 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 2152 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 2153 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 2154 // / / / / / / / /
WiredHome 23:a50ded45dbaf 2155 // / / / /___ / /__________ / /
WiredHome 23:a50ded45dbaf 2156 // / / / ____/ /__________ / / /
WiredHome 23:a50ded45dbaf 2157 // / / / / / / / /
WiredHome 23:a50ded45dbaf 2158 // / / / /__________ ___________/ / / /
WiredHome 23:a50ded45dbaf 2159 // /__/ /_____________/ /_____________/ /__/
WiredHome 23:a50ded45dbaf 2160
WiredHome 23:a50ded45dbaf 2161 #include "WebColors.h"
WiredHome 23:a50ded45dbaf 2162 #include <algorithm>
WiredHome 23:a50ded45dbaf 2163
WiredHome 23:a50ded45dbaf 2164 extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 2165
WiredHome 23:a50ded45dbaf 2166 /// This activates a small set of tests for the graphics library.
WiredHome 23:a50ded45dbaf 2167 ///
WiredHome 23:a50ded45dbaf 2168 /// Call this API and pass it the reference to the display class.
WiredHome 23:a50ded45dbaf 2169 /// It will then run a series of tests. It accepts interaction via
WiredHome 23:a50ded45dbaf 2170 /// stdin to switch from automatic test mode to manual, run a specific
WiredHome 23:a50ded45dbaf 2171 /// test, or to exit the test mode.
WiredHome 23:a50ded45dbaf 2172 ///
WiredHome 72:ecffe56af969 2173 /// @param[in] lcd is a reference to the display class.
WiredHome 72:ecffe56af969 2174 /// @param[in] pc is a reference to a serial interface, typically the USB to PC.
WiredHome 23:a50ded45dbaf 2175 ///
WiredHome 23:a50ded45dbaf 2176 void RunTestSet(RA8875 & lcd, Serial & pc);
WiredHome 23:a50ded45dbaf 2177
WiredHome 23:a50ded45dbaf 2178
WiredHome 23:a50ded45dbaf 2179 // To enable the test code, uncomment this section, or copy the
WiredHome 23:a50ded45dbaf 2180 // necessary pieces to your "main()".
WiredHome 23:a50ded45dbaf 2181 //
WiredHome 23:a50ded45dbaf 2182 // #include "mbed.h"
WiredHome 23:a50ded45dbaf 2183 // #include "RA8875.h"
WiredHome 23:a50ded45dbaf 2184 // RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 23:a50ded45dbaf 2185 // Serial pc(USBTX, USBRX);
WiredHome 23:a50ded45dbaf 2186 // extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 2187 // int main()
WiredHome 23:a50ded45dbaf 2188 // {
WiredHome 23:a50ded45dbaf 2189 // pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 23:a50ded45dbaf 2190 // pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 23:a50ded45dbaf 2191 //
WiredHome 23:a50ded45dbaf 2192 // pc.printf("Turning on display\r\n");
WiredHome 101:e0aad446094a 2193 // lcd.init();
WiredHome 23:a50ded45dbaf 2194 // lcd.Reset();
WiredHome 23:a50ded45dbaf 2195 // lcd.Power(true); // display power is on, but the backlight is independent
WiredHome 23:a50ded45dbaf 2196 // lcd.Backlight(0.5);
WiredHome 23:a50ded45dbaf 2197 // RunTestSet(lcd, pc);
WiredHome 23:a50ded45dbaf 2198 // }
WiredHome 23:a50ded45dbaf 2199
WiredHome 23:a50ded45dbaf 2200 #endif // TESTENABLE
WiredHome 23:a50ded45dbaf 2201
WiredHome 56:7a85d226ad0d 2202 #endif