Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Sun Jan 12 21:18:47 2014 +0000
Revision:
22:f6ea795eb541
Parent:
21:3c1efb192927
Child:
23:a50ded45dbaf
Update documentation only.

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 19:3f82c1161fd2 7 #define RA8875_DEFAULT_SPI_FREQ 1000000
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 19:3f82c1161fd2 13 // What better place for some test code than in here...
WiredHome 19:3f82c1161fd2 14 #define TESTENABLE
WiredHome 19:3f82c1161fd2 15
WiredHome 19:3f82c1161fd2 16 #define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
WiredHome 19:3f82c1161fd2 17
WiredHome 19:3f82c1161fd2 18 /// DOS colors - slightly color enhanced
WiredHome 20:6e2e4a8372eb 19 #define Black (color_t)(RGB(0,0,0))
WiredHome 20:6e2e4a8372eb 20 #define Blue (color_t)(RGB(0,0,187))
WiredHome 20:6e2e4a8372eb 21 #define Green (color_t)(RGB(0,187,0))
WiredHome 20:6e2e4a8372eb 22 #define Cyan (color_t)(RGB(0,187,187))
WiredHome 20:6e2e4a8372eb 23 #define Red (color_t)(RGB(187,0,0))
WiredHome 20:6e2e4a8372eb 24 #define Magenta (color_t)(RGB(187,0,187))
WiredHome 20:6e2e4a8372eb 25 #define Brown (color_t)(RGB(187,187,0))
WiredHome 20:6e2e4a8372eb 26 #define Gray (color_t)(RGB(187,187,187))
WiredHome 20:6e2e4a8372eb 27 #define Charcoal (color_t)(RGB(85,85,85))
WiredHome 20:6e2e4a8372eb 28 #define BrightBlue (color_t)(RGB(85,85,255))
WiredHome 20:6e2e4a8372eb 29 #define BrightGreen (color_t)(RGB(85,255,85))
WiredHome 20:6e2e4a8372eb 30 #define BrightCyan (color_t)(RGB(85,255,255))
WiredHome 20:6e2e4a8372eb 31 #define Orange (color_t)(RGB(255,85,85))
WiredHome 20:6e2e4a8372eb 32 #define Pink (color_t)(RGB(255,85,255))
WiredHome 20:6e2e4a8372eb 33 #define Yellow (color_t)(RGB(255,255,85))
WiredHome 20:6e2e4a8372eb 34 #define White (color_t)(RGB(255,255,255))
WiredHome 20:6e2e4a8372eb 35
WiredHome 20:6e2e4a8372eb 36 #define BrightRed (color_t)(RGB(255,0,0))
WiredHome 19:3f82c1161fd2 37
WiredHome 19:3f82c1161fd2 38 //namespace SW_graphics
WiredHome 19:3f82c1161fd2 39 //{
WiredHome 19:3f82c1161fd2 40
WiredHome 19:3f82c1161fd2 41 /// color type definition to let the compiler help keep us honest.
WiredHome 19:3f82c1161fd2 42 ///
WiredHome 19:3f82c1161fd2 43 /// colors can be defined with the RGB(r,g,b) macro, and there
WiredHome 19:3f82c1161fd2 44 /// are a number of predefined colors:
WiredHome 19:3f82c1161fd2 45 /// - Black, Blue, Green, Cyan,
WiredHome 19:3f82c1161fd2 46 /// - Red, Magenta, Brown, Gray,
WiredHome 19:3f82c1161fd2 47 /// - Charcoal, BrightBlue, BrightGreen, BrightCyan,
WiredHome 19:3f82c1161fd2 48 /// - Orange, Pink, Yellow, White
WiredHome 19:3f82c1161fd2 49 ///
WiredHome 19:3f82c1161fd2 50 typedef uint16_t color_t;
WiredHome 19:3f82c1161fd2 51
WiredHome 19:3f82c1161fd2 52 /// background fill info for drawing Text, Rectangles, RoundedRectanges, Circles, Ellipses and Triangles.
WiredHome 19:3f82c1161fd2 53 typedef enum
WiredHome 19:3f82c1161fd2 54 {
WiredHome 19:3f82c1161fd2 55 NOFILL, ///< do not fill the object with the background color
WiredHome 19:3f82c1161fd2 56 FILL ///< fill the object space with the background color
WiredHome 19:3f82c1161fd2 57 } fill_t;
WiredHome 19:3f82c1161fd2 58
WiredHome 19:3f82c1161fd2 59 /// return values from functions
WiredHome 19:3f82c1161fd2 60 //typedef enum
WiredHome 19:3f82c1161fd2 61 //{
WiredHome 19:3f82c1161fd2 62 // noerror,
WiredHome 19:3f82c1161fd2 63 // bad_parameter
WiredHome 19:3f82c1161fd2 64 //} RetCode_t;
WiredHome 19:3f82c1161fd2 65
WiredHome 21:3c1efb192927 66 /// This is a graphics library for the Raio RA8875 Display Controller chip
WiredHome 21:3c1efb192927 67 /// attached to a 4-wire SPI interface.
WiredHome 21:3c1efb192927 68 ///
WiredHome 21:3c1efb192927 69 /// It offers both primitive and high level APIs.
WiredHome 21:3c1efb192927 70 /// Central to this API is a coordinate system, where the origin (0,0) is in
WiredHome 21:3c1efb192927 71 /// the top-left corner of the display, and the width extends positive to the
WiredHome 21:3c1efb192927 72 /// right and the height extends positive toward the bottom.
WiredHome 21:3c1efb192927 73 ///
WiredHome 21:3c1efb192927 74 /// As there are both graphics and text commands, one must take care to use
WiredHome 21:3c1efb192927 75 /// the proper coordinate system for each. Some of the text APIs are in units
WiredHome 21:3c1efb192927 76 /// of column and row, which is measured in character positions (so dependent
WiredHome 21:3c1efb192927 77 /// on the font size).
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 19:3f82c1161fd2 85 ISO8859_1,
WiredHome 19:3f82c1161fd2 86 ISO8859_2,
WiredHome 19:3f82c1161fd2 87 ISO8859_3,
WiredHome 19:3f82c1161fd2 88 ISO8859_4
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 19:3f82c1161fd2 94 normal,
WiredHome 19:3f82c1161fd2 95 rotated
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 19:3f82c1161fd2 101 align_none,
WiredHome 19:3f82c1161fd2 102 align_full
WiredHome 19:3f82c1161fd2 103 } alignment_t;
WiredHome 19:3f82c1161fd2 104
WiredHome 19:3f82c1161fd2 105 /// Scale factor - 1, 2, 3 4
WiredHome 19:3f82c1161fd2 106 typedef unsigned int HorizontalScale;
WiredHome 19:3f82c1161fd2 107
WiredHome 19:3f82c1161fd2 108 /// Scale factor - 1, 2, 3, 4
WiredHome 19:3f82c1161fd2 109 typedef unsigned int VerticalScale;
WiredHome 19:3f82c1161fd2 110
WiredHome 19:3f82c1161fd2 111 /// Clear screen region
WiredHome 19:3f82c1161fd2 112 typedef enum
WiredHome 19:3f82c1161fd2 113 {
WiredHome 19:3f82c1161fd2 114 FULLWINDOW,
WiredHome 19:3f82c1161fd2 115 ACTIVEWINDOW
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 19:3f82c1161fd2 134 /// Destructor doesn't have much to do.
WiredHome 19:3f82c1161fd2 135 //~RA8875();
WiredHome 19:3f82c1161fd2 136
WiredHome 19:3f82c1161fd2 137 /// Write a command to the display
WiredHome 19:3f82c1161fd2 138 ///
WiredHome 19:3f82c1161fd2 139 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 140 ///
WiredHome 19:3f82c1161fd2 141 /// @param command is the command to write.
WiredHome 19:3f82c1161fd2 142 /// @data is optional data to be written to the command register
WiredHome 19:3f82c1161fd2 143 /// and only occurs if the data is in the range [0 - 0xFF].
WiredHome 19:3f82c1161fd2 144 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 145 ///
WiredHome 19:3f82c1161fd2 146 RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
WiredHome 19:3f82c1161fd2 147
WiredHome 19:3f82c1161fd2 148 /// Write a data byte 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 data is the data to write.
WiredHome 19:3f82c1161fd2 153 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 154 ///
WiredHome 19:3f82c1161fd2 155 RetCode_t WriteData(unsigned char data);
WiredHome 19:3f82c1161fd2 156
WiredHome 19:3f82c1161fd2 157 /// Read a command register
WiredHome 19:3f82c1161fd2 158 ///
WiredHome 19:3f82c1161fd2 159 /// @param command is the command register to read.
WiredHome 19:3f82c1161fd2 160 /// @returns the value read from the register.
WiredHome 19:3f82c1161fd2 161 ///
WiredHome 19:3f82c1161fd2 162 unsigned char ReadCommand(unsigned char command);
WiredHome 19:3f82c1161fd2 163
WiredHome 19:3f82c1161fd2 164 /// Read a data byte to the display
WiredHome 19:3f82c1161fd2 165 ///
WiredHome 19:3f82c1161fd2 166 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 167 ///
WiredHome 19:3f82c1161fd2 168 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 169 ///
WiredHome 19:3f82c1161fd2 170 unsigned char ReadData(void);
WiredHome 19:3f82c1161fd2 171
WiredHome 19:3f82c1161fd2 172 /// Read the display status
WiredHome 19:3f82c1161fd2 173 ///
WiredHome 19:3f82c1161fd2 174 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 175 ///
WiredHome 19:3f82c1161fd2 176 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 177 ///
WiredHome 19:3f82c1161fd2 178 unsigned char ReadStatus(void);
WiredHome 19:3f82c1161fd2 179
WiredHome 19:3f82c1161fd2 180 /// get the width in pixels of the currently active font
WiredHome 19:3f82c1161fd2 181 ///
WiredHome 19:3f82c1161fd2 182 /// @returns font width in pixels.
WiredHome 19:3f82c1161fd2 183 ///
WiredHome 19:3f82c1161fd2 184 unsigned int fontwidth(void);
WiredHome 19:3f82c1161fd2 185
WiredHome 19:3f82c1161fd2 186 /// get the height in pixels of the currently active font
WiredHome 19:3f82c1161fd2 187 ///
WiredHome 19:3f82c1161fd2 188 /// @returns font height in pixels.
WiredHome 19:3f82c1161fd2 189 ///
WiredHome 19:3f82c1161fd2 190 unsigned int fontheight(void);
WiredHome 19:3f82c1161fd2 191
WiredHome 19:3f82c1161fd2 192 /// get the number of colums based on the currently active font
WiredHome 19:3f82c1161fd2 193 ///
WiredHome 19:3f82c1161fd2 194 /// @returns number of columns.
WiredHome 19:3f82c1161fd2 195 ///
WiredHome 19:3f82c1161fd2 196 virtual int columns(void);
WiredHome 19:3f82c1161fd2 197
WiredHome 19:3f82c1161fd2 198 /// get the number of rows based on the currently active font
WiredHome 19:3f82c1161fd2 199 ///
WiredHome 19:3f82c1161fd2 200 /// @returns number of rows.
WiredHome 19:3f82c1161fd2 201 ///
WiredHome 19:3f82c1161fd2 202 virtual int rows(void);
WiredHome 19:3f82c1161fd2 203
WiredHome 19:3f82c1161fd2 204 /// get the screen width in pixels
WiredHome 19:3f82c1161fd2 205 ///
WiredHome 19:3f82c1161fd2 206 /// @returns screen width in pixels.
WiredHome 19:3f82c1161fd2 207 ///
WiredHome 19:3f82c1161fd2 208 virtual int width(void);
WiredHome 19:3f82c1161fd2 209
WiredHome 19:3f82c1161fd2 210 /// get the screen height in pixels
WiredHome 19:3f82c1161fd2 211 ///
WiredHome 19:3f82c1161fd2 212 /// @returns screen height in pixels.
WiredHome 19:3f82c1161fd2 213 ///
WiredHome 19:3f82c1161fd2 214 virtual int height(void);
WiredHome 19:3f82c1161fd2 215
WiredHome 19:3f82c1161fd2 216 /// Set cursor position based on the current font size.
WiredHome 19:3f82c1161fd2 217 ///
WiredHome 19:3f82c1161fd2 218 /// @param x is the horizontal position in character positions
WiredHome 19:3f82c1161fd2 219 /// @param y is the vertical position in character positions
WiredHome 19:3f82c1161fd2 220 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 221 ///
WiredHome 19:3f82c1161fd2 222 virtual RetCode_t locate(unsigned int x, unsigned int y);
WiredHome 19:3f82c1161fd2 223
WiredHome 19:3f82c1161fd2 224 /// Prepare the controller to write text to the screen by positioning
WiredHome 19:3f82c1161fd2 225 /// the cursor.
WiredHome 19:3f82c1161fd2 226 ///
WiredHome 19:3f82c1161fd2 227 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 228 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 229 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 230 ///
WiredHome 19:3f82c1161fd2 231 RetCode_t SetTextCursor(unsigned int x, unsigned int y);
WiredHome 19:3f82c1161fd2 232
WiredHome 19:3f82c1161fd2 233 /// Select the ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 234 ///
WiredHome 19:3f82c1161fd2 235 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 236 ///
WiredHome 19:3f82c1161fd2 237 /// @param font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 238 ///
WiredHome 19:3f82c1161fd2 239 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 240 /// the command is not executed.
WiredHome 19:3f82c1161fd2 241 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 242 ///
WiredHome 19:3f82c1161fd2 243 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 19:3f82c1161fd2 244
WiredHome 19:3f82c1161fd2 245 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 246 ///
WiredHome 19:3f82c1161fd2 247 /// This command lets you make several modifications to any text that
WiredHome 19:3f82c1161fd2 248 /// is written.
WiredHome 19:3f82c1161fd2 249 ///
WiredHome 19:3f82c1161fd2 250 /// Options can be combined:
WiredHome 19:3f82c1161fd2 251 /// Default:
WiredHome 19:3f82c1161fd2 252 /// @li Full alignment disabled,
WiredHome 19:3f82c1161fd2 253 /// @li Font with Background color,
WiredHome 19:3f82c1161fd2 254 /// @li Font in normal orientiation,
WiredHome 19:3f82c1161fd2 255 /// @li Horizontal scale x 1
WiredHome 19:3f82c1161fd2 256 /// @li Vertical scale x 1
WiredHome 19:3f82c1161fd2 257 /// @li alignment
WiredHome 19:3f82c1161fd2 258 ///
WiredHome 19:3f82c1161fd2 259 /// @param fillit defaults to FILL, but can be NOFILL
WiredHome 19:3f82c1161fd2 260 /// @param angle defaults to normal, but can be rotated
WiredHome 19:3f82c1161fd2 261 /// @param hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 262 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 263 /// @param vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 264 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 265 /// @param alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 266 /// align_full.
WiredHome 19:3f82c1161fd2 267 ///
WiredHome 19:3f82c1161fd2 268 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 269 /// the command is not executed.
WiredHome 19:3f82c1161fd2 270 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 271 ///
WiredHome 19:3f82c1161fd2 272 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 19:3f82c1161fd2 273 font_angle_t angle = normal,
WiredHome 19:3f82c1161fd2 274 HorizontalScale hScale = 1,
WiredHome 19:3f82c1161fd2 275 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 276 alignment_t alignment = align_none);
WiredHome 19:3f82c1161fd2 277
WiredHome 19:3f82c1161fd2 278 /// Control the font size
WiredHome 19:3f82c1161fd2 279 ///
WiredHome 19:3f82c1161fd2 280 /// This command lets you set the font enlargement for both horizontal
WiredHome 19:3f82c1161fd2 281 /// and vertical, independent of the rotation, background, and
WiredHome 19:3f82c1161fd2 282 /// alignment. @see SetTextFontControl.
WiredHome 19:3f82c1161fd2 283 ///
WiredHome 19:3f82c1161fd2 284 /// @param hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 285 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 286 /// @param vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 287 /// and scales the font size by this amount.
WiredHome 19:3f82c1161fd2 288 ///
WiredHome 19:3f82c1161fd2 289 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 290 /// the command is not executed.
WiredHome 19:3f82c1161fd2 291 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 292 ///
WiredHome 19:3f82c1161fd2 293 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = 1);
WiredHome 19:3f82c1161fd2 294
WiredHome 19:3f82c1161fd2 295 /// put a character on the screen.
WiredHome 19:3f82c1161fd2 296 ///
WiredHome 19:3f82c1161fd2 297 /// @param c is the character.
WiredHome 19:3f82c1161fd2 298 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 299 ///
WiredHome 19:3f82c1161fd2 300 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 301
WiredHome 19:3f82c1161fd2 302 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 303 ///
WiredHome 19:3f82c1161fd2 304 /// @param string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 305 ///
WiredHome 19:3f82c1161fd2 306 void puts(const char * string);
WiredHome 19:3f82c1161fd2 307
WiredHome 19:3f82c1161fd2 308 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 309 ///
WiredHome 19:3f82c1161fd2 310 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 311 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 312 /// @param string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 313 ///
WiredHome 19:3f82c1161fd2 314 void puts(unsigned int x, unsigned int y, const char * string);
WiredHome 19:3f82c1161fd2 315
WiredHome 19:3f82c1161fd2 316 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 317 /// the memory cursor.
WiredHome 19:3f82c1161fd2 318 ///
WiredHome 19:3f82c1161fd2 319 /// @param x is the horizontal position in pixels (from the left edge)
WiredHome 19:3f82c1161fd2 320 /// @param y is the vertical position in pixels (from the top edge)
WiredHome 19:3f82c1161fd2 321 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 322 ///
WiredHome 19:3f82c1161fd2 323 RetCode_t SetMemoryCursor(unsigned int x, unsigned int y);
WiredHome 19:3f82c1161fd2 324
WiredHome 19:3f82c1161fd2 325 /// Set the window, which controls where items are written to the screen.
WiredHome 19:3f82c1161fd2 326 ///
WiredHome 19:3f82c1161fd2 327 /// When something hits the window width, it wraps back to the left side
WiredHome 19:3f82c1161fd2 328 /// and down a row. If the initial write is outside the window, it will
WiredHome 19:3f82c1161fd2 329 /// be captured into the window when it crosses a boundary.
WiredHome 19:3f82c1161fd2 330 ///
WiredHome 19:3f82c1161fd2 331 /// @param x is the left edge in pixels.
WiredHome 19:3f82c1161fd2 332 /// @param y is the top edge in pixels.
WiredHome 19:3f82c1161fd2 333 /// @param width is the window width in pixels.
WiredHome 19:3f82c1161fd2 334 /// @param height is the window height in pixels.
WiredHome 19:3f82c1161fd2 335 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 336 ///
WiredHome 19:3f82c1161fd2 337 RetCode_t SetWindow(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
WiredHome 19:3f82c1161fd2 338
WiredHome 19:3f82c1161fd2 339 /// Clear the screen.
WiredHome 19:3f82c1161fd2 340 ///
WiredHome 19:3f82c1161fd2 341 /// The behavior is to clear the whole screen. @see clsw().
WiredHome 19:3f82c1161fd2 342 ///
WiredHome 19:3f82c1161fd2 343 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 344 ///
WiredHome 19:3f82c1161fd2 345 virtual RetCode_t cls(void);
WiredHome 19:3f82c1161fd2 346
WiredHome 19:3f82c1161fd2 347 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 348 ///
WiredHome 19:3f82c1161fd2 349 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 350 /// parameter, the action can be restricted to the active window, which
WiredHome 19:3f82c1161fd2 351 /// can be set with the @see SetWindow method.
WiredHome 19:3f82c1161fd2 352 ///
WiredHome 19:3f82c1161fd2 353 /// @param region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 354 /// or may be set to ACTIVEWINDOW.
WiredHome 19:3f82c1161fd2 355 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 356 ///
WiredHome 19:3f82c1161fd2 357 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 358
WiredHome 19:3f82c1161fd2 359 /// Set the background color.
WiredHome 19:3f82c1161fd2 360 ///
WiredHome 19:3f82c1161fd2 361 /// @param color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 362 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 363 ///
WiredHome 19:3f82c1161fd2 364 virtual RetCode_t background(color_t color);
WiredHome 19:3f82c1161fd2 365
WiredHome 19:3f82c1161fd2 366 /// Set the background color.
WiredHome 19:3f82c1161fd2 367 ///
WiredHome 19:3f82c1161fd2 368 /// @param r is the red element of the color.
WiredHome 19:3f82c1161fd2 369 /// @param g is the green element of the color.
WiredHome 19:3f82c1161fd2 370 /// @param b is the blue element of the color.
WiredHome 19:3f82c1161fd2 371 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 372 ///
WiredHome 19:3f82c1161fd2 373 virtual RetCode_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 374
WiredHome 19:3f82c1161fd2 375 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 376 ///
WiredHome 19:3f82c1161fd2 377 /// @param color is expressed in 16-bit format.
WiredHome 19:3f82c1161fd2 378 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 379 ///
WiredHome 19:3f82c1161fd2 380 virtual RetCode_t foreground(color_t color);
WiredHome 19:3f82c1161fd2 381
WiredHome 19:3f82c1161fd2 382 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 383 ///
WiredHome 19:3f82c1161fd2 384 /// @param R is the red element of the color.
WiredHome 19:3f82c1161fd2 385 /// @param G is the green element of the color.
WiredHome 19:3f82c1161fd2 386 /// @param B is the blue element of the color.
WiredHome 19:3f82c1161fd2 387 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 388 ///
WiredHome 19:3f82c1161fd2 389 virtual RetCode_t foreground(unsigned char R, unsigned char G, unsigned char B);
WiredHome 19:3f82c1161fd2 390
WiredHome 19:3f82c1161fd2 391 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 392 ///
WiredHome 19:3f82c1161fd2 393 /// @returns the current foreground color.
WiredHome 19:3f82c1161fd2 394 ///
WiredHome 19:3f82c1161fd2 395 unsigned int GetForeColor(void);
WiredHome 19:3f82c1161fd2 396
WiredHome 19:3f82c1161fd2 397 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 398 ///
WiredHome 19:3f82c1161fd2 399 /// @note As a side effect, this also sets the foreground color
WiredHome 19:3f82c1161fd2 400 /// affecting all subsequent operations.
WiredHome 19:3f82c1161fd2 401 ///
WiredHome 19:3f82c1161fd2 402 /// @param x is the horizontal offset to this pixel.
WiredHome 19:3f82c1161fd2 403 /// @param y is the vertical offset to this pixel.
WiredHome 19:3f82c1161fd2 404 /// @param color defines the color for the pixel.
WiredHome 19:3f82c1161fd2 405 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 406 ///
WiredHome 19:3f82c1161fd2 407 virtual RetCode_t pixel(unsigned int x, unsigned int y, color_t color);
WiredHome 19:3f82c1161fd2 408
WiredHome 19:3f82c1161fd2 409 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 410 ///
WiredHome 19:3f82c1161fd2 411 /// @param x is the horizontal offset to this pixel.
WiredHome 19:3f82c1161fd2 412 /// @param y is the veritical offset to this pixel.
WiredHome 19:3f82c1161fd2 413 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 414 ///
WiredHome 19:3f82c1161fd2 415 virtual RetCode_t pixel(unsigned int x, unsigned int y);
WiredHome 19:3f82c1161fd2 416
WiredHome 19:3f82c1161fd2 417 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 418 ///
WiredHome 19:3f82c1161fd2 419 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 420 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 421 ///
WiredHome 19:3f82c1161fd2 422 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 423 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 424 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 425 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 426 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 427 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 428 ///
WiredHome 19:3f82c1161fd2 429 RetCode_t line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 430 color_t color);
WiredHome 19:3f82c1161fd2 431
WiredHome 19:3f82c1161fd2 432 /// Draw a line
WiredHome 19:3f82c1161fd2 433 ///
WiredHome 19:3f82c1161fd2 434 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 435 ///
WiredHome 19:3f82c1161fd2 436 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 437 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 438 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 439 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 440 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 441 ///
WiredHome 19:3f82c1161fd2 442 RetCode_t line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2);
WiredHome 19:3f82c1161fd2 443
WiredHome 19:3f82c1161fd2 444 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 445 ///
WiredHome 19:3f82c1161fd2 446 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 447 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 448 ///
WiredHome 19:3f82c1161fd2 449 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 450 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 451 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 452 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 453 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 454 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 455 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 456 ///
WiredHome 19:3f82c1161fd2 457 RetCode_t rect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 458 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 459
WiredHome 19:3f82c1161fd2 460 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 461 ///
WiredHome 19:3f82c1161fd2 462 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 463 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 464 ///
WiredHome 19:3f82c1161fd2 465 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 466 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 467 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 468 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 469 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 470 /// @param fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 19:3f82c1161fd2 471 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 472 ///
WiredHome 19:3f82c1161fd2 473 RetCode_t fillrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 474 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 475
WiredHome 19:3f82c1161fd2 476 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 477 ///
WiredHome 19:3f82c1161fd2 478 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 479 ///
WiredHome 19:3f82c1161fd2 480 /// @param x1 is the horizontal start of the line.
WiredHome 19:3f82c1161fd2 481 /// @param y1 is the vertical start of the line.
WiredHome 19:3f82c1161fd2 482 /// @param x2 is the horizontal end of the line.
WiredHome 19:3f82c1161fd2 483 /// @param y2 is the vertical end of the line.
WiredHome 19:3f82c1161fd2 484 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 485 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 486 ///
WiredHome 19:3f82c1161fd2 487 RetCode_t rect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 488 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 489
WiredHome 19:3f82c1161fd2 490 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 491 ///
WiredHome 21:3c1efb192927 492 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 493 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 494 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 495 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 496 ///
WiredHome 19:3f82c1161fd2 497 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 498 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 499 ///
WiredHome 21:3c1efb192927 500 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 501 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 502 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 503 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 504 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 505 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 506 /// is returned.
WiredHome 22:f6ea795eb541 507 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 508 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 509 /// is returned.
WiredHome 19:3f82c1161fd2 510 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 511 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 512 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 513 ///
WiredHome 19:3f82c1161fd2 514 RetCode_t fillroundrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 515 unsigned int radius1, unsigned int radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 516
WiredHome 19:3f82c1161fd2 517 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 518 ///
WiredHome 21:3c1efb192927 519 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 520 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 521 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 522 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 523 ///
WiredHome 19:3f82c1161fd2 524 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 525 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 526 ///
WiredHome 21:3c1efb192927 527 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 528 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 529 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 530 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 531 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 532 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 533 /// is returned.
WiredHome 22:f6ea795eb541 534 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 535 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 536 /// is returned.
WiredHome 19:3f82c1161fd2 537 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 538 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 539 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 540 ///
WiredHome 19:3f82c1161fd2 541 RetCode_t roundrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 542 unsigned int radius1, unsigned int radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 543
WiredHome 19:3f82c1161fd2 544 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 545 ///
WiredHome 21:3c1efb192927 546 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 547 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 548 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 549 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 550 ///
WiredHome 21:3c1efb192927 551 /// @param x1 is the horizontal start of the line and must be <= x2.
WiredHome 21:3c1efb192927 552 /// @param y1 is the vertical start of the line and must be <= y2.
WiredHome 21:3c1efb192927 553 /// @param x2 is the horizontal end of the line and must be >= x1.
WiredHome 21:3c1efb192927 554 /// @param y2 is the vertical end of the line and must be >= y1.
WiredHome 22:f6ea795eb541 555 /// @param radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 556 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 557 /// is returned.
WiredHome 22:f6ea795eb541 558 /// @param radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 559 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 560 /// is returned.
WiredHome 19:3f82c1161fd2 561 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 562 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 563 ///
WiredHome 19:3f82c1161fd2 564 RetCode_t roundrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 565 unsigned int radius1, unsigned int radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 566
WiredHome 19:3f82c1161fd2 567 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 568 ///
WiredHome 19:3f82c1161fd2 569 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 570 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 571 ///
WiredHome 19:3f82c1161fd2 572 /// @param x1 is the horizontal for point 1.
WiredHome 21:3c1efb192927 573 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 574 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 575 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 576 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 577 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 578 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 579 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 580 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 581 ///
WiredHome 19:3f82c1161fd2 582 RetCode_t triangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 583 unsigned int x3, unsigned int y3, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 584
WiredHome 19:3f82c1161fd2 585 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 586 ///
WiredHome 19:3f82c1161fd2 587 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 588 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 589 ///
WiredHome 19:3f82c1161fd2 590 /// @param x1 is the horizontal for point 1.
WiredHome 19:3f82c1161fd2 591 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 592 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 593 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 594 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 595 /// @param y3 is the vertical for point 3.
WiredHome 19:3f82c1161fd2 596 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 597 /// @param fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 19:3f82c1161fd2 598 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 599 ///
WiredHome 19:3f82c1161fd2 600 RetCode_t filltriangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 601 unsigned int x3, unsigned int y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 602
WiredHome 19:3f82c1161fd2 603 /// Draw a triangle
WiredHome 19:3f82c1161fd2 604 ///
WiredHome 19:3f82c1161fd2 605 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 606 ///
WiredHome 19:3f82c1161fd2 607 /// @param x1 is the horizontal for point 1.
WiredHome 19:3f82c1161fd2 608 /// @param y1 is the vertical for point 1.
WiredHome 19:3f82c1161fd2 609 /// @param x2 is the horizontal for point 2.
WiredHome 19:3f82c1161fd2 610 /// @param y2 is the vertical for point 2.
WiredHome 19:3f82c1161fd2 611 /// @param x3 is the horizontal for point 3.
WiredHome 19:3f82c1161fd2 612 /// @param y3 is the vertical for point 3.
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 19:3f82c1161fd2 616 RetCode_t triangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,
WiredHome 19:3f82c1161fd2 617 unsigned int x3, unsigned int y3, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 618
WiredHome 19:3f82c1161fd2 619 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 620 ///
WiredHome 19:3f82c1161fd2 621 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 622 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 623 ///
WiredHome 19:3f82c1161fd2 624 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 625 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 626 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 627 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 628 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 629 ///
WiredHome 19:3f82c1161fd2 630 RetCode_t circle(unsigned int x, unsigned int y, unsigned int radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 631
WiredHome 19:3f82c1161fd2 632 /// Draw a filled circle using the specified color.
WiredHome 19:3f82c1161fd2 633 ///
WiredHome 19:3f82c1161fd2 634 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 635 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 636 ///
WiredHome 19:3f82c1161fd2 637 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 638 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 639 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 640 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 641 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 642 ///
WiredHome 19:3f82c1161fd2 643 RetCode_t fillcircle(unsigned int x, unsigned int y, unsigned int radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 644
WiredHome 19:3f82c1161fd2 645 /// Draw a circle.
WiredHome 19:3f82c1161fd2 646 ///
WiredHome 19:3f82c1161fd2 647 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 648 ///
WiredHome 19:3f82c1161fd2 649 /// @param x is the horizontal center of the circle.
WiredHome 19:3f82c1161fd2 650 /// @param y is the vertical center of the circle.
WiredHome 19:3f82c1161fd2 651 /// @param radius defines the size of the circle.
WiredHome 19:3f82c1161fd2 652 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 653 ///
WiredHome 19:3f82c1161fd2 654 RetCode_t circle(unsigned int x, unsigned int y, unsigned int radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 655
WiredHome 19:3f82c1161fd2 656 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 657 ///
WiredHome 19:3f82c1161fd2 658 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 659 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 660 ///
WiredHome 19:3f82c1161fd2 661 /// @param x is the horizontal center of the ellipse.
WiredHome 19:3f82c1161fd2 662 /// @param y is the vertical center of the ellipse.
WiredHome 22:f6ea795eb541 663 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 22:f6ea795eb541 664 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 19:3f82c1161fd2 665 /// @param color defines the foreground color.
WiredHome 19:3f82c1161fd2 666 /// @param fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 667 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 668 ///
WiredHome 19:3f82c1161fd2 669 RetCode_t ellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius1,
WiredHome 19:3f82c1161fd2 670 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 671
WiredHome 19:3f82c1161fd2 672 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 673 ///
WiredHome 19:3f82c1161fd2 674 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 675 ///
WiredHome 19:3f82c1161fd2 676 /// @param x is the horizontal center of the ellipse.
WiredHome 19:3f82c1161fd2 677 /// @param y is the vertical center of the ellipse.
WiredHome 22:f6ea795eb541 678 /// @param radius1 defines the horizontal radius of the ellipse.
WiredHome 22:f6ea795eb541 679 /// @param radius2 defines the vertical radius of the ellipse.
WiredHome 19:3f82c1161fd2 680 /// @param fillit defines whether the circle is filled or not.
WiredHome 19:3f82c1161fd2 681 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 682 ///
WiredHome 19:3f82c1161fd2 683 RetCode_t ellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius1, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 684
WiredHome 19:3f82c1161fd2 685 /// Control display power
WiredHome 19:3f82c1161fd2 686 ///
WiredHome 19:3f82c1161fd2 687 /// @param on when set to true will turn on the display, when false it is turned off.
WiredHome 19:3f82c1161fd2 688 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 689 ///
WiredHome 19:3f82c1161fd2 690 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 691
WiredHome 19:3f82c1161fd2 692 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 693 ///
WiredHome 19:3f82c1161fd2 694 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 695 ///
WiredHome 19:3f82c1161fd2 696 RetCode_t Reset(void);
WiredHome 19:3f82c1161fd2 697
WiredHome 19:3f82c1161fd2 698 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 699 ///
WiredHome 19:3f82c1161fd2 700 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 701 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 702 ///
WiredHome 19:3f82c1161fd2 703 /// @param brightness ranges from 0 (off) to 255 (full on)
WiredHome 19:3f82c1161fd2 704 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 705 ///
WiredHome 19:3f82c1161fd2 706 RetCode_t Backlight_u8(unsigned char brightness);
WiredHome 19:3f82c1161fd2 707
WiredHome 19:3f82c1161fd2 708 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 709 ///
WiredHome 19:3f82c1161fd2 710 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 711 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 712 ///
WiredHome 19:3f82c1161fd2 713 /// @param brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 19:3f82c1161fd2 714 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 715 ///
WiredHome 19:3f82c1161fd2 716 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 717
WiredHome 19:3f82c1161fd2 718 /// Set a reference to a bitmap font, provided by the user.
WiredHome 19:3f82c1161fd2 719 ///
WiredHome 19:3f82c1161fd2 720 /// @note Tool to create the fonts is accessible from its creator
WiredHome 19:3f82c1161fd2 721 /// available at http://www.mikroe.com.
WiredHome 19:3f82c1161fd2 722 /// Change the data to an array of type char[].
WiredHome 19:3f82c1161fd2 723 ///
WiredHome 19:3f82c1161fd2 724 /// @param font is a pointer to a specially formed font array.
WiredHome 19:3f82c1161fd2 725 /// This special font array has a 4-byte header, followed by
WiredHome 19:3f82c1161fd2 726 /// the data:
WiredHome 19:3f82c1161fd2 727 /// - the number of bytes per char
WiredHome 19:3f82c1161fd2 728 /// - the vertical size in pixels for each character
WiredHome 19:3f82c1161fd2 729 /// - the horizontal size in pixels for each character
WiredHome 19:3f82c1161fd2 730 /// - the number of bytes per vertical line (width of the array)
WiredHome 19:3f82c1161fd2 731 /// @returns error code.
WiredHome 19:3f82c1161fd2 732 ///
WiredHome 19:3f82c1161fd2 733 RetCode_t set_font(const unsigned char * font);
WiredHome 19:3f82c1161fd2 734
WiredHome 19:3f82c1161fd2 735 /// Get the RGB value for a DOS color.
WiredHome 19:3f82c1161fd2 736 ///
WiredHome 19:3f82c1161fd2 737 /// @param i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 738 /// @returns the RGB color of the selected index, or 0
WiredHome 19:3f82c1161fd2 739 /// if the index is out of bounds.
WiredHome 19:3f82c1161fd2 740 ///
WiredHome 19:3f82c1161fd2 741 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 742
WiredHome 19:3f82c1161fd2 743 /// Get the color name (string) for a DOS color.
WiredHome 19:3f82c1161fd2 744 ///
WiredHome 19:3f82c1161fd2 745 /// @param i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 746 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 747 /// or NULL if the index is out of bounds.
WiredHome 19:3f82c1161fd2 748 ///
WiredHome 19:3f82c1161fd2 749 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 750
WiredHome 19:3f82c1161fd2 751
WiredHome 19:3f82c1161fd2 752 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 753 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 754 void ClearPerformance();
WiredHome 19:3f82c1161fd2 755
WiredHome 19:3f82c1161fd2 756 /// Report the performance metrics for drawing functions using
WiredHome 19:3f82c1161fd2 757 /// printf()
WiredHome 19:3f82c1161fd2 758 void ReportPerformance();
WiredHome 19:3f82c1161fd2 759 #endif
WiredHome 19:3f82c1161fd2 760
WiredHome 19:3f82c1161fd2 761 private:
WiredHome 19:3f82c1161fd2 762 /// Set the SPI port frequency (in Hz).
WiredHome 19:3f82c1161fd2 763 ///
WiredHome 19:3f82c1161fd2 764 /// @note attempts to call this API at runtime, with the display
WiredHome 19:3f82c1161fd2 765 /// already online, cause the system to lockup.
WiredHome 19:3f82c1161fd2 766 /// Not sure why, so moving this to private to run once.
WiredHome 19:3f82c1161fd2 767 ///
WiredHome 19:3f82c1161fd2 768 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 19:3f82c1161fd2 769 /// its capabilities. Limited tests were performed for the display
WiredHome 19:3f82c1161fd2 770 /// in the range of 1,000,000 to 50,000,000 Hz. The display was
WiredHome 19:3f82c1161fd2 771 /// a bit erratic above 20,000,000 Hz, so this became the default,
WiredHome 19:3f82c1161fd2 772 /// even though it might have been the bench-level wiring that posed
WiredHome 19:3f82c1161fd2 773 /// the limit.
WiredHome 19:3f82c1161fd2 774 ///
WiredHome 19:3f82c1161fd2 775 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 776 ///
WiredHome 19:3f82c1161fd2 777 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ);
WiredHome 19:3f82c1161fd2 778
WiredHome 19:3f82c1161fd2 779
WiredHome 19:3f82c1161fd2 780 /// Initialize the chip, which is normally done as part of the
WiredHome 19:3f82c1161fd2 781 /// constructor, so not called by the user.
WiredHome 19:3f82c1161fd2 782 ///
WiredHome 19:3f82c1161fd2 783 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 784 ///
WiredHome 19:3f82c1161fd2 785 RetCode_t init(void);
WiredHome 19:3f82c1161fd2 786
WiredHome 19:3f82c1161fd2 787 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 788 ///
WiredHome 19:3f82c1161fd2 789 /// @param chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 790 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 791 /// the pin selection is the invert of this.
WiredHome 19:3f82c1161fd2 792 /// @returns success/failure code. @see RetCode_t.
WiredHome 19:3f82c1161fd2 793 ///
WiredHome 19:3f82c1161fd2 794 RetCode_t select(bool chipsel);
WiredHome 19:3f82c1161fd2 795
WiredHome 19:3f82c1161fd2 796 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 797 ///
WiredHome 19:3f82c1161fd2 798 /// @param data is the value to write.
WiredHome 19:3f82c1161fd2 799 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 800 /// in while shifting out.
WiredHome 19:3f82c1161fd2 801 ///
WiredHome 19:3f82c1161fd2 802 unsigned char spiwrite(unsigned char data);
WiredHome 19:3f82c1161fd2 803
WiredHome 19:3f82c1161fd2 804 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 805 ///
WiredHome 19:3f82c1161fd2 806 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 807 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 808 ///
WiredHome 19:3f82c1161fd2 809 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 810 /// in while shifting out.
WiredHome 19:3f82c1161fd2 811 ///
WiredHome 19:3f82c1161fd2 812 unsigned char spiread();
WiredHome 19:3f82c1161fd2 813
WiredHome 19:3f82c1161fd2 814 SPI spi; ///< spi port
WiredHome 19:3f82c1161fd2 815 DigitalOut cs; ///< chip select pin, assumed active low
WiredHome 19:3f82c1161fd2 816 DigitalOut res; ///< reset pin, assumed active low
WiredHome 19:3f82c1161fd2 817 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 19:3f82c1161fd2 818
WiredHome 19:3f82c1161fd2 819 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 820 typedef enum
WiredHome 19:3f82c1161fd2 821 {
WiredHome 19:3f82c1161fd2 822 PRF_CLS,
WiredHome 19:3f82c1161fd2 823 PRF_DRAWPOINT,
WiredHome 19:3f82c1161fd2 824 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 825 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 826 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 827 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 828 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 829 PRF_DRAWELLIPSE,
WiredHome 19:3f82c1161fd2 830 METRICCOUNT
WiredHome 19:3f82c1161fd2 831 } method_e;
WiredHome 19:3f82c1161fd2 832 unsigned long metrics[METRICCOUNT];
WiredHome 19:3f82c1161fd2 833 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 834 Timer performance;
WiredHome 19:3f82c1161fd2 835 #endif
WiredHome 19:3f82c1161fd2 836 };
WiredHome 19:3f82c1161fd2 837
WiredHome 19:3f82c1161fd2 838 //} // namespace
WiredHome 19:3f82c1161fd2 839
WiredHome 19:3f82c1161fd2 840 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 841
WiredHome 19:3f82c1161fd2 842 #endif