KSM edits to RA8875

Dependents:   Liz_Test_Code

Committer:
WiredHome
Date:
Sun Dec 28 03:14:35 2014 +0000
Revision:
78:faf49c381591
Parent:
77:9206c13aa527
Child:
79:544eb4964795
Continue work on touch screen, and some file refactoring for easier maintenance.

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