LCD LIB

Dependents:   HagridOS5

Fork of RA8875 by David Smart

Committer:
WiredHome
Date:
Sun Aug 17 15:38:51 2014 +0000
Revision:
62:ba5d33438fda
Parent:
61:8f3153bf0baa
Child:
66:468a11f05580
Fixed a bug in the pixel API which was visible when line( ) with same x,y coordinates for both points was used.

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