Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Committer:
WiredHome
Date:
Fri Dec 26 21:34:28 2014 +0000
Revision:
77:9206c13aa527
Parent:
76:c981284eb513
Child:
78:faf49c381591
Functioning touch panel updates - added method for calibration and a new API to get the touch in the "display" coordinate system.

Who changed what in which revision?

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