KSM edits to RA8875

Dependents:   Liz_Test_Code

Committer:
WiredHome
Date:
Sun Dec 28 21:50:28 2014 +0000
Revision:
81:01da2e34283d
Parent:
79:544eb4964795
Child:
82:f7d300f26540
Refactored constructor() and init().; Added rect_t as a rectangle type.; Added new rect() methods that use rect_t.; Added touch panel calibration (and some renamed touch* methods).

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