Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Sat Feb 08 17:35:45 2014 +0000
Revision:
41:2956a0a221e5
Parent:
40:04aa280dfa39
Child:
43:3becae133285
Added PrintScreen method, to capture the current image to a file system.; Improved performance of pixel streaming (rendering a bitmap and capturing a bitmap).; Ran performance checks, then disabled debug and the performance information.

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