KSM edits to RA8875

Dependents:   Liz_Test_Code

Committer:
WiredHome
Date:
Mon Mar 10 11:40:56 2014 +0000
Revision:
44:207594dece70
Parent:
43:3becae133285
Child:
45:679c2fb8480c
Layer support is nearly complete. It is functioning, but might benefit from a little refactoring of the API for transparency and mode.

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