Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Sun Aug 31 14:37:37 2014 +0000
Revision:
66:468a11f05580
Parent:
62:ba5d33438fda
Child:
68:ab08efabfc88
Increase the SPI clock rate by splitting the write from the read to better match the RA8875 display capabilities.

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 19:3f82c1161fd2 5 #include "GraphicsDisplay.h"
WiredHome 19:3f82c1161fd2 6
WiredHome 41:2956a0a221e5 7 #define RA8875_DEFAULT_SPI_FREQ 5000000
WiredHome 19:3f82c1161fd2 8
WiredHome 19:3f82c1161fd2 9 // Define this to enable code that monitors the performance of various
WiredHome 19:3f82c1161fd2 10 // graphics commands.
WiredHome 58:26658a56112a 11 #define PERF_METRICS
WiredHome 19:3f82c1161fd2 12
WiredHome 23:a50ded45dbaf 13 // What better place for some test code than in here and the companion
WiredHome 23:a50ded45dbaf 14 // .cpp file. See also the bottom of this file.
WiredHome 62:ba5d33438fda 15 //#define TESTENABLE
WiredHome 19:3f82c1161fd2 16
WiredHome 19:3f82c1161fd2 17 /// DOS colors - slightly color enhanced
WiredHome 20:6e2e4a8372eb 18 #define Black (color_t)(RGB(0,0,0))
WiredHome 20:6e2e4a8372eb 19 #define Blue (color_t)(RGB(0,0,187))
WiredHome 20:6e2e4a8372eb 20 #define Green (color_t)(RGB(0,187,0))
WiredHome 20:6e2e4a8372eb 21 #define Cyan (color_t)(RGB(0,187,187))
WiredHome 20:6e2e4a8372eb 22 #define Red (color_t)(RGB(187,0,0))
WiredHome 20:6e2e4a8372eb 23 #define Magenta (color_t)(RGB(187,0,187))
WiredHome 20:6e2e4a8372eb 24 #define Brown (color_t)(RGB(187,187,0))
WiredHome 20:6e2e4a8372eb 25 #define Gray (color_t)(RGB(187,187,187))
WiredHome 20:6e2e4a8372eb 26 #define Charcoal (color_t)(RGB(85,85,85))
WiredHome 62:ba5d33438fda 27 #define BrightBlue (color_t)(RGB(0,0,255))
WiredHome 62:ba5d33438fda 28 #define BrightGreen (color_t)(RGB(0,255,0))
WiredHome 62:ba5d33438fda 29 #define BrightCyan (color_t)(RGB(0,255,255))
WiredHome 62:ba5d33438fda 30 #define BrightRed (color_t)(RGB(255,0,0))
WiredHome 20:6e2e4a8372eb 31 #define Orange (color_t)(RGB(255,85,85))
WiredHome 20:6e2e4a8372eb 32 #define Pink (color_t)(RGB(255,85,255))
WiredHome 20:6e2e4a8372eb 33 #define Yellow (color_t)(RGB(255,255,85))
WiredHome 20:6e2e4a8372eb 34 #define White (color_t)(RGB(255,255,255))
WiredHome 20:6e2e4a8372eb 35
WiredHome 62:ba5d33438fda 36 #define DarkBlue (color_t)(RGB(0,0,63))
WiredHome 62:ba5d33438fda 37 #define DarkGreen (color_t)(RGB(0,63,0))
WiredHome 62:ba5d33438fda 38 #define DarkCyan (color_t)(RGB(0,63,63))
WiredHome 62:ba5d33438fda 39 #define DarkRed (color_t)(RGB(63,0,0))
WiredHome 62:ba5d33438fda 40 #define DarkMagenta (color_t)(RGB(63,0,63))
WiredHome 62:ba5d33438fda 41 #define DarkBrown (color_t)(RGB(63,63,0))
WiredHome 62:ba5d33438fda 42 #define DarkGray (color_t)(RGB(63,63,63))
WiredHome 61:8f3153bf0baa 43
WiredHome 19:3f82c1161fd2 44
WiredHome 19:3f82c1161fd2 45 //namespace SW_graphics
WiredHome 19:3f82c1161fd2 46 //{
WiredHome 19:3f82c1161fd2 47
WiredHome 24:8ca861acf12d 48
WiredHome 21:3c1efb192927 49 /// This is a graphics library for the Raio RA8875 Display Controller chip
WiredHome 21:3c1efb192927 50 /// attached to a 4-wire SPI interface.
WiredHome 21:3c1efb192927 51 ///
WiredHome 56:7a85d226ad0d 52 /// It offers both primitive and high level APIs.
WiredHome 56:7a85d226ad0d 53 ///
WiredHome 21:3c1efb192927 54 /// Central to this API is a coordinate system, where the origin (0,0) is in
WiredHome 56:7a85d226ad0d 55 /// the top-left corner of the display, and the width (x) extends positive to the
WiredHome 56:7a85d226ad0d 56 /// right and the height (y) extends positive toward the bottom.
WiredHome 21:3c1efb192927 57 ///
WiredHome 56:7a85d226ad0d 58 /// @caution As there are both graphics and text commands, one must take care to use
WiredHome 21:3c1efb192927 59 /// the proper coordinate system for each. Some of the text APIs are in units
WiredHome 29:422616aa04bd 60 /// of column and row, which is measured in character positions (and dependent
WiredHome 56:7a85d226ad0d 61 /// on the font size), where other text APIs permit pixel level positioning.
WiredHome 56:7a85d226ad0d 62 ///
WiredHome 56:7a85d226ad0d 63 /// @code
WiredHome 56:7a85d226ad0d 64 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 65 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 66 ///
WiredHome 56:7a85d226ad0d 67 /// int main()
WiredHome 56:7a85d226ad0d 68 /// {
WiredHome 56:7a85d226ad0d 69 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 70 /// lcd.circle( 400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 71 /// lcd.fillcircle( 400,25, 15, RGB(128,255,128));
WiredHome 56:7a85d226ad0d 72 /// lcd.ellipse( 440,75, 35,20, BrightBlue);
WiredHome 56:7a85d226ad0d 73 /// lcd.fillellipse( 440,75, 25,10, Blue);
WiredHome 56:7a85d226ad0d 74 /// lcd.triangle( 440,100, 475,110, 450,125, Magenta);
WiredHome 56:7a85d226ad0d 75 /// lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
WiredHome 56:7a85d226ad0d 76 /// lcd.rect( 400,130, 475,155, Brown);
WiredHome 56:7a85d226ad0d 77 /// lcd.fillrect( 405,135, 470,150, Pink);
WiredHome 56:7a85d226ad0d 78 /// lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
WiredHome 56:7a85d226ad0d 79 /// lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
WiredHome 56:7a85d226ad0d 80 /// lcd.line( 430,200, 460,230, RGB(0,255,0));
WiredHome 56:7a85d226ad0d 81 /// for (int i=0; i<=30; i+=5)
WiredHome 56:7a85d226ad0d 82 /// lcd.pixel(435+i,200+i, White);
WiredHome 56:7a85d226ad0d 83 /// }
WiredHome 56:7a85d226ad0d 84 /// @endcode
WiredHome 29:422616aa04bd 85 ///
WiredHome 31:c72e12cd5c67 86 /// @todo Add Scroll support for text.
WiredHome 37:f19b7e7449dc 87 /// @todo Improve sync between internal and external font support - cursor, window, scroll.
WiredHome 29:422616aa04bd 88 /// @todo Add Hardware reset signal.
WiredHome 29:422616aa04bd 89 /// @todo Add Keypad Support.
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 19:3f82c1161fd2 177 /// @param mosi is the SPI master out slave in pin on the mbed.
WiredHome 19:3f82c1161fd2 178 /// @param miso is the SPI master in slave out pin on the mbed.
WiredHome 19:3f82c1161fd2 179 /// @param sclk is the SPI shift clock pin on the mbed.
WiredHome 19:3f82c1161fd2 180 /// @param 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 19:3f82c1161fd2 182 /// @param 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 19:3f82c1161fd2 185 /// @param name is a text name for this object, which will permit
WiredHome 19:3f82c1161fd2 186 /// capturing stdout 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 61:8f3153bf0baa 215 /// @param 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 44:207594dece70 259 /// @param 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 44:207594dece70 279 /// @param layer1 sets the layer 1 transparency.
WiredHome 44:207594dece70 280 /// @param 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 53:86d24b9480b9 290 /// @param 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
hexley 54:e117ad10fba6 296 /// Initialize theTouch Panel controller with default values
hexley 54:e117ad10fba6 297 ///
WiredHome 56:7a85d226ad0d 298 /// @returns success/failure code. @see RetCode_t.
WiredHome 56:7a85d226ad0d 299 ///
hexley 54:e117ad10fba6 300 RetCode_t TouchPanelInit(void);
hexley 54:e117ad10fba6 301
hexley 54:e117ad10fba6 302 /// Initialize the Touch Panel controller with detailed settings.
hexley 54:e117ad10fba6 303 ///
hexley 54:e117ad10fba6 304 /// @param[in] bTpEnable Touch Panel enable/disable control:
hexley 54:e117ad10fba6 305 /// - TP_ENABLE: enable the touch panel
hexley 54:e117ad10fba6 306 /// - TP_DISABLE: disable the touch panel
WiredHome 56:7a85d226ad0d 307 /// @param[in] bTpAutoManual Touch Panel operating mode:
hexley 54:e117ad10fba6 308 /// - TP_MODE_AUTO: automatic capture
hexley 54:e117ad10fba6 309 /// - TP_MODE_MANUAL: manual capture
WiredHome 56:7a85d226ad0d 310 /// @param[in] bTpDebounce Debounce circuit enable for touch panel interrupt:
hexley 54:e117ad10fba6 311 /// - TP_DEBOUNCE_OFF: disable the debounce circuit
hexley 54:e117ad10fba6 312 /// - TP_DEBOUNCE_ON: enable the debounce circuit
WiredHome 56:7a85d226ad0d 313 /// @param[in] bTpManualMode When Manual Mode is selected, this sets the mode:
hexley 54:e117ad10fba6 314 /// - TP_MANUAL_IDLE: touch panel is idle
hexley 54:e117ad10fba6 315 /// - TP_MANUAL_WAIT: wait for touch panel event
hexley 54:e117ad10fba6 316 /// - TP_MANUAL_LATCH_X: latch X data
hexley 54:e117ad10fba6 317 /// - TP_MANUAL_LATCH_Y: latch Y data
WiredHome 56:7a85d226ad0d 318 /// @param[in] bTpAdcClkDiv Sets the ADC clock as a fraction of the System CLK:
hexley 54:e117ad10fba6 319 /// - TP_ADC_CLKDIV_1: Use CLK
hexley 54:e117ad10fba6 320 /// - TP_ADC_CLKDIV_2: Use CLK/2
hexley 54:e117ad10fba6 321 /// - TP_ADC_CLKDIV_4: Use CLK/4
hexley 54:e117ad10fba6 322 /// - TP_ADC_CLKDIV_8: Use CLK/8
hexley 54:e117ad10fba6 323 /// - TP_ADC_CLKDIV_16: Use CLK/16
hexley 54:e117ad10fba6 324 /// - TP_ADC_CLKDIV_32: Use CLK/32
hexley 54:e117ad10fba6 325 /// - TP_ADC_CLKDIV_64: Use CLK/64
hexley 54:e117ad10fba6 326 /// - TP_ADC_CLKDIV_128: Use CLK/128
WiredHome 56:7a85d226ad0d 327 /// @param[in] bTpAdcSampleTime Touch Panel sample time delay before ADC data is ready:
hexley 54:e117ad10fba6 328 /// - TP_ADC_SAMPLE_512_CLKS: Wait 512 system clocks
hexley 54:e117ad10fba6 329 /// - TP_ADC_SAMPLE_1024_CLKS: Wait 1024 system clocks
hexley 54:e117ad10fba6 330 /// - TP_ADC_SAMPLE_2048_CLKS: Wait 2048 system clocks
hexley 54:e117ad10fba6 331 /// - TP_ADC_SAMPLE_4096_CLKS: Wait 4096 system clocks
hexley 54:e117ad10fba6 332 /// - TP_ADC_SAMPLE_8192_CLKS: Wait 8192 system clocks
hexley 54:e117ad10fba6 333 /// - TP_ADC_SAMPLE_16384_CLKS: Wait 16384 system clocks
hexley 54:e117ad10fba6 334 /// - TP_ADC_SAMPLE_32768_CLKS: Wait 32768 system clocks
hexley 54:e117ad10fba6 335 /// - TP_ADC_SAMPLE_65536_CLKS: Wait 65536 system clocks
WiredHome 56:7a85d226ad0d 336 /// @returns success/failure code. @see RetCode_t.
WiredHome 56:7a85d226ad0d 337 ///
hexley 54:e117ad10fba6 338 RetCode_t TouchPanelInit(uint8_t bTpEnable, uint8_t bTpAutoManual, uint8_t bTpDebounce, uint8_t bTpManualMode, uint8_t bTpAdcClkDiv, uint8_t bTpAdcSampleTime);
WiredHome 53:86d24b9480b9 339
hexley 54:e117ad10fba6 340 /// Poll the TouchPanel and on a touch event return the filtered x, y coordinates.
hexley 54:e117ad10fba6 341 ///
WiredHome 56:7a85d226ad0d 342 /// @param[inout] x is the x position where the touch was registered.
WiredHome 56:7a85d226ad0d 343 /// @param[inout] y is the y position where the touch was registered.
WiredHome 56:7a85d226ad0d 344 /// @returns true if touch was detected, in which case the x and y values were set.
WiredHome 56:7a85d226ad0d 345 ///
hexley 54:e117ad10fba6 346 unsigned char TouchPanelRead(loc_t *x, loc_t *y);
hexley 54:e117ad10fba6 347
hexley 54:e117ad10fba6 348 /// Poll the TouchPanel and on a touch event return the raw x, y coordinates.
hexley 54:e117ad10fba6 349 ///
WiredHome 56:7a85d226ad0d 350 /// @param[inout] x is the x position where the touch was registered.
WiredHome 56:7a85d226ad0d 351 /// @param[inout] y is the y position where the touch was registered.
WiredHome 56:7a85d226ad0d 352 /// @returns true if touch was detected, in which case the x and y values were set.
WiredHome 56:7a85d226ad0d 353 ///
hexley 54:e117ad10fba6 354 unsigned char TouchPanelReadRaw(loc_t *x, loc_t *y);
hexley 54:e117ad10fba6 355
hexley 54:e117ad10fba6 356 /// Append interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 357 ///
hexley 54:e117ad10fba6 358 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 359 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 360 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 361 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 362 /// - RA8875_INT_BTE: BTE process complete interrupt
hexley 54:e117ad10fba6 363 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
WiredHome 56:7a85d226ad0d 364 /// @param[in] fptr is a callback function to handle the interrupt event.
WiredHome 56:7a85d226ad0d 365 /// @returns none
hexley 54:e117ad10fba6 366 ///
hexley 54:e117ad10fba6 367 void AppendISR(uint8_t bISRType, void(*fptr)(void));
hexley 54:e117ad10fba6 368
hexley 54:e117ad10fba6 369 /// Unappend interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 370 ///
hexley 54:e117ad10fba6 371 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 372 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 373 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 374 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 375 /// - RA8875_INT_BTE: BTE process complete interrupt
hexley 54:e117ad10fba6 376 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
hexley 54:e117ad10fba6 377 /// @return none
hexley 54:e117ad10fba6 378 ///
hexley 54:e117ad10fba6 379 void UnAppendISR(uint8_t bISRType);
hexley 54:e117ad10fba6 380
WiredHome 38:38d503b4fad6 381 /// Write a command to the display with a word of data.
WiredHome 38:38d503b4fad6 382 ///
WiredHome 38:38d503b4fad6 383 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 384 ///
WiredHome 38:38d503b4fad6 385 /// @param command is the command to write.
WiredHome 38:38d503b4fad6 386 /// @param data is data to be written to the command register.
WiredHome 38:38d503b4fad6 387 /// @returns success/failure code. @see RetCode_t.
WiredHome 38:38d503b4fad6 388 ///
WiredHome 38:38d503b4fad6 389 RetCode_t WriteCommandW(uint8_t command, uint16_t data);
WiredHome 38:38d503b4fad6 390
WiredHome 19:3f82c1161fd2 391 /// Write a command to the display
WiredHome 19:3f82c1161fd2 392 ///
WiredHome 19:3f82c1161fd2 393 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 394 ///
WiredHome 19:3f82c1161fd2 395 /// @param command is the command to write.
WiredHome 33:b6b710758ab3 396 /// @param data is optional data to be written to the command register
WiredHome 19:3f82c1161fd2 397 /// and only occurs if the data is in the range [0 - 0xFF].
WiredHome 19:3f82c1161fd2 398 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 399 ///
WiredHome 32:0e4f2ae512e2 400 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
WiredHome 19:3f82c1161fd2 401
WiredHome 38:38d503b4fad6 402 /// Write a data word to the display
WiredHome 38:38d503b4fad6 403 ///
WiredHome 38:38d503b4fad6 404 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 405 ///
WiredHome 38:38d503b4fad6 406 /// @param data is the data to write.
WiredHome 38:38d503b4fad6 407 /// @returns success/failure code. @see RetCode_t.
WiredHome 38:38d503b4fad6 408 ///
WiredHome 38:38d503b4fad6 409 RetCode_t WriteDataW(uint16_t data);
WiredHome 38:38d503b4fad6 410
WiredHome 19:3f82c1161fd2 411 /// Write a data byte to the display
WiredHome 19:3f82c1161fd2 412 ///
WiredHome 19:3f82c1161fd2 413 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 414 ///
WiredHome 19:3f82c1161fd2 415 /// @param data is the data to write.
WiredHome 19:3f82c1161fd2 416 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 417 ///
WiredHome 32:0e4f2ae512e2 418 virtual RetCode_t WriteData(unsigned char data);
WiredHome 19:3f82c1161fd2 419
WiredHome 19:3f82c1161fd2 420 /// Read a command register
WiredHome 19:3f82c1161fd2 421 ///
WiredHome 19:3f82c1161fd2 422 /// @param command is the command register to read.
WiredHome 19:3f82c1161fd2 423 /// @returns the value read from the register.
WiredHome 19:3f82c1161fd2 424 ///
WiredHome 19:3f82c1161fd2 425 unsigned char ReadCommand(unsigned char command);
WiredHome 19:3f82c1161fd2 426
WiredHome 41:2956a0a221e5 427 /// Read a data byte from the display
WiredHome 19:3f82c1161fd2 428 ///
WiredHome 19:3f82c1161fd2 429 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 430 ///
WiredHome 19:3f82c1161fd2 431 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 432 ///
WiredHome 19:3f82c1161fd2 433 unsigned char ReadData(void);
WiredHome 19:3f82c1161fd2 434
WiredHome 41:2956a0a221e5 435 /// Read a word from the display
WiredHome 41:2956a0a221e5 436 ///
WiredHome 41:2956a0a221e5 437 /// This is a high level command, and may invoke several primitives.
WiredHome 41:2956a0a221e5 438 ///
WiredHome 41:2956a0a221e5 439 /// @returns data that was read.
WiredHome 41:2956a0a221e5 440 ///
WiredHome 41:2956a0a221e5 441 uint16_t ReadDataW(void);
WiredHome 41:2956a0a221e5 442
WiredHome 19:3f82c1161fd2 443 /// Read the display status
WiredHome 19:3f82c1161fd2 444 ///
WiredHome 19:3f82c1161fd2 445 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 446 ///
WiredHome 19:3f82c1161fd2 447 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 448 ///
WiredHome 19:3f82c1161fd2 449 unsigned char ReadStatus(void);
WiredHome 19:3f82c1161fd2 450
WiredHome 19:3f82c1161fd2 451 /// get the width in pixels of the currently active font
WiredHome 19:3f82c1161fd2 452 ///
WiredHome 19:3f82c1161fd2 453 /// @returns font width in pixels.
WiredHome 19:3f82c1161fd2 454 ///
WiredHome 37:f19b7e7449dc 455 dim_t fontwidth(void);
WiredHome 19:3f82c1161fd2 456
WiredHome 19:3f82c1161fd2 457 /// get the height in pixels of the currently active font
WiredHome 19:3f82c1161fd2 458 ///
WiredHome 19:3f82c1161fd2 459 /// @returns font height in pixels.
WiredHome 19:3f82c1161fd2 460 ///
WiredHome 37:f19b7e7449dc 461 dim_t fontheight(void);
WiredHome 19:3f82c1161fd2 462
WiredHome 19:3f82c1161fd2 463 /// get the number of colums based on the currently active font
WiredHome 19:3f82c1161fd2 464 ///
WiredHome 19:3f82c1161fd2 465 /// @returns number of columns.
WiredHome 19:3f82c1161fd2 466 ///
WiredHome 19:3f82c1161fd2 467 virtual int columns(void);
WiredHome 19:3f82c1161fd2 468
WiredHome 19:3f82c1161fd2 469 /// get the number of rows based on the currently active font
WiredHome 19:3f82c1161fd2 470 ///
WiredHome 19:3f82c1161fd2 471 /// @returns number of rows.
WiredHome 19:3f82c1161fd2 472 ///
WiredHome 19:3f82c1161fd2 473 virtual int rows(void);
WiredHome 19:3f82c1161fd2 474
WiredHome 19:3f82c1161fd2 475 /// get the screen width in pixels
WiredHome 19:3f82c1161fd2 476 ///
WiredHome 19:3f82c1161fd2 477 /// @returns screen width in pixels.
WiredHome 19:3f82c1161fd2 478 ///
WiredHome 38:38d503b4fad6 479 virtual dim_t width(void);
WiredHome 19:3f82c1161fd2 480
WiredHome 19:3f82c1161fd2 481 /// get the screen height in pixels
WiredHome 19:3f82c1161fd2 482 ///
WiredHome 19:3f82c1161fd2 483 /// @returns screen height in pixels.
WiredHome 19:3f82c1161fd2 484 ///
WiredHome 38:38d503b4fad6 485 virtual dim_t height(void);
WiredHome 19:3f82c1161fd2 486
WiredHome 43:3becae133285 487 /// get the color depth in bits per pixel.
WiredHome 43:3becae133285 488 ///
WiredHome 43:3becae133285 489 /// @returns 8 or 16 only.
WiredHome 43:3becae133285 490 ///
WiredHome 43:3becae133285 491 virtual dim_t color_bpp(void);
WiredHome 43:3becae133285 492
WiredHome 19:3f82c1161fd2 493 /// Set cursor position based on the current font size.
WiredHome 19:3f82c1161fd2 494 ///
WiredHome 32:0e4f2ae512e2 495 /// @param column is the horizontal position in character positions
WiredHome 32:0e4f2ae512e2 496 /// @param row is the vertical position in character positions
WiredHome 19:3f82c1161fd2 497 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 498 ///
WiredHome 37:f19b7e7449dc 499 virtual RetCode_t locate(textloc_t column, textloc_t row);
WiredHome 19:3f82c1161fd2 500
WiredHome 19:3f82c1161fd2 501 /// Prepare the controller to write text to the screen by positioning
WiredHome 19:3f82c1161fd2 502 /// the cursor.
WiredHome 19:3f82c1161fd2 503 ///
WiredHome 56:7a85d226ad0d 504 /// @code
WiredHome 56:7a85d226ad0d 505 /// lcd.SetTextCursor(100, 25);
WiredHome 56:7a85d226ad0d 506 /// lcd.puts("Hello");
WiredHome 56:7a85d226ad0d 507 /// @endcode
WiredHome 56:7a85d226ad0d 508 ///
WiredHome 19:3f82c1161fd2 509 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 510 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 511 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 512 ///
WiredHome 37:f19b7e7449dc 513 RetCode_t SetTextCursor(loc_t x, loc_t y);
WiredHome 29:422616aa04bd 514
WiredHome 37:f19b7e7449dc 515 /// Get the current cursor position in pixels.
WiredHome 37:f19b7e7449dc 516 ///
WiredHome 56:7a85d226ad0d 517 /// @code
WiredHome 56:7a85d226ad0d 518 /// point_t point = GetTextCursor();
WiredHome 56:7a85d226ad0d 519 /// if (point.x > 100 && point.y > 150)
WiredHome 56:7a85d226ad0d 520 /// //...
WiredHome 56:7a85d226ad0d 521 /// @endcode
WiredHome 56:7a85d226ad0d 522 ///
WiredHome 37:f19b7e7449dc 523 /// @returns cursor position.
WiredHome 37:f19b7e7449dc 524 ///
WiredHome 37:f19b7e7449dc 525 point_t GetTextCursor(void);
WiredHome 37:f19b7e7449dc 526
WiredHome 29:422616aa04bd 527 /// Get the current cursor horizontal position in pixels.
WiredHome 29:422616aa04bd 528 ///
WiredHome 29:422616aa04bd 529 /// @returns cursor position horizontal offset.
WiredHome 29:422616aa04bd 530 ///
WiredHome 37:f19b7e7449dc 531 loc_t GetTextCursor_X(void);
WiredHome 29:422616aa04bd 532
WiredHome 29:422616aa04bd 533 /// Get the current cursor vertical position in pixels.
WiredHome 29:422616aa04bd 534 ///
WiredHome 29:422616aa04bd 535 /// @returns cursor position vertical offset.
WiredHome 29:422616aa04bd 536 ///
WiredHome 37:f19b7e7449dc 537 loc_t GetTextCursor_Y(void);
WiredHome 29:422616aa04bd 538
WiredHome 23:a50ded45dbaf 539 /// Configure additional Cursor Control settings.
WiredHome 23:a50ded45dbaf 540 ///
WiredHome 23:a50ded45dbaf 541 /// This API lets you modify other cursor control settings;
WiredHome 23:a50ded45dbaf 542 /// Cursor visible/hidden, Cursor blink/normal,
WiredHome 23:a50ded45dbaf 543 /// Cursor I-Beam/underscore/box.
WiredHome 23:a50ded45dbaf 544 ///
WiredHome 24:8ca861acf12d 545 /// @param cursor can be set to NOCURSOR (default), IBEAM,
WiredHome 24:8ca861acf12d 546 /// UNDER, or BLOCK.
WiredHome 23:a50ded45dbaf 547 /// @param blink can be set to true or false (default false)
WiredHome 23:a50ded45dbaf 548 /// @returns success/failure code. @see RetCode_t
WiredHome 23:a50ded45dbaf 549 ///
WiredHome 24:8ca861acf12d 550 RetCode_t SetTextCursorControl(cursor_t cursor = NOCURSOR, bool blink = false);
WiredHome 23:a50ded45dbaf 551
WiredHome 19:3f82c1161fd2 552 /// Select the ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 553 ///
WiredHome 19:3f82c1161fd2 554 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 555 ///
WiredHome 19:3f82c1161fd2 556 /// @param font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 557 ///
WiredHome 19:3f82c1161fd2 558 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 559 /// the command is not executed.
WiredHome 19:3f82c1161fd2 560 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 561 ///
WiredHome 19:3f82c1161fd2 562 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 19:3f82c1161fd2 563
WiredHome 19:3f82c1161fd2 564 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 565 ///
WiredHome 19:3f82c1161fd2 566 /// This command lets you make several modifications to any text that
WiredHome 56:7a85d226ad0d 567 /// will be written to the screen.
WiredHome 19:3f82c1161fd2 568 ///
WiredHome 19:3f82c1161fd2 569 /// Options can be combined:
WiredHome 19:3f82c1161fd2 570 /// Default:
WiredHome 19:3f82c1161fd2 571 /// @li Full alignment disabled,
WiredHome 19:3f82c1161fd2 572 /// @li Font with Background color,
WiredHome 19:3f82c1161fd2 573 /// @li Font in normal orientiation,
WiredHome 19:3f82c1161fd2 574 /// @li Horizontal scale x 1
WiredHome 19:3f82c1161fd2 575 /// @li Vertical scale x 1
WiredHome 19:3f82c1161fd2 576 /// @li alignment
WiredHome 19:3f82c1161fd2 577 ///
WiredHome 19:3f82c1161fd2 578 /// @param fillit defaults to FILL, but can be NOFILL
WiredHome 19:3f82c1161fd2 579 /// @param angle defaults to normal, but can be rotated
WiredHome 19:3f82c1161fd2 580 /// @param hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 581 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 582 /// @param vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 583 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 584 /// @param alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 585 /// align_full.
WiredHome 19:3f82c1161fd2 586 ///
WiredHome 19:3f82c1161fd2 587 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 588 /// the command is not executed.
WiredHome 19:3f82c1161fd2 589 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 590 ///
WiredHome 19:3f82c1161fd2 591 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 19:3f82c1161fd2 592 font_angle_t angle = normal,
WiredHome 19:3f82c1161fd2 593 HorizontalScale hScale = 1,
WiredHome 19:3f82c1161fd2 594 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 595 alignment_t alignment = align_none);
WiredHome 19:3f82c1161fd2 596
WiredHome 19:3f82c1161fd2 597 /// Control the font size
WiredHome 19:3f82c1161fd2 598 ///
WiredHome 19:3f82c1161fd2 599 /// This command lets you set the font enlargement for both horizontal
WiredHome 19:3f82c1161fd2 600 /// and vertical, independent of the rotation, background, and
WiredHome 19:3f82c1161fd2 601 /// alignment. @see SetTextFontControl.
WiredHome 19:3f82c1161fd2 602 ///
WiredHome 19:3f82c1161fd2 603 /// @param hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 604 /// and scales the font size by this amount.
WiredHome 40:04aa280dfa39 605 /// @param vScale is an optional parameter that defaults to the hScale value,
WiredHome 40:04aa280dfa39 606 /// but can be 1, 2, 3, or 4, and scales the font size by this amount.
WiredHome 40:04aa280dfa39 607 ///
WiredHome 40:04aa280dfa39 608 /// @code
WiredHome 40:04aa280dfa39 609 /// lcd.SetTextFontSize(2); // Set the font to 2x normal size
WiredHome 56:7a85d226ad0d 610 /// lcd.puts("Two times");
WiredHome 40:04aa280dfa39 611 /// lcd.SetTextFontSize(2,3); // Set the font to 2x Width and 3x Height
WiredHome 56:7a85d226ad0d 612 /// lcd.puts("2*2 3*h");
WiredHome 40:04aa280dfa39 613 /// lcd.SetTextFontSize(); // Restore to normal size in both dimensions
WiredHome 56:7a85d226ad0d 614 /// lcd.puts("normal");
WiredHome 40:04aa280dfa39 615 /// @endcode
WiredHome 19:3f82c1161fd2 616 ///
WiredHome 19:3f82c1161fd2 617 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 618 /// the command is not executed.
WiredHome 19:3f82c1161fd2 619 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 620 ///
WiredHome 40:04aa280dfa39 621 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
WiredHome 19:3f82c1161fd2 622
WiredHome 19:3f82c1161fd2 623 /// put a character on the screen.
WiredHome 19:3f82c1161fd2 624 ///
WiredHome 19:3f82c1161fd2 625 /// @param c is the character.
WiredHome 19:3f82c1161fd2 626 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 627 ///
WiredHome 19:3f82c1161fd2 628 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 629
WiredHome 19:3f82c1161fd2 630 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 631 ///
WiredHome 56:7a85d226ad0d 632 /// @code
WiredHome 56:7a85d226ad0d 633 /// lcd.puts("Test STring");
WiredHome 56:7a85d226ad0d 634 /// @endcode
WiredHome 56:7a85d226ad0d 635 ///
WiredHome 19:3f82c1161fd2 636 /// @param string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 637 ///
WiredHome 19:3f82c1161fd2 638 void puts(const char * string);
WiredHome 19:3f82c1161fd2 639
WiredHome 19:3f82c1161fd2 640 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 641 ///
WiredHome 56:7a85d226ad0d 642 /// @code
WiredHome 56:7a85d226ad0d 643 /// lcd.puts(10,25, "Test STring");
WiredHome 56:7a85d226ad0d 644 /// @endcode
WiredHome 56:7a85d226ad0d 645 ///
WiredHome 19:3f82c1161fd2 646 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 647 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 648 /// @param string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 649 ///
WiredHome 37:f19b7e7449dc 650 void puts(loc_t x, loc_t y, const char * string);
WiredHome 19:3f82c1161fd2 651
WiredHome 19:3f82c1161fd2 652 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 653 /// the memory cursor.
WiredHome 19:3f82c1161fd2 654 ///
WiredHome 19:3f82c1161fd2 655 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 656 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 657 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 658 ///
WiredHome 37:f19b7e7449dc 659 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 660
WiredHome 41:2956a0a221e5 661 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 662 /// the memory read cursor.
WiredHome 41:2956a0a221e5 663 ///
WiredHome 41:2956a0a221e5 664 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 41:2956a0a221e5 665 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 41:2956a0a221e5 666 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 667 ///
WiredHome 41:2956a0a221e5 668 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 669
WiredHome 19:3f82c1161fd2 670 /// Set the window, which controls where items are written to the screen.
WiredHome 19:3f82c1161fd2 671 ///
WiredHome 19:3f82c1161fd2 672 /// When something hits the window width, it wraps back to the left side
WiredHome 19:3f82c1161fd2 673 /// and down a row. If the initial write is outside the window, it will
WiredHome 19:3f82c1161fd2 674 /// be captured into the window when it crosses a boundary.
WiredHome 19:3f82c1161fd2 675 ///
WiredHome 56:7a85d226ad0d 676 /// @code
WiredHome 56:7a85d226ad0d 677 /// lcd.window(10,10, 80,80);
WiredHome 56:7a85d226ad0d 678 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 56:7a85d226ad0d 679 /// @endcode
WiredHome 56:7a85d226ad0d 680 ///
WiredHome 19:3f82c1161fd2 681 /// @param x is the left edge in pixels.
WiredHome 19:3f82c1161fd2 682 /// @param y is the top edge in pixels.
WiredHome 19:3f82c1161fd2 683 /// @param width is the window width in pixels.
WiredHome 19:3f82c1161fd2 684 /// @param height is the window height in pixels.
WiredHome 19:3f82c1161fd2 685 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 686 ///
WiredHome 37:f19b7e7449dc 687 virtual RetCode_t window(loc_t x, loc_t y, dim_t width, dim_t height);
WiredHome 19:3f82c1161fd2 688
WiredHome 61:8f3153bf0baa 689 /// Clear either the specified layer, or the active layer.
WiredHome 19:3f82c1161fd2 690 ///
WiredHome 61:8f3153bf0baa 691 /// The behavior is to clear the whole screen for the specified
WiredHome 61:8f3153bf0baa 692 /// layer. When not specified, the active drawing layer is cleared.
WiredHome 61:8f3153bf0baa 693 /// This command can also be used to specifically clear either,
WiredHome 61:8f3153bf0baa 694 /// or both layers. @see clsw().
WiredHome 19:3f82c1161fd2 695 ///
WiredHome 56:7a85d226ad0d 696 /// @code
WiredHome 56:7a85d226ad0d 697 /// lcd.cls();
WiredHome 56:7a85d226ad0d 698 /// @endcode
WiredHome 56:7a85d226ad0d 699 ///
WiredHome 61:8f3153bf0baa 700 /// @param layers is optional. If not provided, the active layer
WiredHome 61:8f3153bf0baa 701 /// is cleared. If bit 0 is set, layer 0 is cleared, if bit
WiredHome 61:8f3153bf0baa 702 /// 1 is set, layer 1 is cleared. If both are set, both layers
WiredHome 61:8f3153bf0baa 703 /// are cleared. Any other value does not cause an action.
WiredHome 61:8f3153bf0baa 704 ///
WiredHome 19:3f82c1161fd2 705 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 706 ///
WiredHome 61:8f3153bf0baa 707 virtual RetCode_t cls(uint16_t layers = 0);
WiredHome 19:3f82c1161fd2 708
WiredHome 19:3f82c1161fd2 709 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 710 ///
WiredHome 19:3f82c1161fd2 711 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 712 /// parameter, the action can be restricted to the active window, which
WiredHome 32:0e4f2ae512e2 713 /// can be set with the @see window method.
WiredHome 19:3f82c1161fd2 714 ///
WiredHome 56:7a85d226ad0d 715 /// @code
WiredHome 56:7a85d226ad0d 716 /// lcd.window(20,20, 40,10);
WiredHome 56:7a85d226ad0d 717 /// lcd.clsw();
WiredHome 56:7a85d226ad0d 718 /// @endcode
WiredHome 56:7a85d226ad0d 719 ///
WiredHome 19:3f82c1161fd2 720 /// @param region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 721 /// or may be set to ACTIVEWINDOW.
WiredHome 19:3f82c1161fd2 722 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 723 ///
WiredHome 19:3f82c1161fd2 724 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 725
WiredHome 19:3f82c1161fd2 726 /// Set the background color.
WiredHome 19:3f82c1161fd2 727 ///
WiredHome 19:3f82c1161fd2 728 /// @param color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 729 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 730 ///
WiredHome 19:3f82c1161fd2 731 virtual RetCode_t background(color_t color);
WiredHome 19:3f82c1161fd2 732
WiredHome 19:3f82c1161fd2 733 /// Set the background color.
WiredHome 19:3f82c1161fd2 734 ///
WiredHome 19:3f82c1161fd2 735 /// @param r is the red element of the color.
WiredHome 19:3f82c1161fd2 736 /// @param g is the green element of the color.
WiredHome 19:3f82c1161fd2 737 /// @param b is the blue element of the color.
WiredHome 19:3f82c1161fd2 738 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 739 ///
WiredHome 19:3f82c1161fd2 740 virtual RetCode_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 741
WiredHome 19:3f82c1161fd2 742 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 743 ///
WiredHome 19:3f82c1161fd2 744 /// @param color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 745 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 746 ///
WiredHome 19:3f82c1161fd2 747 virtual RetCode_t foreground(color_t color);
WiredHome 19:3f82c1161fd2 748
WiredHome 19:3f82c1161fd2 749 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 750 ///
WiredHome 37:f19b7e7449dc 751 /// @param r is the red element of the color.
WiredHome 37:f19b7e7449dc 752 /// @param g is the green element of the color.
WiredHome 37:f19b7e7449dc 753 /// @param b is the blue element of the color.
WiredHome 19:3f82c1161fd2 754 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 755 ///
WiredHome 37:f19b7e7449dc 756 virtual RetCode_t foreground(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 757
WiredHome 19:3f82c1161fd2 758 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 759 ///
WiredHome 19:3f82c1161fd2 760 /// @returns the current foreground color.
WiredHome 19:3f82c1161fd2 761 ///
WiredHome 37:f19b7e7449dc 762 color_t GetForeColor(void);
WiredHome 19:3f82c1161fd2 763
WiredHome 19:3f82c1161fd2 764 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 765 ///
WiredHome 41:2956a0a221e5 766 /// @note Unlike many other operations, this does not
WiredHome 41:2956a0a221e5 767 /// set the forecolor!
WiredHome 19:3f82c1161fd2 768 ///
WiredHome 19:3f82c1161fd2 769 /// @param x is the horizontal offset to this pixel.
WiredHome 19:3f82c1161fd2 770 /// @param y is the vertical offset to this pixel.
WiredHome 19:3f82c1161fd2 771 /// @param color defines the color for the pixel.
WiredHome 19:3f82c1161fd2 772 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 773 ///
WiredHome 37:f19b7e7449dc 774 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color);
WiredHome 19:3f82c1161fd2 775
WiredHome 19:3f82c1161fd2 776 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 777 ///
WiredHome 19:3f82c1161fd2 778 /// @param x is the horizontal offset to this pixel.
WiredHome 19:3f82c1161fd2 779 /// @param y is the veritical offset to this pixel.
WiredHome 19:3f82c1161fd2 780 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 781 ///
WiredHome 37:f19b7e7449dc 782 virtual RetCode_t pixel(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 783
WiredHome 41:2956a0a221e5 784 /// Get a pixel from the display.
WiredHome 41:2956a0a221e5 785 ///
WiredHome 41:2956a0a221e5 786 /// @param x is the horizontal offset to this pixel.
WiredHome 41:2956a0a221e5 787 /// @param y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 788 /// @returns the pixel. see @color_t
WiredHome 41:2956a0a221e5 789 ///
WiredHome 41:2956a0a221e5 790 virtual color_t getPixel(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 791
WiredHome 41:2956a0a221e5 792 /// Write a stream of pixels to the display.
WiredHome 41:2956a0a221e5 793 ///
WiredHome 41:2956a0a221e5 794 /// @param p is a pointer to a color_t array to write.
WiredHome 41:2956a0a221e5 795 /// @param count is the number of pixels to write.
WiredHome 41:2956a0a221e5 796 /// @param x is the horizontal position on the display.
WiredHome 41:2956a0a221e5 797 /// @param y is the vertical position on the display.
WiredHome 41:2956a0a221e5 798 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 799 ///
WiredHome 41:2956a0a221e5 800 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 801
WiredHome 41:2956a0a221e5 802 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 803 ///
WiredHome 41:2956a0a221e5 804 /// @param p is a pointer to a color_t array to accept the stream.
WiredHome 41:2956a0a221e5 805 /// @param count is the number of pixels to read.
WiredHome 41:2956a0a221e5 806 /// @param x is the horizontal offset to this pixel.
WiredHome 41:2956a0a221e5 807 /// @param y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 808 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 809 ///
WiredHome 41:2956a0a221e5 810 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 811
WiredHome 19:3f82c1161fd2 812 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 813 ///
WiredHome 19:3f82c1161fd2 814 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 815 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 816 ///
WiredHome 19:3f82c1161fd2 817 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 818 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 819 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 820 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 821 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 822 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 823 ///
WiredHome 56:7a85d226ad0d 824 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color);
WiredHome 19:3f82c1161fd2 825
WiredHome 19:3f82c1161fd2 826 /// Draw a line
WiredHome 19:3f82c1161fd2 827 ///
WiredHome 19:3f82c1161fd2 828 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 829 ///
WiredHome 19:3f82c1161fd2 830 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 831 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 832 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 833 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 834 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 835 ///
WiredHome 37:f19b7e7449dc 836 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2);
WiredHome 19:3f82c1161fd2 837
WiredHome 19:3f82c1161fd2 838 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 839 ///
WiredHome 19:3f82c1161fd2 840 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 841 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 842 ///
WiredHome 19:3f82c1161fd2 843 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 844 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 845 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 846 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 847 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 848 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 849 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 850 ///
WiredHome 37:f19b7e7449dc 851 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 852 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 853
WiredHome 19:3f82c1161fd2 854 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 855 ///
WiredHome 19:3f82c1161fd2 856 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 857 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 858 ///
WiredHome 19:3f82c1161fd2 859 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 860 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 861 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 862 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 863 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 864 /// @param fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 19:3f82c1161fd2 865 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 866 ///
WiredHome 37:f19b7e7449dc 867 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 868 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 869
WiredHome 19:3f82c1161fd2 870 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 871 ///
WiredHome 19:3f82c1161fd2 872 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 873 ///
WiredHome 19:3f82c1161fd2 874 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 875 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 876 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 877 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 878 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 879 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 880 ///
WiredHome 37:f19b7e7449dc 881 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 882 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 883
WiredHome 19:3f82c1161fd2 884 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 885 ///
WiredHome 21:3c1efb192927 886 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 887 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 888 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 889 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 890 ///
WiredHome 19:3f82c1161fd2 891 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 892 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 893 ///
WiredHome 21:3c1efb192927 894 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 895 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 896 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 897 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 898 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 899 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 900 /// is returned.
WiredHome 22:f6ea795eb541 901 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 902 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 903 /// is returned.
WiredHome 19:3f82c1161fd2 904 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 905 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 906 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 907 ///
WiredHome 37:f19b7e7449dc 908 RetCode_t fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 909 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 910
WiredHome 19:3f82c1161fd2 911 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 912 ///
WiredHome 21:3c1efb192927 913 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 914 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 915 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 916 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 917 ///
WiredHome 19:3f82c1161fd2 918 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 919 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 920 ///
WiredHome 21:3c1efb192927 921 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 922 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 923 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 924 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 925 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 926 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 927 /// is returned.
WiredHome 22:f6ea795eb541 928 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 929 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 930 /// is returned.
WiredHome 19:3f82c1161fd2 931 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 932 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 933 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 934 ///
WiredHome 37:f19b7e7449dc 935 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 936 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 937
WiredHome 19:3f82c1161fd2 938 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 939 ///
WiredHome 21:3c1efb192927 940 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 941 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 942 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 943 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 944 ///
WiredHome 21:3c1efb192927 945 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 946 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 947 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 948 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 949 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 950 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 951 /// is returned.
WiredHome 22:f6ea795eb541 952 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 953 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 954 /// is returned.
WiredHome 19:3f82c1161fd2 955 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 956 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 957 ///
WiredHome 37:f19b7e7449dc 958 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 959 dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 960
WiredHome 19:3f82c1161fd2 961 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 962 ///
WiredHome 19:3f82c1161fd2 963 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 964 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 965 ///
WiredHome 19:3f82c1161fd2 966 /// @param x1 is the horizontal for point 1.
WiredHome 21:3c1efb192927 967 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 968 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 969 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 970 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 971 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 972 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 973 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 974 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 975 ///
WiredHome 37:f19b7e7449dc 976 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 977 loc_t x3, loc_t y3, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 978
WiredHome 19:3f82c1161fd2 979 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 980 ///
WiredHome 19:3f82c1161fd2 981 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 982 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 983 ///
WiredHome 19:3f82c1161fd2 984 /// @param x1 is the horizontal for point 1.
WiredHome 19:3f82c1161fd2 985 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 986 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 987 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 988 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 989 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 990 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 991 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 992 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 993 ///
WiredHome 37:f19b7e7449dc 994 RetCode_t filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 995 loc_t x3, loc_t y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 996
WiredHome 19:3f82c1161fd2 997 /// Draw a triangle
WiredHome 19:3f82c1161fd2 998 ///
WiredHome 19:3f82c1161fd2 999 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 1000 ///
WiredHome 19:3f82c1161fd2 1001 /// @param x1 is the horizontal for point 1.
WiredHome 19:3f82c1161fd2 1002 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 1003 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 1004 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 1005 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 1006 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 1007 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 1008 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1009 ///
WiredHome 37:f19b7e7449dc 1010 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 1011 loc_t x3, loc_t y3, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1012
WiredHome 19:3f82c1161fd2 1013 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 1014 ///
WiredHome 19:3f82c1161fd2 1015 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1016 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1017 ///
WiredHome 19:3f82c1161fd2 1018 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 1019 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 1020 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 1021 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 1022 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1023 ///
WiredHome 37:f19b7e7449dc 1024 RetCode_t circle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1025
WiredHome 19:3f82c1161fd2 1026 /// Draw a filled circle using 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 19:3f82c1161fd2 1031 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 1032 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 1033 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 1034 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 1035 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1036 ///
WiredHome 37:f19b7e7449dc 1037 RetCode_t fillcircle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 1038
WiredHome 19:3f82c1161fd2 1039 /// Draw a circle.
WiredHome 19:3f82c1161fd2 1040 ///
WiredHome 19:3f82c1161fd2 1041 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 1042 ///
WiredHome 19:3f82c1161fd2 1043 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 1044 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 1045 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 1046 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1047 ///
WiredHome 37:f19b7e7449dc 1048 RetCode_t circle(loc_t x, loc_t y, dim_t radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1049
WiredHome 19:3f82c1161fd2 1050 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 1051 ///
WiredHome 19:3f82c1161fd2 1052 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1053 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1054 ///
WiredHome 19:3f82c1161fd2 1055 /// @param x is the horizontal center of the ellipse.
WiredHome 19:3f82c1161fd2 1056 /// @param y is the vertical center of the ellipse.
WiredHome 22:f6ea795eb541 1057 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 22:f6ea795eb541 1058 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 19:3f82c1161fd2 1059 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 1060 /// @param fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 1061 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1062 ///
WiredHome 37:f19b7e7449dc 1063 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 19:3f82c1161fd2 1064 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1065
WiredHome 25:9556a3a9b7cc 1066 /// Draw a filled Ellipse using the specified color
WiredHome 25:9556a3a9b7cc 1067 ///
WiredHome 25:9556a3a9b7cc 1068 /// @note As a side effect, this changes the current
WiredHome 25:9556a3a9b7cc 1069 /// foreground color for subsequent operations.
WiredHome 25:9556a3a9b7cc 1070 ///
WiredHome 25:9556a3a9b7cc 1071 /// @param x is the horizontal center of the ellipse.
WiredHome 25:9556a3a9b7cc 1072 /// @param y is the vertical center of the ellipse.
WiredHome 25:9556a3a9b7cc 1073 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 25:9556a3a9b7cc 1074 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 25:9556a3a9b7cc 1075 /// @param color defines the foreground color.
WiredHome 25:9556a3a9b7cc 1076 /// @param fillit defines whether the circle is filled or not.
WiredHome 25:9556a3a9b7cc 1077 /// @returns success/failure code. @see RetCode_t.
WiredHome 25:9556a3a9b7cc 1078 ///
WiredHome 37:f19b7e7449dc 1079 RetCode_t fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 25:9556a3a9b7cc 1080 color_t color, fill_t fillit = FILL);
WiredHome 25:9556a3a9b7cc 1081
WiredHome 19:3f82c1161fd2 1082 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 1083 ///
WiredHome 19:3f82c1161fd2 1084 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 1085 ///
WiredHome 19:3f82c1161fd2 1086 /// @param x is the horizontal center of the ellipse.
WiredHome 19:3f82c1161fd2 1087 /// @param y is the vertical center of the ellipse.
WiredHome 22:f6ea795eb541 1088 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 22:f6ea795eb541 1089 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 19:3f82c1161fd2 1090 /// @param fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 1091 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1092 ///
WiredHome 37:f19b7e7449dc 1093 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 1094
WiredHome 19:3f82c1161fd2 1095 /// Control display power
WiredHome 19:3f82c1161fd2 1096 ///
WiredHome 19:3f82c1161fd2 1097 /// @param on when set to true will turn on the display, when false it is turned off.
WiredHome 19:3f82c1161fd2 1098 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1099 ///
WiredHome 19:3f82c1161fd2 1100 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 1101
WiredHome 19:3f82c1161fd2 1102 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 1103 ///
WiredHome 19:3f82c1161fd2 1104 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1105 ///
WiredHome 19:3f82c1161fd2 1106 RetCode_t Reset(void);
WiredHome 19:3f82c1161fd2 1107
WiredHome 19:3f82c1161fd2 1108 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 1109 ///
WiredHome 19:3f82c1161fd2 1110 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 1111 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 1112 ///
WiredHome 19:3f82c1161fd2 1113 /// @param brightness ranges from 0 (off) to 255 (full on)
WiredHome 19:3f82c1161fd2 1114 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1115 ///
WiredHome 19:3f82c1161fd2 1116 RetCode_t Backlight_u8(unsigned char brightness);
WiredHome 19:3f82c1161fd2 1117
WiredHome 19:3f82c1161fd2 1118 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 1119 ///
WiredHome 19:3f82c1161fd2 1120 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 1121 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 1122 ///
WiredHome 19:3f82c1161fd2 1123 /// @param brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 19:3f82c1161fd2 1124 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1125 ///
WiredHome 19:3f82c1161fd2 1126 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 1127
WiredHome 32:0e4f2ae512e2 1128 /// Select a bitmap font (provided by the user) for all subsequent text.
WiredHome 19:3f82c1161fd2 1129 ///
WiredHome 19:3f82c1161fd2 1130 /// @note Tool to create the fonts is accessible from its creator
WiredHome 19:3f82c1161fd2 1131 /// available at http://www.mikroe.com.
WiredHome 19:3f82c1161fd2 1132 /// Change the data to an array of type char[].
WiredHome 19:3f82c1161fd2 1133 ///
WiredHome 19:3f82c1161fd2 1134 /// @param font is a pointer to a specially formed font array.
WiredHome 19:3f82c1161fd2 1135 /// This special font array has a 4-byte header, followed by
WiredHome 19:3f82c1161fd2 1136 /// the data:
WiredHome 19:3f82c1161fd2 1137 /// - the number of bytes per char
WiredHome 19:3f82c1161fd2 1138 /// - the vertical size in pixels for each character
WiredHome 19:3f82c1161fd2 1139 /// - the horizontal size in pixels for each character
WiredHome 19:3f82c1161fd2 1140 /// - the number of bytes per vertical line (width of the array)
WiredHome 19:3f82c1161fd2 1141 /// @returns error code.
WiredHome 19:3f82c1161fd2 1142 ///
WiredHome 30:e0f2da88bdf6 1143 virtual RetCode_t set_font(const unsigned char * font = NULL);
WiredHome 19:3f82c1161fd2 1144
WiredHome 19:3f82c1161fd2 1145 /// Get the RGB value for a DOS color.
WiredHome 19:3f82c1161fd2 1146 ///
WiredHome 19:3f82c1161fd2 1147 /// @param i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 1148 /// @returns the RGB color of the selected index, or 0
WiredHome 19:3f82c1161fd2 1149 /// if the index is out of bounds.
WiredHome 19:3f82c1161fd2 1150 ///
WiredHome 19:3f82c1161fd2 1151 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 1152
WiredHome 19:3f82c1161fd2 1153 /// Get the color name (string) for a DOS color.
WiredHome 19:3f82c1161fd2 1154 ///
WiredHome 19:3f82c1161fd2 1155 /// @param i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 1156 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 1157 /// or NULL if the index is out of bounds.
WiredHome 19:3f82c1161fd2 1158 ///
WiredHome 19:3f82c1161fd2 1159 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 1160
WiredHome 55:dfbabef7003e 1161 /// Advanced method indicating the start of a graphics stream.
WiredHome 55:dfbabef7003e 1162 ///
WiredHome 55:dfbabef7003e 1163 /// This is called prior to a stream of pixel data being sent.
WiredHome 55:dfbabef7003e 1164 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 1165 /// class in order to prepare the hardware to accept the streaming
WiredHome 55:dfbabef7003e 1166 /// data.
WiredHome 55:dfbabef7003e 1167 ///
WiredHome 55:dfbabef7003e 1168 /// Following this command, a series of @see _putp() commands can
WiredHome 55:dfbabef7003e 1169 /// be used to send individual pixels to the screen.
WiredHome 55:dfbabef7003e 1170 ///
WiredHome 55:dfbabef7003e 1171 /// To conclude the graphics stream, @see _EndGraphicsStream should
WiredHome 55:dfbabef7003e 1172 /// be callled.
WiredHome 55:dfbabef7003e 1173 ///
WiredHome 55:dfbabef7003e 1174 /// @returns error code.
WiredHome 55:dfbabef7003e 1175 ///
WiredHome 55:dfbabef7003e 1176 virtual RetCode_t _StartGraphicsStream(void);
WiredHome 55:dfbabef7003e 1177
WiredHome 55:dfbabef7003e 1178 /// Advanced method to put a single color pixel to the screen.
WiredHome 55:dfbabef7003e 1179 ///
WiredHome 55:dfbabef7003e 1180 /// This method may be called as many times as necessary after
WiredHome 55:dfbabef7003e 1181 /// @see _StartGraphicsStream() is called, and it should be followed
WiredHome 55:dfbabef7003e 1182 /// by _EndGraphicsStream.
WiredHome 55:dfbabef7003e 1183 ///
WiredHome 55:dfbabef7003e 1184 /// @param pixel is a color value to be put on the screen.
WiredHome 55:dfbabef7003e 1185 /// @returns error code.
WiredHome 55:dfbabef7003e 1186 ///
WiredHome 55:dfbabef7003e 1187 virtual RetCode_t _putp(color_t pixel);
WiredHome 55:dfbabef7003e 1188
WiredHome 55:dfbabef7003e 1189 /// Advanced method indicating the end of a graphics stream.
WiredHome 55:dfbabef7003e 1190 ///
WiredHome 55:dfbabef7003e 1191 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 55:dfbabef7003e 1192 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 1193 /// class in order to stop the hardware from accept the streaming
WiredHome 55:dfbabef7003e 1194 /// data.
WiredHome 55:dfbabef7003e 1195 ///
WiredHome 55:dfbabef7003e 1196 /// @returns error code.
WiredHome 55:dfbabef7003e 1197 ///
WiredHome 55:dfbabef7003e 1198 virtual RetCode_t _EndGraphicsStream(void);
WiredHome 19:3f82c1161fd2 1199
WiredHome 57:bd53a9e165a1 1200 /// Set the SPI port frequency (in Hz).
WiredHome 57:bd53a9e165a1 1201 ///
WiredHome 66:468a11f05580 1202 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 66:468a11f05580 1203 /// its capabilities. The RA8875 can accept writes via SPI faster
WiredHome 66:468a11f05580 1204 /// than a read can be performed. The frequency set by this API
WiredHome 66:468a11f05580 1205 /// is for the SPI writes. It will automatically reduce the SPI
WiredHome 66:468a11f05580 1206 /// clock rate when a read is performed, and restore it for the
WiredHome 66:468a11f05580 1207 /// next write.
WiredHome 57:bd53a9e165a1 1208 ///
WiredHome 66:468a11f05580 1209 /// @note The primary effect of this is to recover more CPU cycles
WiredHome 66:468a11f05580 1210 /// for your application code. Keep in mind that when more than
WiredHome 66:468a11f05580 1211 /// one command is sent to the display controller, that it
WiredHome 66:468a11f05580 1212 /// will wait for the controller to finish the prior command.
WiredHome 66:468a11f05580 1213 /// In this case, the performance is limited by the RA8875.
WiredHome 57:bd53a9e165a1 1214 ///
WiredHome 66:468a11f05580 1215 /// @param Hz is the frequency in Hz, tested range includes the
WiredHome 66:468a11f05580 1216 /// range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
WiredHome 66:468a11f05580 1217 /// outside this range will be accepted, but operation may
WiredHome 66:468a11f05580 1218 /// be unreliable.
WiredHome 57:bd53a9e165a1 1219 /// @returns success/failure code. @see RetCode_t.
WiredHome 57:bd53a9e165a1 1220 ///
WiredHome 57:bd53a9e165a1 1221 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ);
WiredHome 57:bd53a9e165a1 1222
WiredHome 57:bd53a9e165a1 1223
WiredHome 19:3f82c1161fd2 1224 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 1225 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 1226 void ClearPerformance();
WiredHome 19:3f82c1161fd2 1227
WiredHome 66:468a11f05580 1228 /// Count idle time.
WiredHome 66:468a11f05580 1229 ///
WiredHome 66:468a11f05580 1230 /// @param t is the amount of idle time to accumulate.
WiredHome 66:468a11f05580 1231 ///
WiredHome 66:468a11f05580 1232 void CountIdleTime(uint32_t t);
WiredHome 66:468a11f05580 1233
WiredHome 19:3f82c1161fd2 1234 /// Report the performance metrics for drawing functions using
WiredHome 41:2956a0a221e5 1235 /// the available serial channel.
WiredHome 41:2956a0a221e5 1236 ///
WiredHome 41:2956a0a221e5 1237 /// @param pc is the serial channel to write to.
WiredHome 41:2956a0a221e5 1238 ///
WiredHome 41:2956a0a221e5 1239 void ReportPerformance(Serial & pc);
WiredHome 19:3f82c1161fd2 1240 #endif
WiredHome 19:3f82c1161fd2 1241
hexley 54:e117ad10fba6 1242 // Touch Panel public macros
hexley 54:e117ad10fba6 1243
hexley 54:e117ad10fba6 1244 /* Touch Panel Enable/Disable Reg TPCR0[7] */
hexley 54:e117ad10fba6 1245 #define TP_ENABLE ((uint8_t)(1<<7))
hexley 54:e117ad10fba6 1246 #define TP_DISABLE ((uint8_t)(0<<7))
hexley 54:e117ad10fba6 1247
hexley 54:e117ad10fba6 1248 /* Touch Panel operating mode Reg TPCR1[6] */
hexley 54:e117ad10fba6 1249 #define TP_MODE_AUTO ((uint8_t)(0<<6))
hexley 54:e117ad10fba6 1250 #define TP_MODE_MANUAL ((uint8_t)(1<<6))
hexley 54:e117ad10fba6 1251
hexley 54:e117ad10fba6 1252 /* Touch Panel debounce Reg TPCR1[2] */
hexley 54:e117ad10fba6 1253 #define TP_DEBOUNCE_OFF ((uint8_t)(0<<2))
hexley 54:e117ad10fba6 1254 #define TP_DEBOUNCE_ON ((uint8_t)(1<<2))
hexley 54:e117ad10fba6 1255
hexley 54:e117ad10fba6 1256 /* Touch Panel manual modes Reg TPCR1[1:0] */
hexley 54:e117ad10fba6 1257 #define TP_MANUAL_IDLE 0
hexley 54:e117ad10fba6 1258 #define TP_MANUAL_WAIT 1
hexley 54:e117ad10fba6 1259 #define TP_MANUAL_LATCH_X 2
hexley 54:e117ad10fba6 1260 #define TP_MANUAL_LATCH_Y 3
hexley 54:e117ad10fba6 1261
hexley 54:e117ad10fba6 1262 /* Touch Panel ADC Clock modes Reg TPCR0[2:0] */
hexley 54:e117ad10fba6 1263 #define TP_ADC_CLKDIV_1 0
hexley 54:e117ad10fba6 1264 #define TP_ADC_CLKDIV_2 1
hexley 54:e117ad10fba6 1265 #define TP_ADC_CLKDIV_4 2
hexley 54:e117ad10fba6 1266 #define TP_ADC_CLKDIV_8 3
hexley 54:e117ad10fba6 1267 #define TP_ADC_CLKDIV_16 4
hexley 54:e117ad10fba6 1268 #define TP_ADC_CLKDIV_32 5
hexley 54:e117ad10fba6 1269 #define TP_ADC_CLKDIV_64 6
hexley 54:e117ad10fba6 1270 #define TP_ADC_CLKDIV_128 7
hexley 54:e117ad10fba6 1271
hexley 54:e117ad10fba6 1272
hexley 54:e117ad10fba6 1273 /* Touch Panel Sample Time Reg TPCR0[6:4] */
hexley 54:e117ad10fba6 1274 #define TP_ADC_SAMPLE_512_CLKS ((uint8_t)(0<<4))
hexley 54:e117ad10fba6 1275 #define TP_ADC_SAMPLE_1024_CLKS ((uint8_t)(1<<4))
hexley 54:e117ad10fba6 1276 #define TP_ADC_SAMPLE_2048_CLKS ((uint8_t)(2<<4))
hexley 54:e117ad10fba6 1277 #define TP_ADC_SAMPLE_4096_CLKS ((uint8_t)(3<<4))
hexley 54:e117ad10fba6 1278 #define TP_ADC_SAMPLE_8192_CLKS ((uint8_t)(4<<4))
hexley 54:e117ad10fba6 1279 #define TP_ADC_SAMPLE_16384_CLKS ((uint8_t)(5<<4))
hexley 54:e117ad10fba6 1280 #define TP_ADC_SAMPLE_32768_CLKS ((uint8_t)(6<<4))
hexley 54:e117ad10fba6 1281 #define TP_ADC_SAMPLE_65536_CLKS ((uint8_t)(7<<4))
hexley 54:e117ad10fba6 1282
hexley 54:e117ad10fba6 1283 /* RA8875 interrupt enable/flag/clear masks */
hexley 54:e117ad10fba6 1284 #define RA8875_INT_KEYSCAN ((uint8_t)(1<<4)) /**< KEYSCAN interrupts */
hexley 54:e117ad10fba6 1285 #define RA8875_INT_DMA ((uint8_t)(1<<3)) /**< DMA interrupts */
hexley 54:e117ad10fba6 1286 #define RA8875_INT_TP ((uint8_t)(1<<2)) /**< Touch panel interrupts */
hexley 54:e117ad10fba6 1287 #define RA8875_INT_BTE ((uint8_t)(1<<1)) /**< BTE process complete interrupts */
hexley 54:e117ad10fba6 1288 #define RA8875_INT_BTEMCU_FONTWR ((uint8_t)(1<<0)) /**< BTE-MCU-R/W or Font-Write interrupts */
hexley 54:e117ad10fba6 1289
hexley 54:e117ad10fba6 1290
WiredHome 19:3f82c1161fd2 1291 private:
hexley 54:e117ad10fba6 1292 /// Touch Panel register name definitions
hexley 54:e117ad10fba6 1293 #define TPCR0 0x70
hexley 54:e117ad10fba6 1294 #define TPCR1 0x71
hexley 54:e117ad10fba6 1295 #define TPXH 0x72
hexley 54:e117ad10fba6 1296 #define TPYH 0x73
hexley 54:e117ad10fba6 1297 #define TPXYL 0x74
hexley 54:e117ad10fba6 1298 #define INTC1 0xF0
hexley 54:e117ad10fba6 1299 #define INTC2 0xF1
hexley 54:e117ad10fba6 1300
hexley 54:e117ad10fba6 1301 /// Specify the default settings for the Touch Panel, where different from the chip defaults
hexley 54:e117ad10fba6 1302 #define TP_MODE_DEFAULT TP_MODE_AUTO
hexley 54:e117ad10fba6 1303 #define TP_DEBOUNCE_DEFAULT TP_DEBOUNCE_ON
hexley 54:e117ad10fba6 1304 #define TP_ADC_CLKDIV_DEFAULT TP_ADC_CLKDIV_8
hexley 54:e117ad10fba6 1305
hexley 54:e117ad10fba6 1306 #define TP_ADC_SAMPLE_DEFAULT_CLKS TP_ADC_SAMPLE_8192_CLKS
hexley 54:e117ad10fba6 1307
hexley 54:e117ad10fba6 1308 /// Other Touch Panel params
hexley 54:e117ad10fba6 1309 #define TPBUFSIZE 16 // Depth of the averaging buffers for x and y data
hexley 54:e117ad10fba6 1310
hexley 54:e117ad10fba6 1311
WiredHome 19:3f82c1161fd2 1312 /// Initialize the chip, which is normally done as part of the
WiredHome 61:8f3153bf0baa 1313 /// constructor, so not typically called by the user.
WiredHome 19:3f82c1161fd2 1314 ///
WiredHome 43:3becae133285 1315 /// @note This API permits configuration, however it is not [yet]
WiredHome 43:3becae133285 1316 /// available to the end user. Be sure the parameters
WiredHome 43:3becae133285 1317 /// are consistent with each other - see the RA8875 user
WiredHome 43:3becae133285 1318 /// manual.
WiredHome 43:3becae133285 1319 ///
WiredHome 43:3becae133285 1320 /// @param width in pixels to configure the display for.
WiredHome 43:3becae133285 1321 /// @param height in pixels to configure the display for.
WiredHome 43:3becae133285 1322 /// @param color_bpp can be either 8 or 16, but must be consistent
WiredHome 43:3becae133285 1323 /// with the width and height parameters.
WiredHome 19:3f82c1161fd2 1324 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1325 ///
WiredHome 43:3becae133285 1326 RetCode_t init(int width, int height, int color_bpp);
WiredHome 19:3f82c1161fd2 1327
WiredHome 29:422616aa04bd 1328 /// Internal function to put a character using the built-in (internal) font engine
WiredHome 29:422616aa04bd 1329 ///
WiredHome 29:422616aa04bd 1330 /// @param is the character to put to the screen.
WiredHome 29:422616aa04bd 1331 /// @returns the character put.
WiredHome 29:422616aa04bd 1332 ///
WiredHome 29:422616aa04bd 1333 int _internal_putc(int c);
WiredHome 29:422616aa04bd 1334
WiredHome 29:422616aa04bd 1335 /// Internal function to put a character using the external font engine
WiredHome 29:422616aa04bd 1336 ///
WiredHome 29:422616aa04bd 1337 /// @param is the character to put to the screen.
WiredHome 29:422616aa04bd 1338 /// @returns the character put.
WiredHome 29:422616aa04bd 1339 ///
WiredHome 29:422616aa04bd 1340 int _external_putc(int c);
WiredHome 29:422616aa04bd 1341
WiredHome 19:3f82c1161fd2 1342 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 1343 ///
WiredHome 19:3f82c1161fd2 1344 /// @param chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 1345 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 1346 /// the pin selection is the invert of this.
WiredHome 19:3f82c1161fd2 1347 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1348 ///
WiredHome 19:3f82c1161fd2 1349 RetCode_t select(bool chipsel);
WiredHome 19:3f82c1161fd2 1350
WiredHome 66:468a11f05580 1351 /// Wait while the status register indicates the controller is busy.
WiredHome 66:468a11f05580 1352 ///
WiredHome 66:468a11f05580 1353 /// @param mask is the mask of bits to monitor.
WiredHome 66:468a11f05580 1354 /// @returns true if a normal exit.
WiredHome 66:468a11f05580 1355 /// @returns false if a timeout exit.
WiredHome 66:468a11f05580 1356 ///
WiredHome 66:468a11f05580 1357 bool _WaitWhileBusy(uint8_t mask);
WiredHome 66:468a11f05580 1358
WiredHome 66:468a11f05580 1359 /// Wait while the the register anded with the mask is true.
WiredHome 66:468a11f05580 1360 ///
WiredHome 66:468a11f05580 1361 /// @param reg is the register to monitor
WiredHome 66:468a11f05580 1362 /// @param mask is the bit mask to monitor
WiredHome 66:468a11f05580 1363 /// @returns true if it was a normal exit
WiredHome 66:468a11f05580 1364 /// @returns false if it was a timeout that caused the exit.
WiredHome 66:468a11f05580 1365 ///
WiredHome 66:468a11f05580 1366 bool _WaitWhileReg(uint8_t reg, uint8_t mask);
WiredHome 66:468a11f05580 1367
WiredHome 19:3f82c1161fd2 1368 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 1369 ///
WiredHome 19:3f82c1161fd2 1370 /// @param data is the value to write.
WiredHome 19:3f82c1161fd2 1371 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 1372 /// in while shifting out.
WiredHome 19:3f82c1161fd2 1373 ///
WiredHome 19:3f82c1161fd2 1374 unsigned char spiwrite(unsigned char data);
WiredHome 19:3f82c1161fd2 1375
WiredHome 19:3f82c1161fd2 1376 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 1377 ///
WiredHome 19:3f82c1161fd2 1378 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 1379 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 1380 ///
WiredHome 19:3f82c1161fd2 1381 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 1382 /// in while shifting out.
WiredHome 19:3f82c1161fd2 1383 ///
WiredHome 19:3f82c1161fd2 1384 unsigned char spiread();
WiredHome 19:3f82c1161fd2 1385
WiredHome 19:3f82c1161fd2 1386 SPI spi; ///< spi port
WiredHome 66:468a11f05580 1387 unsigned long spiwritefreq; ///< saved write freq
WiredHome 66:468a11f05580 1388 unsigned long spireadfreq; ///< saved read freq
WiredHome 19:3f82c1161fd2 1389 DigitalOut cs; ///< chip select pin, assumed active low
WiredHome 19:3f82c1161fd2 1390 DigitalOut res; ///< reset pin, assumed active low
WiredHome 19:3f82c1161fd2 1391 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 37:f19b7e7449dc 1392 loc_t cursor_x, cursor_y; ///< used for external fonts only
WiredHome 19:3f82c1161fd2 1393
WiredHome 19:3f82c1161fd2 1394 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 1395 typedef enum
WiredHome 19:3f82c1161fd2 1396 {
WiredHome 19:3f82c1161fd2 1397 PRF_CLS,
WiredHome 41:2956a0a221e5 1398 PRF_DRAWPIXEL,
WiredHome 41:2956a0a221e5 1399 PRF_PIXELSTREAM,
WiredHome 41:2956a0a221e5 1400 PRF_READPIXEL,
WiredHome 41:2956a0a221e5 1401 PRF_READPIXELSTREAM,
WiredHome 19:3f82c1161fd2 1402 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 1403 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 1404 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 1405 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 1406 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 1407 PRF_DRAWELLIPSE,
WiredHome 19:3f82c1161fd2 1408 METRICCOUNT
WiredHome 19:3f82c1161fd2 1409 } method_e;
WiredHome 19:3f82c1161fd2 1410 unsigned long metrics[METRICCOUNT];
WiredHome 66:468a11f05580 1411 unsigned long idlecounter;
WiredHome 19:3f82c1161fd2 1412 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 1413 Timer performance;
WiredHome 19:3f82c1161fd2 1414 #endif
WiredHome 19:3f82c1161fd2 1415 };
WiredHome 19:3f82c1161fd2 1416
WiredHome 19:3f82c1161fd2 1417 //} // namespace
WiredHome 19:3f82c1161fd2 1418
WiredHome 19:3f82c1161fd2 1419 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 1420
WiredHome 23:a50ded45dbaf 1421
WiredHome 23:a50ded45dbaf 1422 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 1423 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 1424 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 1425 // / / / / / / / /
WiredHome 23:a50ded45dbaf 1426 // / / / /___ / /__________ / /
WiredHome 23:a50ded45dbaf 1427 // / / / ____/ /__________ / / /
WiredHome 23:a50ded45dbaf 1428 // / / / / / / / /
WiredHome 23:a50ded45dbaf 1429 // / / / /__________ ___________/ / / /
WiredHome 23:a50ded45dbaf 1430 // /__/ /_____________/ /_____________/ /__/
WiredHome 23:a50ded45dbaf 1431
WiredHome 23:a50ded45dbaf 1432 #include "WebColors.h"
WiredHome 23:a50ded45dbaf 1433 #include "Arial12x12.h"
WiredHome 23:a50ded45dbaf 1434 #include <algorithm>
WiredHome 23:a50ded45dbaf 1435
WiredHome 23:a50ded45dbaf 1436 extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 1437
WiredHome 23:a50ded45dbaf 1438 /// This activates a small set of tests for the graphics library.
WiredHome 23:a50ded45dbaf 1439 ///
WiredHome 23:a50ded45dbaf 1440 /// Call this API and pass it the reference to the display class.
WiredHome 23:a50ded45dbaf 1441 /// It will then run a series of tests. It accepts interaction via
WiredHome 23:a50ded45dbaf 1442 /// stdin to switch from automatic test mode to manual, run a specific
WiredHome 23:a50ded45dbaf 1443 /// test, or to exit the test mode.
WiredHome 23:a50ded45dbaf 1444 ///
WiredHome 23:a50ded45dbaf 1445 /// @param lcd is a reference to the display class.
WiredHome 23:a50ded45dbaf 1446 /// @param pc is a reference to a serial interface, typically the USB to PC.
WiredHome 23:a50ded45dbaf 1447 ///
WiredHome 23:a50ded45dbaf 1448 void RunTestSet(RA8875 & lcd, Serial & pc);
WiredHome 23:a50ded45dbaf 1449
WiredHome 23:a50ded45dbaf 1450
WiredHome 23:a50ded45dbaf 1451 // To enable the test code, uncomment this section, or copy the
WiredHome 23:a50ded45dbaf 1452 // necessary pieces to your "main()".
WiredHome 23:a50ded45dbaf 1453 //
WiredHome 23:a50ded45dbaf 1454 // #include "mbed.h"
WiredHome 23:a50ded45dbaf 1455 // #include "RA8875.h"
WiredHome 23:a50ded45dbaf 1456 // RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 23:a50ded45dbaf 1457 // Serial pc(USBTX, USBRX);
WiredHome 23:a50ded45dbaf 1458 // extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 1459 // int main()
WiredHome 23:a50ded45dbaf 1460 // {
WiredHome 23:a50ded45dbaf 1461 // pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 23:a50ded45dbaf 1462 // pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 23:a50ded45dbaf 1463 //
WiredHome 23:a50ded45dbaf 1464 // pc.printf("Turning on display\r\n");
WiredHome 23:a50ded45dbaf 1465 // lcd.Reset();
WiredHome 23:a50ded45dbaf 1466 // lcd.Power(true); // display power is on, but the backlight is independent
WiredHome 23:a50ded45dbaf 1467 // lcd.Backlight(0.5);
WiredHome 23:a50ded45dbaf 1468 // RunTestSet(lcd, pc);
WiredHome 23:a50ded45dbaf 1469 // }
WiredHome 23:a50ded45dbaf 1470
WiredHome 23:a50ded45dbaf 1471 #endif // TESTENABLE
WiredHome 23:a50ded45dbaf 1472
WiredHome 56:7a85d226ad0d 1473 #endif