Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Mon Jan 19 15:44:41 2015 +0000
Revision:
88:bfddef6ec836
Parent:
87:ee2240581aa7
Child:
90:d113d71ae4f0
Added a timeout to the touch calibration process, so that it will return if there is no touchscreen, user not present, or a stuck touchscreen.

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