Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Thu Dec 17 12:16:40 2015 +0000
Revision:
98:ecebed9b80b2
Parent:
96:40b74dd3695b
Child:
99:66edf771373a
Significant changes to the support for Soft Fonts (User defined fonts), to directly leverage the output of the GLCD Font Creator tool and require nearly zero manual changes. This deprecates the old API setfont in favor of SelectUserFont.

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