LCD LIB

Dependents:   HagridOS5

Fork of RA8875 by David Smart

Committer:
WiredHome
Date:
Sun Jan 12 17:40:32 2014 +0000
Revision:
19:3f82c1161fd2
Child:
20:6e2e4a8372eb
Initial commit - mostly working (not Triangles, Externals Fonts). Not ready for other users.

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