Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Sun Mar 09 23:45:23 2014 +0000
Revision:
43:3becae133285
Parent:
41:2956a0a221e5
Child:
44:207594dece70
Initial support (not yet complete) for more screen resolutions and for display layers.

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