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

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

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

Offline Help Manual (Windows chm)

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

Committer:
WiredHome
Date:
Mon Mar 17 11:29:40 2014 +0000
Revision:
53:86d24b9480b9
Parent:
50:2c4f474a2453
Child:
54:e117ad10fba6
Child:
63:ed787f5fcdc4
Moved cursor definitions into the class.; Added support for setting the background color register for transparency.

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 44:207594dece70 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 29:422616aa04bd 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 20:6e2e4a8372eb 27 #define BrightBlue (color_t)(RGB(85,85,255))
WiredHome 20:6e2e4a8372eb 28 #define BrightGreen (color_t)(RGB(85,255,85))
WiredHome 20:6e2e4a8372eb 29 #define BrightCyan (color_t)(RGB(85,255,255))
WiredHome 20:6e2e4a8372eb 30 #define Orange (color_t)(RGB(255,85,85))
WiredHome 20:6e2e4a8372eb 31 #define Pink (color_t)(RGB(255,85,255))
WiredHome 20:6e2e4a8372eb 32 #define Yellow (color_t)(RGB(255,255,85))
WiredHome 20:6e2e4a8372eb 33 #define White (color_t)(RGB(255,255,255))
WiredHome 20:6e2e4a8372eb 34
WiredHome 20:6e2e4a8372eb 35 #define BrightRed (color_t)(RGB(255,0,0))
WiredHome 19:3f82c1161fd2 36
WiredHome 19:3f82c1161fd2 37 //namespace SW_graphics
WiredHome 19:3f82c1161fd2 38 //{
WiredHome 19:3f82c1161fd2 39
WiredHome 24:8ca861acf12d 40
WiredHome 21:3c1efb192927 41 /// This is a graphics library for the Raio RA8875 Display Controller chip
WiredHome 21:3c1efb192927 42 /// attached to a 4-wire SPI interface.
WiredHome 21:3c1efb192927 43 ///
WiredHome 29:422616aa04bd 44 /// It offers both primitive and high level APIs.\\
WiredHome 21:3c1efb192927 45 /// Central to this API is a coordinate system, where the origin (0,0) is in
WiredHome 21:3c1efb192927 46 /// the top-left corner of the display, and the width extends positive to the
WiredHome 21:3c1efb192927 47 /// right and the height extends positive toward the bottom.
WiredHome 21:3c1efb192927 48 ///
WiredHome 21:3c1efb192927 49 /// As there are both graphics and text commands, one must take care to use
WiredHome 21:3c1efb192927 50 /// the proper coordinate system for each. Some of the text APIs are in units
WiredHome 29:422616aa04bd 51 /// of column and row, which is measured in character positions (and dependent
WiredHome 29:422616aa04bd 52 /// on the font size), and other text APIs permit pixel level positioning.
WiredHome 29:422616aa04bd 53 ///
WiredHome 31:c72e12cd5c67 54 /// @todo Add Scroll support for text.
WiredHome 37:f19b7e7449dc 55 /// @todo Improve sync between internal and external font support - cursor, window, scroll.
WiredHome 29:422616aa04bd 56 /// @todo Find out why it can't shift frequency after constructor runs.
WiredHome 29:422616aa04bd 57 /// @todo Add Hardware reset signal.
WiredHome 29:422616aa04bd 58 /// @todo Add Touch Screen support.
WiredHome 29:422616aa04bd 59 /// @todo Add Keypad Support.
WiredHome 44:207594dece70 60 /// @todo Add high level objects - x-y graph, meter, others... but these will
WiredHome 44:207594dece70 61 /// probably be best served in another class, since they may not
WiredHome 44:207594dece70 62 /// be needed for many uses.
WiredHome 21:3c1efb192927 63 ///
WiredHome 19:3f82c1161fd2 64 class RA8875 : public GraphicsDisplay
WiredHome 19:3f82c1161fd2 65 {
WiredHome 19:3f82c1161fd2 66 public:
WiredHome 53:86d24b9480b9 67 /// cursor type to be shown as the text cursor.
WiredHome 53:86d24b9480b9 68 typedef enum
WiredHome 53:86d24b9480b9 69 {
WiredHome 53:86d24b9480b9 70 NOCURSOR, ///< cursor is hidden
WiredHome 53:86d24b9480b9 71 IBEAM, ///< | cursor
WiredHome 53:86d24b9480b9 72 UNDER, ///< _ cursor
WiredHome 53:86d24b9480b9 73 BLOCK ///< Block cursor
WiredHome 53:86d24b9480b9 74 } cursor_t;
WiredHome 53:86d24b9480b9 75
WiredHome 19:3f82c1161fd2 76 /// font type selection.
WiredHome 19:3f82c1161fd2 77 typedef enum
WiredHome 19:3f82c1161fd2 78 {
WiredHome 31:c72e12cd5c67 79 ISO8859_1, ///< ISO8859-1 font
WiredHome 31:c72e12cd5c67 80 ISO8859_2, ///< ISO8859-2 font
WiredHome 31:c72e12cd5c67 81 ISO8859_3, ///< ISO8859-3 font
WiredHome 31:c72e12cd5c67 82 ISO8859_4 ///< ISO8859-4 font
WiredHome 19:3f82c1161fd2 83 } font_t;
WiredHome 19:3f82c1161fd2 84
WiredHome 19:3f82c1161fd2 85 /// font rotation selection
WiredHome 19:3f82c1161fd2 86 typedef enum
WiredHome 19:3f82c1161fd2 87 {
WiredHome 31:c72e12cd5c67 88 normal, ///< normal orientation
WiredHome 31:c72e12cd5c67 89 rotated ///< rotated orientation
WiredHome 19:3f82c1161fd2 90 } font_angle_t;
WiredHome 19:3f82c1161fd2 91
WiredHome 19:3f82c1161fd2 92 /// alignment
WiredHome 19:3f82c1161fd2 93 typedef enum
WiredHome 19:3f82c1161fd2 94 {
WiredHome 31:c72e12cd5c67 95 align_none, ///< align - none
WiredHome 31:c72e12cd5c67 96 align_full ///< align - full
WiredHome 19:3f82c1161fd2 97 } alignment_t;
WiredHome 19:3f82c1161fd2 98
WiredHome 19:3f82c1161fd2 99 /// Scale factor - 1, 2, 3 4
WiredHome 40:04aa280dfa39 100 typedef int HorizontalScale;
WiredHome 19:3f82c1161fd2 101
WiredHome 19:3f82c1161fd2 102 /// Scale factor - 1, 2, 3, 4
WiredHome 40:04aa280dfa39 103 typedef int VerticalScale;
WiredHome 19:3f82c1161fd2 104
WiredHome 19:3f82c1161fd2 105 /// Clear screen region
WiredHome 19:3f82c1161fd2 106 typedef enum
WiredHome 19:3f82c1161fd2 107 {
WiredHome 31:c72e12cd5c67 108 FULLWINDOW, ///< Full screen
WiredHome 31:c72e12cd5c67 109 ACTIVEWINDOW ///< active window/region
WiredHome 19:3f82c1161fd2 110 } Region_t;
WiredHome 19:3f82c1161fd2 111
WiredHome 53:86d24b9480b9 112 /// Set the Layer 1/2 Display Mode
WiredHome 53:86d24b9480b9 113 typedef enum
WiredHome 53:86d24b9480b9 114 {
WiredHome 53:86d24b9480b9 115 OnlyLayer1, ///< Only layer 1 is visible
WiredHome 53:86d24b9480b9 116 OnlyLayer2, ///< Only layer 2 is visible
WiredHome 53:86d24b9480b9 117 LightenOverlay, ///< Lighten-overlay mode
WiredHome 53:86d24b9480b9 118 TransparentMode, ///< Transparent mode
WiredHome 53:86d24b9480b9 119 BooleanOR, ///< Boolean OR mode
WiredHome 53:86d24b9480b9 120 BooleanAND, ///< Boolean AND mode
WiredHome 53:86d24b9480b9 121 FloatingWindow ///< Floating Window mode
WiredHome 53:86d24b9480b9 122 } LayerMode_T;
WiredHome 53:86d24b9480b9 123
WiredHome 19:3f82c1161fd2 124 /// Constructor for a display based on the RAiO RA8875
WiredHome 19:3f82c1161fd2 125 /// display controller.
WiredHome 19:3f82c1161fd2 126 ///
WiredHome 19:3f82c1161fd2 127 /// @param mosi is the SPI master out slave in pin on the mbed.
WiredHome 19:3f82c1161fd2 128 /// @param miso is the SPI master in slave out pin on the mbed.
WiredHome 19:3f82c1161fd2 129 /// @param sclk is the SPI shift clock pin on the mbed.
WiredHome 19:3f82c1161fd2 130 /// @param csel is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 131 /// active low chip select for the display controller.
WiredHome 19:3f82c1161fd2 132 /// @param reset is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 133 /// active low reset input on the display controller -
WiredHome 19:3f82c1161fd2 134 /// but this is not currently used.
WiredHome 19:3f82c1161fd2 135 /// @param name is a text name for this object, which will permit
WiredHome 19:3f82c1161fd2 136 /// capturing stdout and printf() directly to it.
WiredHome 19:3f82c1161fd2 137 ///
WiredHome 19:3f82c1161fd2 138 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset, const char * name = "lcd");
WiredHome 19:3f82c1161fd2 139
WiredHome 45:679c2fb8480c 140 // Destructor doesn't have much to do as this would typically be created
WiredHome 45:679c2fb8480c 141 // at startup, and not at runtime.
WiredHome 19:3f82c1161fd2 142 //~RA8875();
WiredHome 19:3f82c1161fd2 143
WiredHome 50:2c4f474a2453 144 /// Select the drawing layer for subsequent commands.
WiredHome 43:3becae133285 145 ///
WiredHome 43:3becae133285 146 /// If the screen configuration is 480 x 272, or if it is 800 x 480
WiredHome 43:3becae133285 147 /// and 8-bit color, the the display supports two layers, which can
WiredHome 43:3becae133285 148 /// be independently drawn on and shown. Additionally, complex
WiredHome 43:3becae133285 149 /// operations involving both layers are permitted.
WiredHome 43:3becae133285 150 ///
WiredHome 43:3becae133285 151 /// @note The user manual refers to Layer 1 and Layer 2, however the
WiredHome 43:3becae133285 152 /// actual register values are value 0 and 1. This and other APIs
WiredHome 53:86d24b9480b9 153 /// that reference the layers use the values 0 and 1.
WiredHome 43:3becae133285 154 ///
WiredHome 43:3becae133285 155 /// @param layer selects the layer for subsequence commands, where
WiredHome 43:3becae133285 156 /// the values 0 and 1 represent layers 1 and 2 (as referred
WiredHome 43:3becae133285 157 /// to in the user manual).
WiredHome 43:3becae133285 158 /// @returns success/failure code. @see RetCode_t.
WiredHome 43:3becae133285 159 ///
WiredHome 50:2c4f474a2453 160 RetCode_t SelectDrawingLayer(uint16_t layer);
WiredHome 43:3becae133285 161
WiredHome 44:207594dece70 162 /// Set the Layer presentation mode.
WiredHome 44:207594dece70 163 ///
WiredHome 44:207594dece70 164 /// This sets the presentation mode for layers, and permits showing
WiredHome 44:207594dece70 165 /// a single layer, or applying a mode where the two layers
WiredHome 44:207594dece70 166 /// are combined using one of the hardware methods.
WiredHome 44:207594dece70 167 ///
WiredHome 44:207594dece70 168 /// @param mode sets the mode in the Layer Transparency Register.
WiredHome 44:207594dece70 169 /// @returns success/failure code. @see RetCode_t.
WiredHome 44:207594dece70 170 ///
WiredHome 53:86d24b9480b9 171 RetCode_t SetLayerMode(LayerMode_T mode);
WiredHome 44:207594dece70 172
WiredHome 44:207594dece70 173 /// Set the layer transparency for each layer.
WiredHome 44:207594dece70 174 ///
WiredHome 44:207594dece70 175 /// Set the transparency, where the range of values is
WiredHome 44:207594dece70 176 /// from zero (fully visible) to eight (fully transparent).
WiredHome 44:207594dece70 177 /// The input value is automatically limited to this range.
WiredHome 44:207594dece70 178 ///
WiredHome 44:207594dece70 179 /// @param layer1 sets the layer 1 transparency.
WiredHome 44:207594dece70 180 /// @param layer2 sets the layer 2 transparency.
WiredHome 44:207594dece70 181 /// @returns success/failure code. @see RetCode_t.
WiredHome 44:207594dece70 182 ///
WiredHome 44:207594dece70 183 RetCode_t SetLayerTransparency(uint8_t layer1, uint8_t layer2);
WiredHome 44:207594dece70 184
WiredHome 53:86d24b9480b9 185 /// Set the background color register used for transparency.
WiredHome 53:86d24b9480b9 186 ///
WiredHome 53:86d24b9480b9 187 /// This command sets the background color registers that are used
WiredHome 53:86d24b9480b9 188 /// in the transparent color operations involving the layers.
WiredHome 53:86d24b9480b9 189 ///
WiredHome 53:86d24b9480b9 190 /// @param color is optional and expressed in 16-bit format. If not
WiredHome 53:86d24b9480b9 191 /// supplied, a default of Black is used.
WiredHome 53:86d24b9480b9 192 /// @returns success/failure code. @see RetCode_t.
WiredHome 53:86d24b9480b9 193 ///
WiredHome 53:86d24b9480b9 194 RetCode_t SetBackgroundTransparencyColor(color_t color = RGB(0,0,0));
WiredHome 53:86d24b9480b9 195
WiredHome 38:38d503b4fad6 196 /// Write a command to the display with a word of data.
WiredHome 38:38d503b4fad6 197 ///
WiredHome 38:38d503b4fad6 198 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 199 ///
WiredHome 38:38d503b4fad6 200 /// @param command is the command to write.
WiredHome 38:38d503b4fad6 201 /// @param data is data to be written to the command register.
WiredHome 38:38d503b4fad6 202 /// @returns success/failure code. @see RetCode_t.
WiredHome 38:38d503b4fad6 203 ///
WiredHome 38:38d503b4fad6 204 RetCode_t WriteCommandW(uint8_t command, uint16_t data);
WiredHome 38:38d503b4fad6 205
WiredHome 19:3f82c1161fd2 206 /// Write a command to the display
WiredHome 19:3f82c1161fd2 207 ///
WiredHome 19:3f82c1161fd2 208 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 209 ///
WiredHome 19:3f82c1161fd2 210 /// @param command is the command to write.
WiredHome 33:b6b710758ab3 211 /// @param data is optional data to be written to the command register
WiredHome 19:3f82c1161fd2 212 /// and only occurs if the data is in the range [0 - 0xFF].
WiredHome 19:3f82c1161fd2 213 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 214 ///
WiredHome 32:0e4f2ae512e2 215 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
WiredHome 19:3f82c1161fd2 216
WiredHome 38:38d503b4fad6 217 /// Write a data word to the display
WiredHome 38:38d503b4fad6 218 ///
WiredHome 38:38d503b4fad6 219 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 220 ///
WiredHome 38:38d503b4fad6 221 /// @param data is the data to write.
WiredHome 38:38d503b4fad6 222 /// @returns success/failure code. @see RetCode_t.
WiredHome 38:38d503b4fad6 223 ///
WiredHome 38:38d503b4fad6 224 RetCode_t WriteDataW(uint16_t data);
WiredHome 38:38d503b4fad6 225
WiredHome 19:3f82c1161fd2 226 /// Write a data byte to the display
WiredHome 19:3f82c1161fd2 227 ///
WiredHome 19:3f82c1161fd2 228 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 229 ///
WiredHome 19:3f82c1161fd2 230 /// @param data is the data to write.
WiredHome 19:3f82c1161fd2 231 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 232 ///
WiredHome 32:0e4f2ae512e2 233 virtual RetCode_t WriteData(unsigned char data);
WiredHome 19:3f82c1161fd2 234
WiredHome 19:3f82c1161fd2 235 /// Read a command register
WiredHome 19:3f82c1161fd2 236 ///
WiredHome 19:3f82c1161fd2 237 /// @param command is the command register to read.
WiredHome 19:3f82c1161fd2 238 /// @returns the value read from the register.
WiredHome 19:3f82c1161fd2 239 ///
WiredHome 19:3f82c1161fd2 240 unsigned char ReadCommand(unsigned char command);
WiredHome 19:3f82c1161fd2 241
WiredHome 41:2956a0a221e5 242 /// Read a data byte from the display
WiredHome 19:3f82c1161fd2 243 ///
WiredHome 19:3f82c1161fd2 244 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 245 ///
WiredHome 19:3f82c1161fd2 246 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 247 ///
WiredHome 19:3f82c1161fd2 248 unsigned char ReadData(void);
WiredHome 19:3f82c1161fd2 249
WiredHome 41:2956a0a221e5 250 /// Read a word from the display
WiredHome 41:2956a0a221e5 251 ///
WiredHome 41:2956a0a221e5 252 /// This is a high level command, and may invoke several primitives.
WiredHome 41:2956a0a221e5 253 ///
WiredHome 41:2956a0a221e5 254 /// @returns data that was read.
WiredHome 41:2956a0a221e5 255 ///
WiredHome 41:2956a0a221e5 256 uint16_t ReadDataW(void);
WiredHome 41:2956a0a221e5 257
WiredHome 19:3f82c1161fd2 258 /// Read the display status
WiredHome 19:3f82c1161fd2 259 ///
WiredHome 19:3f82c1161fd2 260 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 261 ///
WiredHome 19:3f82c1161fd2 262 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 263 ///
WiredHome 19:3f82c1161fd2 264 unsigned char ReadStatus(void);
WiredHome 19:3f82c1161fd2 265
WiredHome 19:3f82c1161fd2 266 /// get the width in pixels of the currently active font
WiredHome 19:3f82c1161fd2 267 ///
WiredHome 19:3f82c1161fd2 268 /// @returns font width in pixels.
WiredHome 19:3f82c1161fd2 269 ///
WiredHome 37:f19b7e7449dc 270 dim_t fontwidth(void);
WiredHome 19:3f82c1161fd2 271
WiredHome 19:3f82c1161fd2 272 /// get the height in pixels of the currently active font
WiredHome 19:3f82c1161fd2 273 ///
WiredHome 19:3f82c1161fd2 274 /// @returns font height in pixels.
WiredHome 19:3f82c1161fd2 275 ///
WiredHome 37:f19b7e7449dc 276 dim_t fontheight(void);
WiredHome 19:3f82c1161fd2 277
WiredHome 19:3f82c1161fd2 278 /// get the number of colums based on the currently active font
WiredHome 19:3f82c1161fd2 279 ///
WiredHome 19:3f82c1161fd2 280 /// @returns number of columns.
WiredHome 19:3f82c1161fd2 281 ///
WiredHome 19:3f82c1161fd2 282 virtual int columns(void);
WiredHome 19:3f82c1161fd2 283
WiredHome 19:3f82c1161fd2 284 /// get the number of rows based on the currently active font
WiredHome 19:3f82c1161fd2 285 ///
WiredHome 19:3f82c1161fd2 286 /// @returns number of rows.
WiredHome 19:3f82c1161fd2 287 ///
WiredHome 19:3f82c1161fd2 288 virtual int rows(void);
WiredHome 19:3f82c1161fd2 289
WiredHome 19:3f82c1161fd2 290 /// get the screen width in pixels
WiredHome 19:3f82c1161fd2 291 ///
WiredHome 19:3f82c1161fd2 292 /// @returns screen width in pixels.
WiredHome 19:3f82c1161fd2 293 ///
WiredHome 38:38d503b4fad6 294 virtual dim_t width(void);
WiredHome 19:3f82c1161fd2 295
WiredHome 19:3f82c1161fd2 296 /// get the screen height in pixels
WiredHome 19:3f82c1161fd2 297 ///
WiredHome 19:3f82c1161fd2 298 /// @returns screen height in pixels.
WiredHome 19:3f82c1161fd2 299 ///
WiredHome 38:38d503b4fad6 300 virtual dim_t height(void);
WiredHome 19:3f82c1161fd2 301
WiredHome 43:3becae133285 302 /// get the color depth in bits per pixel.
WiredHome 43:3becae133285 303 ///
WiredHome 43:3becae133285 304 /// @returns 8 or 16 only.
WiredHome 43:3becae133285 305 ///
WiredHome 43:3becae133285 306 virtual dim_t color_bpp(void);
WiredHome 43:3becae133285 307
WiredHome 19:3f82c1161fd2 308 /// Set cursor position based on the current font size.
WiredHome 19:3f82c1161fd2 309 ///
WiredHome 32:0e4f2ae512e2 310 /// @param column is the horizontal position in character positions
WiredHome 32:0e4f2ae512e2 311 /// @param row is the vertical position in character positions
WiredHome 19:3f82c1161fd2 312 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 313 ///
WiredHome 37:f19b7e7449dc 314 virtual RetCode_t locate(textloc_t column, textloc_t row);
WiredHome 19:3f82c1161fd2 315
WiredHome 19:3f82c1161fd2 316 /// Prepare the controller to write text to the screen by positioning
WiredHome 19:3f82c1161fd2 317 /// the cursor.
WiredHome 19:3f82c1161fd2 318 ///
WiredHome 19:3f82c1161fd2 319 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 320 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 321 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 322 ///
WiredHome 37:f19b7e7449dc 323 RetCode_t SetTextCursor(loc_t x, loc_t y);
WiredHome 29:422616aa04bd 324
WiredHome 37:f19b7e7449dc 325 /// Get the current cursor position in pixels.
WiredHome 37:f19b7e7449dc 326 ///
WiredHome 37:f19b7e7449dc 327 /// @returns cursor position.
WiredHome 37:f19b7e7449dc 328 ///
WiredHome 37:f19b7e7449dc 329 point_t GetTextCursor(void);
WiredHome 37:f19b7e7449dc 330
WiredHome 29:422616aa04bd 331 /// Get the current cursor horizontal position in pixels.
WiredHome 29:422616aa04bd 332 ///
WiredHome 29:422616aa04bd 333 /// @returns cursor position horizontal offset.
WiredHome 29:422616aa04bd 334 ///
WiredHome 37:f19b7e7449dc 335 loc_t GetTextCursor_X(void);
WiredHome 29:422616aa04bd 336
WiredHome 29:422616aa04bd 337 /// Get the current cursor vertical position in pixels.
WiredHome 29:422616aa04bd 338 ///
WiredHome 29:422616aa04bd 339 /// @returns cursor position vertical offset.
WiredHome 29:422616aa04bd 340 ///
WiredHome 37:f19b7e7449dc 341 loc_t GetTextCursor_Y(void);
WiredHome 29:422616aa04bd 342
WiredHome 23:a50ded45dbaf 343 /// Configure additional Cursor Control settings.
WiredHome 23:a50ded45dbaf 344 ///
WiredHome 23:a50ded45dbaf 345 /// This API lets you modify other cursor control settings;
WiredHome 23:a50ded45dbaf 346 /// Cursor visible/hidden, Cursor blink/normal,
WiredHome 23:a50ded45dbaf 347 /// Cursor I-Beam/underscore/box.
WiredHome 23:a50ded45dbaf 348 ///
WiredHome 24:8ca861acf12d 349 /// @param cursor can be set to NOCURSOR (default), IBEAM,
WiredHome 24:8ca861acf12d 350 /// UNDER, or BLOCK.
WiredHome 23:a50ded45dbaf 351 /// @param blink can be set to true or false (default false)
WiredHome 23:a50ded45dbaf 352 /// @returns success/failure code. @see RetCode_t
WiredHome 23:a50ded45dbaf 353 ///
WiredHome 24:8ca861acf12d 354 RetCode_t SetTextCursorControl(cursor_t cursor = NOCURSOR, bool blink = false);
WiredHome 23:a50ded45dbaf 355
WiredHome 19:3f82c1161fd2 356 /// Select the ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 357 ///
WiredHome 19:3f82c1161fd2 358 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 359 ///
WiredHome 19:3f82c1161fd2 360 /// @param font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 361 ///
WiredHome 19:3f82c1161fd2 362 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 363 /// the command is not executed.
WiredHome 19:3f82c1161fd2 364 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 365 ///
WiredHome 19:3f82c1161fd2 366 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 19:3f82c1161fd2 367
WiredHome 19:3f82c1161fd2 368 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 369 ///
WiredHome 19:3f82c1161fd2 370 /// This command lets you make several modifications to any text that
WiredHome 19:3f82c1161fd2 371 /// is written.
WiredHome 19:3f82c1161fd2 372 ///
WiredHome 19:3f82c1161fd2 373 /// Options can be combined:
WiredHome 19:3f82c1161fd2 374 /// Default:
WiredHome 19:3f82c1161fd2 375 /// @li Full alignment disabled,
WiredHome 19:3f82c1161fd2 376 /// @li Font with Background color,
WiredHome 19:3f82c1161fd2 377 /// @li Font in normal orientiation,
WiredHome 19:3f82c1161fd2 378 /// @li Horizontal scale x 1
WiredHome 19:3f82c1161fd2 379 /// @li Vertical scale x 1
WiredHome 19:3f82c1161fd2 380 /// @li alignment
WiredHome 19:3f82c1161fd2 381 ///
WiredHome 19:3f82c1161fd2 382 /// @param fillit defaults to FILL, but can be NOFILL
WiredHome 19:3f82c1161fd2 383 /// @param angle defaults to normal, but can be rotated
WiredHome 19:3f82c1161fd2 384 /// @param hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 385 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 386 /// @param vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 387 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 388 /// @param alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 389 /// align_full.
WiredHome 19:3f82c1161fd2 390 ///
WiredHome 19:3f82c1161fd2 391 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 392 /// the command is not executed.
WiredHome 19:3f82c1161fd2 393 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 394 ///
WiredHome 19:3f82c1161fd2 395 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 19:3f82c1161fd2 396 font_angle_t angle = normal,
WiredHome 19:3f82c1161fd2 397 HorizontalScale hScale = 1,
WiredHome 19:3f82c1161fd2 398 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 399 alignment_t alignment = align_none);
WiredHome 19:3f82c1161fd2 400
WiredHome 19:3f82c1161fd2 401 /// Control the font size
WiredHome 19:3f82c1161fd2 402 ///
WiredHome 19:3f82c1161fd2 403 /// This command lets you set the font enlargement for both horizontal
WiredHome 19:3f82c1161fd2 404 /// and vertical, independent of the rotation, background, and
WiredHome 19:3f82c1161fd2 405 /// alignment. @see SetTextFontControl.
WiredHome 19:3f82c1161fd2 406 ///
WiredHome 19:3f82c1161fd2 407 /// @param hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 408 /// and scales the font size by this amount.
WiredHome 40:04aa280dfa39 409 /// @param vScale is an optional parameter that defaults to the hScale value,
WiredHome 40:04aa280dfa39 410 /// but can be 1, 2, 3, or 4, and scales the font size by this amount.
WiredHome 40:04aa280dfa39 411 ///
WiredHome 40:04aa280dfa39 412 /// @code
WiredHome 40:04aa280dfa39 413 /// lcd.SetTextFontSize(2); // Set the font to 2x normal size
WiredHome 40:04aa280dfa39 414 /// lcd.SetTextFontSize(2,3); // Set the font to 2x Width and 3x Height
WiredHome 40:04aa280dfa39 415 /// lcd.SetTextFontSize(); // Restore to normal size in both dimensions
WiredHome 40:04aa280dfa39 416 /// @endcode
WiredHome 19:3f82c1161fd2 417 ///
WiredHome 19:3f82c1161fd2 418 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 419 /// the command is not executed.
WiredHome 19:3f82c1161fd2 420 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 421 ///
WiredHome 40:04aa280dfa39 422 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
WiredHome 19:3f82c1161fd2 423
WiredHome 19:3f82c1161fd2 424 /// put a character on the screen.
WiredHome 19:3f82c1161fd2 425 ///
WiredHome 19:3f82c1161fd2 426 /// @param c is the character.
WiredHome 19:3f82c1161fd2 427 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 428 ///
WiredHome 19:3f82c1161fd2 429 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 430
WiredHome 19:3f82c1161fd2 431 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 432 ///
WiredHome 19:3f82c1161fd2 433 /// @param string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 434 ///
WiredHome 19:3f82c1161fd2 435 void puts(const char * string);
WiredHome 19:3f82c1161fd2 436
WiredHome 19:3f82c1161fd2 437 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 438 ///
WiredHome 19:3f82c1161fd2 439 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 440 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 441 /// @param string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 442 ///
WiredHome 37:f19b7e7449dc 443 void puts(loc_t x, loc_t y, const char * string);
WiredHome 19:3f82c1161fd2 444
WiredHome 19:3f82c1161fd2 445 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 446 /// the memory cursor.
WiredHome 19:3f82c1161fd2 447 ///
WiredHome 19:3f82c1161fd2 448 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 449 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 450 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 451 ///
WiredHome 37:f19b7e7449dc 452 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 453
WiredHome 41:2956a0a221e5 454 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 455 /// the memory read cursor.
WiredHome 41:2956a0a221e5 456 ///
WiredHome 41:2956a0a221e5 457 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 41:2956a0a221e5 458 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 41:2956a0a221e5 459 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 460 ///
WiredHome 41:2956a0a221e5 461 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 462
WiredHome 19:3f82c1161fd2 463 /// Set the window, which controls where items are written to the screen.
WiredHome 19:3f82c1161fd2 464 ///
WiredHome 19:3f82c1161fd2 465 /// When something hits the window width, it wraps back to the left side
WiredHome 19:3f82c1161fd2 466 /// and down a row. If the initial write is outside the window, it will
WiredHome 19:3f82c1161fd2 467 /// be captured into the window when it crosses a boundary.
WiredHome 19:3f82c1161fd2 468 ///
WiredHome 19:3f82c1161fd2 469 /// @param x is the left edge in pixels.
WiredHome 19:3f82c1161fd2 470 /// @param y is the top edge in pixels.
WiredHome 19:3f82c1161fd2 471 /// @param width is the window width in pixels.
WiredHome 19:3f82c1161fd2 472 /// @param height is the window height in pixels.
WiredHome 19:3f82c1161fd2 473 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 474 ///
WiredHome 37:f19b7e7449dc 475 virtual RetCode_t window(loc_t x, loc_t y, dim_t width, dim_t height);
WiredHome 19:3f82c1161fd2 476
WiredHome 19:3f82c1161fd2 477 /// Clear the screen.
WiredHome 19:3f82c1161fd2 478 ///
WiredHome 19:3f82c1161fd2 479 /// The behavior is to clear the whole screen. @see clsw().
WiredHome 19:3f82c1161fd2 480 ///
WiredHome 19:3f82c1161fd2 481 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 482 ///
WiredHome 19:3f82c1161fd2 483 virtual RetCode_t cls(void);
WiredHome 19:3f82c1161fd2 484
WiredHome 19:3f82c1161fd2 485 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 486 ///
WiredHome 19:3f82c1161fd2 487 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 488 /// parameter, the action can be restricted to the active window, which
WiredHome 32:0e4f2ae512e2 489 /// can be set with the @see window method.
WiredHome 19:3f82c1161fd2 490 ///
WiredHome 19:3f82c1161fd2 491 /// @param region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 492 /// or may be set to ACTIVEWINDOW.
WiredHome 19:3f82c1161fd2 493 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 494 ///
WiredHome 19:3f82c1161fd2 495 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 496
WiredHome 19:3f82c1161fd2 497 /// Set the background color.
WiredHome 19:3f82c1161fd2 498 ///
WiredHome 19:3f82c1161fd2 499 /// @param color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 500 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 501 ///
WiredHome 19:3f82c1161fd2 502 virtual RetCode_t background(color_t color);
WiredHome 19:3f82c1161fd2 503
WiredHome 19:3f82c1161fd2 504 /// Set the background color.
WiredHome 19:3f82c1161fd2 505 ///
WiredHome 19:3f82c1161fd2 506 /// @param r is the red element of the color.
WiredHome 19:3f82c1161fd2 507 /// @param g is the green element of the color.
WiredHome 19:3f82c1161fd2 508 /// @param b is the blue element of the color.
WiredHome 19:3f82c1161fd2 509 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 510 ///
WiredHome 19:3f82c1161fd2 511 virtual RetCode_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 512
WiredHome 19:3f82c1161fd2 513 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 514 ///
WiredHome 19:3f82c1161fd2 515 /// @param color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 516 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 517 ///
WiredHome 19:3f82c1161fd2 518 virtual RetCode_t foreground(color_t color);
WiredHome 19:3f82c1161fd2 519
WiredHome 19:3f82c1161fd2 520 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 521 ///
WiredHome 37:f19b7e7449dc 522 /// @param r is the red element of the color.
WiredHome 37:f19b7e7449dc 523 /// @param g is the green element of the color.
WiredHome 37:f19b7e7449dc 524 /// @param b is the blue element of the color.
WiredHome 19:3f82c1161fd2 525 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 526 ///
WiredHome 37:f19b7e7449dc 527 virtual RetCode_t foreground(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 528
WiredHome 19:3f82c1161fd2 529 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 530 ///
WiredHome 19:3f82c1161fd2 531 /// @returns the current foreground color.
WiredHome 19:3f82c1161fd2 532 ///
WiredHome 37:f19b7e7449dc 533 color_t GetForeColor(void);
WiredHome 19:3f82c1161fd2 534
WiredHome 19:3f82c1161fd2 535 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 536 ///
WiredHome 41:2956a0a221e5 537 /// @note Unlike many other operations, this does not
WiredHome 41:2956a0a221e5 538 /// set the forecolor!
WiredHome 19:3f82c1161fd2 539 ///
WiredHome 19:3f82c1161fd2 540 /// @param x is the horizontal offset to this pixel.
WiredHome 19:3f82c1161fd2 541 /// @param y is the vertical offset to this pixel.
WiredHome 19:3f82c1161fd2 542 /// @param color defines the color for the pixel.
WiredHome 19:3f82c1161fd2 543 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 544 ///
WiredHome 37:f19b7e7449dc 545 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color);
WiredHome 19:3f82c1161fd2 546
WiredHome 19:3f82c1161fd2 547 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 548 ///
WiredHome 19:3f82c1161fd2 549 /// @param x is the horizontal offset to this pixel.
WiredHome 19:3f82c1161fd2 550 /// @param y is the veritical offset to this pixel.
WiredHome 19:3f82c1161fd2 551 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 552 ///
WiredHome 37:f19b7e7449dc 553 virtual RetCode_t pixel(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 554
WiredHome 41:2956a0a221e5 555 /// Get a pixel from the display.
WiredHome 41:2956a0a221e5 556 ///
WiredHome 41:2956a0a221e5 557 /// @param x is the horizontal offset to this pixel.
WiredHome 41:2956a0a221e5 558 /// @param y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 559 /// @returns the pixel. see @color_t
WiredHome 41:2956a0a221e5 560 ///
WiredHome 41:2956a0a221e5 561 virtual color_t getPixel(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 562
WiredHome 41:2956a0a221e5 563 /// Write a stream of pixels to the display.
WiredHome 41:2956a0a221e5 564 ///
WiredHome 41:2956a0a221e5 565 /// @param p is a pointer to a color_t array to write.
WiredHome 41:2956a0a221e5 566 /// @param count is the number of pixels to write.
WiredHome 41:2956a0a221e5 567 /// @param x is the horizontal position on the display.
WiredHome 41:2956a0a221e5 568 /// @param y is the vertical position on the display.
WiredHome 41:2956a0a221e5 569 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 570 ///
WiredHome 41:2956a0a221e5 571 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 572
WiredHome 41:2956a0a221e5 573 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 574 ///
WiredHome 41:2956a0a221e5 575 /// @param p is a pointer to a color_t array to accept the stream.
WiredHome 41:2956a0a221e5 576 /// @param count is the number of pixels to read.
WiredHome 41:2956a0a221e5 577 /// @param x is the horizontal offset to this pixel.
WiredHome 41:2956a0a221e5 578 /// @param y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 579 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 580 ///
WiredHome 41:2956a0a221e5 581 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 582
WiredHome 19:3f82c1161fd2 583 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 584 ///
WiredHome 19:3f82c1161fd2 585 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 586 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 587 ///
WiredHome 19:3f82c1161fd2 588 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 589 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 590 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 591 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 592 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 593 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 594 ///
WiredHome 37:f19b7e7449dc 595 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 596 color_t color);
WiredHome 19:3f82c1161fd2 597
WiredHome 19:3f82c1161fd2 598 /// Draw a line
WiredHome 19:3f82c1161fd2 599 ///
WiredHome 19:3f82c1161fd2 600 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 601 ///
WiredHome 19:3f82c1161fd2 602 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 603 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 604 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 605 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 606 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 607 ///
WiredHome 37:f19b7e7449dc 608 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2);
WiredHome 19:3f82c1161fd2 609
WiredHome 19:3f82c1161fd2 610 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 611 ///
WiredHome 19:3f82c1161fd2 612 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 613 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 614 ///
WiredHome 19:3f82c1161fd2 615 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 616 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 617 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 618 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 619 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 620 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 621 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 622 ///
WiredHome 37:f19b7e7449dc 623 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 624 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 625
WiredHome 19:3f82c1161fd2 626 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 627 ///
WiredHome 19:3f82c1161fd2 628 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 629 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 630 ///
WiredHome 19:3f82c1161fd2 631 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 632 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 633 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 634 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 635 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 636 /// @param fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 19:3f82c1161fd2 637 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 638 ///
WiredHome 37:f19b7e7449dc 639 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 640 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 641
WiredHome 19:3f82c1161fd2 642 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 643 ///
WiredHome 19:3f82c1161fd2 644 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 645 ///
WiredHome 19:3f82c1161fd2 646 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 647 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 648 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 649 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 650 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 651 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 652 ///
WiredHome 37:f19b7e7449dc 653 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 654 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 655
WiredHome 19:3f82c1161fd2 656 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 657 ///
WiredHome 21:3c1efb192927 658 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 659 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 660 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 661 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 662 ///
WiredHome 19:3f82c1161fd2 663 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 664 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 665 ///
WiredHome 21:3c1efb192927 666 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 667 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 668 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 669 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 670 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 671 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 672 /// is returned.
WiredHome 22:f6ea795eb541 673 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 674 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 675 /// is returned.
WiredHome 19:3f82c1161fd2 676 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 677 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 678 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 679 ///
WiredHome 37:f19b7e7449dc 680 RetCode_t fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 681 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 682
WiredHome 19:3f82c1161fd2 683 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 684 ///
WiredHome 21:3c1efb192927 685 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 686 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 687 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 688 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 689 ///
WiredHome 19:3f82c1161fd2 690 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 691 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 692 ///
WiredHome 21:3c1efb192927 693 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 694 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 695 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 696 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 697 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 698 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 699 /// is returned.
WiredHome 22:f6ea795eb541 700 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 701 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 702 /// is returned.
WiredHome 19:3f82c1161fd2 703 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 704 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 705 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 706 ///
WiredHome 37:f19b7e7449dc 707 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 708 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 709
WiredHome 19:3f82c1161fd2 710 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 711 ///
WiredHome 21:3c1efb192927 712 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 713 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 714 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 715 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 716 ///
WiredHome 21:3c1efb192927 717 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 718 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 719 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 720 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 721 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 722 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 723 /// is returned.
WiredHome 22:f6ea795eb541 724 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 725 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 726 /// is returned.
WiredHome 19:3f82c1161fd2 727 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 728 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 729 ///
WiredHome 37:f19b7e7449dc 730 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 731 dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 732
WiredHome 19:3f82c1161fd2 733 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 734 ///
WiredHome 19:3f82c1161fd2 735 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 736 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 737 ///
WiredHome 19:3f82c1161fd2 738 /// @param x1 is the horizontal for point 1.
WiredHome 21:3c1efb192927 739 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 740 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 741 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 742 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 743 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 744 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 745 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 746 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 747 ///
WiredHome 37:f19b7e7449dc 748 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 749 loc_t x3, loc_t y3, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 750
WiredHome 19:3f82c1161fd2 751 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 752 ///
WiredHome 19:3f82c1161fd2 753 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 754 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 755 ///
WiredHome 19:3f82c1161fd2 756 /// @param x1 is the horizontal for point 1.
WiredHome 19:3f82c1161fd2 757 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 758 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 759 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 760 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 761 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 762 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 763 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 764 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 765 ///
WiredHome 37:f19b7e7449dc 766 RetCode_t filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 767 loc_t x3, loc_t y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 768
WiredHome 19:3f82c1161fd2 769 /// Draw a triangle
WiredHome 19:3f82c1161fd2 770 ///
WiredHome 19:3f82c1161fd2 771 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 772 ///
WiredHome 19:3f82c1161fd2 773 /// @param x1 is the horizontal for point 1.
WiredHome 19:3f82c1161fd2 774 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 775 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 776 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 777 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 778 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 779 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 780 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 781 ///
WiredHome 37:f19b7e7449dc 782 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 783 loc_t x3, loc_t y3, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 784
WiredHome 19:3f82c1161fd2 785 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 786 ///
WiredHome 19:3f82c1161fd2 787 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 788 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 789 ///
WiredHome 19:3f82c1161fd2 790 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 791 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 792 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 793 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 794 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 795 ///
WiredHome 37:f19b7e7449dc 796 RetCode_t circle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 797
WiredHome 19:3f82c1161fd2 798 /// Draw a filled circle using the specified color.
WiredHome 19:3f82c1161fd2 799 ///
WiredHome 19:3f82c1161fd2 800 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 801 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 802 ///
WiredHome 19:3f82c1161fd2 803 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 804 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 805 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 806 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 807 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 808 ///
WiredHome 37:f19b7e7449dc 809 RetCode_t fillcircle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 810
WiredHome 19:3f82c1161fd2 811 /// Draw a circle.
WiredHome 19:3f82c1161fd2 812 ///
WiredHome 19:3f82c1161fd2 813 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 814 ///
WiredHome 19:3f82c1161fd2 815 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 816 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 817 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 818 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 819 ///
WiredHome 37:f19b7e7449dc 820 RetCode_t circle(loc_t x, loc_t y, dim_t radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 821
WiredHome 19:3f82c1161fd2 822 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 823 ///
WiredHome 19:3f82c1161fd2 824 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 825 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 826 ///
WiredHome 19:3f82c1161fd2 827 /// @param x is the horizontal center of the ellipse.
WiredHome 19:3f82c1161fd2 828 /// @param y is the vertical center of the ellipse.
WiredHome 22:f6ea795eb541 829 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 22:f6ea795eb541 830 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 19:3f82c1161fd2 831 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 832 /// @param fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 833 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 834 ///
WiredHome 37:f19b7e7449dc 835 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 19:3f82c1161fd2 836 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 837
WiredHome 25:9556a3a9b7cc 838 /// Draw a filled Ellipse using the specified color
WiredHome 25:9556a3a9b7cc 839 ///
WiredHome 25:9556a3a9b7cc 840 /// @note As a side effect, this changes the current
WiredHome 25:9556a3a9b7cc 841 /// foreground color for subsequent operations.
WiredHome 25:9556a3a9b7cc 842 ///
WiredHome 25:9556a3a9b7cc 843 /// @param x is the horizontal center of the ellipse.
WiredHome 25:9556a3a9b7cc 844 /// @param y is the vertical center of the ellipse.
WiredHome 25:9556a3a9b7cc 845 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 25:9556a3a9b7cc 846 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 25:9556a3a9b7cc 847 /// @param color defines the foreground color.
WiredHome 25:9556a3a9b7cc 848 /// @param fillit defines whether the circle is filled or not.
WiredHome 25:9556a3a9b7cc 849 /// @returns success/failure code. @see RetCode_t.
WiredHome 25:9556a3a9b7cc 850 ///
WiredHome 37:f19b7e7449dc 851 RetCode_t fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 25:9556a3a9b7cc 852 color_t color, fill_t fillit = FILL);
WiredHome 25:9556a3a9b7cc 853
WiredHome 19:3f82c1161fd2 854 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 855 ///
WiredHome 19:3f82c1161fd2 856 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 857 ///
WiredHome 19:3f82c1161fd2 858 /// @param x is the horizontal center of the ellipse.
WiredHome 19:3f82c1161fd2 859 /// @param y is the vertical center of the ellipse.
WiredHome 22:f6ea795eb541 860 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 22:f6ea795eb541 861 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 19:3f82c1161fd2 862 /// @param fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 863 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 864 ///
WiredHome 37:f19b7e7449dc 865 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 866
WiredHome 19:3f82c1161fd2 867 /// Control display power
WiredHome 19:3f82c1161fd2 868 ///
WiredHome 19:3f82c1161fd2 869 /// @param on when set to true will turn on the display, when false it is turned off.
WiredHome 19:3f82c1161fd2 870 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 871 ///
WiredHome 19:3f82c1161fd2 872 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 873
WiredHome 19:3f82c1161fd2 874 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 875 ///
WiredHome 19:3f82c1161fd2 876 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 877 ///
WiredHome 19:3f82c1161fd2 878 RetCode_t Reset(void);
WiredHome 19:3f82c1161fd2 879
WiredHome 19:3f82c1161fd2 880 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 881 ///
WiredHome 19:3f82c1161fd2 882 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 883 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 884 ///
WiredHome 19:3f82c1161fd2 885 /// @param brightness ranges from 0 (off) to 255 (full on)
WiredHome 19:3f82c1161fd2 886 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 887 ///
WiredHome 19:3f82c1161fd2 888 RetCode_t Backlight_u8(unsigned char brightness);
WiredHome 19:3f82c1161fd2 889
WiredHome 19:3f82c1161fd2 890 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 891 ///
WiredHome 19:3f82c1161fd2 892 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 893 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 894 ///
WiredHome 19:3f82c1161fd2 895 /// @param brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 19:3f82c1161fd2 896 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 897 ///
WiredHome 19:3f82c1161fd2 898 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 899
WiredHome 32:0e4f2ae512e2 900 /// Select a bitmap font (provided by the user) for all subsequent text.
WiredHome 19:3f82c1161fd2 901 ///
WiredHome 19:3f82c1161fd2 902 /// @note Tool to create the fonts is accessible from its creator
WiredHome 19:3f82c1161fd2 903 /// available at http://www.mikroe.com.
WiredHome 19:3f82c1161fd2 904 /// Change the data to an array of type char[].
WiredHome 19:3f82c1161fd2 905 ///
WiredHome 19:3f82c1161fd2 906 /// @param font is a pointer to a specially formed font array.
WiredHome 19:3f82c1161fd2 907 /// This special font array has a 4-byte header, followed by
WiredHome 19:3f82c1161fd2 908 /// the data:
WiredHome 19:3f82c1161fd2 909 /// - the number of bytes per char
WiredHome 19:3f82c1161fd2 910 /// - the vertical size in pixels for each character
WiredHome 19:3f82c1161fd2 911 /// - the horizontal size in pixels for each character
WiredHome 19:3f82c1161fd2 912 /// - the number of bytes per vertical line (width of the array)
WiredHome 19:3f82c1161fd2 913 /// @returns error code.
WiredHome 19:3f82c1161fd2 914 ///
WiredHome 30:e0f2da88bdf6 915 virtual RetCode_t set_font(const unsigned char * font = NULL);
WiredHome 19:3f82c1161fd2 916
WiredHome 19:3f82c1161fd2 917 /// Get the RGB value for a DOS color.
WiredHome 19:3f82c1161fd2 918 ///
WiredHome 19:3f82c1161fd2 919 /// @param i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 920 /// @returns the RGB color of the selected index, or 0
WiredHome 19:3f82c1161fd2 921 /// if the index is out of bounds.
WiredHome 19:3f82c1161fd2 922 ///
WiredHome 19:3f82c1161fd2 923 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 924
WiredHome 19:3f82c1161fd2 925 /// Get the color name (string) for a DOS color.
WiredHome 19:3f82c1161fd2 926 ///
WiredHome 19:3f82c1161fd2 927 /// @param i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 928 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 929 /// or NULL if the index is out of bounds.
WiredHome 19:3f82c1161fd2 930 ///
WiredHome 19:3f82c1161fd2 931 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 932
WiredHome 19:3f82c1161fd2 933
WiredHome 19:3f82c1161fd2 934 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 935 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 936 void ClearPerformance();
WiredHome 19:3f82c1161fd2 937
WiredHome 19:3f82c1161fd2 938 /// Report the performance metrics for drawing functions using
WiredHome 41:2956a0a221e5 939 /// the available serial channel.
WiredHome 41:2956a0a221e5 940 ///
WiredHome 41:2956a0a221e5 941 /// @param pc is the serial channel to write to.
WiredHome 41:2956a0a221e5 942 ///
WiredHome 41:2956a0a221e5 943 void ReportPerformance(Serial & pc);
WiredHome 19:3f82c1161fd2 944 #endif
WiredHome 19:3f82c1161fd2 945
WiredHome 19:3f82c1161fd2 946 private:
WiredHome 19:3f82c1161fd2 947 /// Set the SPI port frequency (in Hz).
WiredHome 19:3f82c1161fd2 948 ///
WiredHome 19:3f82c1161fd2 949 /// @note attempts to call this API at runtime, with the display
WiredHome 19:3f82c1161fd2 950 /// already online, cause the system to lockup.
WiredHome 19:3f82c1161fd2 951 /// Not sure why, so moving this to private to run once.
WiredHome 19:3f82c1161fd2 952 ///
WiredHome 19:3f82c1161fd2 953 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 19:3f82c1161fd2 954 /// its capabilities. Limited tests were performed for the display
WiredHome 19:3f82c1161fd2 955 /// in the range of 1,000,000 to 50,000,000 Hz. The display was
WiredHome 19:3f82c1161fd2 956 /// a bit erratic above 20,000,000 Hz, so this became the default,
WiredHome 19:3f82c1161fd2 957 /// even though it might have been the bench-level wiring that posed
WiredHome 19:3f82c1161fd2 958 /// the limit.
WiredHome 19:3f82c1161fd2 959 ///
WiredHome 19:3f82c1161fd2 960 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 961 ///
WiredHome 19:3f82c1161fd2 962 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ);
WiredHome 19:3f82c1161fd2 963
WiredHome 19:3f82c1161fd2 964
WiredHome 19:3f82c1161fd2 965 /// Initialize the chip, which is normally done as part of the
WiredHome 19:3f82c1161fd2 966 /// constructor, so not called by the user.
WiredHome 19:3f82c1161fd2 967 ///
WiredHome 43:3becae133285 968 /// @note This API permits configuration, however it is not [yet]
WiredHome 43:3becae133285 969 /// available to the end user. Be sure the parameters
WiredHome 43:3becae133285 970 /// are consistent with each other - see the RA8875 user
WiredHome 43:3becae133285 971 /// manual.
WiredHome 43:3becae133285 972 ///
WiredHome 43:3becae133285 973 /// @param width in pixels to configure the display for.
WiredHome 43:3becae133285 974 /// @param height in pixels to configure the display for.
WiredHome 43:3becae133285 975 /// @param color_bpp can be either 8 or 16, but must be consistent
WiredHome 43:3becae133285 976 /// with the width and height parameters.
WiredHome 19:3f82c1161fd2 977 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 978 ///
WiredHome 43:3becae133285 979 RetCode_t init(int width, int height, int color_bpp);
WiredHome 19:3f82c1161fd2 980
WiredHome 32:0e4f2ae512e2 981 /// method indicating the start of a graphics stream.
WiredHome 32:0e4f2ae512e2 982 ///
WiredHome 32:0e4f2ae512e2 983 /// This is called prior to a stream of pixel data being sent.
WiredHome 32:0e4f2ae512e2 984 /// This may cause register configuration changes in the derived
WiredHome 32:0e4f2ae512e2 985 /// class in order to prepare the hardware to accept the streaming
WiredHome 32:0e4f2ae512e2 986 /// data.
WiredHome 32:0e4f2ae512e2 987 ///
WiredHome 32:0e4f2ae512e2 988 /// Following this command, a series of @see putp() commands can
WiredHome 32:0e4f2ae512e2 989 /// be used to send individual pixels to the screen.
WiredHome 32:0e4f2ae512e2 990 ///
WiredHome 32:0e4f2ae512e2 991 /// To conclude the graphics stream, @see _EndGraphicsStream should
WiredHome 32:0e4f2ae512e2 992 /// be callled.
WiredHome 32:0e4f2ae512e2 993 ///
WiredHome 32:0e4f2ae512e2 994 /// @returns error code.
WiredHome 32:0e4f2ae512e2 995 ///
WiredHome 32:0e4f2ae512e2 996 virtual RetCode_t _StartGraphicsStream(void);
WiredHome 32:0e4f2ae512e2 997
WiredHome 32:0e4f2ae512e2 998 /// method to put a single color pixel to the screen.
WiredHome 32:0e4f2ae512e2 999 ///
WiredHome 32:0e4f2ae512e2 1000 /// This method may be called as many times as necessary after
WiredHome 32:0e4f2ae512e2 1001 /// @see _StartGraphicsStream() is called, and it should be followed
WiredHome 32:0e4f2ae512e2 1002 /// by _EndGraphicsStream.
WiredHome 32:0e4f2ae512e2 1003 ///
WiredHome 32:0e4f2ae512e2 1004 /// @param pixel is a color value to be put on the screen.
WiredHome 32:0e4f2ae512e2 1005 /// @returns error code.
WiredHome 32:0e4f2ae512e2 1006 ///
WiredHome 32:0e4f2ae512e2 1007 virtual RetCode_t putp(color_t pixel);
WiredHome 32:0e4f2ae512e2 1008
WiredHome 32:0e4f2ae512e2 1009 /// method indicating the end of a graphics stream.
WiredHome 32:0e4f2ae512e2 1010 ///
WiredHome 32:0e4f2ae512e2 1011 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 32:0e4f2ae512e2 1012 /// This may cause register configuration changes in the derived
WiredHome 32:0e4f2ae512e2 1013 /// class in order to stop the hardware from accept the streaming
WiredHome 32:0e4f2ae512e2 1014 /// data.
WiredHome 32:0e4f2ae512e2 1015 ///
WiredHome 32:0e4f2ae512e2 1016 /// @returns error code.
WiredHome 32:0e4f2ae512e2 1017 ///
WiredHome 32:0e4f2ae512e2 1018 virtual RetCode_t _EndGraphicsStream(void);
WiredHome 32:0e4f2ae512e2 1019
WiredHome 29:422616aa04bd 1020 /// Internal function to put a character using the built-in (internal) font engine
WiredHome 29:422616aa04bd 1021 ///
WiredHome 29:422616aa04bd 1022 /// @param is the character to put to the screen.
WiredHome 29:422616aa04bd 1023 /// @returns the character put.
WiredHome 29:422616aa04bd 1024 ///
WiredHome 29:422616aa04bd 1025 int _internal_putc(int c);
WiredHome 29:422616aa04bd 1026
WiredHome 29:422616aa04bd 1027 /// Internal function to put a character using the external font engine
WiredHome 29:422616aa04bd 1028 ///
WiredHome 29:422616aa04bd 1029 /// @param is the character to put to the screen.
WiredHome 29:422616aa04bd 1030 /// @returns the character put.
WiredHome 29:422616aa04bd 1031 ///
WiredHome 29:422616aa04bd 1032 int _external_putc(int c);
WiredHome 29:422616aa04bd 1033
WiredHome 19:3f82c1161fd2 1034 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 1035 ///
WiredHome 19:3f82c1161fd2 1036 /// @param chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 1037 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 1038 /// the pin selection is the invert of this.
WiredHome 19:3f82c1161fd2 1039 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 1040 ///
WiredHome 19:3f82c1161fd2 1041 RetCode_t select(bool chipsel);
WiredHome 19:3f82c1161fd2 1042
WiredHome 19:3f82c1161fd2 1043 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 1044 ///
WiredHome 19:3f82c1161fd2 1045 /// @param data is the value to write.
WiredHome 19:3f82c1161fd2 1046 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 1047 /// in while shifting out.
WiredHome 19:3f82c1161fd2 1048 ///
WiredHome 19:3f82c1161fd2 1049 unsigned char spiwrite(unsigned char data);
WiredHome 19:3f82c1161fd2 1050
WiredHome 19:3f82c1161fd2 1051 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 1052 ///
WiredHome 19:3f82c1161fd2 1053 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 1054 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 1055 ///
WiredHome 19:3f82c1161fd2 1056 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 1057 /// in while shifting out.
WiredHome 19:3f82c1161fd2 1058 ///
WiredHome 19:3f82c1161fd2 1059 unsigned char spiread();
WiredHome 19:3f82c1161fd2 1060
WiredHome 19:3f82c1161fd2 1061 SPI spi; ///< spi port
WiredHome 19:3f82c1161fd2 1062 DigitalOut cs; ///< chip select pin, assumed active low
WiredHome 19:3f82c1161fd2 1063 DigitalOut res; ///< reset pin, assumed active low
WiredHome 19:3f82c1161fd2 1064 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 37:f19b7e7449dc 1065 loc_t cursor_x, cursor_y; ///< used for external fonts only
WiredHome 19:3f82c1161fd2 1066
WiredHome 19:3f82c1161fd2 1067 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 1068 typedef enum
WiredHome 19:3f82c1161fd2 1069 {
WiredHome 19:3f82c1161fd2 1070 PRF_CLS,
WiredHome 41:2956a0a221e5 1071 PRF_DRAWPIXEL,
WiredHome 41:2956a0a221e5 1072 PRF_PIXELSTREAM,
WiredHome 41:2956a0a221e5 1073 PRF_READPIXEL,
WiredHome 41:2956a0a221e5 1074 PRF_READPIXELSTREAM,
WiredHome 19:3f82c1161fd2 1075 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 1076 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 1077 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 1078 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 1079 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 1080 PRF_DRAWELLIPSE,
WiredHome 19:3f82c1161fd2 1081 METRICCOUNT
WiredHome 19:3f82c1161fd2 1082 } method_e;
WiredHome 19:3f82c1161fd2 1083 unsigned long metrics[METRICCOUNT];
WiredHome 19:3f82c1161fd2 1084 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 1085 Timer performance;
WiredHome 19:3f82c1161fd2 1086 #endif
WiredHome 19:3f82c1161fd2 1087 };
WiredHome 19:3f82c1161fd2 1088
WiredHome 19:3f82c1161fd2 1089 //} // namespace
WiredHome 19:3f82c1161fd2 1090
WiredHome 19:3f82c1161fd2 1091 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 1092
WiredHome 23:a50ded45dbaf 1093
WiredHome 23:a50ded45dbaf 1094 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 1095 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 1096 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 1097 // / / / / / / / /
WiredHome 23:a50ded45dbaf 1098 // / / / /___ / /__________ / /
WiredHome 23:a50ded45dbaf 1099 // / / / ____/ /__________ / / /
WiredHome 23:a50ded45dbaf 1100 // / / / / / / / /
WiredHome 23:a50ded45dbaf 1101 // / / / /__________ ___________/ / / /
WiredHome 23:a50ded45dbaf 1102 // /__/ /_____________/ /_____________/ /__/
WiredHome 23:a50ded45dbaf 1103
WiredHome 23:a50ded45dbaf 1104 #include "WebColors.h"
WiredHome 23:a50ded45dbaf 1105 #include "Arial12x12.h"
WiredHome 23:a50ded45dbaf 1106 #include <algorithm>
WiredHome 23:a50ded45dbaf 1107
WiredHome 23:a50ded45dbaf 1108 extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 1109
WiredHome 23:a50ded45dbaf 1110 /// This activates a small set of tests for the graphics library.
WiredHome 23:a50ded45dbaf 1111 ///
WiredHome 23:a50ded45dbaf 1112 /// Call this API and pass it the reference to the display class.
WiredHome 23:a50ded45dbaf 1113 /// It will then run a series of tests. It accepts interaction via
WiredHome 23:a50ded45dbaf 1114 /// stdin to switch from automatic test mode to manual, run a specific
WiredHome 23:a50ded45dbaf 1115 /// test, or to exit the test mode.
WiredHome 23:a50ded45dbaf 1116 ///
WiredHome 23:a50ded45dbaf 1117 /// @param lcd is a reference to the display class.
WiredHome 23:a50ded45dbaf 1118 /// @param pc is a reference to a serial interface, typically the USB to PC.
WiredHome 23:a50ded45dbaf 1119 ///
WiredHome 23:a50ded45dbaf 1120 void RunTestSet(RA8875 & lcd, Serial & pc);
WiredHome 23:a50ded45dbaf 1121
WiredHome 23:a50ded45dbaf 1122
WiredHome 23:a50ded45dbaf 1123 // To enable the test code, uncomment this section, or copy the
WiredHome 23:a50ded45dbaf 1124 // necessary pieces to your "main()".
WiredHome 23:a50ded45dbaf 1125 //
WiredHome 23:a50ded45dbaf 1126 // #include "mbed.h"
WiredHome 23:a50ded45dbaf 1127 // #include "RA8875.h"
WiredHome 23:a50ded45dbaf 1128 // RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 23:a50ded45dbaf 1129 // Serial pc(USBTX, USBRX);
WiredHome 23:a50ded45dbaf 1130 // extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 1131 // int main()
WiredHome 23:a50ded45dbaf 1132 // {
WiredHome 23:a50ded45dbaf 1133 // pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 23:a50ded45dbaf 1134 // pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 23:a50ded45dbaf 1135 //
WiredHome 23:a50ded45dbaf 1136 // pc.printf("Turning on display\r\n");
WiredHome 23:a50ded45dbaf 1137 // lcd.Reset();
WiredHome 23:a50ded45dbaf 1138 // lcd.Power(true); // display power is on, but the backlight is independent
WiredHome 23:a50ded45dbaf 1139 // lcd.Backlight(0.5);
WiredHome 23:a50ded45dbaf 1140 // RunTestSet(lcd, pc);
WiredHome 23:a50ded45dbaf 1141 // }
WiredHome 23:a50ded45dbaf 1142
WiredHome 23:a50ded45dbaf 1143 #endif // TESTENABLE
WiredHome 23:a50ded45dbaf 1144
WiredHome 19:3f82c1161fd2 1145 #endif