Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Committer:
WiredHome
Date:
Wed Jan 02 23:42:15 2019 +0000
Revision:
157:1565f38ca44b
Parent:
156:4bdb2772128d
Child:
162:a2d7f1988711
Child:
172:7abb03bf31be
Improvement to resistive touch to simplify startup.; Init default for the backlight to be dimmer, since many users power it only from their PC, which isn't capable of full backlight power.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 78:faf49c381591 1 ///
WiredHome 78:faf49c381591 2 /// @mainpage RA8875 Display Controller Driver library
WiredHome 78:faf49c381591 3 ///
WiredHome 78:faf49c381591 4 /// The RA8875 Display controller is a powerful interface for low cost displays. It
WiredHome 152:a013ac0133e4 5 /// can support displays up to 800 x 480 pixels x 16-bit color. Another common
WiredHome 78:faf49c381591 6 /// implementation is 480 x 272 x 16 with two layers. The two layers can be
WiredHome 78:faf49c381591 7 /// exchanged, or blended in various ways (transparency, OR, AND, and more).
WiredHome 78:faf49c381591 8 /// It includes graphics acceleration capabilities for drawing primitives,
WiredHome 78:faf49c381591 9 /// such as line, rectangle, circles, and more.
WiredHome 78:faf49c381591 10 ///
WiredHome 101:e0aad446094a 11 /// It is not a display for super-fast animations, video, picture frames and so forth,
WiredHome 101:e0aad446094a 12 /// at least when using the SPI ports. Performance has not been evaluated with one
WiredHome 101:e0aad446094a 13 /// of the parallel port options.
WiredHome 101:e0aad446094a 14 ///
WiredHome 78:faf49c381591 15 /// The controller additionally supports backlight control (via PWM), keypad scanning
WiredHome 125:7a0b70f56550 16 /// (for a 4 x 5 matrix) and resistive touch-panel support. Recently support for a
WiredHome 125:7a0b70f56550 17 /// capacitive touch screen was integrated, in a manner that makes the resistive and
WiredHome 125:7a0b70f56550 18 /// capactive interfaces nearly identical.
WiredHome 78:faf49c381591 19 ///
WiredHome 78:faf49c381591 20 /// @section Display_Config Display Configuration
WiredHome 78:faf49c381591 21 ///
WiredHome 78:faf49c381591 22 /// This section details basics for bringing the display online. At a minimum,
WiredHome 78:faf49c381591 23 /// the display is instantiated. After that any of the available commands
WiredHome 78:faf49c381591 24 /// may be issued.
WiredHome 78:faf49c381591 25 ///
WiredHome 78:faf49c381591 26 /// During the instantiation, the display is powered on, cleared, and the backlight
WiredHome 78:faf49c381591 27 /// is energized. Additionally, the keypad and touchscreen features are activated.
WiredHome 78:faf49c381591 28 /// It is important to keep in mind that the keypad had the default mapping, and
WiredHome 78:faf49c381591 29 /// the touchscreen does not have the calibration matrix configured, so additional
WiredHome 78:faf49c381591 30 /// steps may be necessary.
WiredHome 78:faf49c381591 31 ///
WiredHome 78:faf49c381591 32 /// @code
WiredHome 78:faf49c381591 33 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 81:01da2e34283d 34 /// lcd.init();
WiredHome 78:faf49c381591 35 /// lcd.foreground(Blue);
WiredHome 78:faf49c381591 36 /// lcd.line(0,0, 479,271);
WiredHome 78:faf49c381591 37 /// ...
WiredHome 78:faf49c381591 38 /// @endcode
WiredHome 78:faf49c381591 39 ///
WiredHome 78:faf49c381591 40 /// @section Touch_Panel Touch Panel
WiredHome 78:faf49c381591 41 ///
WiredHome 78:faf49c381591 42 /// The supported touch panel interface is for a resistive panel, and is natively
WiredHome 78:faf49c381591 43 /// supported by the RA8875 controller. There are a few steps to enable this interface.
WiredHome 78:faf49c381591 44 ///
WiredHome 78:faf49c381591 45 /// @subsection Touch_Panel_Enable Touch Panel Enable
WiredHome 78:faf49c381591 46 ///
WiredHome 106:c80828f5dea4 47 /// See @ref TouchPanelInit has two forms - fully automatic, and controlled. See the APIs for
WiredHome 78:faf49c381591 48 /// details.
WiredHome 78:faf49c381591 49 ///
WiredHome 78:faf49c381591 50 /// @subsection Touch_Panel_Calibration
WiredHome 78:faf49c381591 51 ///
WiredHome 78:faf49c381591 52 /// The touch panel is not initially calibrated on startup. The application should
WiredHome 78:faf49c381591 53 /// provide a means to activate the calibration process, and that should not require
WiredHome 78:faf49c381591 54 /// the touchscreen as it may not yet be usable. Alternately, a calibration matrix
WiredHome 78:faf49c381591 55 /// can be loaded from non-volatile and installed.
WiredHome 78:faf49c381591 56 ///
WiredHome 78:faf49c381591 57 /// @section Keypad Keypad
WiredHome 78:faf49c381591 58 ///
WiredHome 78:faf49c381591 59 /// The keypad has a default keypad mapping, but there is an API that permits
WiredHome 78:faf49c381591 60 /// installing a custom keymap.
WiredHome 78:faf49c381591 61 ///
WiredHome 101:e0aad446094a 62 /// @todo Add APIs for the 2nd PWM channel, which might be quite useful as a simple
WiredHome 101:e0aad446094a 63 /// beeper.
WiredHome 101:e0aad446094a 64 /// @todo Figure out how to "init()" in the constructor. I ran into some issues if
WiredHome 101:e0aad446094a 65 /// the display was instantiated before main(), and the code would not run,
WiredHome 101:e0aad446094a 66 /// thus the exposure and activation of the init() function. If the constructor
WiredHome 101:e0aad446094a 67 /// was within main(), then it seemed to work as expected.
WiredHome 101:e0aad446094a 68 ///
WiredHome 19:3f82c1161fd2 69 #ifndef RA8875_H
WiredHome 19:3f82c1161fd2 70 #define RA8875_H
WiredHome 19:3f82c1161fd2 71 #include <mbed.h>
WiredHome 19:3f82c1161fd2 72
WiredHome 77:9206c13aa527 73 #include "RA8875_Regs.h"
WiredHome 19:3f82c1161fd2 74 #include "GraphicsDisplay.h"
WiredHome 19:3f82c1161fd2 75
WiredHome 41:2956a0a221e5 76 #define RA8875_DEFAULT_SPI_FREQ 5000000
WiredHome 19:3f82c1161fd2 77
WiredHome 156:4bdb2772128d 78 #ifndef MBED_ENCODE_VERSION
WiredHome 156:4bdb2772128d 79 #define MBED_ENCODE_VERSION(major, minor, patch) ((major)*10000 + (minor)*100 + (patch))
WiredHome 156:4bdb2772128d 80 #endif
WiredHome 156:4bdb2772128d 81
WiredHome 19:3f82c1161fd2 82 // Define this to enable code that monitors the performance of various
WiredHome 19:3f82c1161fd2 83 // graphics commands.
WiredHome 78:faf49c381591 84 //#define PERF_METRICS
WiredHome 19:3f82c1161fd2 85
WiredHome 23:a50ded45dbaf 86 // What better place for some test code than in here and the companion
WiredHome 23:a50ded45dbaf 87 // .cpp file. See also the bottom of this file.
WiredHome 99:66edf771373a 88 //#define TESTENABLE
WiredHome 19:3f82c1161fd2 89
WiredHome 19:3f82c1161fd2 90 /// DOS colors - slightly color enhanced
WiredHome 20:6e2e4a8372eb 91 #define Black (color_t)(RGB(0,0,0))
WiredHome 20:6e2e4a8372eb 92 #define Blue (color_t)(RGB(0,0,187))
WiredHome 20:6e2e4a8372eb 93 #define Green (color_t)(RGB(0,187,0))
WiredHome 20:6e2e4a8372eb 94 #define Cyan (color_t)(RGB(0,187,187))
WiredHome 20:6e2e4a8372eb 95 #define Red (color_t)(RGB(187,0,0))
WiredHome 20:6e2e4a8372eb 96 #define Magenta (color_t)(RGB(187,0,187))
WiredHome 81:01da2e34283d 97 #define Brown (color_t)(RGB(63,63,0))
WiredHome 20:6e2e4a8372eb 98 #define Gray (color_t)(RGB(187,187,187))
WiredHome 20:6e2e4a8372eb 99 #define Charcoal (color_t)(RGB(85,85,85))
WiredHome 62:ba5d33438fda 100 #define BrightBlue (color_t)(RGB(0,0,255))
WiredHome 62:ba5d33438fda 101 #define BrightGreen (color_t)(RGB(0,255,0))
WiredHome 62:ba5d33438fda 102 #define BrightCyan (color_t)(RGB(0,255,255))
WiredHome 62:ba5d33438fda 103 #define BrightRed (color_t)(RGB(255,0,0))
WiredHome 20:6e2e4a8372eb 104 #define Orange (color_t)(RGB(255,85,85))
WiredHome 20:6e2e4a8372eb 105 #define Pink (color_t)(RGB(255,85,255))
WiredHome 81:01da2e34283d 106 #define Yellow (color_t)(RGB(187,187,0))
WiredHome 20:6e2e4a8372eb 107 #define White (color_t)(RGB(255,255,255))
WiredHome 20:6e2e4a8372eb 108
WiredHome 62:ba5d33438fda 109 #define DarkBlue (color_t)(RGB(0,0,63))
WiredHome 62:ba5d33438fda 110 #define DarkGreen (color_t)(RGB(0,63,0))
WiredHome 62:ba5d33438fda 111 #define DarkCyan (color_t)(RGB(0,63,63))
WiredHome 62:ba5d33438fda 112 #define DarkRed (color_t)(RGB(63,0,0))
WiredHome 62:ba5d33438fda 113 #define DarkMagenta (color_t)(RGB(63,0,63))
WiredHome 62:ba5d33438fda 114 #define DarkBrown (color_t)(RGB(63,63,0))
WiredHome 62:ba5d33438fda 115 #define DarkGray (color_t)(RGB(63,63,63))
WiredHome 61:8f3153bf0baa 116
WiredHome 82:f7d300f26540 117 #define min(a,b) ((a<b)?a:b)
WiredHome 82:f7d300f26540 118 #define max(a,b) ((a>b)?a:b)
WiredHome 82:f7d300f26540 119
WiredHome 19:3f82c1161fd2 120
WiredHome 124:1690a7ae871c 121 /// FT5206 definitions follow
WiredHome 124:1690a7ae871c 122 #define FT5206_I2C_FREQUENCY 400000
WiredHome 124:1690a7ae871c 123
WiredHome 124:1690a7ae871c 124 #define FT5206_I2C_ADDRESS 0x38
WiredHome 124:1690a7ae871c 125 #define FT5206_NUMBER_OF_REGISTERS 31 // there are more registers, but this
WiredHome 124:1690a7ae871c 126 // is enough to get all 5 touch coordinates.
WiredHome 124:1690a7ae871c 127
WiredHome 124:1690a7ae871c 128 #define FT5206_NUMBER_OF_TOTAL_REGISTERS 0xFE
WiredHome 124:1690a7ae871c 129
WiredHome 124:1690a7ae871c 130 #define FT5206_DEVICE_MODE 0x00 // Normal, test, etc.
WiredHome 124:1690a7ae871c 131 #define FT5206_GEST_ID 0x01 // Gesture detected
WiredHome 124:1690a7ae871c 132 #define FT5206_TD_STATUS 0x02 // How many points detected (3:0). 1-5 is valid.
WiredHome 124:1690a7ae871c 133
WiredHome 124:1690a7ae871c 134 #define FT5206_TOUCH1_XH 0x03 // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 135 #define FT5206_TOUCH1_XL 0x04
WiredHome 124:1690a7ae871c 136 #define FT5206_TOUCH1_YH 0x05 // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 137 #define FT5206_TOUCH1_YL 0x06
WiredHome 124:1690a7ae871c 138
WiredHome 124:1690a7ae871c 139 #define FT5206_TOUCH2_XH 0x09 // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 140 #define FT5206_TOUCH2_XL 0x0a
WiredHome 124:1690a7ae871c 141 #define FT5206_TOUCH2_YH 0x0b // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 142 #define FT5206_TOUCH2_YL 0x0c
WiredHome 124:1690a7ae871c 143
WiredHome 124:1690a7ae871c 144 #define FT5206_TOUCH3_XH 0x0f // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 145 #define FT5206_TOUCH3_XL 0x10
WiredHome 124:1690a7ae871c 146 #define FT5206_TOUCH3_YH 0x11 // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 147 #define FT5206_TOUCH3_YL 0x12
WiredHome 124:1690a7ae871c 148
WiredHome 124:1690a7ae871c 149 #define FT5206_TOUCH4_XH 0x15 // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 150 #define FT5206_TOUCH4_XL 0x16
WiredHome 124:1690a7ae871c 151 #define FT5206_TOUCH4_YH 0x17 // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 152 #define FT5206_TOUCH4_YL 0x18
WiredHome 124:1690a7ae871c 153
WiredHome 124:1690a7ae871c 154 #define FT5206_TOUCH5_XH 0x1b // Event Flag, Touch X Position
WiredHome 124:1690a7ae871c 155 #define FT5206_TOUCH5_XL 0x1c
WiredHome 124:1690a7ae871c 156 #define FT5206_TOUCH5_YH 0x1d // Touch ID, Touch Y Position
WiredHome 124:1690a7ae871c 157 #define FT5206_TOUCH5_YL 0x1e
WiredHome 124:1690a7ae871c 158
WiredHome 124:1690a7ae871c 159 // For typical usage, the registers listed below are not used.
WiredHome 124:1690a7ae871c 160 #define FT5206_ID_G_THGROUP 0x80 // Valid touching detect threshold
WiredHome 124:1690a7ae871c 161 #define FT5206_ID_G_THPEAK 0x81 // Valid touching peak detect threshold
WiredHome 124:1690a7ae871c 162 #define FT5206_ID_G_THCAL 0x82 // The threshold when calculating the focus of touching
WiredHome 124:1690a7ae871c 163 #define FT5206_ID_G_THWATER 0x83 // The threshold when there is surface water
WiredHome 124:1690a7ae871c 164 #define FT5206_ID_G_THTEMP 0x84 // The threshold of temperature compensation
WiredHome 124:1690a7ae871c 165 #define FT5206_ID_G_CTRL 0x86 // Power control mode
WiredHome 124:1690a7ae871c 166 #define FT5206_ID_G_TIME_ENTER_MONITOR 0x87 // The timer of entering monitor status
WiredHome 124:1690a7ae871c 167 #define FT5206_ID_G_PERIODACTIVE 0x88 // Period Active
WiredHome 124:1690a7ae871c 168 #define FT5206_ID_G_PERIODMONITOR 0x89 // The timer of entering idle while in monitor status
WiredHome 124:1690a7ae871c 169 #define FT5206_ID_G_AUTO_CLB_MODE 0xA0 // Auto calibration mode
WiredHome 124:1690a7ae871c 170
WiredHome 124:1690a7ae871c 171 #define FT5206_TOUCH_LIB_VERSION_H 0xA1 // Firmware Library Version H byte
WiredHome 124:1690a7ae871c 172 #define FT5206_TOUCH_LIB_VERSION_L 0xA2 // Firmware Library Version L byte
WiredHome 124:1690a7ae871c 173 #define FT5206_ID_G_CIPHER 0xA3 // Chip vendor ID
WiredHome 124:1690a7ae871c 174 #define FT5206_G_MODE 0xA4 // The interrupt status to host
WiredHome 124:1690a7ae871c 175 #define FT5206_ID_G_PMODE 0xA5 // Power Consume Mode
WiredHome 124:1690a7ae871c 176 #define FT5206_FIRMID 0xA6 // Firmware ID
WiredHome 124:1690a7ae871c 177 #define FT5206_ID_G_STATE 0xA7 // Running State
WiredHome 124:1690a7ae871c 178 #define FT5206_ID_G_FT5201ID 0xA8 // CTPM Vendor ID
WiredHome 124:1690a7ae871c 179 #define FT5206_ID_G_ERR 0xA9 // Error Code
WiredHome 124:1690a7ae871c 180 #define FT5206_ID_G_CLB 0xAA // Configure TP module during calibration in Test Mode
WiredHome 124:1690a7ae871c 181 #define FT5206_ID_G_B_AREA_TH 0xAE // The threshold of big area
WiredHome 124:1690a7ae871c 182 #define FT5206_LOG_MSG_CNT 0xFE // The log MSG count
WiredHome 124:1690a7ae871c 183 #define FT5206_LOG_CUR_CHA 0xFF // Current character of log message, will point to the next
WiredHome 124:1690a7ae871c 184 // character when one character is read.
WiredHome 124:1690a7ae871c 185 #define FT5206_GEST_ID_MOVE_UP 0x10
WiredHome 124:1690a7ae871c 186 #define FT5206_GEST_ID_MOVE_LEFT 0x14
WiredHome 124:1690a7ae871c 187 #define FT5206_GEST_ID_MOVE_DOWN 0x18
WiredHome 124:1690a7ae871c 188 #define FT5206_GEST_ID_MOVE_RIGHT 0x1c
WiredHome 124:1690a7ae871c 189 #define FT5206_GEST_ID_ZOOM_IN 0x48
WiredHome 124:1690a7ae871c 190 #define FT5206_GEST_ID_ZOOM_OUT 0x49
WiredHome 124:1690a7ae871c 191 #define FT5206_GEST_ID_NO_GESTURE 0x00
WiredHome 124:1690a7ae871c 192
WiredHome 124:1690a7ae871c 193 #define FT5206_EVENT_FLAG_PUT_DOWN 0x00
WiredHome 124:1690a7ae871c 194 #define FT5206_EVENT_FLAG_PUT_UP 0x01
WiredHome 124:1690a7ae871c 195 #define FT5206_EVENT_FLAG_CONTACT 0x02
WiredHome 124:1690a7ae871c 196 #define FT5206_EVENT_FLAG_RESERVED 0x03
WiredHome 124:1690a7ae871c 197
WiredHome 124:1690a7ae871c 198 #define FT5206_ID_G_POLLING_MODE 0x00
WiredHome 124:1690a7ae871c 199 #define FT5206_ID_G_TRIGGER_MODE 0x01
WiredHome 124:1690a7ae871c 200
WiredHome 124:1690a7ae871c 201 #define FT5206_ID_G_PMODE_ACTIVE 0x00
WiredHome 124:1690a7ae871c 202 #define FT5206_ID_G_PMODE_MONITOR 0x01
WiredHome 124:1690a7ae871c 203 #define FT5206_ID_G_PMODE_HIBERNATE 0x03
WiredHome 124:1690a7ae871c 204
WiredHome 124:1690a7ae871c 205 #define FT5206_ID_G_STATE_CONFIGURE 0x00
WiredHome 124:1690a7ae871c 206 #define FT5206_ID_G_STATE_WORK 0x01
WiredHome 124:1690a7ae871c 207 #define FT5206_ID_G_STATE_CALIBRATION 0x02
WiredHome 124:1690a7ae871c 208 #define FT5206_ID_G_STATE_FACTORY 0x03
WiredHome 124:1690a7ae871c 209 #define FT5206_ID_G_STATE_AUTO_CALIBRATION 0x04
WiredHome 124:1690a7ae871c 210 /// end of FT5206 definitions
WiredHome 124:1690a7ae871c 211
WiredHome 124:1690a7ae871c 212
WiredHome 19:3f82c1161fd2 213 //namespace SW_graphics
WiredHome 19:3f82c1161fd2 214 //{
WiredHome 19:3f82c1161fd2 215
WiredHome 96:40b74dd3695b 216 class FPointerDummy; // used by the callback methods.
WiredHome 24:8ca861acf12d 217
WiredHome 21:3c1efb192927 218 /// This is a graphics library for the Raio RA8875 Display Controller chip
WiredHome 21:3c1efb192927 219 /// attached to a 4-wire SPI interface.
WiredHome 21:3c1efb192927 220 ///
WiredHome 56:7a85d226ad0d 221 /// It offers both primitive and high level APIs.
WiredHome 56:7a85d226ad0d 222 ///
WiredHome 21:3c1efb192927 223 /// Central to this API is a coordinate system, where the origin (0,0) is in
WiredHome 56:7a85d226ad0d 224 /// the top-left corner of the display, and the width (x) extends positive to the
WiredHome 56:7a85d226ad0d 225 /// right and the height (y) extends positive toward the bottom.
WiredHome 21:3c1efb192927 226 ///
WiredHome 125:7a0b70f56550 227 /// @note As there are both graphics and text commands, one must take care to use
WiredHome 21:3c1efb192927 228 /// the proper coordinate system for each. Some of the text APIs are in units
WiredHome 29:422616aa04bd 229 /// of column and row, which is measured in character positions (and dependent
WiredHome 56:7a85d226ad0d 230 /// on the font size), where other text APIs permit pixel level positioning.
WiredHome 56:7a85d226ad0d 231 ///
WiredHome 56:7a85d226ad0d 232 /// @code
WiredHome 56:7a85d226ad0d 233 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 234 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 235 ///
WiredHome 56:7a85d226ad0d 236 /// int main()
WiredHome 56:7a85d226ad0d 237 /// {
WiredHome 81:01da2e34283d 238 /// lcd.init();
WiredHome 56:7a85d226ad0d 239 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 240 /// lcd.circle( 400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 241 /// lcd.fillcircle( 400,25, 15, RGB(128,255,128));
WiredHome 56:7a85d226ad0d 242 /// lcd.ellipse( 440,75, 35,20, BrightBlue);
WiredHome 56:7a85d226ad0d 243 /// lcd.fillellipse( 440,75, 25,10, Blue);
WiredHome 56:7a85d226ad0d 244 /// lcd.triangle( 440,100, 475,110, 450,125, Magenta);
WiredHome 56:7a85d226ad0d 245 /// lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
WiredHome 56:7a85d226ad0d 246 /// lcd.rect( 400,130, 475,155, Brown);
WiredHome 56:7a85d226ad0d 247 /// lcd.fillrect( 405,135, 470,150, Pink);
WiredHome 56:7a85d226ad0d 248 /// lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
WiredHome 56:7a85d226ad0d 249 /// lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
WiredHome 56:7a85d226ad0d 250 /// lcd.line( 430,200, 460,230, RGB(0,255,0));
WiredHome 56:7a85d226ad0d 251 /// for (int i=0; i<=30; i+=5)
WiredHome 56:7a85d226ad0d 252 /// lcd.pixel(435+i,200+i, White);
WiredHome 56:7a85d226ad0d 253 /// }
WiredHome 56:7a85d226ad0d 254 /// @endcode
WiredHome 29:422616aa04bd 255 ///
WiredHome 31:c72e12cd5c67 256 /// @todo Add Scroll support for text.
WiredHome 75:ca78388cfd77 257 /// @todo Add Hardware reset signal - but testing to date indicates it is not needed.
WiredHome 44:207594dece70 258 /// @todo Add high level objects - x-y graph, meter, others... but these will
WiredHome 44:207594dece70 259 /// probably be best served in another class, since they may not
WiredHome 44:207594dece70 260 /// be needed for many uses.
WiredHome 21:3c1efb192927 261 ///
WiredHome 19:3f82c1161fd2 262 class RA8875 : public GraphicsDisplay
WiredHome 19:3f82c1161fd2 263 {
WiredHome 19:3f82c1161fd2 264 public:
WiredHome 53:86d24b9480b9 265 /// cursor type to be shown as the text cursor.
WiredHome 53:86d24b9480b9 266 typedef enum
WiredHome 53:86d24b9480b9 267 {
WiredHome 53:86d24b9480b9 268 NOCURSOR, ///< cursor is hidden
WiredHome 53:86d24b9480b9 269 IBEAM, ///< | cursor
WiredHome 53:86d24b9480b9 270 UNDER, ///< _ cursor
WiredHome 53:86d24b9480b9 271 BLOCK ///< Block cursor
WiredHome 53:86d24b9480b9 272 } cursor_t;
WiredHome 53:86d24b9480b9 273
WiredHome 19:3f82c1161fd2 274 /// font type selection.
WiredHome 19:3f82c1161fd2 275 typedef enum
WiredHome 19:3f82c1161fd2 276 {
WiredHome 31:c72e12cd5c67 277 ISO8859_1, ///< ISO8859-1 font
WiredHome 31:c72e12cd5c67 278 ISO8859_2, ///< ISO8859-2 font
WiredHome 31:c72e12cd5c67 279 ISO8859_3, ///< ISO8859-3 font
WiredHome 31:c72e12cd5c67 280 ISO8859_4 ///< ISO8859-4 font
WiredHome 19:3f82c1161fd2 281 } font_t;
WiredHome 19:3f82c1161fd2 282
WiredHome 84:e102021864b5 283 /// display orientation
WiredHome 19:3f82c1161fd2 284 typedef enum
WiredHome 19:3f82c1161fd2 285 {
WiredHome 84:e102021864b5 286 normal, ///< normal (landscape) orientation
WiredHome 84:e102021864b5 287 rotate_0 = normal, ///< alternate to 'normal'
WiredHome 84:e102021864b5 288 rotate_90, ///< rotated clockwise 90 degree
WiredHome 84:e102021864b5 289 rotate_180, ///< rotated (clockwise) 180 degree
WiredHome 84:e102021864b5 290 rotate_270, ///< rotated clockwise 270 degree
WiredHome 84:e102021864b5 291 } orientation_t;
WiredHome 19:3f82c1161fd2 292
WiredHome 19:3f82c1161fd2 293 /// alignment
WiredHome 19:3f82c1161fd2 294 typedef enum
WiredHome 19:3f82c1161fd2 295 {
WiredHome 31:c72e12cd5c67 296 align_none, ///< align - none
WiredHome 31:c72e12cd5c67 297 align_full ///< align - full
WiredHome 19:3f82c1161fd2 298 } alignment_t;
WiredHome 19:3f82c1161fd2 299
WiredHome 127:db7f2c704693 300 /// Font Horizontal Scale factor - 1, 2, 3 4
WiredHome 40:04aa280dfa39 301 typedef int HorizontalScale;
WiredHome 19:3f82c1161fd2 302
WiredHome 127:db7f2c704693 303 /// Font Vertical Scale factor - 1, 2, 3, 4
WiredHome 40:04aa280dfa39 304 typedef int VerticalScale;
WiredHome 19:3f82c1161fd2 305
WiredHome 19:3f82c1161fd2 306 /// Clear screen region
WiredHome 19:3f82c1161fd2 307 typedef enum
WiredHome 19:3f82c1161fd2 308 {
WiredHome 31:c72e12cd5c67 309 FULLWINDOW, ///< Full screen
WiredHome 31:c72e12cd5c67 310 ACTIVEWINDOW ///< active window/region
WiredHome 19:3f82c1161fd2 311 } Region_t;
WiredHome 19:3f82c1161fd2 312
WiredHome 61:8f3153bf0baa 313 /// Set the Layer Display Mode. @ref SetLayerMode
WiredHome 53:86d24b9480b9 314 typedef enum
WiredHome 53:86d24b9480b9 315 {
WiredHome 61:8f3153bf0baa 316 ShowLayer0, ///< Only layer 0 is visible, layer 1 is hidden (default)
WiredHome 56:7a85d226ad0d 317 ShowLayer1, ///< Only layer 1 is visible, layer 0 is hidden
WiredHome 53:86d24b9480b9 318 LightenOverlay, ///< Lighten-overlay mode
WiredHome 53:86d24b9480b9 319 TransparentMode, ///< Transparent mode
WiredHome 53:86d24b9480b9 320 BooleanOR, ///< Boolean OR mode
WiredHome 53:86d24b9480b9 321 BooleanAND, ///< Boolean AND mode
WiredHome 53:86d24b9480b9 322 FloatingWindow ///< Floating Window mode
WiredHome 53:86d24b9480b9 323 } LayerMode_T;
WiredHome 53:86d24b9480b9 324
hexley 54:e117ad10fba6 325 /// Touch Panel modes
hexley 54:e117ad10fba6 326 typedef enum
hexley 54:e117ad10fba6 327 {
hexley 54:e117ad10fba6 328 TP_Auto, ///< Auto touch detection mode
hexley 54:e117ad10fba6 329 TP_Manual, ///< Manual touch detection mode
hexley 54:e117ad10fba6 330 } tpmode_t;
WiredHome 96:40b74dd3695b 331
WiredHome 96:40b74dd3695b 332 /// printscreen callback commands
WiredHome 96:40b74dd3695b 333 typedef enum
WiredHome 96:40b74dd3695b 334 {
WiredHome 96:40b74dd3695b 335 OPEN, ///< command to open the file. cast uint32_t * to the buffer to get the total size to be written.
WiredHome 96:40b74dd3695b 336 WRITE, ///< command to write some data, buffer points to the data and the size is in bytes.
WiredHome 96:40b74dd3695b 337 CLOSE, ///< command to close the file
WiredHome 96:40b74dd3695b 338 } filecmd_t;
WiredHome 96:40b74dd3695b 339
WiredHome 96:40b74dd3695b 340 /// print screen callback
WiredHome 96:40b74dd3695b 341 ///
WiredHome 96:40b74dd3695b 342 /// The special form of the print screen will pass one blob at a time
WiredHome 149:c62c4b2d6a15 343 /// to the callback. There are basic commands declaring that the stream
WiredHome 96:40b74dd3695b 344 /// can be opened, a block written, and the stream closed. There is
WiredHome 96:40b74dd3695b 345 /// also a command to communicate the total size being delivered.
WiredHome 96:40b74dd3695b 346 ///
WiredHome 149:c62c4b2d6a15 347 /// If the idle callback is registered, it will be activated passing
WiredHome 149:c62c4b2d6a15 348 /// a parameter indicating the percent complete, which may be of value.
WiredHome 149:c62c4b2d6a15 349 ///
WiredHome 96:40b74dd3695b 350 /// @code
WiredHome 96:40b74dd3695b 351 /// lcd.PrintScreen(x,y,w,h,callback);
WiredHome 96:40b74dd3695b 352 /// ...
WiredHome 96:40b74dd3695b 353 /// void callback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 354 /// switch(cmd) {
WiredHome 96:40b74dd3695b 355 /// case OPEN:
WiredHome 96:40b74dd3695b 356 /// pc.printf("About to write %u bytes\r\n", *(uint32_t *)buffer);
WiredHome 96:40b74dd3695b 357 /// fh = fopen("file.bmp", "w+b");
WiredHome 96:40b74dd3695b 358 /// break;
WiredHome 96:40b74dd3695b 359 /// case WRITE:
WiredHome 96:40b74dd3695b 360 /// fwrite(buffer, size, fh);
WiredHome 96:40b74dd3695b 361 /// break;
WiredHome 96:40b74dd3695b 362 /// case CLOSE:
WiredHome 96:40b74dd3695b 363 /// fclose(fh);
WiredHome 96:40b74dd3695b 364 /// break;
WiredHome 96:40b74dd3695b 365 /// default:
WiredHome 96:40b74dd3695b 366 /// pc.printf("Unexpected callback %d\r\n", cmd);
WiredHome 96:40b74dd3695b 367 /// break;
WiredHome 96:40b74dd3695b 368 /// }
WiredHome 96:40b74dd3695b 369 /// }
WiredHome 96:40b74dd3695b 370 /// @endcode
WiredHome 96:40b74dd3695b 371 ///
WiredHome 106:c80828f5dea4 372 /// @param cmd is the command to execute. See @ref filecmd_t.
WiredHome 96:40b74dd3695b 373 /// @param buffer is a pointer to the buffer being passed.
WiredHome 96:40b74dd3695b 374 /// @param size is the number of bytes in the buffer.
WiredHome 123:2f45e80fec5f 375 /// @returns the noerror signal.
WiredHome 96:40b74dd3695b 376 ///
WiredHome 96:40b74dd3695b 377 typedef RetCode_t (* PrintCallback_T)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
hexley 54:e117ad10fba6 378
WiredHome 125:7a0b70f56550 379 /// Idle reason provided in the Idle Callback
WiredHome 123:2f45e80fec5f 380 typedef enum {
WiredHome 123:2f45e80fec5f 381 unknown, ///< reason has not been assigned (this should not happen)
WiredHome 123:2f45e80fec5f 382 status_wait, ///< driver is polling the status register while busy
WiredHome 123:2f45e80fec5f 383 command_wait, ///< driver is polling the command register while busy
WiredHome 123:2f45e80fec5f 384 getc_wait, ///< user has called the getc function
WiredHome 123:2f45e80fec5f 385 touch_wait, ///< user has called the touch function
WiredHome 149:c62c4b2d6a15 386 touchcal_wait, ///< driver is performing a touch calibration
WiredHome 149:c62c4b2d6a15 387 progress, ///< communicates progress
WiredHome 123:2f45e80fec5f 388 } IdleReason_T;
WiredHome 123:2f45e80fec5f 389
WiredHome 123:2f45e80fec5f 390 /// Idle Callback
WiredHome 123:2f45e80fec5f 391 ///
WiredHome 123:2f45e80fec5f 392 /// This defines the interface for an idle callback. That is, when the
WiredHome 125:7a0b70f56550 393 /// driver is held up, pending some event, it can call a previously registered
WiredHome 123:2f45e80fec5f 394 /// idle function. This could be most useful for servicing a watchdog.
WiredHome 123:2f45e80fec5f 395 ///
WiredHome 123:2f45e80fec5f 396 /// The user code, which is notified via this API, can force the idle
WiredHome 123:2f45e80fec5f 397 /// to abort, by returning the external_abort value back to the driver.
WiredHome 125:7a0b70f56550 398 /// It is important to note that the abort could leave the driver in
WiredHome 125:7a0b70f56550 399 /// an undesireable state, so this should be used with care.
WiredHome 125:7a0b70f56550 400 ///
WiredHome 125:7a0b70f56550 401 /// @note Should it be called the BusyCallback? It is true, that it will
WiredHome 125:7a0b70f56550 402 /// call this function when the RA8875 is busy, but this is also
WiredHome 125:7a0b70f56550 403 /// when the CPU is largely idle.
WiredHome 125:7a0b70f56550 404 ///
WiredHome 125:7a0b70f56550 405 /// @code
WiredHome 149:c62c4b2d6a15 406 /// RetCode_t myIdle_handler(RA8875::IdleReason_T reason, uint16_t param)
WiredHome 125:7a0b70f56550 407 /// {
WiredHome 125:7a0b70f56550 408 /// idleFlasher = !idleFlasher;
WiredHome 125:7a0b70f56550 409 /// if (it_has_been_too_long())
WiredHome 125:7a0b70f56550 410 /// return external_abort;
WiredHome 125:7a0b70f56550 411 /// else
WiredHome 125:7a0b70f56550 412 /// return noerror;
WiredHome 125:7a0b70f56550 413 /// }
WiredHome 125:7a0b70f56550 414 /// @endcode
WiredHome 125:7a0b70f56550 415 ///
WiredHome 125:7a0b70f56550 416 /// @param reason informs the callback why it is idle.
WiredHome 149:c62c4b2d6a15 417 /// @param param is a 2nd parameter, which is used for certain reason codes
WiredHome 149:c62c4b2d6a15 418 /// for 'progress' reason code, param ranges from 0 to 100 (percent)
WiredHome 123:2f45e80fec5f 419 /// @returns noerror to allow the driver continue waiting.
WiredHome 123:2f45e80fec5f 420 /// @returns external_abort if the pending action should be aborted.
WiredHome 123:2f45e80fec5f 421 ///
WiredHome 149:c62c4b2d6a15 422 typedef RetCode_t (* IdleCallback_T)(IdleReason_T reason, uint16_t param = 0);
WiredHome 123:2f45e80fec5f 423
WiredHome 125:7a0b70f56550 424 /// Basic constructor for a display based on the RAiO RA8875
WiredHome 125:7a0b70f56550 425 /// display controller, which can be used with no touchscreen,
WiredHome 125:7a0b70f56550 426 /// or the RA8875 managed resistive touchscreen.
WiredHome 124:1690a7ae871c 427 ///
WiredHome 124:1690a7ae871c 428 /// This constructor differs from the alternate by supportting
WiredHome 124:1690a7ae871c 429 /// either No Touch Screen, or the RA8875 built-in resistive
WiredHome 125:7a0b70f56550 430 /// touch screen. If the application requires the use of the
WiredHome 154:ad2450fc3dc3 431 /// capacitive touchscreen, the alternate constructor must
WiredHome 125:7a0b70f56550 432 /// be used.
WiredHome 19:3f82c1161fd2 433 ///
WiredHome 61:8f3153bf0baa 434 /// This configures the registers and calls the @ref init method.
WiredHome 61:8f3153bf0baa 435 ///
WiredHome 56:7a85d226ad0d 436 /// @code
WiredHome 56:7a85d226ad0d 437 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 438 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 439 ///
WiredHome 56:7a85d226ad0d 440 /// int main()
WiredHome 56:7a85d226ad0d 441 /// {
WiredHome 157:1565f38ca44b 442 /// lcd.init(); // defaults for 480x272x16 at low brightness
WiredHome 56:7a85d226ad0d 443 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 444 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 445 /// }
WiredHome 56:7a85d226ad0d 446 /// @endcode
WiredHome 56:7a85d226ad0d 447 ///
WiredHome 72:ecffe56af969 448 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 72:ecffe56af969 449 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 72:ecffe56af969 450 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 72:ecffe56af969 451 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 452 /// active low chip select for the display controller.
WiredHome 72:ecffe56af969 453 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 454 /// active low reset input on the display controller -
WiredHome 19:3f82c1161fd2 455 /// but this is not currently used.
WiredHome 72:ecffe56af969 456 /// @param[in] name is a text name for this object, which will permit
WiredHome 72:ecffe56af969 457 /// capturing stdout to puts() and printf() directly to it.
WiredHome 19:3f82c1161fd2 458 ///
WiredHome 124:1690a7ae871c 459 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 124:1690a7ae871c 460 const char * name = "lcd");
WiredHome 124:1690a7ae871c 461
WiredHome 124:1690a7ae871c 462
WiredHome 124:1690a7ae871c 463 /// Constructor for a display based on the RAiO RA8875
WiredHome 124:1690a7ae871c 464 /// display controller (use for TouchScreen: Capacitive only)
WiredHome 124:1690a7ae871c 465 ///
WiredHome 124:1690a7ae871c 466 /// This constructor differs from the alternate by including support
WiredHome 124:1690a7ae871c 467 /// for the Capactive Touch screen.
WiredHome 124:1690a7ae871c 468 ///
WiredHome 125:7a0b70f56550 469 /// @code
WiredHome 125:7a0b70f56550 470 /// #include "RA8875.h"
WiredHome 125:7a0b70f56550 471 /// RA8875 lcd(p5, p6, p7, p12, NC, p9,p10,p13, "tft");
WiredHome 125:7a0b70f56550 472 ///
WiredHome 125:7a0b70f56550 473 /// int main()
WiredHome 125:7a0b70f56550 474 /// {
WiredHome 125:7a0b70f56550 475 /// lcd.init();
WiredHome 125:7a0b70f56550 476 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 125:7a0b70f56550 477 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 125:7a0b70f56550 478 /// TouchCode_t tp = lcd.TouchPanelReadable();
WiredHome 125:7a0b70f56550 479 /// if (tp == touch)
WiredHome 125:7a0b70f56550 480 /// ...
WiredHome 125:7a0b70f56550 481 /// }
WiredHome 125:7a0b70f56550 482 /// @endcode
WiredHome 125:7a0b70f56550 483 ///
WiredHome 124:1690a7ae871c 484 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 124:1690a7ae871c 485 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 124:1690a7ae871c 486 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 124:1690a7ae871c 487 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 124:1690a7ae871c 488 /// active low chip select for the display controller.
WiredHome 124:1690a7ae871c 489 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 124:1690a7ae871c 490 /// active low reset input on the display controller -
WiredHome 124:1690a7ae871c 491 /// but this is not currently used.
WiredHome 124:1690a7ae871c 492 /// @param[in] sda is the I2C Serial Data pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 493 /// @param[in] scl is the I2C Serial Clock pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 494 /// @param[in] irq is the Interrupt Request pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 495 /// @param[in] name is a text name for this object, which will permit
WiredHome 124:1690a7ae871c 496 /// capturing stdout to puts() and printf() directly to it.
WiredHome 124:1690a7ae871c 497 ///
WiredHome 124:1690a7ae871c 498 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 124:1690a7ae871c 499 PinName sda, PinName scl, PinName irq, const char * name = "lcd");
WiredHome 124:1690a7ae871c 500
WiredHome 19:3f82c1161fd2 501
WiredHome 45:679c2fb8480c 502 // Destructor doesn't have much to do as this would typically be created
WiredHome 45:679c2fb8480c 503 // at startup, and not at runtime.
WiredHome 19:3f82c1161fd2 504 //~RA8875();
WiredHome 19:3f82c1161fd2 505
WiredHome 79:544eb4964795 506 /// Initialize the driver.
WiredHome 79:544eb4964795 507 ///
WiredHome 132:a5d7a8541683 508 /// The RA8875 can control typical displays from the 480x272 to 800x480, and it supports 8 or 16-bit color.
WiredHome 132:a5d7a8541683 509 /// It also supports 2 graphics layers, but it cannot support 2 layers at the maximum color depth and
WiredHome 132:a5d7a8541683 510 /// screen size. When configured under 480x400, it will support both 16-bit color depth and 2 drawing layers.
WiredHome 132:a5d7a8541683 511 /// Above 480x400 it support either 16-bit color, or 2 layers, but not both.
WiredHome 132:a5d7a8541683 512 ///
WiredHome 132:a5d7a8541683 513 /// Typical of the displays that are readily purchased, you will find 480x272 and 800x480 resolutions.
WiredHome 106:c80828f5dea4 514 ///
WiredHome 81:01da2e34283d 515 /// @param[in] width in pixels to configure the display for. This parameter is optional
WiredHome 81:01da2e34283d 516 /// and the default is 480.
WiredHome 81:01da2e34283d 517 /// @param[in] height in pixels to configure the display for. This parameter is optional
WiredHome 81:01da2e34283d 518 /// and the default is 272.
WiredHome 81:01da2e34283d 519 /// @param[in] color_bpp can be either 8 or 16, but must be consistent
WiredHome 81:01da2e34283d 520 /// with the width and height parameters. This parameter is optional
WiredHome 81:01da2e34283d 521 /// and the default is 16.
WiredHome 131:5bd6ba2ee4a1 522 /// @param[in] poweron defines if the display should be initialized into the power-on or off state.
WiredHome 132:a5d7a8541683 523 /// If power is non-zero(on), the backlight is set to this value. This parameter is optional
WiredHome 157:1565f38ca44b 524 /// and the default is 40 (on at a low brightness level because many users power
WiredHome 157:1565f38ca44b 525 /// the module from their PC USB port and it often cannot support the curent
WiredHome 157:1565f38ca44b 526 /// required for full brightness). See @ref Power.
WiredHome 81:01da2e34283d 527 /// @param[in] keypadon defines if the keypad support should be enabled. This parameter is optional
WiredHome 106:c80828f5dea4 528 /// and the default is true (enabled). See @ref KeypadInit.
WiredHome 124:1690a7ae871c 529 /// @param[in] touchscreeenon defines if the touchscreen support should be enabled.
WiredHome 132:a5d7a8541683 530 /// This parameter is optional and the default is true (enabled). See @ref TouchPanelInit.
WiredHome 124:1690a7ae871c 531 /// - If the constructor was called with support for the capacitive driver, this
WiredHome 124:1690a7ae871c 532 /// parameter causes the driver to initialize.
WiredHome 124:1690a7ae871c 533 /// - If the constructor was called without support for the capacitive driver, this
WiredHome 124:1690a7ae871c 534 /// parameter is used to enable and initialize the resistive touchscreen driver.
WiredHome 106:c80828f5dea4 535 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 79:544eb4964795 536 ///
WiredHome 81:01da2e34283d 537 RetCode_t init(int width = 480, int height = 272, int color_bpp = 16,
WiredHome 157:1565f38ca44b 538 uint8_t poweron = 40, bool keypadon = true, bool touchscreeenon = true);
WiredHome 124:1690a7ae871c 539
WiredHome 125:7a0b70f56550 540
WiredHome 79:544eb4964795 541 /// Get a pointer to the error code.
WiredHome 79:544eb4964795 542 ///
WiredHome 79:544eb4964795 543 /// This method returns a pointer to a text string that matches the
WiredHome 106:c80828f5dea4 544 /// code. See @ref RetCode_t.
WiredHome 79:544eb4964795 545 ///
WiredHome 79:544eb4964795 546 /// @param[in] code is the return value from RetCode_t to look up.
WiredHome 79:544eb4964795 547 /// @returns a pointer to the text message representing code. If code
WiredHome 79:544eb4964795 548 /// is not a valid value, then it returns the text for bad_parameter;
WiredHome 125:7a0b70f56550 549 ///
WiredHome 79:544eb4964795 550 const char * GetErrorMessage(RetCode_t code);
WiredHome 79:544eb4964795 551
WiredHome 79:544eb4964795 552
WiredHome 50:2c4f474a2453 553 /// Select the drawing layer for subsequent commands.
WiredHome 43:3becae133285 554 ///
WiredHome 43:3becae133285 555 /// If the screen configuration is 480 x 272, or if it is 800 x 480
WiredHome 43:3becae133285 556 /// and 8-bit color, the the display supports two layers, which can
WiredHome 43:3becae133285 557 /// be independently drawn on and shown. Additionally, complex
WiredHome 43:3becae133285 558 /// operations involving both layers are permitted.
WiredHome 43:3becae133285 559 ///
WiredHome 142:6e9bff59878a 560 /// @attention If the current display configuration does not support
WiredHome 142:6e9bff59878a 561 /// multiple layers, then layer 0 will be selected.
WiredHome 142:6e9bff59878a 562 ///
WiredHome 56:7a85d226ad0d 563 /// @code
WiredHome 56:7a85d226ad0d 564 /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
WiredHome 56:7a85d226ad0d 565 /// lcd.rect(400,130, 475,155,Brown);
WiredHome 56:7a85d226ad0d 566 /// lcd.SelectDrawingLayer(1);
WiredHome 56:7a85d226ad0d 567 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 568 /// wait(1);
WiredHome 56:7a85d226ad0d 569 /// lcd.SetLayerMode(ShowLayer1);
WiredHome 56:7a85d226ad0d 570 /// @endcode
WiredHome 56:7a85d226ad0d 571 ///
WiredHome 61:8f3153bf0baa 572 /// @attention The user manual refers to Layer 1 and Layer 2, however the
WiredHome 61:8f3153bf0baa 573 /// actual register values are value 0 and 1. This API as well as
WiredHome 61:8f3153bf0baa 574 /// others that reference the layers use the values 0 and 1 for
WiredHome 61:8f3153bf0baa 575 /// cleaner iteration in the code.
WiredHome 43:3becae133285 576 ///
WiredHome 72:ecffe56af969 577 /// @param[in] layer is 0 or 1 to select the layer for subsequent
WiredHome 61:8f3153bf0baa 578 /// commands.
WiredHome 143:e872d65a710d 579 /// @param[out] prevLayer is an optiona pointer to where the previous layer
WiredHome 143:e872d65a710d 580 /// will be written, making it a little easer to restore layers.
WiredHome 143:e872d65a710d 581 /// Writes 0 or 1 when the pointer is not NULL.
WiredHome 143:e872d65a710d 582 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 143:e872d65a710d 583 ///
WiredHome 143:e872d65a710d 584 virtual RetCode_t SelectDrawingLayer(uint16_t layer, uint16_t * prevLayer = NULL);
WiredHome 125:7a0b70f56550 585
WiredHome 43:3becae133285 586
WiredHome 61:8f3153bf0baa 587 /// Get the currently active drawing layer.
WiredHome 61:8f3153bf0baa 588 ///
WiredHome 61:8f3153bf0baa 589 /// This returns a value, 0 or 1, based on the screen configuration
WiredHome 61:8f3153bf0baa 590 /// and the currently active drawing layer.
WiredHome 61:8f3153bf0baa 591 ///
WiredHome 61:8f3153bf0baa 592 /// @code
WiredHome 61:8f3153bf0baa 593 /// uint16_t prevLayer = lcd.GetDrawingLayer();
WiredHome 61:8f3153bf0baa 594 /// lcd.SelectDrawingLayer(x);
WiredHome 61:8f3153bf0baa 595 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 61:8f3153bf0baa 596 /// lcd.SelectDrawingLayer(prevLayer);
WiredHome 61:8f3153bf0baa 597 /// @endcode
WiredHome 61:8f3153bf0baa 598 ///
WiredHome 61:8f3153bf0baa 599 /// @attention The user manual refers to Layer 1 and Layer 2, however the
WiredHome 61:8f3153bf0baa 600 /// actual register values are value 0 and 1. This API as well as
WiredHome 61:8f3153bf0baa 601 /// others that reference the layers use the values 0 and 1 for
WiredHome 61:8f3153bf0baa 602 /// cleaner iteration in the code.
WiredHome 61:8f3153bf0baa 603 ///
WiredHome 61:8f3153bf0baa 604 /// @returns the current drawing layer; 0 or 1.
WiredHome 61:8f3153bf0baa 605 ///
WiredHome 142:6e9bff59878a 606 virtual uint16_t GetDrawingLayer(void);
WiredHome 125:7a0b70f56550 607
WiredHome 61:8f3153bf0baa 608
WiredHome 44:207594dece70 609 /// Set the Layer presentation mode.
WiredHome 44:207594dece70 610 ///
WiredHome 44:207594dece70 611 /// This sets the presentation mode for layers, and permits showing
WiredHome 44:207594dece70 612 /// a single layer, or applying a mode where the two layers
WiredHome 44:207594dece70 613 /// are combined using one of the hardware methods.
WiredHome 44:207594dece70 614 ///
WiredHome 61:8f3153bf0baa 615 /// Refer to the RA8875 data sheet for full details.
WiredHome 61:8f3153bf0baa 616 ///
WiredHome 56:7a85d226ad0d 617 /// @code
WiredHome 56:7a85d226ad0d 618 /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
WiredHome 56:7a85d226ad0d 619 /// lcd.rect(400,130, 475,155,Brown);
WiredHome 56:7a85d226ad0d 620 /// lcd.SelectDrawingLayer(1);
WiredHome 56:7a85d226ad0d 621 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 622 /// wait(1);
WiredHome 56:7a85d226ad0d 623 /// lcd.SetLayerMode(ShowLayer1);
WiredHome 56:7a85d226ad0d 624 /// @endcode
WiredHome 56:7a85d226ad0d 625 ///
WiredHome 72:ecffe56af969 626 /// @param[in] mode sets the mode in the Layer Transparency Register.
WiredHome 106:c80828f5dea4 627 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 44:207594dece70 628 ///
WiredHome 53:86d24b9480b9 629 RetCode_t SetLayerMode(LayerMode_T mode);
WiredHome 125:7a0b70f56550 630
WiredHome 44:207594dece70 631
WiredHome 82:f7d300f26540 632 /// Get the Layer presentation mode.
WiredHome 82:f7d300f26540 633 ///
WiredHome 106:c80828f5dea4 634 /// This gets the current layer mode. See @ref LayerMode_T.
WiredHome 82:f7d300f26540 635 ///
WiredHome 82:f7d300f26540 636 /// @returns layer mode.
WiredHome 82:f7d300f26540 637 ///
WiredHome 82:f7d300f26540 638 LayerMode_T GetLayerMode(void);
WiredHome 125:7a0b70f56550 639
WiredHome 82:f7d300f26540 640
WiredHome 44:207594dece70 641 /// Set the layer transparency for each layer.
WiredHome 44:207594dece70 642 ///
WiredHome 44:207594dece70 643 /// Set the transparency, where the range of values is
WiredHome 44:207594dece70 644 /// from zero (fully visible) to eight (fully transparent).
WiredHome 44:207594dece70 645 /// The input value is automatically limited to this range.
WiredHome 44:207594dece70 646 ///
WiredHome 56:7a85d226ad0d 647 /// @code
WiredHome 56:7a85d226ad0d 648 /// // draw something on each layer, then step-fade across
WiredHome 56:7a85d226ad0d 649 /// display.SetLayerMode(RA8875::TransparentMode);
WiredHome 56:7a85d226ad0d 650 /// for (i=0; i<=8; i++) {
WiredHome 56:7a85d226ad0d 651 /// display.SetLayerTransparency(i, 8-i);
WiredHome 56:7a85d226ad0d 652 /// wait_ms(200);
WiredHome 56:7a85d226ad0d 653 /// }
WiredHome 56:7a85d226ad0d 654 /// @endcode
WiredHome 56:7a85d226ad0d 655 ///
WiredHome 72:ecffe56af969 656 /// @param[in] layer1 sets the layer 1 transparency.
WiredHome 72:ecffe56af969 657 /// @param[in] layer2 sets the layer 2 transparency.
WiredHome 106:c80828f5dea4 658 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 44:207594dece70 659 ///
WiredHome 44:207594dece70 660 RetCode_t SetLayerTransparency(uint8_t layer1, uint8_t layer2);
WiredHome 125:7a0b70f56550 661
WiredHome 44:207594dece70 662
WiredHome 53:86d24b9480b9 663 /// Set the background color register used for transparency.
WiredHome 53:86d24b9480b9 664 ///
WiredHome 53:86d24b9480b9 665 /// This command sets the background color registers that are used
WiredHome 53:86d24b9480b9 666 /// in the transparent color operations involving the layers.
WiredHome 53:86d24b9480b9 667 ///
WiredHome 72:ecffe56af969 668 /// @param[in] color is optional and expressed in 16-bit format. If not
WiredHome 53:86d24b9480b9 669 /// supplied, a default of Black is used.
WiredHome 106:c80828f5dea4 670 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 53:86d24b9480b9 671 ///
WiredHome 53:86d24b9480b9 672 RetCode_t SetBackgroundTransparencyColor(color_t color = RGB(0,0,0));
hexley 54:e117ad10fba6 673
WiredHome 73:f22a18707b5e 674
WiredHome 73:f22a18707b5e 675 /// Get the background color value used for transparency.
WiredHome 73:f22a18707b5e 676 ///
WiredHome 73:f22a18707b5e 677 /// This command reads the background color registers that define
WiredHome 73:f22a18707b5e 678 /// the transparency color for operations involving layers.
WiredHome 73:f22a18707b5e 679 ///
WiredHome 73:f22a18707b5e 680 /// @returns the color.
WiredHome 73:f22a18707b5e 681 ///
WiredHome 73:f22a18707b5e 682 color_t GetBackgroundTransparencyColor(void);
WiredHome 73:f22a18707b5e 683
WiredHome 125:7a0b70f56550 684
hexley 54:e117ad10fba6 685 /// Initialize theTouch Panel controller with default values
hexley 54:e117ad10fba6 686 ///
WiredHome 78:faf49c381591 687 /// This activates the simplified touch panel init, which may work for
WiredHome 78:faf49c381591 688 /// most uses. The alternate API is available if fine-grained control
WiredHome 124:1690a7ae871c 689 /// of the numerous settings of the resistive panel is needed.
WiredHome 78:faf49c381591 690 ///
WiredHome 157:1565f38ca44b 691 /// Additionally, for an even simpler interface for most RESISTIVE
WiredHome 157:1565f38ca44b 692 /// touch use cases, the init() method can perform the calibration.
WiredHome 157:1565f38ca44b 693 ///
WiredHome 106:c80828f5dea4 694 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 56:7a85d226ad0d 695 ///
hexley 54:e117ad10fba6 696 RetCode_t TouchPanelInit(void);
hexley 54:e117ad10fba6 697
WiredHome 125:7a0b70f56550 698
hexley 54:e117ad10fba6 699 /// Initialize the Touch Panel controller with detailed settings.
hexley 54:e117ad10fba6 700 ///
WiredHome 78:faf49c381591 701 /// This is the detailed touch panel init, which provides the ability
WiredHome 124:1690a7ae871c 702 /// to set nearly every option.
WiredHome 124:1690a7ae871c 703 ///
WiredHome 124:1690a7ae871c 704 /// @note If the capacitive touch panel was constructed, this behaves
WiredHome 124:1690a7ae871c 705 /// the same as the simplified version.
WiredHome 78:faf49c381591 706 ///
hexley 54:e117ad10fba6 707 /// @param[in] bTpEnable Touch Panel enable/disable control:
hexley 54:e117ad10fba6 708 /// - TP_ENABLE: enable the touch panel
hexley 54:e117ad10fba6 709 /// - TP_DISABLE: disable the touch panel
WiredHome 56:7a85d226ad0d 710 /// @param[in] bTpAutoManual Touch Panel operating mode:
hexley 54:e117ad10fba6 711 /// - TP_MODE_AUTO: automatic capture
hexley 54:e117ad10fba6 712 /// - TP_MODE_MANUAL: manual capture
WiredHome 56:7a85d226ad0d 713 /// @param[in] bTpDebounce Debounce circuit enable for touch panel interrupt:
hexley 54:e117ad10fba6 714 /// - TP_DEBOUNCE_OFF: disable the debounce circuit
hexley 54:e117ad10fba6 715 /// - TP_DEBOUNCE_ON: enable the debounce circuit
WiredHome 56:7a85d226ad0d 716 /// @param[in] bTpManualMode When Manual Mode is selected, this sets the mode:
hexley 54:e117ad10fba6 717 /// - TP_MANUAL_IDLE: touch panel is idle
hexley 54:e117ad10fba6 718 /// - TP_MANUAL_WAIT: wait for touch panel event
hexley 54:e117ad10fba6 719 /// - TP_MANUAL_LATCH_X: latch X data
hexley 54:e117ad10fba6 720 /// - TP_MANUAL_LATCH_Y: latch Y data
WiredHome 56:7a85d226ad0d 721 /// @param[in] bTpAdcClkDiv Sets the ADC clock as a fraction of the System CLK:
hexley 54:e117ad10fba6 722 /// - TP_ADC_CLKDIV_1: Use CLK
hexley 54:e117ad10fba6 723 /// - TP_ADC_CLKDIV_2: Use CLK/2
hexley 54:e117ad10fba6 724 /// - TP_ADC_CLKDIV_4: Use CLK/4
hexley 54:e117ad10fba6 725 /// - TP_ADC_CLKDIV_8: Use CLK/8
hexley 54:e117ad10fba6 726 /// - TP_ADC_CLKDIV_16: Use CLK/16
hexley 54:e117ad10fba6 727 /// - TP_ADC_CLKDIV_32: Use CLK/32
hexley 54:e117ad10fba6 728 /// - TP_ADC_CLKDIV_64: Use CLK/64
hexley 54:e117ad10fba6 729 /// - TP_ADC_CLKDIV_128: Use CLK/128
WiredHome 56:7a85d226ad0d 730 /// @param[in] bTpAdcSampleTime Touch Panel sample time delay before ADC data is ready:
hexley 54:e117ad10fba6 731 /// - TP_ADC_SAMPLE_512_CLKS: Wait 512 system clocks
hexley 54:e117ad10fba6 732 /// - TP_ADC_SAMPLE_1024_CLKS: Wait 1024 system clocks
hexley 54:e117ad10fba6 733 /// - TP_ADC_SAMPLE_2048_CLKS: Wait 2048 system clocks
hexley 54:e117ad10fba6 734 /// - TP_ADC_SAMPLE_4096_CLKS: Wait 4096 system clocks
hexley 54:e117ad10fba6 735 /// - TP_ADC_SAMPLE_8192_CLKS: Wait 8192 system clocks
hexley 54:e117ad10fba6 736 /// - TP_ADC_SAMPLE_16384_CLKS: Wait 16384 system clocks
hexley 54:e117ad10fba6 737 /// - TP_ADC_SAMPLE_32768_CLKS: Wait 32768 system clocks
hexley 54:e117ad10fba6 738 /// - TP_ADC_SAMPLE_65536_CLKS: Wait 65536 system clocks
WiredHome 106:c80828f5dea4 739 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 56:7a85d226ad0d 740 ///
WiredHome 78:faf49c381591 741 RetCode_t TouchPanelInit(uint8_t bTpEnable, uint8_t bTpAutoManual, uint8_t bTpDebounce,
WiredHome 78:faf49c381591 742 uint8_t bTpManualMode, uint8_t bTpAdcClkDiv, uint8_t bTpAdcSampleTime);
WiredHome 53:86d24b9480b9 743
WiredHome 123:2f45e80fec5f 744
WiredHome 123:2f45e80fec5f 745 /// Get the screen calibrated point of touch.
WiredHome 123:2f45e80fec5f 746 ///
WiredHome 123:2f45e80fec5f 747 /// This method determines if there is a touch and if so it will provide
WiredHome 123:2f45e80fec5f 748 /// the screen-relative touch coordinates. This method can be used in
WiredHome 123:2f45e80fec5f 749 /// a manner similar to Serial.readable(), to determine if there was a
WiredHome 123:2f45e80fec5f 750 /// touch and indicate that - but not care about the coordinates. Alternately,
WiredHome 123:2f45e80fec5f 751 /// if a valid pointer to a point_t is provided, then if a touch is detected
WiredHome 123:2f45e80fec5f 752 /// the point_t will be populated with data.
WiredHome 123:2f45e80fec5f 753 ///
WiredHome 123:2f45e80fec5f 754 /// @code
WiredHome 123:2f45e80fec5f 755 /// Timer t;
WiredHome 123:2f45e80fec5f 756 /// t.start();
WiredHome 123:2f45e80fec5f 757 /// do {
WiredHome 123:2f45e80fec5f 758 /// point_t point = {0, 0};
WiredHome 123:2f45e80fec5f 759 /// if (display.TouchPanelReadable(&point)) {
WiredHome 123:2f45e80fec5f 760 /// display.pixel(point, Red);
WiredHome 123:2f45e80fec5f 761 /// }
WiredHome 123:2f45e80fec5f 762 /// } while (t.read_ms() < 30000);
WiredHome 123:2f45e80fec5f 763 /// @endcode
WiredHome 123:2f45e80fec5f 764 ///
WiredHome 123:2f45e80fec5f 765 /// @param[out] TouchPoint is a pointer to a point_t, which is set as the touch point, if a touch is registered.
WiredHome 123:2f45e80fec5f 766 /// @returns a value indicating the state of the touch,
WiredHome 123:2f45e80fec5f 767 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 123:2f45e80fec5f 768 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 123:2f45e80fec5f 769 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 770 /// - held: held after touch, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 771 /// - release: indicates a release, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 772 ///
WiredHome 123:2f45e80fec5f 773 TouchCode_t TouchPanelReadable(point_t * TouchPoint = NULL);
WiredHome 123:2f45e80fec5f 774
WiredHome 125:7a0b70f56550 775
WiredHome 124:1690a7ae871c 776 /// Get the reported touch gesture, if any.
WiredHome 124:1690a7ae871c 777 ///
WiredHome 124:1690a7ae871c 778 /// If it could detect a gesture, it will return a value based on
WiredHome 132:a5d7a8541683 779 /// the interpreted gesture.
WiredHome 124:1690a7ae871c 780 ///
WiredHome 124:1690a7ae871c 781 /// Valid gesture values are:
WiredHome 124:1690a7ae871c 782 /// @li 0x00 No gesture
WiredHome 132:a5d7a8541683 783 /// @li 0x48 Zoom in
WiredHome 132:a5d7a8541683 784 /// @li 0x49 Zoom out
WiredHome 132:a5d7a8541683 785 ///
WiredHome 132:a5d7a8541683 786 /// The following gestures are defined in the FT5206 specification, but
WiredHome 132:a5d7a8541683 787 /// do not appear to work.
WiredHome 124:1690a7ae871c 788 /// @li 0x10 Move up
WiredHome 124:1690a7ae871c 789 /// @li 0x14 Move left
WiredHome 124:1690a7ae871c 790 /// @li 0x18 Move down
WiredHome 124:1690a7ae871c 791 /// @li 0x1C Move right
WiredHome 124:1690a7ae871c 792 ///
WiredHome 124:1690a7ae871c 793 /// @returns gesture information.
WiredHome 124:1690a7ae871c 794 ///
WiredHome 124:1690a7ae871c 795 uint8_t TouchGesture(void) { return gesture; }
WiredHome 124:1690a7ae871c 796
WiredHome 123:2f45e80fec5f 797
WiredHome 124:1690a7ae871c 798 /// Get the count of registered touches.
WiredHome 124:1690a7ae871c 799 ///
WiredHome 124:1690a7ae871c 800 /// @returns count of touch points to communicate; 0 to 5.
WiredHome 124:1690a7ae871c 801 ///
WiredHome 124:1690a7ae871c 802 int TouchCount(void) { return numberOfTouchPoints; }
WiredHome 125:7a0b70f56550 803
WiredHome 124:1690a7ae871c 804
WiredHome 124:1690a7ae871c 805 /// Get the count of possible touch channels.
WiredHome 124:1690a7ae871c 806 ///
WiredHome 124:1690a7ae871c 807 /// @returns count of touch channels supported by the hardware.
WiredHome 124:1690a7ae871c 808 ///
WiredHome 124:1690a7ae871c 809 int TouchChannels(void);
WiredHome 125:7a0b70f56550 810
WiredHome 124:1690a7ae871c 811
WiredHome 124:1690a7ae871c 812 /// Get the Touch ID value for a specified touch channel.
WiredHome 124:1690a7ae871c 813 ///
WiredHome 124:1690a7ae871c 814 /// Touch ID is a tracking number based on the order of the touch
WiredHome 124:1690a7ae871c 815 /// detections. The first touch is ID 0, the next is ID 1, and
WiredHome 124:1690a7ae871c 816 /// so on. If the first touch is lifted (no touch), the touch count
WiredHome 124:1690a7ae871c 817 /// decrements, and the remaining touch is communicated on
WiredHome 124:1690a7ae871c 818 /// touch channel zero, even as the Touch ID remains as originally
WiredHome 124:1690a7ae871c 819 /// reported (1 in this example). In this way, it is easy to track
WiredHome 132:a5d7a8541683 820 /// a specific touch.
WiredHome 124:1690a7ae871c 821 ///
WiredHome 124:1690a7ae871c 822 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 823 /// presently reported as touched.
WiredHome 124:1690a7ae871c 824 ///
WiredHome 124:1690a7ae871c 825 /// @param[in] channel is the touch channel, from 0 to 4, or 0 to getTouchCount()-1
WiredHome 124:1690a7ae871c 826 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 827 /// @returns the touch ID, or 15 if you get the ID for an untouched channel.
WiredHome 124:1690a7ae871c 828 /// @returns 0 if an invalid channel is queried.
WiredHome 124:1690a7ae871c 829 ///
WiredHome 124:1690a7ae871c 830 uint8_t TouchID(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].touchID : touchInfo[0].touchID; }
WiredHome 125:7a0b70f56550 831
WiredHome 124:1690a7ae871c 832
WiredHome 124:1690a7ae871c 833 /// Get the Touch Code for a touch channel.
WiredHome 124:1690a7ae871c 834 ///
WiredHome 124:1690a7ae871c 835 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 836 /// presently reported as touched.
WiredHome 124:1690a7ae871c 837 ///
WiredHome 124:1690a7ae871c 838 /// @param[in] channel is the touch channel, from 0 to 4, or 0 to getTouchCount()-1
WiredHome 124:1690a7ae871c 839 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 840 /// @returns the touch code (@ref TouchCode_t).
WiredHome 124:1690a7ae871c 841 /// @returns channel 0 information if an invalid channel is queried.
WiredHome 124:1690a7ae871c 842 ///
WiredHome 124:1690a7ae871c 843 TouchCode_t TouchCode(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].touchCode : touchInfo[0].touchCode; }
WiredHome 124:1690a7ae871c 844
WiredHome 125:7a0b70f56550 845
WiredHome 124:1690a7ae871c 846 /// Get the coordinates for a touch channel.
WiredHome 124:1690a7ae871c 847 ///
WiredHome 124:1690a7ae871c 848 /// This returns the (X,Y) coordinates for a touch channel.
WiredHome 132:a5d7a8541683 849 ///
WiredHome 124:1690a7ae871c 850 ///
WiredHome 124:1690a7ae871c 851 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 852 /// presently reported as touched.
WiredHome 124:1690a7ae871c 853 ///
WiredHome 124:1690a7ae871c 854 /// @param[in] channel is an optional touch channel, from 0 to 4, or 0 to getTouchCount()-1.
WiredHome 124:1690a7ae871c 855 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 856 /// @returns the coordinates as a point_t structure.
WiredHome 124:1690a7ae871c 857 /// @returns channel 0 information if an invalid channel is queried.
WiredHome 124:1690a7ae871c 858 ///
WiredHome 124:1690a7ae871c 859 point_t TouchCoordinates(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].coordinates : touchInfo[0].coordinates; }
WiredHome 125:7a0b70f56550 860
WiredHome 131:5bd6ba2ee4a1 861
WiredHome 79:544eb4964795 862 /// Poll the TouchPanel and on a touch event return the a to d filtered x, y coordinates.
hexley 54:e117ad10fba6 863 ///
WiredHome 78:faf49c381591 864 /// This method reads the touch controller, which has a 10-bit range for each the
WiredHome 79:544eb4964795 865 /// x and the y axis.
WiredHome 79:544eb4964795 866 ///
WiredHome 79:544eb4964795 867 /// @note The returned values are not in display (pixel) units but are in analog to
WiredHome 79:544eb4964795 868 /// digital converter units.
WiredHome 78:faf49c381591 869 ///
WiredHome 131:5bd6ba2ee4a1 870 /// @note This API is usually not needed and is likely to be deprecated.
WiredHome 131:5bd6ba2ee4a1 871 /// See @ref TouchPanelComputeCalibration.
WiredHome 106:c80828f5dea4 872 /// See @ref TouchPanelReadable.
WiredHome 78:faf49c381591 873 ///
WiredHome 79:544eb4964795 874 /// @param[out] x is the x scale a/d value.
WiredHome 79:544eb4964795 875 /// @param[out] y is the y scale a/d value.
WiredHome 83:7bad0068cca0 876 /// @returns a value indicating the state of the touch,
WiredHome 83:7bad0068cca0 877 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 878 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 879 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 83:7bad0068cca0 880 /// - held: held after touch, touch coordinates are returned.
WiredHome 83:7bad0068cca0 881 /// - release: indicates a release, touch coordinates are returned.
WiredHome 56:7a85d226ad0d 882 ///
WiredHome 83:7bad0068cca0 883 TouchCode_t TouchPanelA2DFiltered(int *x, int *y);
hexley 54:e117ad10fba6 884
WiredHome 125:7a0b70f56550 885
WiredHome 79:544eb4964795 886 /// Poll the TouchPanel and on a touch event return the a to d raw x, y coordinates.
hexley 54:e117ad10fba6 887 ///
WiredHome 78:faf49c381591 888 /// This method reads the touch controller, which has a 10-bit range for each the
WiredHome 78:faf49c381591 889 /// x and the y axis. A number of samples of the raw data are taken, filtered,
WiredHome 79:544eb4964795 890 /// and the results are returned.
WiredHome 78:faf49c381591 891 ///
WiredHome 79:544eb4964795 892 /// @note The returned values are not in display (pixel) units but are in analog to
WiredHome 79:544eb4964795 893 /// digital converter units.
WiredHome 79:544eb4964795 894 ///
WiredHome 131:5bd6ba2ee4a1 895 /// @note This API is usually not needed and is likely to be deprecated.
WiredHome 131:5bd6ba2ee4a1 896 /// See @ref TouchPanelComputeCalibration.
WiredHome 106:c80828f5dea4 897 /// See @ref TouchPanelReadable.
WiredHome 78:faf49c381591 898 ///
WiredHome 79:544eb4964795 899 /// @param[out] x is the x scale a/d value.
WiredHome 79:544eb4964795 900 /// @param[out] y is the y scale a/d value.
WiredHome 83:7bad0068cca0 901 /// @returns a value indicating the state of the touch,
WiredHome 83:7bad0068cca0 902 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 903 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 904 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 83:7bad0068cca0 905 /// - held: held after touch, touch coordinates are returned.
WiredHome 83:7bad0068cca0 906 /// - release: indicates a release, touch coordinates are returned.
WiredHome 83:7bad0068cca0 907 ///
WiredHome 83:7bad0068cca0 908 TouchCode_t TouchPanelA2DRaw(int *x, int *y);
WiredHome 125:7a0b70f56550 909
WiredHome 83:7bad0068cca0 910
WiredHome 85:022bba13c5c4 911 /// Wait for a touch panel touch and return it.
WiredHome 85:022bba13c5c4 912 ///
WiredHome 85:022bba13c5c4 913 /// This method is similar to Serial.getc() in that it will wait for a touch
WiredHome 85:022bba13c5c4 914 /// and then return. In order to extract the coordinates of the touch, a
WiredHome 85:022bba13c5c4 915 /// valid pointer to a point_t must be provided.
WiredHome 85:022bba13c5c4 916 ///
WiredHome 85:022bba13c5c4 917 /// @note There is no timeout on this function, so its use is not recommended.
WiredHome 85:022bba13c5c4 918 ///
WiredHome 85:022bba13c5c4 919 /// @code
WiredHome 85:022bba13c5c4 920 /// Timer t;
WiredHome 85:022bba13c5c4 921 /// t.start();
WiredHome 85:022bba13c5c4 922 /// do {
WiredHome 85:022bba13c5c4 923 /// point_t point = {0, 0};
WiredHome 85:022bba13c5c4 924 /// display.TouchPanelGet(&point); // hangs here until touch
WiredHome 85:022bba13c5c4 925 /// display.pixel(point, Red);
WiredHome 85:022bba13c5c4 926 /// } while (t.read_ms() < 30000);
WiredHome 85:022bba13c5c4 927 /// @endcode
WiredHome 85:022bba13c5c4 928 ///
WiredHome 85:022bba13c5c4 929 /// @param[out] TouchPoint is the touch point, if a touch is registered.
WiredHome 85:022bba13c5c4 930 /// @returns a value indicating the state of the touch,
WiredHome 85:022bba13c5c4 931 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 85:022bba13c5c4 932 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 85:022bba13c5c4 933 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 85:022bba13c5c4 934 /// - held: held after touch, touch coordinates are returned.
WiredHome 85:022bba13c5c4 935 /// - release: indicates a release, touch coordinates are returned.
WiredHome 85:022bba13c5c4 936 ///
WiredHome 85:022bba13c5c4 937 TouchCode_t TouchPanelGet(point_t * TouchPoint);
WiredHome 85:022bba13c5c4 938
WiredHome 83:7bad0068cca0 939
WiredHome 157:1565f38ca44b 940 /// Configuration Option for the Resistive Touch Panel Calibration.
WiredHome 157:1565f38ca44b 941 ///
WiredHome 157:1565f38ca44b 942 /// This method is only useful for the resistive touchscreen.
WiredHome 157:1565f38ca44b 943 ///
WiredHome 157:1565f38ca44b 944 /// Also, this method is optional - the user can take all of the responsibility
WiredHome 157:1565f38ca44b 945 /// in their code, or for simplicity sake, this API can be used prior
WiredHome 157:1565f38ca44b 946 /// to the init method.
WiredHome 157:1565f38ca44b 947 ///
WiredHome 157:1565f38ca44b 948 /// @code
WiredHome 157:1565f38ca44b 949 /// RA8875 lcd(p5, p6, p7, p12, NC);
WiredHome 157:1565f38ca44b 950 /// ...
WiredHome 157:1565f38ca44b 951 /// // Be sure you previously mounted the "/sd" file system to put the cal there.
WiredHome 157:1565f38ca44b 952 /// lcd.ResTouchPanelCfg("/sd/tpcal.cfg", "Touch '+' to calibrate the touch panel");
WiredHome 157:1565f38ca44b 953 ///
WiredHome 157:1565f38ca44b 954 /// // Only if the touch panel is enabled, AND is configured as the resistive
WiredHome 157:1565f38ca44b 955 /// // panel will the prior command be useful.
WiredHome 157:1565f38ca44b 956 /// lcd.init(LCD_W,LCD_H,LCD_C,40, false, true);
WiredHome 157:1565f38ca44b 957 ///
WiredHome 157:1565f38ca44b 958 /// @endcode
WiredHome 157:1565f38ca44b 959 ///
WiredHome 157:1565f38ca44b 960 /// @param[in] tpFQFN is a pointer to a fully qualified read-write accessible
WiredHome 157:1565f38ca44b 961 /// filename where the calibration is held.
WiredHome 157:1565f38ca44b 962 /// @param[in] tpCalMessage is an optional pointer to a message shown to the
WiredHome 157:1565f38ca44b 963 /// user in the calibration process.
WiredHome 157:1565f38ca44b 964 /// - If this parameter is not included, a default message will be shown.
WiredHome 157:1565f38ca44b 965 /// - If this parameter points to a NULL string, no message is shown.
WiredHome 157:1565f38ca44b 966 /// - If this parameter points to a non-NULL string, that string will be shown.
WiredHome 157:1565f38ca44b 967 ///
WiredHome 157:1565f38ca44b 968 void ResTouchPanelCfg(const char * tpFQFN = NULL, const char * tpCalMessage = NULL);
WiredHome 157:1565f38ca44b 969
WiredHome 157:1565f38ca44b 970
WiredHome 77:9206c13aa527 971 /// Calibrate the touch panel.
WiredHome 77:9206c13aa527 972 ///
WiredHome 77:9206c13aa527 973 /// This method accepts two lists - one list is target points in ,
WiredHome 77:9206c13aa527 974 /// display coordinates and the other is a lit of raw touch coordinate
WiredHome 77:9206c13aa527 975 /// values. It generates a calibration matrix for later use. This
WiredHome 77:9206c13aa527 976 /// matrix is also accessible to the calling API, which may store
WiredHome 77:9206c13aa527 977 /// the matrix in persistent memory and then install the calibration
WiredHome 77:9206c13aa527 978 /// matrix on the next power cycle. By doing so, it can avoid the
WiredHome 77:9206c13aa527 979 /// need to calibrate on every power cycle.
WiredHome 77:9206c13aa527 980 ///
WiredHome 81:01da2e34283d 981 /// @note The methods "TouchPanelComputeCalibration", "TouchPanelReadable", and
WiredHome 77:9206c13aa527 982 /// indirectly the "TouchPanelSetMatrix" methods are all derived
WiredHome 77:9206c13aa527 983 /// from a program by Carlos E. Vidales. See the copyright note
WiredHome 77:9206c13aa527 984 /// for further details. See also the article
WiredHome 77:9206c13aa527 985 /// http://www.embedded.com/design/system-integration/4023968/How-To-Calibrate-Touch-Screens
WiredHome 77:9206c13aa527 986 ///
WiredHome 77:9206c13aa527 987 /// @copyright Copyright (c) 2001, Carlos E. Vidales. All rights reserved.
WiredHome 78:faf49c381591 988 /// This sample program was written and put in the public domain
WiredHome 78:faf49c381591 989 /// by Carlos E. Vidales. The program is provided "as is"
WiredHome 78:faf49c381591 990 /// without warranty of any kind, either expressed or implied.
WiredHome 78:faf49c381591 991 /// If you choose to use the program within your own products
WiredHome 78:faf49c381591 992 /// you do so at your own risk, and assume the responsibility
WiredHome 78:faf49c381591 993 /// for servicing, repairing or correcting the program should
WiredHome 78:faf49c381591 994 /// it prove defective in any manner.
WiredHome 78:faf49c381591 995 /// You may copy and distribute the program's source code in any
WiredHome 78:faf49c381591 996 /// medium, provided that you also include in each copy an
WiredHome 78:faf49c381591 997 /// appropriate copyright notice and disclaimer of warranty.
WiredHome 78:faf49c381591 998 /// You may also modify this program and distribute copies of
WiredHome 78:faf49c381591 999 /// it provided that you include prominent notices stating
WiredHome 78:faf49c381591 1000 /// that you changed the file(s) and the date of any change,
WiredHome 78:faf49c381591 1001 /// and that you do not charge any royalties or licenses for
WiredHome 78:faf49c381591 1002 /// its use.
WiredHome 77:9206c13aa527 1003 ///
WiredHome 77:9206c13aa527 1004 /// @param[in] display is a pointer to a set of 3 points, which
WiredHome 77:9206c13aa527 1005 /// are in display units of measure. These are the targets
WiredHome 77:9206c13aa527 1006 /// the calibration was aiming for.
WiredHome 77:9206c13aa527 1007 /// @param[in] screen is a pointer to a set of 3 points, which
WiredHome 77:9206c13aa527 1008 /// are in touchscreen units of measure. These are the
WiredHome 77:9206c13aa527 1009 /// registered touches.
WiredHome 77:9206c13aa527 1010 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 77:9206c13aa527 1011 /// as a result of the calibration. This can be saved in
WiredHome 77:9206c13aa527 1012 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 106:c80828f5dea4 1013 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 77:9206c13aa527 1014 ///
WiredHome 81:01da2e34283d 1015 RetCode_t TouchPanelComputeCalibration(point_t display[3], point_t screen[3], tpMatrix_t * matrix);
WiredHome 81:01da2e34283d 1016
WiredHome 81:01da2e34283d 1017
WiredHome 81:01da2e34283d 1018 /// Perform the touch panel calibration process.
WiredHome 81:01da2e34283d 1019 ///
WiredHome 81:01da2e34283d 1020 /// This method provides the easy "shortcut" to calibrating the touch panel.
WiredHome 81:01da2e34283d 1021 /// The process will automatically generate the calibration points, present
WiredHome 81:01da2e34283d 1022 /// the targets on-screen, detect the touches, compute the calibration
WiredHome 81:01da2e34283d 1023 /// matrix, and optionally provide the calibration matrix to the calling code
WiredHome 81:01da2e34283d 1024 /// for persistence in non-volatile memory.
WiredHome 81:01da2e34283d 1025 ///
WiredHome 81:01da2e34283d 1026 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 81:01da2e34283d 1027 /// as a result of the calibration. This can be saved in
WiredHome 81:01da2e34283d 1028 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 106:c80828f5dea4 1029 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 1030 ///
WiredHome 85:022bba13c5c4 1031 RetCode_t TouchPanelCalibrate(tpMatrix_t * matrix = NULL);
WiredHome 81:01da2e34283d 1032
WiredHome 125:7a0b70f56550 1033
WiredHome 81:01da2e34283d 1034 /// Perform the touch panel calibration process.
WiredHome 81:01da2e34283d 1035 ///
WiredHome 81:01da2e34283d 1036 /// This method provides the easy "shortcut" to calibrating the touch panel.
WiredHome 81:01da2e34283d 1037 /// The process will automatically generate the calibration points, present
WiredHome 81:01da2e34283d 1038 /// the targets on-screen, detect the touches, compute the calibration
WiredHome 81:01da2e34283d 1039 /// matrix, and optionally provide the calibration matrix to the calling code
WiredHome 81:01da2e34283d 1040 /// for persistence in non-volatile memory.
WiredHome 81:01da2e34283d 1041 ///
WiredHome 81:01da2e34283d 1042 /// @param[in] msg is a text message to present on the screen during the
WiredHome 81:01da2e34283d 1043 /// calibration process.
WiredHome 81:01da2e34283d 1044 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 81:01da2e34283d 1045 /// as a result of the calibration. This can be saved in
WiredHome 81:01da2e34283d 1046 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 88:bfddef6ec836 1047 /// @param[in] maxwait_s is the maximum number of seconds to wait for a touch
WiredHome 88:bfddef6ec836 1048 /// calibration. If no touch panel installed, it then reports
WiredHome 155:b3f225ae572c 1049 /// touch_cal_timeout. Default: 30 s.
WiredHome 106:c80828f5dea4 1050 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 1051 ///
WiredHome 155:b3f225ae572c 1052 RetCode_t TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix = NULL, int maxwait_s = 30);
WiredHome 77:9206c13aa527 1053
WiredHome 125:7a0b70f56550 1054
WiredHome 157:1565f38ca44b 1055 /// Set the calibration matrix for the resistive touch panel.
WiredHome 77:9206c13aa527 1056 ///
WiredHome 77:9206c13aa527 1057 /// This method is used to set the calibration matrix for the touch panel. After
WiredHome 106:c80828f5dea4 1058 /// performing the calibration (See @ref TouchPanelComputeCalibration), the matrix can be stored.
WiredHome 77:9206c13aa527 1059 /// On a subsequence power cycle, the matrix may be restored from non-volatile and
WiredHome 77:9206c13aa527 1060 /// passed in to this method. It will then be held to perform the corrections when
WiredHome 77:9206c13aa527 1061 /// reading the touch panel point.
WiredHome 77:9206c13aa527 1062 ///
WiredHome 78:faf49c381591 1063 /// @code
WiredHome 78:faf49c381591 1064 /// FILE * fh = fopen("/local/tpmatrix.cfg", "r");
WiredHome 78:faf49c381591 1065 /// if (fh) {
WiredHome 78:faf49c381591 1066 /// tpMatrix_t matrix;
WiredHome 78:faf49c381591 1067 /// if (fread(fh, &matrix, sizeof(tpMatrix_t))) {
WiredHome 78:faf49c381591 1068 /// lcd.TouchPanelSetMatrix(&matrix);
WiredHome 78:faf49c381591 1069 /// }
WiredHome 78:faf49c381591 1070 /// fclose(fh);
WiredHome 78:faf49c381591 1071 /// }
WiredHome 78:faf49c381591 1072 /// @endcode
WiredHome 78:faf49c381591 1073 ///
WiredHome 77:9206c13aa527 1074 /// @param[in] matrix is a pointer to the touch panel calibration matrix.
WiredHome 106:c80828f5dea4 1075 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 77:9206c13aa527 1076 ///
WiredHome 77:9206c13aa527 1077 RetCode_t TouchPanelSetMatrix(tpMatrix_t * matrix);
WiredHome 157:1565f38ca44b 1078
WiredHome 157:1565f38ca44b 1079 /// Get the calibration matrix for the resistive touch panel.
WiredHome 157:1565f38ca44b 1080 ///
WiredHome 157:1565f38ca44b 1081 /// This method returns a const pointer to the matrix. If this matrix has
WiredHome 157:1565f38ca44b 1082 /// not be set, with either the TouchPanelSetMatrix API or the calibration
WiredHome 157:1565f38ca44b 1083 /// process, the results are indeterminate.
WiredHome 157:1565f38ca44b 1084 ///
WiredHome 157:1565f38ca44b 1085 /// return const tpMatrix_t pointer
WiredHome 157:1565f38ca44b 1086 ///
WiredHome 157:1565f38ca44b 1087 const tpMatrix_t * TouchPanelGetMatrix();
WiredHome 125:7a0b70f56550 1088
WiredHome 75:ca78388cfd77 1089 #if 0
hexley 54:e117ad10fba6 1090 /// Append interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 1091 ///
hexley 54:e117ad10fba6 1092 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 1093 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 1094 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 1095 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 1096 /// - RA8875_INT_BTE: BTE process complete interrupt
hexley 54:e117ad10fba6 1097 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
WiredHome 56:7a85d226ad0d 1098 /// @param[in] fptr is a callback function to handle the interrupt event.
WiredHome 56:7a85d226ad0d 1099 /// @returns none
hexley 54:e117ad10fba6 1100 ///
hexley 54:e117ad10fba6 1101 void AppendISR(uint8_t bISRType, void(*fptr)(void));
hexley 54:e117ad10fba6 1102
hexley 54:e117ad10fba6 1103 /// Unappend interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 1104 ///
hexley 54:e117ad10fba6 1105 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 1106 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 1107 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 1108 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 1109 /// - RA8875_INT_BTE: BTE process complete interrupt
hexley 54:e117ad10fba6 1110 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
hexley 54:e117ad10fba6 1111 /// @return none
hexley 54:e117ad10fba6 1112 ///
hexley 54:e117ad10fba6 1113 void UnAppendISR(uint8_t bISRType);
WiredHome 75:ca78388cfd77 1114 #endif
WiredHome 77:9206c13aa527 1115
WiredHome 125:7a0b70f56550 1116
WiredHome 71:dcac8efd842d 1117 /// Initialize the keypad interface on the RA8875 controller.
WiredHome 71:dcac8efd842d 1118 ///
WiredHome 71:dcac8efd842d 1119 /// Enables the keypad subsystem. It will scan the 4 x 5 matrix
WiredHome 131:5bd6ba2ee4a1 1120 /// and make available key presses.
WiredHome 71:dcac8efd842d 1121 ///
WiredHome 71:dcac8efd842d 1122 /// @note See section 5-13 of RAIO RA8875 data sheet for more details.
WiredHome 125:7a0b70f56550 1123 /// @note When using the display from buy-display.com, be sure that
WiredHome 71:dcac8efd842d 1124 /// the option for the keypad is configured on the hardware.
WiredHome 71:dcac8efd842d 1125 ///
WiredHome 71:dcac8efd842d 1126 /// All parameters are optional.
WiredHome 76:c981284eb513 1127 /// @param[in] scanEnable when true, enables the key scan function (default: true).
WiredHome 76:c981284eb513 1128 /// @param[in] longDetect when true, additionally enables the long key held detection (default: false).
WiredHome 71:dcac8efd842d 1129 /// @param[in] sampleTime setting (range: 0 - 3, default: 0).
WiredHome 71:dcac8efd842d 1130 /// @param[in] scanFrequency setting (range: 0 - 7, default: 0).
WiredHome 71:dcac8efd842d 1131 /// @param[in] longTimeAdjustment (range: 0 - 3, default: 0).
WiredHome 76:c981284eb513 1132 /// @param[in] interruptEnable when true, enables interrupts from keypress (default: false).
WiredHome 76:c981284eb513 1133 /// @param[in] wakeupEnable when true, activates the wakeup function (default: false).
WiredHome 71:dcac8efd842d 1134 ///
WiredHome 106:c80828f5dea4 1135 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 71:dcac8efd842d 1136 ///
WiredHome 71:dcac8efd842d 1137 RetCode_t KeypadInit(bool scanEnable = true, bool longDetect = false,
WiredHome 71:dcac8efd842d 1138 uint8_t sampleTime = 0, uint8_t scanFrequency = 0,
WiredHome 71:dcac8efd842d 1139 uint8_t longTimeAdjustment = 0,
WiredHome 71:dcac8efd842d 1140 bool interruptEnable = false, bool wakeupEnable = false);
WiredHome 71:dcac8efd842d 1141
WiredHome 125:7a0b70f56550 1142
WiredHome 75:ca78388cfd77 1143 /// Create Key Code definitions for the key matrix.
WiredHome 75:ca78388cfd77 1144 ///
WiredHome 75:ca78388cfd77 1145 /// This API provides a table of 22 key-code assignments for the matrix of keys.
WiredHome 75:ca78388cfd77 1146 /// This can be used to translate the keys 1 - 20 into some other value, as
WiredHome 75:ca78388cfd77 1147 /// well as to communicate the "no key" (zero) and "error state" (21).
WiredHome 75:ca78388cfd77 1148 ///
WiredHome 75:ca78388cfd77 1149 /// In this way, a keypad could easily emulate a piece of a keyboard, transforming
WiredHome 75:ca78388cfd77 1150 /// 0 - 20 into the values 0, '0', '1', '2', '3', '4', '5', '6', '7', '8',
WiredHome 125:7a0b70f56550 1151 /// '9', '+', '-', '*' , '/', '=', '(bs)', '(cr)', and so on...
WiredHome 75:ca78388cfd77 1152 ///
WiredHome 75:ca78388cfd77 1153 /// @code
WiredHome 75:ca78388cfd77 1154 /// // Return Value by Row, Column Example reassignment
WiredHome 75:ca78388cfd77 1155 /// // Column 0 1 2 3 4
WiredHome 75:ca78388cfd77 1156 /// // +-------------------------+ +-------------------------+
WiredHome 76:c981284eb513 1157 /// // Row 0 | 1 2 3 4 5 | | '7' '8' '9' ',' '<-' |
WiredHome 75:ca78388cfd77 1158 /// // 1 | 6 7 8 9 10 | | '4' '5' '6' '/' '-' |
WiredHome 75:ca78388cfd77 1159 /// // 2 | 11 12 13 14 15 | | '1' '2' '3' '*' '+' |
WiredHome 76:c981284eb513 1160 /// // 3 | 16 17 18 19 20 | | '0' '.' '(' ')' '\n' |
WiredHome 75:ca78388cfd77 1161 /// // +-------------------------+ +-------------------------+
WiredHome 75:ca78388cfd77 1162 /// // Return value 0 = No Key pressed
WiredHome 75:ca78388cfd77 1163 /// // Return value 21 = Error
WiredHome 77:9206c13aa527 1164 /// const uint8_t CodeList[22] =
WiredHome 77:9206c13aa527 1165 /// {0, '7', '8', '9', ',', '\h',
WiredHome 77:9206c13aa527 1166 /// '4', '5', '6', '/', '-',
WiredHome 77:9206c13aa527 1167 /// '1', '2', '3', '*', '+',
WiredHome 77:9206c13aa527 1168 /// '0', '.', '(', ')', '\n',
WiredHome 77:9206c13aa527 1169 /// '\x1b'};
WiredHome 77:9206c13aa527 1170 /// lcd.SetKeyMap(CodeList);
WiredHome 75:ca78388cfd77 1171 /// @endcode
WiredHome 75:ca78388cfd77 1172 ///
WiredHome 75:ca78388cfd77 1173 /// @param[in] CodeList is a pointer to an always available byte-array
WiredHome 75:ca78388cfd77 1174 /// where the first 22 bytes are used as the transformation
WiredHome 75:ca78388cfd77 1175 /// from raw code to your reassigned value.
WiredHome 75:ca78388cfd77 1176 /// If CodeList is NULL, the original raw value key map is
WiredHome 75:ca78388cfd77 1177 /// restored.
WiredHome 75:ca78388cfd77 1178 /// @returns noerror.
WiredHome 75:ca78388cfd77 1179 ///
WiredHome 75:ca78388cfd77 1180 RetCode_t SetKeyMap(const uint8_t * CodeList = NULL);
WiredHome 75:ca78388cfd77 1181
WiredHome 125:7a0b70f56550 1182
WiredHome 71:dcac8efd842d 1183 /// Determine if a key has been hit
WiredHome 71:dcac8efd842d 1184 ///
WiredHome 71:dcac8efd842d 1185 /// @returns true if a key has been hit
WiredHome 71:dcac8efd842d 1186 ///
WiredHome 75:ca78388cfd77 1187 bool readable();
WiredHome 71:dcac8efd842d 1188
WiredHome 125:7a0b70f56550 1189
WiredHome 71:dcac8efd842d 1190 /// Blocking read of the keypad.
WiredHome 71:dcac8efd842d 1191 ///
WiredHome 125:7a0b70f56550 1192 /// @note: This is a blocking read, so it is important to first call _kbhit()
WiredHome 71:dcac8efd842d 1193 /// to avoid hanging your processes.
WiredHome 71:dcac8efd842d 1194 ///
WiredHome 71:dcac8efd842d 1195 /// A keypad connected to the RA8875 is connected in a matrix of 4 rows and 5 columns.
WiredHome 75:ca78388cfd77 1196 /// When pressed, this method will return a code in the range of 1 through 20, reserving
WiredHome 75:ca78388cfd77 1197 /// the value 0 to indicate that no key is pressed.
WiredHome 71:dcac8efd842d 1198 ///
WiredHome 71:dcac8efd842d 1199 /// Additionally, if configured to detect a "long press", bit 7 will be set to indicate
WiredHome 71:dcac8efd842d 1200 /// this. In this situation, first a "normal press" would be detected and signaled and
WiredHome 71:dcac8efd842d 1201 /// soon after that a "long press" of the same key would be detected and communicated.
WiredHome 71:dcac8efd842d 1202 ///
WiredHome 75:ca78388cfd77 1203 /// @return 8-bit where bit 7 indicates a long press. The remaining bits indicate the
WiredHome 75:ca78388cfd77 1204 /// keypress using 0 = no key pressed, 1 - 20 = the key pressed.
WiredHome 71:dcac8efd842d 1205 ///
WiredHome 75:ca78388cfd77 1206 uint8_t getc();
WiredHome 75:ca78388cfd77 1207
WiredHome 82:f7d300f26540 1208
WiredHome 82:f7d300f26540 1209 /// Determine if a point is within a rectangle.
WiredHome 82:f7d300f26540 1210 ///
WiredHome 82:f7d300f26540 1211 /// @param[in] rect is a rectangular region to use.
WiredHome 82:f7d300f26540 1212 /// @param[in] p is a point to analyze to see if it is within the rect.
WiredHome 82:f7d300f26540 1213 /// @returns true if p is within rect.
WiredHome 82:f7d300f26540 1214 ///
WiredHome 82:f7d300f26540 1215 bool Intersect(rect_t rect, point_t p);
WiredHome 82:f7d300f26540 1216
WiredHome 131:5bd6ba2ee4a1 1217 /// Determine if a rectangle intersects another rectangle.
WiredHome 131:5bd6ba2ee4a1 1218 ///
WiredHome 131:5bd6ba2ee4a1 1219 /// @param[in] rect1 is a rectangular region.
WiredHome 131:5bd6ba2ee4a1 1220 /// @param[in] rect2 is a second rectangular region.
WiredHome 147:3494792458d9 1221 /// @returns true if any part of rect2 intersects rect1.
WiredHome 131:5bd6ba2ee4a1 1222 ///
WiredHome 131:5bd6ba2ee4a1 1223 bool Intersect(rect_t rect1, rect_t rect2);
WiredHome 82:f7d300f26540 1224
WiredHome 147:3494792458d9 1225 /// Determine if a rectangle intersects another rectangle and provides
WiredHome 147:3494792458d9 1226 /// the area of intersection.
WiredHome 147:3494792458d9 1227 ///
WiredHome 147:3494792458d9 1228 /// @code
WiredHome 147:3494792458d9 1229 /// +---------------------+
WiredHome 147:3494792458d9 1230 /// | rect1 |
WiredHome 147:3494792458d9 1231 /// | |
WiredHome 147:3494792458d9 1232 /// | +------------------+
WiredHome 147:3494792458d9 1233 /// | | rect3 | |
WiredHome 147:3494792458d9 1234 /// | | | |
WiredHome 147:3494792458d9 1235 /// +---------------------+ |
WiredHome 147:3494792458d9 1236 /// | rect2 |
WiredHome 147:3494792458d9 1237 /// +------------------+
WiredHome 147:3494792458d9 1238 /// @endcode
WiredHome 147:3494792458d9 1239 ///
WiredHome 147:3494792458d9 1240 /// @note that the first parameter is a pointer to a rect and the
WiredHome 147:3494792458d9 1241 ///
WiredHome 147:3494792458d9 1242 /// @param[inout] pRect1 is a pointer to a rectangular region, and returns
WiredHome 147:3494792458d9 1243 /// the area of intersection.
WiredHome 147:3494792458d9 1244 /// @param[in] pRect2 is a pointer to a second rectangular region.
WiredHome 147:3494792458d9 1245 /// @returns true if pRect1 and pRect2 intersect and pRect1 is written with
WiredHome 147:3494792458d9 1246 /// the rectangle describing the intersection.
WiredHome 147:3494792458d9 1247 ///
WiredHome 147:3494792458d9 1248 bool Intersect(rect_t * rect1, const rect_t * rect2);
WiredHome 147:3494792458d9 1249
WiredHome 147:3494792458d9 1250
WiredHome 38:38d503b4fad6 1251 /// Write a command to the display with a word of data.
WiredHome 38:38d503b4fad6 1252 ///
WiredHome 38:38d503b4fad6 1253 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 1254 ///
WiredHome 72:ecffe56af969 1255 /// @param[in] command is the command to write.
WiredHome 72:ecffe56af969 1256 /// @param[in] data is data to be written to the command register.
WiredHome 106:c80828f5dea4 1257 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 38:38d503b4fad6 1258 ///
WiredHome 38:38d503b4fad6 1259 RetCode_t WriteCommandW(uint8_t command, uint16_t data);
WiredHome 38:38d503b4fad6 1260
WiredHome 125:7a0b70f56550 1261
WiredHome 19:3f82c1161fd2 1262 /// Write a command to the display
WiredHome 19:3f82c1161fd2 1263 ///
WiredHome 19:3f82c1161fd2 1264 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1265 ///
WiredHome 72:ecffe56af969 1266 /// @param[in] command is the command to write.
WiredHome 72:ecffe56af969 1267 /// @param[in] data is optional data to be written to the command register
WiredHome 19:3f82c1161fd2 1268 /// and only occurs if the data is in the range [0 - 0xFF].
WiredHome 106:c80828f5dea4 1269 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1270 ///
WiredHome 32:0e4f2ae512e2 1271 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
WiredHome 125:7a0b70f56550 1272
WiredHome 19:3f82c1161fd2 1273
WiredHome 38:38d503b4fad6 1274 /// Write a data word to the display
WiredHome 38:38d503b4fad6 1275 ///
WiredHome 38:38d503b4fad6 1276 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 1277 ///
WiredHome 72:ecffe56af969 1278 /// @param[in] data is the data to write.
WiredHome 106:c80828f5dea4 1279 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 38:38d503b4fad6 1280 ///
WiredHome 38:38d503b4fad6 1281 RetCode_t WriteDataW(uint16_t data);
WiredHome 125:7a0b70f56550 1282
WiredHome 38:38d503b4fad6 1283
WiredHome 19:3f82c1161fd2 1284 /// Write a data byte to the display
WiredHome 19:3f82c1161fd2 1285 ///
WiredHome 19:3f82c1161fd2 1286 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1287 ///
WiredHome 72:ecffe56af969 1288 /// @param[in] data is the data to write.
WiredHome 106:c80828f5dea4 1289 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1290 ///
WiredHome 32:0e4f2ae512e2 1291 virtual RetCode_t WriteData(unsigned char data);
WiredHome 125:7a0b70f56550 1292
WiredHome 19:3f82c1161fd2 1293
WiredHome 19:3f82c1161fd2 1294 /// Read a command register
WiredHome 19:3f82c1161fd2 1295 ///
WiredHome 72:ecffe56af969 1296 /// @param[in] command is the command register to read.
WiredHome 19:3f82c1161fd2 1297 /// @returns the value read from the register.
WiredHome 19:3f82c1161fd2 1298 ///
WiredHome 19:3f82c1161fd2 1299 unsigned char ReadCommand(unsigned char command);
WiredHome 136:224e03d5c31f 1300
WiredHome 136:224e03d5c31f 1301
WiredHome 136:224e03d5c31f 1302 /// Read a word from a command register
WiredHome 136:224e03d5c31f 1303 ///
WiredHome 136:224e03d5c31f 1304 /// @param[in] command is the command register to read.
WiredHome 136:224e03d5c31f 1305 /// @returns the value read from the register.
WiredHome 136:224e03d5c31f 1306 ///
WiredHome 136:224e03d5c31f 1307 uint16_t ReadCommandW(unsigned char command);
WiredHome 19:3f82c1161fd2 1308
WiredHome 136:224e03d5c31f 1309
WiredHome 41:2956a0a221e5 1310 /// Read a data byte from the display
WiredHome 19:3f82c1161fd2 1311 ///
WiredHome 19:3f82c1161fd2 1312 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1313 ///
WiredHome 19:3f82c1161fd2 1314 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 1315 ///
WiredHome 19:3f82c1161fd2 1316 unsigned char ReadData(void);
WiredHome 125:7a0b70f56550 1317
WiredHome 19:3f82c1161fd2 1318
WiredHome 41:2956a0a221e5 1319 /// Read a word from the display
WiredHome 41:2956a0a221e5 1320 ///
WiredHome 41:2956a0a221e5 1321 /// This is a high level command, and may invoke several primitives.
WiredHome 41:2956a0a221e5 1322 ///
WiredHome 41:2956a0a221e5 1323 /// @returns data that was read.
WiredHome 41:2956a0a221e5 1324 ///
WiredHome 41:2956a0a221e5 1325 uint16_t ReadDataW(void);
WiredHome 41:2956a0a221e5 1326
WiredHome 125:7a0b70f56550 1327
WiredHome 19:3f82c1161fd2 1328 /// Read the display status
WiredHome 19:3f82c1161fd2 1329 ///
WiredHome 19:3f82c1161fd2 1330 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1331 ///
WiredHome 19:3f82c1161fd2 1332 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 1333 ///
WiredHome 19:3f82c1161fd2 1334 unsigned char ReadStatus(void);
WiredHome 19:3f82c1161fd2 1335
WiredHome 125:7a0b70f56550 1336
WiredHome 19:3f82c1161fd2 1337 /// get the width in pixels of the currently active font
WiredHome 19:3f82c1161fd2 1338 ///
WiredHome 19:3f82c1161fd2 1339 /// @returns font width in pixels.
WiredHome 19:3f82c1161fd2 1340 ///
WiredHome 37:f19b7e7449dc 1341 dim_t fontwidth(void);
WiredHome 19:3f82c1161fd2 1342
WiredHome 125:7a0b70f56550 1343
WiredHome 19:3f82c1161fd2 1344 /// get the height in pixels of the currently active font
WiredHome 19:3f82c1161fd2 1345 ///
WiredHome 19:3f82c1161fd2 1346 /// @returns font height in pixels.
WiredHome 19:3f82c1161fd2 1347 ///
WiredHome 37:f19b7e7449dc 1348 dim_t fontheight(void);
WiredHome 125:7a0b70f56550 1349
WiredHome 19:3f82c1161fd2 1350
WiredHome 19:3f82c1161fd2 1351 /// get the number of colums based on the currently active font
WiredHome 19:3f82c1161fd2 1352 ///
WiredHome 19:3f82c1161fd2 1353 /// @returns number of columns.
WiredHome 19:3f82c1161fd2 1354 ///
WiredHome 19:3f82c1161fd2 1355 virtual int columns(void);
WiredHome 19:3f82c1161fd2 1356
WiredHome 125:7a0b70f56550 1357
WiredHome 19:3f82c1161fd2 1358 /// get the number of rows based on the currently active font
WiredHome 19:3f82c1161fd2 1359 ///
WiredHome 19:3f82c1161fd2 1360 /// @returns number of rows.
WiredHome 19:3f82c1161fd2 1361 ///
WiredHome 19:3f82c1161fd2 1362 virtual int rows(void);
WiredHome 19:3f82c1161fd2 1363
WiredHome 125:7a0b70f56550 1364
WiredHome 19:3f82c1161fd2 1365 /// get the screen width in pixels
WiredHome 19:3f82c1161fd2 1366 ///
WiredHome 19:3f82c1161fd2 1367 /// @returns screen width in pixels.
WiredHome 19:3f82c1161fd2 1368 ///
WiredHome 38:38d503b4fad6 1369 virtual dim_t width(void);
WiredHome 19:3f82c1161fd2 1370
WiredHome 125:7a0b70f56550 1371
WiredHome 19:3f82c1161fd2 1372 /// get the screen height in pixels
WiredHome 19:3f82c1161fd2 1373 ///
WiredHome 19:3f82c1161fd2 1374 /// @returns screen height in pixels.
WiredHome 19:3f82c1161fd2 1375 ///
WiredHome 38:38d503b4fad6 1376 virtual dim_t height(void);
WiredHome 19:3f82c1161fd2 1377
WiredHome 125:7a0b70f56550 1378
WiredHome 43:3becae133285 1379 /// get the color depth in bits per pixel.
WiredHome 43:3becae133285 1380 ///
WiredHome 43:3becae133285 1381 /// @returns 8 or 16 only.
WiredHome 43:3becae133285 1382 ///
WiredHome 43:3becae133285 1383 virtual dim_t color_bpp(void);
WiredHome 43:3becae133285 1384
WiredHome 19:3f82c1161fd2 1385 /// Set cursor position based on the current font size.
WiredHome 19:3f82c1161fd2 1386 ///
WiredHome 72:ecffe56af969 1387 /// @param[in] column is the horizontal position in character positions
WiredHome 72:ecffe56af969 1388 /// @param[in] row is the vertical position in character positions
WiredHome 106:c80828f5dea4 1389 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1390 ///
WiredHome 37:f19b7e7449dc 1391 virtual RetCode_t locate(textloc_t column, textloc_t row);
WiredHome 19:3f82c1161fd2 1392
WiredHome 125:7a0b70f56550 1393
WiredHome 19:3f82c1161fd2 1394 /// Prepare the controller to write text to the screen by positioning
WiredHome 19:3f82c1161fd2 1395 /// the cursor.
WiredHome 19:3f82c1161fd2 1396 ///
WiredHome 56:7a85d226ad0d 1397 /// @code
WiredHome 56:7a85d226ad0d 1398 /// lcd.SetTextCursor(100, 25);
WiredHome 56:7a85d226ad0d 1399 /// lcd.puts("Hello");
WiredHome 56:7a85d226ad0d 1400 /// @endcode
WiredHome 56:7a85d226ad0d 1401 ///
WiredHome 72:ecffe56af969 1402 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1403 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 106:c80828f5dea4 1404 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1405 ///
WiredHome 37:f19b7e7449dc 1406 RetCode_t SetTextCursor(loc_t x, loc_t y);
WiredHome 29:422616aa04bd 1407
WiredHome 125:7a0b70f56550 1408
WiredHome 103:7e0464ca6c5c 1409 /// Prepare the controller to write text to the screen by positioning
WiredHome 103:7e0464ca6c5c 1410 /// the cursor.
WiredHome 103:7e0464ca6c5c 1411 ///
WiredHome 103:7e0464ca6c5c 1412 /// @code
WiredHome 103:7e0464ca6c5c 1413 /// point_t point = {100, 25};
WiredHome 103:7e0464ca6c5c 1414 /// lcd.SetTextCursor(point);
WiredHome 103:7e0464ca6c5c 1415 /// lcd.puts("Hello");
WiredHome 103:7e0464ca6c5c 1416 /// @endcode
WiredHome 103:7e0464ca6c5c 1417 ///
WiredHome 103:7e0464ca6c5c 1418 /// @param[in] p is the x:y point in pixels from the top-left.
WiredHome 106:c80828f5dea4 1419 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 103:7e0464ca6c5c 1420 ///
WiredHome 103:7e0464ca6c5c 1421 RetCode_t SetTextCursor(point_t p);
WiredHome 103:7e0464ca6c5c 1422
WiredHome 125:7a0b70f56550 1423
WiredHome 37:f19b7e7449dc 1424 /// Get the current cursor position in pixels.
WiredHome 37:f19b7e7449dc 1425 ///
WiredHome 56:7a85d226ad0d 1426 /// @code
WiredHome 56:7a85d226ad0d 1427 /// point_t point = GetTextCursor();
WiredHome 56:7a85d226ad0d 1428 /// if (point.x > 100 && point.y > 150)
WiredHome 56:7a85d226ad0d 1429 /// //...
WiredHome 56:7a85d226ad0d 1430 /// @endcode
WiredHome 56:7a85d226ad0d 1431 ///
WiredHome 37:f19b7e7449dc 1432 /// @returns cursor position.
WiredHome 37:f19b7e7449dc 1433 ///
WiredHome 37:f19b7e7449dc 1434 point_t GetTextCursor(void);
WiredHome 37:f19b7e7449dc 1435
WiredHome 125:7a0b70f56550 1436
WiredHome 29:422616aa04bd 1437 /// Get the current cursor horizontal position in pixels.
WiredHome 29:422616aa04bd 1438 ///
WiredHome 29:422616aa04bd 1439 /// @returns cursor position horizontal offset.
WiredHome 29:422616aa04bd 1440 ///
WiredHome 37:f19b7e7449dc 1441 loc_t GetTextCursor_X(void);
WiredHome 29:422616aa04bd 1442
WiredHome 125:7a0b70f56550 1443
WiredHome 29:422616aa04bd 1444 /// Get the current cursor vertical position in pixels.
WiredHome 29:422616aa04bd 1445 ///
WiredHome 29:422616aa04bd 1446 /// @returns cursor position vertical offset.
WiredHome 29:422616aa04bd 1447 ///
WiredHome 37:f19b7e7449dc 1448 loc_t GetTextCursor_Y(void);
WiredHome 29:422616aa04bd 1449
WiredHome 125:7a0b70f56550 1450
WiredHome 23:a50ded45dbaf 1451 /// Configure additional Cursor Control settings.
WiredHome 23:a50ded45dbaf 1452 ///
WiredHome 23:a50ded45dbaf 1453 /// This API lets you modify other cursor control settings;
WiredHome 23:a50ded45dbaf 1454 /// Cursor visible/hidden, Cursor blink/normal,
WiredHome 23:a50ded45dbaf 1455 /// Cursor I-Beam/underscore/box.
WiredHome 23:a50ded45dbaf 1456 ///
WiredHome 72:ecffe56af969 1457 /// @param[in] cursor can be set to NOCURSOR (default), IBEAM,
WiredHome 24:8ca861acf12d 1458 /// UNDER, or BLOCK.
WiredHome 72:ecffe56af969 1459 /// @param[in] blink can be set to true or false (default false)
WiredHome 106:c80828f5dea4 1460 /// @returns success/failure code. See @ref RetCode_t
WiredHome 23:a50ded45dbaf 1461 ///
WiredHome 24:8ca861acf12d 1462 RetCode_t SetTextCursorControl(cursor_t cursor = NOCURSOR, bool blink = false);
WiredHome 125:7a0b70f56550 1463
WiredHome 23:a50ded45dbaf 1464
WiredHome 98:ecebed9b80b2 1465 /// Select the built-in ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 1466 ///
WiredHome 19:3f82c1161fd2 1467 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 1468 ///
WiredHome 125:7a0b70f56550 1469 /// @note This only modifies the choice of font from the RA8875 internal
WiredHome 98:ecebed9b80b2 1470 /// fonts.
WiredHome 98:ecebed9b80b2 1471 ///
WiredHome 72:ecffe56af969 1472 /// @param[in] font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 1473 ///
WiredHome 19:3f82c1161fd2 1474 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1475 /// the command is not executed.
WiredHome 106:c80828f5dea4 1476 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1477 ///
WiredHome 19:3f82c1161fd2 1478 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 19:3f82c1161fd2 1479
WiredHome 125:7a0b70f56550 1480
WiredHome 84:e102021864b5 1481 /// Sets the display orientation.
WiredHome 84:e102021864b5 1482 ///
WiredHome 84:e102021864b5 1483 /// @note This command does not let you "merge" text onto an existing
WiredHome 84:e102021864b5 1484 /// image, since it reuses the memory for the new orientation.
WiredHome 84:e102021864b5 1485 /// Therefore, it is recommended that you issue a cls() prior
WiredHome 84:e102021864b5 1486 /// to sending text to the screen, or you end with a blended
WiredHome 84:e102021864b5 1487 /// image that is probably not as intended.
WiredHome 84:e102021864b5 1488 ///
WiredHome 125:7a0b70f56550 1489 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1490 ///
WiredHome 84:e102021864b5 1491 /// @code
WiredHome 84:e102021864b5 1492 /// lcd.cls();
WiredHome 84:e102021864b5 1493 /// lcd.SetOrientation(RA8875::normal);
WiredHome 84:e102021864b5 1494 /// lcd.puts(30,30, "Normal Landscape");
WiredHome 84:e102021864b5 1495 /// wait_ms(2500);
WiredHome 84:e102021864b5 1496 ///
WiredHome 84:e102021864b5 1497 /// lcd.cls();
WiredHome 84:e102021864b5 1498 /// lcd.SetOrientation(RA8875::rotate_90);
WiredHome 84:e102021864b5 1499 /// lcd.puts(30,30, "Rotated 90 Text\r\n");
WiredHome 84:e102021864b5 1500 /// wait_ms(2500);
WiredHome 84:e102021864b5 1501 ///
WiredHome 84:e102021864b5 1502 /// lcd.cls();
WiredHome 84:e102021864b5 1503 /// lcd.SetOrientation(RA8875::rotate_180);
WiredHome 84:e102021864b5 1504 /// lcd.puts(30,30, "Rotated 180 Text\r\n");
WiredHome 84:e102021864b5 1505 /// wait_ms(2500);
WiredHome 84:e102021864b5 1506 ///
WiredHome 84:e102021864b5 1507 /// lcd.cls();
WiredHome 84:e102021864b5 1508 /// lcd.SetOrientation(RA8875::rotate_270);
WiredHome 84:e102021864b5 1509 /// lcd.puts(30,30, "Rotated 270 Text\r\n");
WiredHome 84:e102021864b5 1510 /// wait_ms(2500);
WiredHome 84:e102021864b5 1511 /// @endcode
WiredHome 84:e102021864b5 1512 ///
WiredHome 84:e102021864b5 1513 /// @param[in] angle defaults to normal, but can be rotated
WiredHome 84:e102021864b5 1514 /// - normal | rotate_0
WiredHome 84:e102021864b5 1515 /// - rotate_90 (clockwise)
WiredHome 84:e102021864b5 1516 /// - rotate_180
WiredHome 84:e102021864b5 1517 /// - rotate_270 (clockwise)
WiredHome 106:c80828f5dea4 1518 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 84:e102021864b5 1519 ///
WiredHome 84:e102021864b5 1520 RetCode_t SetOrientation(orientation_t angle = normal);
WiredHome 84:e102021864b5 1521
WiredHome 125:7a0b70f56550 1522
WiredHome 19:3f82c1161fd2 1523 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 1524 ///
WiredHome 19:3f82c1161fd2 1525 /// This command lets you make several modifications to any text that
WiredHome 56:7a85d226ad0d 1526 /// will be written to the screen.
WiredHome 19:3f82c1161fd2 1527 ///
WiredHome 125:7a0b70f56550 1528 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1529 ///
WiredHome 19:3f82c1161fd2 1530 /// Options can be combined:
WiredHome 19:3f82c1161fd2 1531 /// Default:
WiredHome 19:3f82c1161fd2 1532 /// @li Full alignment disabled,
WiredHome 19:3f82c1161fd2 1533 /// @li Font with Background color,
WiredHome 84:e102021864b5 1534 /// @li Font in normal orientiation, or rotated 90, 180, or 270 clockwise,
WiredHome 84:e102021864b5 1535 /// @li Horizontal scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1536 /// @li Vertical scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1537 ///
WiredHome 84:e102021864b5 1538 /// @note alignment is a special mode for the fonts, when mixing half and
WiredHome 84:e102021864b5 1539 /// full fonts on one presentation. 'align_full' starts each full
WiredHome 84:e102021864b5 1540 /// character on an even alignment. See section 7-4-7 of the RA8875
WiredHome 84:e102021864b5 1541 /// specification.
WiredHome 19:3f82c1161fd2 1542 ///
WiredHome 72:ecffe56af969 1543 /// @param[in] fillit defaults to FILL, but can be NOFILL
WiredHome 72:ecffe56af969 1544 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1545 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1546 /// @param[in] vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1547 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1548 /// @param[in] alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 1549 /// align_full.
WiredHome 19:3f82c1161fd2 1550 ///
WiredHome 19:3f82c1161fd2 1551 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1552 /// the command is not executed.
WiredHome 106:c80828f5dea4 1553 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1554 ///
WiredHome 19:3f82c1161fd2 1555 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 19:3f82c1161fd2 1556 HorizontalScale hScale = 1,
WiredHome 19:3f82c1161fd2 1557 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 1558 alignment_t alignment = align_none);
WiredHome 19:3f82c1161fd2 1559
WiredHome 125:7a0b70f56550 1560
WiredHome 153:8a85efb3eb71 1561 /// Control the font size of the RA8875 rendered fonts.
WiredHome 19:3f82c1161fd2 1562 ///
WiredHome 19:3f82c1161fd2 1563 /// This command lets you set the font enlargement for both horizontal
WiredHome 19:3f82c1161fd2 1564 /// and vertical, independent of the rotation, background, and
WiredHome 106:c80828f5dea4 1565 /// alignment. See @ref SetTextFontControl.
WiredHome 19:3f82c1161fd2 1566 ///
WiredHome 153:8a85efb3eb71 1567 /// @note This command operates on the RA8875 internal fonts.
WiredHome 153:8a85efb3eb71 1568 /// @note This command also operates on the selected soft font.
WiredHome 98:ecebed9b80b2 1569 ///
WiredHome 72:ecffe56af969 1570 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1571 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1572 /// @param[in] vScale is an optional parameter that defaults to the hScale value,
WiredHome 40:04aa280dfa39 1573 /// but can be 1, 2, 3, or 4, and scales the font size by this amount.
WiredHome 40:04aa280dfa39 1574 ///
WiredHome 40:04aa280dfa39 1575 /// @code
WiredHome 40:04aa280dfa39 1576 /// lcd.SetTextFontSize(2); // Set the font to 2x normal size
WiredHome 56:7a85d226ad0d 1577 /// lcd.puts("Two times");
WiredHome 40:04aa280dfa39 1578 /// lcd.SetTextFontSize(2,3); // Set the font to 2x Width and 3x Height
WiredHome 56:7a85d226ad0d 1579 /// lcd.puts("2*2 3*h");
WiredHome 40:04aa280dfa39 1580 /// lcd.SetTextFontSize(); // Restore to normal size in both dimensions
WiredHome 56:7a85d226ad0d 1581 /// lcd.puts("normal");
WiredHome 153:8a85efb3eb71 1582 /// lcd.SelectUserFont(BPG_Arial63x63); // Large user font
WiredHome 153:8a85efb3eb71 1583 /// lcd.puts("B63x63"); // Show a sample
WiredHome 153:8a85efb3eb71 1584 /// lcd.SetTextFontSize(2); // Now twice as big
WiredHome 153:8a85efb3eb71 1585 /// lcd.puts("x2"); // Show a sample
WiredHome 40:04aa280dfa39 1586 /// @endcode
WiredHome 19:3f82c1161fd2 1587 ///
WiredHome 19:3f82c1161fd2 1588 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1589 /// the command is not executed.
WiredHome 106:c80828f5dea4 1590 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1591 ///
WiredHome 40:04aa280dfa39 1592 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
WiredHome 127:db7f2c704693 1593
WiredHome 127:db7f2c704693 1594
WiredHome 127:db7f2c704693 1595 /// Get the text font size of the RA8875 internal fonts.
WiredHome 127:db7f2c704693 1596 ///
WiredHome 127:db7f2c704693 1597 /// This command lets you retrieve the current settings for the font
WiredHome 127:db7f2c704693 1598 /// horizontal and vertical scale factors. The return value is
WiredHome 127:db7f2c704693 1599 /// one of the scale factors 1, 2, 3, or 4.
WiredHome 127:db7f2c704693 1600 ///
WiredHome 127:db7f2c704693 1601 /// @param[out] hScale is a pointer to memory where the horizontal scale factor
WiredHome 127:db7f2c704693 1602 /// will be written. If the pointer is null, that item will be ignored.
WiredHome 127:db7f2c704693 1603 /// @param[out] vScale is a pointer to memory where the vertical scale factor
WiredHome 127:db7f2c704693 1604 /// will be written. If the pointer is null, that item will be ignored.
WiredHome 127:db7f2c704693 1605 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 127:db7f2c704693 1606 ///
WiredHome 127:db7f2c704693 1607 RetCode_t GetTextFontSize(HorizontalScale * hScale, VerticalScale * vScale);
WiredHome 125:7a0b70f56550 1608
WiredHome 19:3f82c1161fd2 1609 /// put a character on the screen.
WiredHome 19:3f82c1161fd2 1610 ///
WiredHome 72:ecffe56af969 1611 /// @param[in] c is the character.
WiredHome 19:3f82c1161fd2 1612 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 1613 ///
WiredHome 19:3f82c1161fd2 1614 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 1615
WiredHome 125:7a0b70f56550 1616
WiredHome 19:3f82c1161fd2 1617 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 1618 ///
WiredHome 56:7a85d226ad0d 1619 /// @code
WiredHome 56:7a85d226ad0d 1620 /// lcd.puts("Test STring");
WiredHome 56:7a85d226ad0d 1621 /// @endcode
WiredHome 56:7a85d226ad0d 1622 ///
WiredHome 72:ecffe56af969 1623 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 1624 ///
WiredHome 19:3f82c1161fd2 1625 void puts(const char * string);
WiredHome 125:7a0b70f56550 1626
WiredHome 19:3f82c1161fd2 1627
WiredHome 19:3f82c1161fd2 1628 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 1629 ///
WiredHome 56:7a85d226ad0d 1630 /// @code
WiredHome 56:7a85d226ad0d 1631 /// lcd.puts(10,25, "Test STring");
WiredHome 56:7a85d226ad0d 1632 /// @endcode
WiredHome 56:7a85d226ad0d 1633 ///
WiredHome 72:ecffe56af969 1634 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1635 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 72:ecffe56af969 1636 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 1637 ///
WiredHome 37:f19b7e7449dc 1638 void puts(loc_t x, loc_t y, const char * string);
WiredHome 19:3f82c1161fd2 1639
WiredHome 125:7a0b70f56550 1640
WiredHome 19:3f82c1161fd2 1641 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 1642 /// the memory cursor.
WiredHome 19:3f82c1161fd2 1643 ///
WiredHome 72:ecffe56af969 1644 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1645 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 106:c80828f5dea4 1646 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1647 ///
WiredHome 37:f19b7e7449dc 1648 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y);
WiredHome 125:7a0b70f56550 1649
WiredHome 136:224e03d5c31f 1650 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 136:224e03d5c31f 1651 /// the memory cursor.
WiredHome 136:224e03d5c31f 1652 ///
WiredHome 136:224e03d5c31f 1653 /// @param[in] p is the point representing the cursor position to set
WiredHome 136:224e03d5c31f 1654 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 136:224e03d5c31f 1655 ///
WiredHome 136:224e03d5c31f 1656 virtual RetCode_t SetGraphicsCursor(point_t p);
WiredHome 136:224e03d5c31f 1657
WiredHome 136:224e03d5c31f 1658 /// Read the current graphics cursor position as a point.
WiredHome 136:224e03d5c31f 1659 ///
WiredHome 136:224e03d5c31f 1660 /// @returns the graphics cursor as a point.
WiredHome 136:224e03d5c31f 1661 ///
WiredHome 136:224e03d5c31f 1662 virtual point_t GetGraphicsCursor(void);
WiredHome 136:224e03d5c31f 1663
WiredHome 19:3f82c1161fd2 1664
WiredHome 41:2956a0a221e5 1665 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 1666 /// the memory read cursor.
WiredHome 41:2956a0a221e5 1667 ///
WiredHome 72:ecffe56af969 1668 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1669 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 106:c80828f5dea4 1670 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 41:2956a0a221e5 1671 ///
WiredHome 41:2956a0a221e5 1672 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1673
WiredHome 125:7a0b70f56550 1674
WiredHome 111:efe436c43aba 1675 /// Set the window, constraining where items are written to the screen.
WiredHome 111:efe436c43aba 1676 ///
WiredHome 111:efe436c43aba 1677 /// After setting the window, text and graphics are constrained to this
WiredHome 111:efe436c43aba 1678 /// window. Text will wrap from the right edge back to the left and down
WiredHome 111:efe436c43aba 1679 /// one row and from the bottom to the top. Graphics drawing will be clipped
WiredHome 111:efe436c43aba 1680 /// at the edge of the window.
WiredHome 111:efe436c43aba 1681 ///
WiredHome 111:efe436c43aba 1682 /// @note If the initial text write is outside the window, it will be shown
WiredHome 111:efe436c43aba 1683 /// where the cursor position it. Once the write hits the right edge of
WiredHome 111:efe436c43aba 1684 /// the defined window, it will then wrap back to the left edge. Once it
WiredHome 111:efe436c43aba 1685 /// hits the bottom, it wraps to the top of the window. For this reason,
WiredHome 111:efe436c43aba 1686 /// it is common to set the text cursor to the window.
WiredHome 19:3f82c1161fd2 1687 ///
WiredHome 111:efe436c43aba 1688 /// @code
WiredHome 111:efe436c43aba 1689 /// rect_t r = {10,10, 90,90};
WiredHome 111:efe436c43aba 1690 /// lcd.window(r);
WiredHome 111:efe436c43aba 1691 /// lcd.SetTextCursor(r.p1.x, r.p1.y);
WiredHome 111:efe436c43aba 1692 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 111:efe436c43aba 1693 /// lcd.window(); restore to full screen
WiredHome 111:efe436c43aba 1694 /// @endcode
WiredHome 111:efe436c43aba 1695 ///
WiredHome 111:efe436c43aba 1696 /// @param[in] r is the rect_t used to set the window.
WiredHome 111:efe436c43aba 1697 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 111:efe436c43aba 1698 ///
WiredHome 111:efe436c43aba 1699 virtual RetCode_t window(rect_t r);
WiredHome 111:efe436c43aba 1700
WiredHome 125:7a0b70f56550 1701
WiredHome 111:efe436c43aba 1702 /// Set the window, constraining where items are written to the screen.
WiredHome 111:efe436c43aba 1703 ///
WiredHome 111:efe436c43aba 1704 /// After setting the window, text and graphics are constrained to this
WiredHome 111:efe436c43aba 1705 /// window. Text will wrap from the right edge back to the left and down
WiredHome 111:efe436c43aba 1706 /// one row and from the bottom to the top. Graphics drawing will be clipped
WiredHome 111:efe436c43aba 1707 /// at the edge of the window.
WiredHome 111:efe436c43aba 1708 ///
WiredHome 114:dbfb996bfbf3 1709 /// @note if no parameters are provided, it restores the window to full screen.
WiredHome 114:dbfb996bfbf3 1710 ///
WiredHome 111:efe436c43aba 1711 /// @note If the initial text write is outside the window, it will be shown
WiredHome 111:efe436c43aba 1712 /// where the cursor position it. Once the write hits the right edge of
WiredHome 111:efe436c43aba 1713 /// the defined window, it will then wrap back to the left edge. Once it
WiredHome 111:efe436c43aba 1714 /// hits the bottom, it wraps to the top of the window. For this reason,
WiredHome 111:efe436c43aba 1715 /// it is common to set the text cursor to the window.
WiredHome 19:3f82c1161fd2 1716 ///
WiredHome 56:7a85d226ad0d 1717 /// @code
WiredHome 56:7a85d226ad0d 1718 /// lcd.window(10,10, 80,80);
WiredHome 111:efe436c43aba 1719 /// lcd.SetTextCursor(10,10);
WiredHome 56:7a85d226ad0d 1720 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 111:efe436c43aba 1721 /// lcd.window(); restore to full screen
WiredHome 56:7a85d226ad0d 1722 /// @endcode
WiredHome 56:7a85d226ad0d 1723 ///
WiredHome 72:ecffe56af969 1724 /// @param[in] x is the left edge in pixels.
WiredHome 72:ecffe56af969 1725 /// @param[in] y is the top edge in pixels.
WiredHome 72:ecffe56af969 1726 /// @param[in] width is the window width in pixels.
WiredHome 72:ecffe56af969 1727 /// @param[in] height is the window height in pixels.
WiredHome 106:c80828f5dea4 1728 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1729 ///
WiredHome 111:efe436c43aba 1730 virtual RetCode_t window(loc_t x = 0, loc_t y = 0, dim_t width = (dim_t)-1, dim_t height = (dim_t)-1);
WiredHome 19:3f82c1161fd2 1731
WiredHome 125:7a0b70f56550 1732
WiredHome 61:8f3153bf0baa 1733 /// Clear either the specified layer, or the active layer.
WiredHome 19:3f82c1161fd2 1734 ///
WiredHome 61:8f3153bf0baa 1735 /// The behavior is to clear the whole screen for the specified
WiredHome 61:8f3153bf0baa 1736 /// layer. When not specified, the active drawing layer is cleared.
WiredHome 61:8f3153bf0baa 1737 /// This command can also be used to specifically clear either,
WiredHome 106:c80828f5dea4 1738 /// or both layers. See @ref clsw().
WiredHome 19:3f82c1161fd2 1739 ///
WiredHome 56:7a85d226ad0d 1740 /// @code
WiredHome 56:7a85d226ad0d 1741 /// lcd.cls();
WiredHome 56:7a85d226ad0d 1742 /// @endcode
WiredHome 56:7a85d226ad0d 1743 ///
WiredHome 72:ecffe56af969 1744 /// @param[in] layers is optional. If not provided, the active layer
WiredHome 61:8f3153bf0baa 1745 /// is cleared. If bit 0 is set, layer 0 is cleared, if bit
WiredHome 61:8f3153bf0baa 1746 /// 1 is set, layer 1 is cleared. If both are set, both layers
WiredHome 61:8f3153bf0baa 1747 /// are cleared. Any other value does not cause an action.
WiredHome 61:8f3153bf0baa 1748 ///
WiredHome 106:c80828f5dea4 1749 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1750 ///
WiredHome 61:8f3153bf0baa 1751 virtual RetCode_t cls(uint16_t layers = 0);
WiredHome 125:7a0b70f56550 1752
WiredHome 19:3f82c1161fd2 1753
WiredHome 19:3f82c1161fd2 1754 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 1755 ///
WiredHome 19:3f82c1161fd2 1756 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 1757 /// parameter, the action can be restricted to the active window, which
WiredHome 106:c80828f5dea4 1758 /// can be set with the See @ref window method.
WiredHome 19:3f82c1161fd2 1759 ///
WiredHome 56:7a85d226ad0d 1760 /// @code
WiredHome 56:7a85d226ad0d 1761 /// lcd.window(20,20, 40,10);
WiredHome 56:7a85d226ad0d 1762 /// lcd.clsw();
WiredHome 56:7a85d226ad0d 1763 /// @endcode
WiredHome 56:7a85d226ad0d 1764 ///
WiredHome 72:ecffe56af969 1765 /// @param[in] region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 1766 /// or may be set to ACTIVEWINDOW.
WiredHome 106:c80828f5dea4 1767 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1768 ///
WiredHome 19:3f82c1161fd2 1769 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 1770
WiredHome 125:7a0b70f56550 1771
WiredHome 19:3f82c1161fd2 1772 /// Set the background color.
WiredHome 19:3f82c1161fd2 1773 ///
WiredHome 72:ecffe56af969 1774 /// @param[in] color is expressed in 16-bit format.
WiredHome 106:c80828f5dea4 1775 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1776 ///
WiredHome 19:3f82c1161fd2 1777 virtual RetCode_t background(color_t color);
WiredHome 125:7a0b70f56550 1778
WiredHome 19:3f82c1161fd2 1779
WiredHome 19:3f82c1161fd2 1780 /// Set the background color.
WiredHome 19:3f82c1161fd2 1781 ///
WiredHome 72:ecffe56af969 1782 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 1783 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 1784 /// @param[in] b is the blue element of the color.
WiredHome 106:c80828f5dea4 1785 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1786 ///
WiredHome 19:3f82c1161fd2 1787 virtual RetCode_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 1788
WiredHome 125:7a0b70f56550 1789
WiredHome 19:3f82c1161fd2 1790 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 1791 ///
WiredHome 72:ecffe56af969 1792 /// @param[in] color is expressed in 16-bit format.
WiredHome 106:c80828f5dea4 1793 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1794 ///
WiredHome 19:3f82c1161fd2 1795 virtual RetCode_t foreground(color_t color);
WiredHome 19:3f82c1161fd2 1796
WiredHome 125:7a0b70f56550 1797
WiredHome 19:3f82c1161fd2 1798 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 1799 ///
WiredHome 72:ecffe56af969 1800 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 1801 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 1802 /// @param[in] b is the blue element of the color.
WiredHome 106:c80828f5dea4 1803 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1804 ///
WiredHome 37:f19b7e7449dc 1805 virtual RetCode_t foreground(unsigned char r, unsigned char g, unsigned char b);
WiredHome 19:3f82c1161fd2 1806
WiredHome 125:7a0b70f56550 1807
WiredHome 19:3f82c1161fd2 1808 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 1809 ///
WiredHome 19:3f82c1161fd2 1810 /// @returns the current foreground color.
WiredHome 19:3f82c1161fd2 1811 ///
WiredHome 37:f19b7e7449dc 1812 color_t GetForeColor(void);
WiredHome 87:ee2240581aa7 1813
WiredHome 125:7a0b70f56550 1814
WiredHome 87:ee2240581aa7 1815 /// Draw a pixel in the specified color.
WiredHome 87:ee2240581aa7 1816 ///
WiredHome 87:ee2240581aa7 1817 /// @note Unlike many other operations, this does not
WiredHome 87:ee2240581aa7 1818 /// set the forecolor!
WiredHome 87:ee2240581aa7 1819 ///
WiredHome 87:ee2240581aa7 1820 /// @param[in] p is the point_t defining the location.
WiredHome 106:c80828f5dea4 1821 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 87:ee2240581aa7 1822 ///
WiredHome 87:ee2240581aa7 1823 virtual RetCode_t pixel(point_t p, color_t color);
WiredHome 87:ee2240581aa7 1824
WiredHome 125:7a0b70f56550 1825
WiredHome 87:ee2240581aa7 1826 /// Draw a pixel in the current foreground color.
WiredHome 87:ee2240581aa7 1827 ///
WiredHome 87:ee2240581aa7 1828 /// @param[in] p is the point_t defining the location.
WiredHome 106:c80828f5dea4 1829 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 87:ee2240581aa7 1830 ///
WiredHome 87:ee2240581aa7 1831 virtual RetCode_t pixel(point_t p);
WiredHome 125:7a0b70f56550 1832
WiredHome 19:3f82c1161fd2 1833
WiredHome 19:3f82c1161fd2 1834 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 1835 ///
WiredHome 41:2956a0a221e5 1836 /// @note Unlike many other operations, this does not
WiredHome 41:2956a0a221e5 1837 /// set the forecolor!
WiredHome 19:3f82c1161fd2 1838 ///
WiredHome 72:ecffe56af969 1839 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1840 /// @param[in] y is the vertical offset to this pixel.
WiredHome 72:ecffe56af969 1841 /// @param[in] color defines the color for the pixel.
WiredHome 106:c80828f5dea4 1842 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1843 ///
WiredHome 37:f19b7e7449dc 1844 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color);
WiredHome 19:3f82c1161fd2 1845
WiredHome 125:7a0b70f56550 1846
WiredHome 19:3f82c1161fd2 1847 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 1848 ///
WiredHome 72:ecffe56af969 1849 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1850 /// @param[in] y is the veritical offset to this pixel.
WiredHome 106:c80828f5dea4 1851 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1852 ///
WiredHome 37:f19b7e7449dc 1853 virtual RetCode_t pixel(loc_t x, loc_t y);
WiredHome 19:3f82c1161fd2 1854
WiredHome 125:7a0b70f56550 1855
WiredHome 41:2956a0a221e5 1856 /// Get a pixel from the display.
WiredHome 41:2956a0a221e5 1857 ///
WiredHome 72:ecffe56af969 1858 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1859 /// @param[in] y is the vertical offset to this pixel.
WiredHome 41:2956a0a221e5 1860 /// @returns the pixel. see @color_t
WiredHome 41:2956a0a221e5 1861 ///
WiredHome 41:2956a0a221e5 1862 virtual color_t getPixel(loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1863
WiredHome 125:7a0b70f56550 1864
WiredHome 136:224e03d5c31f 1865 /// Write an RGB565 stream of pixels to the display.
WiredHome 41:2956a0a221e5 1866 ///
WiredHome 72:ecffe56af969 1867 /// @param[in] p is a pointer to a color_t array to write.
WiredHome 72:ecffe56af969 1868 /// @param[in] count is the number of pixels to write.
WiredHome 72:ecffe56af969 1869 /// @param[in] x is the horizontal position on the display.
WiredHome 72:ecffe56af969 1870 /// @param[in] y is the vertical position on the display.
WiredHome 106:c80828f5dea4 1871 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 41:2956a0a221e5 1872 ///
WiredHome 41:2956a0a221e5 1873 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 41:2956a0a221e5 1874
WiredHome 125:7a0b70f56550 1875
WiredHome 41:2956a0a221e5 1876 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 1877 ///
WiredHome 72:ecffe56af969 1878 /// @param[in] p is a pointer to a color_t array to accept the stream.
WiredHome 72:ecffe56af969 1879 /// @param[in] count is the number of pixels to read.
WiredHome 72:ecffe56af969 1880 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 1881 /// @param[in] y is the vertical offset to this pixel.
WiredHome 106:c80828f5dea4 1882 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 41:2956a0a221e5 1883 ///
WiredHome 41:2956a0a221e5 1884 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 131:5bd6ba2ee4a1 1885
WiredHome 131:5bd6ba2ee4a1 1886
WiredHome 109:7b94f06f085b 1887 /// Write a boolean stream to the display.
WiredHome 109:7b94f06f085b 1888 ///
WiredHome 109:7b94f06f085b 1889 /// This takes a bit stream in memory and using the current color settings
WiredHome 109:7b94f06f085b 1890 /// it will stream it to the display. Along the way, each bit is translated
WiredHome 109:7b94f06f085b 1891 /// to either the foreground or background color value and then that pixel
WiredHome 109:7b94f06f085b 1892 /// is pushed onward.
WiredHome 109:7b94f06f085b 1893 ///
WiredHome 109:7b94f06f085b 1894 /// This is similar, but different, to the @ref pixelStream API, which is
WiredHome 109:7b94f06f085b 1895 /// given a stream of color values.
WiredHome 109:7b94f06f085b 1896 ///
WiredHome 153:8a85efb3eb71 1897 /// This is most often used for Soft Fonts, and for that reason, this method
WiredHome 153:8a85efb3eb71 1898 /// will scale the presentation based on the selected font size.
WiredHome 153:8a85efb3eb71 1899 /// See @ref SetTextFontSize, So, users may want to SetTextFontSize(1) for
WiredHome 153:8a85efb3eb71 1900 /// 1:1 scaling.
WiredHome 153:8a85efb3eb71 1901 ///
WiredHome 109:7b94f06f085b 1902 /// @param[in] x is the horizontal position on the display.
WiredHome 109:7b94f06f085b 1903 /// @param[in] y is the vertical position on the display.
WiredHome 109:7b94f06f085b 1904 /// @param[in] w is the width of the rectangular region to fill.
WiredHome 109:7b94f06f085b 1905 /// @param[in] h is the height of the rectangular region to fill.
WiredHome 109:7b94f06f085b 1906 /// @param[in] boolStream is the inline memory image from which to extract
WiredHome 109:7b94f06f085b 1907 /// the bitstream.
WiredHome 109:7b94f06f085b 1908 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 109:7b94f06f085b 1909 ///
WiredHome 109:7b94f06f085b 1910 virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream);
WiredHome 125:7a0b70f56550 1911
WiredHome 109:7b94f06f085b 1912
WiredHome 19:3f82c1161fd2 1913 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 1914 ///
WiredHome 19:3f82c1161fd2 1915 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1916 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1917 ///
WiredHome 83:7bad0068cca0 1918 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 1919 /// @param[in] p2 is the point to end the line.
WiredHome 83:7bad0068cca0 1920 /// @param[in] color defines the foreground color.
WiredHome 106:c80828f5dea4 1921 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 1922 ///
WiredHome 83:7bad0068cca0 1923 RetCode_t line(point_t p1, point_t p2, color_t color);
WiredHome 83:7bad0068cca0 1924
WiredHome 125:7a0b70f56550 1925
WiredHome 83:7bad0068cca0 1926 /// Draw a line
WiredHome 83:7bad0068cca0 1927 ///
WiredHome 83:7bad0068cca0 1928 /// Draws a line using the foreground color setting.
WiredHome 83:7bad0068cca0 1929 ///
WiredHome 83:7bad0068cca0 1930 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 1931 /// @param[in] p2 is the point to end the line.
WiredHome 106:c80828f5dea4 1932 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 1933 ///
WiredHome 83:7bad0068cca0 1934 RetCode_t line(point_t p1, point_t p2);
WiredHome 125:7a0b70f56550 1935
WiredHome 83:7bad0068cca0 1936
WiredHome 83:7bad0068cca0 1937 /// Draw a line in the specified color
WiredHome 83:7bad0068cca0 1938 ///
WiredHome 83:7bad0068cca0 1939 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 1940 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 1941 ///
WiredHome 72:ecffe56af969 1942 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1943 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1944 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1945 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 1946 /// @param[in] color defines the foreground color.
WiredHome 106:c80828f5dea4 1947 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1948 ///
WiredHome 56:7a85d226ad0d 1949 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color);
WiredHome 19:3f82c1161fd2 1950
WiredHome 125:7a0b70f56550 1951
WiredHome 19:3f82c1161fd2 1952 /// Draw a line
WiredHome 19:3f82c1161fd2 1953 ///
WiredHome 19:3f82c1161fd2 1954 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 1955 ///
WiredHome 72:ecffe56af969 1956 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 1957 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 1958 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 1959 /// @param[in] y2 is the vertical end of the line.
WiredHome 106:c80828f5dea4 1960 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 1961 ///
WiredHome 37:f19b7e7449dc 1962 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2);
WiredHome 19:3f82c1161fd2 1963
WiredHome 125:7a0b70f56550 1964
WiredHome 144:ba002c4b21b3 1965 /// Draw a thick line
WiredHome 144:ba002c4b21b3 1966 ///
WiredHome 144:ba002c4b21b3 1967 /// Draw a line of a specified thickness and color.
WiredHome 144:ba002c4b21b3 1968 ///
WiredHome 144:ba002c4b21b3 1969 /// In order to draw a thick line, this draws filled circles using
WiredHome 144:ba002c4b21b3 1970 /// bresenham's algorithm to move the center point of the circle.
WiredHome 144:ba002c4b21b3 1971 /// As a result, this is much slower than drawing a 1-pixel line which
WiredHome 144:ba002c4b21b3 1972 /// uses the hardware line drawing algorithm.
WiredHome 144:ba002c4b21b3 1973 ///
WiredHome 144:ba002c4b21b3 1974 /// Drawing multiple parallel lines to create a thick line is faster,
WiredHome 144:ba002c4b21b3 1975 /// however the line drawing was not guaranteed to fill every pixel
WiredHome 144:ba002c4b21b3 1976 /// on the diagonals.
WiredHome 144:ba002c4b21b3 1977 ///
WiredHome 144:ba002c4b21b3 1978 /// @param[in] p1 is the point to start the line.
WiredHome 144:ba002c4b21b3 1979 /// @param[in] p2 is the point to end the line.
WiredHome 144:ba002c4b21b3 1980 /// @param[in] thickness is the line thickness.
WiredHome 144:ba002c4b21b3 1981 /// @param[in] color defines the foreground color.
WiredHome 144:ba002c4b21b3 1982 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 144:ba002c4b21b3 1983 ///
WiredHome 144:ba002c4b21b3 1984 RetCode_t ThickLine(point_t p1, point_t p2, dim_t thickness, color_t color);
WiredHome 144:ba002c4b21b3 1985
WiredHome 144:ba002c4b21b3 1986
WiredHome 19:3f82c1161fd2 1987 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 1988 ///
WiredHome 19:3f82c1161fd2 1989 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 1990 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 1991 ///
WiredHome 81:01da2e34283d 1992 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 1993 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 1994 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 1995 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 1996 ///
WiredHome 82:f7d300f26540 1997 RetCode_t rect(rect_t rect, color_t color, fill_t fillit = NOFILL);
WiredHome 81:01da2e34283d 1998
WiredHome 125:7a0b70f56550 1999
WiredHome 125:7a0b70f56550 2000 /// Draw a filled rectangle in the specified color
WiredHome 81:01da2e34283d 2001 ///
WiredHome 81:01da2e34283d 2002 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 2003 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 2004 ///
WiredHome 81:01da2e34283d 2005 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 2006 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 2007 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2008 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 81:01da2e34283d 2009 ///
WiredHome 81:01da2e34283d 2010 RetCode_t fillrect(rect_t rect, color_t color, fill_t fillit = FILL);
WiredHome 81:01da2e34283d 2011
WiredHome 125:7a0b70f56550 2012
WiredHome 81:01da2e34283d 2013 /// Draw a rectangle in the specified color
WiredHome 81:01da2e34283d 2014 ///
WiredHome 81:01da2e34283d 2015 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 2016 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 2017 ///
WiredHome 72:ecffe56af969 2018 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2019 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2020 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2021 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2022 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 2023 /// @param[in] fillit is optional to FILL the rectangle. default is FILL.
WiredHome 106:c80828f5dea4 2024 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2025 ///
WiredHome 37:f19b7e7449dc 2026 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 2027 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2028
WiredHome 125:7a0b70f56550 2029
WiredHome 19:3f82c1161fd2 2030 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 2031 ///
WiredHome 19:3f82c1161fd2 2032 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2033 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2034 ///
WiredHome 72:ecffe56af969 2035 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2036 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2037 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2038 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2039 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2040 /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 106:c80828f5dea4 2041 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2042 ///
WiredHome 37:f19b7e7449dc 2043 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 2044 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2045
WiredHome 125:7a0b70f56550 2046
WiredHome 19:3f82c1161fd2 2047 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 2048 ///
WiredHome 19:3f82c1161fd2 2049 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2050 ///
WiredHome 72:ecffe56af969 2051 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2052 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2053 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2054 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2055 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2056 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2057 ///
WiredHome 37:f19b7e7449dc 2058 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 2059 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2060
WiredHome 125:7a0b70f56550 2061
WiredHome 19:3f82c1161fd2 2062 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 2063 ///
WiredHome 21:3c1efb192927 2064 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2065 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2066 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2067 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 2068 ///
WiredHome 19:3f82c1161fd2 2069 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2070 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2071 ///
WiredHome 72:ecffe56af969 2072 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2073 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2074 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2075 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2076 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2077 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2078 /// is returned.
WiredHome 72:ecffe56af969 2079 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2080 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2081 /// is returned.
WiredHome 72:ecffe56af969 2082 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2083 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2084 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2085 ///
WiredHome 37:f19b7e7449dc 2086 RetCode_t fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2087 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2088
WiredHome 125:7a0b70f56550 2089
WiredHome 107:f9ccffcb84f1 2090 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 107:f9ccffcb84f1 2091 ///
WiredHome 107:f9ccffcb84f1 2092 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 107:f9ccffcb84f1 2093 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 107:f9ccffcb84f1 2094 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 107:f9ccffcb84f1 2095 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 107:f9ccffcb84f1 2096 ///
WiredHome 107:f9ccffcb84f1 2097 /// @note As a side effect, this changes the current
WiredHome 107:f9ccffcb84f1 2098 /// foreground color for subsequent operations.
WiredHome 107:f9ccffcb84f1 2099 ///
WiredHome 107:f9ccffcb84f1 2100 /// @param[in] r is the rectangle to draw.
WiredHome 107:f9ccffcb84f1 2101 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 2102 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2103 /// is returned.
WiredHome 107:f9ccffcb84f1 2104 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 2105 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2106 /// is returned.
WiredHome 107:f9ccffcb84f1 2107 /// @param[in] color defines the foreground color.
WiredHome 107:f9ccffcb84f1 2108 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 107:f9ccffcb84f1 2109 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 107:f9ccffcb84f1 2110 ///
WiredHome 107:f9ccffcb84f1 2111 RetCode_t fillroundrect(rect_t r,
WiredHome 107:f9ccffcb84f1 2112 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 107:f9ccffcb84f1 2113
WiredHome 125:7a0b70f56550 2114
WiredHome 107:f9ccffcb84f1 2115 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 107:f9ccffcb84f1 2116 ///
WiredHome 107:f9ccffcb84f1 2117 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 107:f9ccffcb84f1 2118 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 107:f9ccffcb84f1 2119 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 107:f9ccffcb84f1 2120 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 107:f9ccffcb84f1 2121 ///
WiredHome 107:f9ccffcb84f1 2122 /// @note As a side effect, this changes the current
WiredHome 107:f9ccffcb84f1 2123 /// foreground color for subsequent operations.
WiredHome 107:f9ccffcb84f1 2124 ///
WiredHome 107:f9ccffcb84f1 2125 /// @param[in] r is the rectangle to draw.
WiredHome 107:f9ccffcb84f1 2126 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 2127 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2128 /// is returned.
WiredHome 107:f9ccffcb84f1 2129 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 107:f9ccffcb84f1 2130 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2131 /// is returned.
WiredHome 107:f9ccffcb84f1 2132 /// @param[in] color defines the foreground color.
WiredHome 107:f9ccffcb84f1 2133 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 107:f9ccffcb84f1 2134 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 107:f9ccffcb84f1 2135 ///
WiredHome 107:f9ccffcb84f1 2136 RetCode_t roundrect(rect_t r,
WiredHome 107:f9ccffcb84f1 2137 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 107:f9ccffcb84f1 2138
WiredHome 125:7a0b70f56550 2139
WiredHome 19:3f82c1161fd2 2140 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 2141 ///
WiredHome 21:3c1efb192927 2142 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2143 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2144 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2145 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 2146 ///
WiredHome 19:3f82c1161fd2 2147 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2148 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2149 ///
WiredHome 72:ecffe56af969 2150 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2151 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2152 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2153 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2154 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2155 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2156 /// is returned.
WiredHome 72:ecffe56af969 2157 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2158 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2159 /// is returned.
WiredHome 72:ecffe56af969 2160 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2161 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2162 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2163 ///
WiredHome 37:f19b7e7449dc 2164 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2165 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2166
WiredHome 125:7a0b70f56550 2167
WiredHome 19:3f82c1161fd2 2168 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 2169 ///
WiredHome 21:3c1efb192927 2170 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2171 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2172 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2173 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 2174 ///
WiredHome 72:ecffe56af969 2175 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2176 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2177 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2178 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2179 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2180 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2181 /// is returned.
WiredHome 72:ecffe56af969 2182 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 21:3c1efb192927 2183 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2184 /// is returned.
WiredHome 72:ecffe56af969 2185 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2186 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2187 ///
WiredHome 37:f19b7e7449dc 2188 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2189 dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2190
WiredHome 125:7a0b70f56550 2191
WiredHome 19:3f82c1161fd2 2192 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 2193 ///
WiredHome 19:3f82c1161fd2 2194 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2195 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2196 ///
WiredHome 72:ecffe56af969 2197 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2198 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2199 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2200 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2201 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2202 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2203 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2204 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2205 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2206 ///
WiredHome 37:f19b7e7449dc 2207 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2208 loc_t x3, loc_t y3, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2209
WiredHome 125:7a0b70f56550 2210
WiredHome 19:3f82c1161fd2 2211 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 2212 ///
WiredHome 19:3f82c1161fd2 2213 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2214 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2215 ///
WiredHome 72:ecffe56af969 2216 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2217 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2218 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2219 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2220 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2221 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2222 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2223 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2224 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2225 ///
WiredHome 37:f19b7e7449dc 2226 RetCode_t filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2227 loc_t x3, loc_t y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2228
WiredHome 125:7a0b70f56550 2229
WiredHome 19:3f82c1161fd2 2230 /// Draw a triangle
WiredHome 19:3f82c1161fd2 2231 ///
WiredHome 19:3f82c1161fd2 2232 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2233 ///
WiredHome 72:ecffe56af969 2234 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2235 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2236 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2237 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2238 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2239 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2240 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 106:c80828f5dea4 2241 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2242 ///
WiredHome 37:f19b7e7449dc 2243 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2244 loc_t x3, loc_t y3, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2245
WiredHome 83:7bad0068cca0 2246
WiredHome 83:7bad0068cca0 2247 /// Draw a circle using the specified color.
WiredHome 83:7bad0068cca0 2248 ///
WiredHome 83:7bad0068cca0 2249 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2250 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2251 ///
WiredHome 83:7bad0068cca0 2252 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2253 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 2254 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2255 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2256 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 2257 ///
WiredHome 83:7bad0068cca0 2258 RetCode_t circle(point_t p, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 2259
WiredHome 125:7a0b70f56550 2260
WiredHome 83:7bad0068cca0 2261 /// Draw a filled circle using the specified color.
WiredHome 83:7bad0068cca0 2262 ///
WiredHome 83:7bad0068cca0 2263 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2264 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2265 ///
WiredHome 83:7bad0068cca0 2266 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2267 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 2268 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2269 /// @param[in] fillit is optional to FILL the circle. default is FILL.
WiredHome 106:c80828f5dea4 2270 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 2271 ///
WiredHome 83:7bad0068cca0 2272 RetCode_t fillcircle(point_t p, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 83:7bad0068cca0 2273
WiredHome 125:7a0b70f56550 2274
WiredHome 83:7bad0068cca0 2275 /// Draw a circle.
WiredHome 83:7bad0068cca0 2276 ///
WiredHome 83:7bad0068cca0 2277 /// Draws a circle using the foreground color setting.
WiredHome 83:7bad0068cca0 2278 ///
WiredHome 83:7bad0068cca0 2279 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2280 /// @param[in] radius defines the size of the circle.
WiredHome 125:7a0b70f56550 2281 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2282 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 83:7bad0068cca0 2283 ///
WiredHome 83:7bad0068cca0 2284 RetCode_t circle(point_t p, dim_t radius, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 2285
WiredHome 125:7a0b70f56550 2286
WiredHome 19:3f82c1161fd2 2287 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 2288 ///
WiredHome 19:3f82c1161fd2 2289 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2290 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2291 ///
WiredHome 72:ecffe56af969 2292 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2293 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2294 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 2295 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2296 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2297 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2298 ///
WiredHome 37:f19b7e7449dc 2299 RetCode_t circle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2300
WiredHome 125:7a0b70f56550 2301
WiredHome 19:3f82c1161fd2 2302 /// Draw a filled circle using the specified color.
WiredHome 19:3f82c1161fd2 2303 ///
WiredHome 19:3f82c1161fd2 2304 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2305 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2306 ///
WiredHome 72:ecffe56af969 2307 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2308 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2309 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 2310 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2311 /// @param[in] fillit is optional to FILL the circle. default is FILL.
WiredHome 106:c80828f5dea4 2312 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2313 ///
WiredHome 37:f19b7e7449dc 2314 RetCode_t fillcircle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2315
WiredHome 125:7a0b70f56550 2316
WiredHome 19:3f82c1161fd2 2317 /// Draw a circle.
WiredHome 19:3f82c1161fd2 2318 ///
WiredHome 19:3f82c1161fd2 2319 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2320 ///
WiredHome 72:ecffe56af969 2321 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2322 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2323 /// @param[in] radius defines the size of the circle.
WiredHome 125:7a0b70f56550 2324 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 106:c80828f5dea4 2325 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2326 ///
WiredHome 37:f19b7e7449dc 2327 RetCode_t circle(loc_t x, loc_t y, dim_t radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2328
WiredHome 19:3f82c1161fd2 2329 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 2330 ///
WiredHome 19:3f82c1161fd2 2331 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2332 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2333 ///
WiredHome 72:ecffe56af969 2334 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2335 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2336 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2337 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2338 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2339 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 106:c80828f5dea4 2340 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2341 ///
WiredHome 37:f19b7e7449dc 2342 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 19:3f82c1161fd2 2343 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2344
WiredHome 125:7a0b70f56550 2345
WiredHome 25:9556a3a9b7cc 2346 /// Draw a filled Ellipse using the specified color
WiredHome 25:9556a3a9b7cc 2347 ///
WiredHome 25:9556a3a9b7cc 2348 /// @note As a side effect, this changes the current
WiredHome 25:9556a3a9b7cc 2349 /// foreground color for subsequent operations.
WiredHome 25:9556a3a9b7cc 2350 ///
WiredHome 72:ecffe56af969 2351 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2352 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2353 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2354 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2355 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2356 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 106:c80828f5dea4 2357 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 25:9556a3a9b7cc 2358 ///
WiredHome 37:f19b7e7449dc 2359 RetCode_t fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 25:9556a3a9b7cc 2360 color_t color, fill_t fillit = FILL);
WiredHome 25:9556a3a9b7cc 2361
WiredHome 125:7a0b70f56550 2362
WiredHome 19:3f82c1161fd2 2363 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 2364 ///
WiredHome 19:3f82c1161fd2 2365 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 2366 ///
WiredHome 72:ecffe56af969 2367 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2368 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2369 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2370 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2371 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 106:c80828f5dea4 2372 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2373 ///
WiredHome 37:f19b7e7449dc 2374 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2375
WiredHome 125:7a0b70f56550 2376
WiredHome 131:5bd6ba2ee4a1 2377
WiredHome 131:5bd6ba2ee4a1 2378 /// Block Move
WiredHome 131:5bd6ba2ee4a1 2379 ///
WiredHome 131:5bd6ba2ee4a1 2380 /// The Block Move API activates the RA8875 Block Transfer Engine. Due to the complex
WiredHome 131:5bd6ba2ee4a1 2381 /// set of possible operations, the user should read the related sections of the
WiredHome 131:5bd6ba2ee4a1 2382 /// RA8875 user manual.
WiredHome 131:5bd6ba2ee4a1 2383 ///
WiredHome 131:5bd6ba2ee4a1 2384 /// Some operations may require that other registers are configured, such as the
WiredHome 131:5bd6ba2ee4a1 2385 /// foreground and background color registers, and others. Those must be set
WiredHome 131:5bd6ba2ee4a1 2386 /// outside of this API.
WiredHome 131:5bd6ba2ee4a1 2387 ///
WiredHome 138:61e93bed397e 2388 /// @code
WiredHome 154:ad2450fc3dc3 2389 /// // Calibrate the resistive touch screen, and store the data on the
WiredHome 154:ad2450fc3dc3 2390 /// // local file system.
WiredHome 154:ad2450fc3dc3 2391 /// //
WiredHome 154:ad2450fc3dc3 2392 /// void CalibrateTS(void)
WiredHome 154:ad2450fc3dc3 2393 /// {
WiredHome 154:ad2450fc3dc3 2394 /// FILE * fh;
WiredHome 154:ad2450fc3dc3 2395 /// tpMatrix_t matrix;
WiredHome 154:ad2450fc3dc3 2396 /// RetCode_t r;
WiredHome 154:ad2450fc3dc3 2397 /// Timer testperiod;
WiredHome 154:ad2450fc3dc3 2398 ///
WiredHome 154:ad2450fc3dc3 2399 /// r = lcd.TouchPanelCalibrate("Calibrate the touch panel", &matrix);
WiredHome 154:ad2450fc3dc3 2400 /// if (r == noerror) {
WiredHome 154:ad2450fc3dc3 2401 /// fh = fopen("/local/tpcal.cfg", "wb");
WiredHome 154:ad2450fc3dc3 2402 /// if (fh) {
WiredHome 154:ad2450fc3dc3 2403 /// fwrite(&matrix, sizeof(tpMatrix_t), 1, fh);
WiredHome 154:ad2450fc3dc3 2404 /// fclose(fh);
WiredHome 154:ad2450fc3dc3 2405 /// printf(" tp cal written.\r\n");
WiredHome 154:ad2450fc3dc3 2406 /// lcd.cls();
WiredHome 154:ad2450fc3dc3 2407 /// } else {
WiredHome 154:ad2450fc3dc3 2408 /// printf(" couldn't open tpcal file.\r\n");
WiredHome 154:ad2450fc3dc3 2409 /// }
WiredHome 154:ad2450fc3dc3 2410 /// } else {
WiredHome 154:ad2450fc3dc3 2411 /// printf("error return: %d\r\n", r);
WiredHome 154:ad2450fc3dc3 2412 /// }
WiredHome 154:ad2450fc3dc3 2413 /// lcd.cls();
WiredHome 154:ad2450fc3dc3 2414 /// }
WiredHome 154:ad2450fc3dc3 2415 ///
WiredHome 154:ad2450fc3dc3 2416 /// // Try to load a previous resistive touch screen calibration from storage. If it
WiredHome 154:ad2450fc3dc3 2417 /// // doesn't exist, activate the touch screen calibration process.
WiredHome 154:ad2450fc3dc3 2418 /// //
WiredHome 154:ad2450fc3dc3 2419 /// void InitTS(void)
WiredHome 154:ad2450fc3dc3 2420 /// {
WiredHome 154:ad2450fc3dc3 2421 /// FILE * fh;
WiredHome 154:ad2450fc3dc3 2422 /// tpMatrix_t matrix;
WiredHome 154:ad2450fc3dc3 2423 ///
WiredHome 154:ad2450fc3dc3 2424 /// fh = fopen("/local/tpcal.cfg", "rb");
WiredHome 154:ad2450fc3dc3 2425 /// if (fh) {
WiredHome 154:ad2450fc3dc3 2426 /// fread(&matrix, sizeof(tpMatrix_t), 1, fh);
WiredHome 154:ad2450fc3dc3 2427 /// fclose(fh);
WiredHome 154:ad2450fc3dc3 2428 /// lcd.TouchPanelSetMatrix(&matrix);
WiredHome 154:ad2450fc3dc3 2429 /// printf(" tp cal loaded.\r\n");
WiredHome 154:ad2450fc3dc3 2430 /// } else {
WiredHome 154:ad2450fc3dc3 2431 /// CalibrateTS();
WiredHome 154:ad2450fc3dc3 2432 /// }
WiredHome 154:ad2450fc3dc3 2433 /// }
WiredHome 154:ad2450fc3dc3 2434 ///
WiredHome 138:61e93bed397e 2435 /// int main()
WiredHome 138:61e93bed397e 2436 /// {
WiredHome 138:61e93bed397e 2437 /// point_t src;
WiredHome 138:61e93bed397e 2438 /// point_t dst;
WiredHome 138:61e93bed397e 2439 /// TouchCode_t touch;
WiredHome 138:61e93bed397e 2440 /// const dim_t RECT_W = 100;
WiredHome 138:61e93bed397e 2441 /// const dim_t RECT_H = 100;
WiredHome 138:61e93bed397e 2442 ///
WiredHome 138:61e93bed397e 2443 /// pc.baud(460800); //I like a snappy terminal, so crank it up!
WiredHome 138:61e93bed397e 2444 /// pc.printf("\r\nRA8875 BTE Move Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 138:61e93bed397e 2445 /// lcd.init(LCD_W,LCD_H,LCD_C, BL_NORM);
WiredHome 138:61e93bed397e 2446 /// lcd.TouchPanelInit();
WiredHome 138:61e93bed397e 2447 /// #ifndef CAP_TOUCH
WiredHome 138:61e93bed397e 2448 /// InitTS(); // Calibration for resistive touch panel
WiredHome 138:61e93bed397e 2449 /// #endif
WiredHome 138:61e93bed397e 2450 ///
WiredHome 138:61e93bed397e 2451 /// RetCode_t r = lcd.RenderImageFile(0,0,"/local/fullscrn.jpg");
WiredHome 138:61e93bed397e 2452 /// if (r) pc.printf(" Error: %d; %s\r\n", r, lcd.GetErrorMessage(r));
WiredHome 138:61e93bed397e 2453 /// while (1) {
WiredHome 138:61e93bed397e 2454 /// touch = lcd.TouchPanelReadable();
WiredHome 138:61e93bed397e 2455 /// if (touch) {
WiredHome 138:61e93bed397e 2456 /// point_t xy = lcd.TouchCoordinates();
WiredHome 138:61e93bed397e 2457 /// TouchCode_t t = lcd.TouchCode();
WiredHome 138:61e93bed397e 2458 ///
WiredHome 138:61e93bed397e 2459 /// if (t == touch) {
WiredHome 138:61e93bed397e 2460 /// src = ComputeTopLeftOfRect(xy, RECT_W/2, RECT_H/2, LCD_W, LCD_H);
WiredHome 138:61e93bed397e 2461 /// } else if (t == release) {
WiredHome 138:61e93bed397e 2462 /// dst = ComputeTopLeftOfRect(xy, RECT_W/2, RECT_H/2, LCD_W, LCD_H);
WiredHome 138:61e93bed397e 2463 /// r = lcd.BlockMove(0,0,dst, 0,0,src, RECT_W,RECT_H, 0x2, 0xC);
WiredHome 138:61e93bed397e 2464 /// }
WiredHome 138:61e93bed397e 2465 /// }
WiredHome 138:61e93bed397e 2466 /// }
WiredHome 138:61e93bed397e 2467 /// }
WiredHome 138:61e93bed397e 2468 /// @endcode
WiredHome 138:61e93bed397e 2469 ///
WiredHome 139:99ec74e3273f 2470 /// @param[in] dstLayer layer [5B.7]. layer value is 0 or 1 representing layer 1 and 2.
WiredHome 131:5bd6ba2ee4a1 2471 /// @param[in] dstDataSelect [50.5] defines the destination data type 0: block, 1: linear.
WiredHome 131:5bd6ba2ee4a1 2472 /// @param[in] dstPoint [58-5B] is a point_t defining the destination coordinate.
WiredHome 139:99ec74e3273f 2473 /// @param[in] srcLayer layer [57.7]. layer value is 0 or 1 representing layer 1 and 2.
WiredHome 131:5bd6ba2ee4a1 2474 /// @param[in] srcDataSelect [50.6] defines the source data type 0: block, 1: linear.
WiredHome 131:5bd6ba2ee4a1 2475 /// @param[in] srcPoint [54-57] is a point_t defining the source coordinate.
WiredHome 131:5bd6ba2ee4a1 2476 /// @param[in] bte_width [5C-5D]. operation width.
WiredHome 131:5bd6ba2ee4a1 2477 /// @param[in] bte_height [5E-5F]. operation height.
WiredHome 131:5bd6ba2ee4a1 2478 /// @param[in] bte_op_code [51.3-0] defines the raster operation function
WiredHome 131:5bd6ba2ee4a1 2479 /// (write/read/move/...)
WiredHome 131:5bd6ba2ee4a1 2480 /// @param[in] bte_rop_code [51.7-4] defines what type of BTE operation to perform
WiredHome 131:5bd6ba2ee4a1 2481 /// (what is placed at the destination)
WiredHome 131:5bd6ba2ee4a1 2482 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 131:5bd6ba2ee4a1 2483 ///
WiredHome 131:5bd6ba2ee4a1 2484 RetCode_t BlockMove(uint8_t dstLayer, uint8_t dstDataSelect, point_t dstPoint,
WiredHome 131:5bd6ba2ee4a1 2485 uint8_t srcLayer, uint8_t srcDataSelect, point_t srcPoint,
WiredHome 137:9e09f6081ef1 2486 dim_t bte_width, dim_t bte_height,
WiredHome 131:5bd6ba2ee4a1 2487 uint8_t bte_op_code, uint8_t bte_rop_code);
WiredHome 131:5bd6ba2ee4a1 2488
WiredHome 131:5bd6ba2ee4a1 2489
WiredHome 19:3f82c1161fd2 2490 /// Control display power
WiredHome 19:3f82c1161fd2 2491 ///
WiredHome 72:ecffe56af969 2492 /// @param[in] on when set to true will turn on the display, when false it is turned off.
WiredHome 106:c80828f5dea4 2493 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2494 ///
WiredHome 19:3f82c1161fd2 2495 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 2496
WiredHome 125:7a0b70f56550 2497
WiredHome 19:3f82c1161fd2 2498 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 2499 ///
WiredHome 106:c80828f5dea4 2500 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2501 ///
WiredHome 19:3f82c1161fd2 2502 RetCode_t Reset(void);
WiredHome 19:3f82c1161fd2 2503
WiredHome 125:7a0b70f56550 2504
WiredHome 19:3f82c1161fd2 2505 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 2506 ///
WiredHome 19:3f82c1161fd2 2507 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 2508 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 2509 ///
WiredHome 72:ecffe56af969 2510 /// @param[in] brightness ranges from 0 (off) to 255 (full on)
WiredHome 106:c80828f5dea4 2511 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2512 ///
WiredHome 131:5bd6ba2ee4a1 2513 RetCode_t Backlight_u8(uint8_t brightness);
WiredHome 125:7a0b70f56550 2514
WiredHome 19:3f82c1161fd2 2515
WiredHome 86:e86b355940f4 2516 /// Get backlight brightness.
WiredHome 86:e86b355940f4 2517 ///
WiredHome 86:e86b355940f4 2518 /// @returns backlight setting from 0 (off) to 255 (full on).
WiredHome 86:e86b355940f4 2519 ///
WiredHome 86:e86b355940f4 2520 uint8_t GetBacklight_u8(void);
WiredHome 86:e86b355940f4 2521
WiredHome 19:3f82c1161fd2 2522 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 2523 ///
WiredHome 19:3f82c1161fd2 2524 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 2525 /// API can be used to set the brightness.
WiredHome 19:3f82c1161fd2 2526 ///
WiredHome 72:ecffe56af969 2527 /// @param[in] brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 106:c80828f5dea4 2528 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2529 ///
WiredHome 19:3f82c1161fd2 2530 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 2531
WiredHome 125:7a0b70f56550 2532
WiredHome 86:e86b355940f4 2533 /// Get backlight brightness.
WiredHome 86:e86b355940f4 2534 ///
WiredHome 86:e86b355940f4 2535 /// @returns backlight setting from 0 (off) to 1.0 (full on).
WiredHome 86:e86b355940f4 2536 ///
WiredHome 86:e86b355940f4 2537 float GetBacklight(void);
WiredHome 86:e86b355940f4 2538
WiredHome 125:7a0b70f56550 2539
WiredHome 98:ecebed9b80b2 2540 /// Select a User Font for all subsequent text.
WiredHome 98:ecebed9b80b2 2541 ///
WiredHome 98:ecebed9b80b2 2542 /// @note Tool to create the fonts is accessible from its creator
WiredHome 98:ecebed9b80b2 2543 /// available at http://www.mikroe.com.
WiredHome 98:ecebed9b80b2 2544 /// For version 1.2.0.0, choose the "Export for TFT and new GLCD"
WiredHome 98:ecebed9b80b2 2545 /// format.
WiredHome 98:ecebed9b80b2 2546 ///
WiredHome 98:ecebed9b80b2 2547 /// @param[in] font is a pointer to a specially formed font resource.
WiredHome 98:ecebed9b80b2 2548 /// @returns error code.
WiredHome 98:ecebed9b80b2 2549 ///
WiredHome 98:ecebed9b80b2 2550 virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
WiredHome 98:ecebed9b80b2 2551
WiredHome 127:db7f2c704693 2552 /// Get the currently selected user font.
WiredHome 127:db7f2c704693 2553 ///
WiredHome 127:db7f2c704693 2554 /// @returns a pointer to the font, or null, if no user font is selected.
WiredHome 127:db7f2c704693 2555 ///
WiredHome 127:db7f2c704693 2556 virtual const uint8_t * GetUserFont(void) { return font; }
WiredHome 19:3f82c1161fd2 2557
WiredHome 19:3f82c1161fd2 2558 /// Get the RGB value for a DOS color.
WiredHome 19:3f82c1161fd2 2559 ///
WiredHome 125:7a0b70f56550 2560 /// @code
WiredHome 125:7a0b70f56550 2561 /// color_t color = DOSColor(12);
WiredHome 125:7a0b70f56550 2562 /// @endcode
WiredHome 125:7a0b70f56550 2563 ///
WiredHome 72:ecffe56af969 2564 /// @param[in] i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 2565 /// @returns the RGB color of the selected index, or 0
WiredHome 19:3f82c1161fd2 2566 /// if the index is out of bounds.
WiredHome 19:3f82c1161fd2 2567 ///
WiredHome 19:3f82c1161fd2 2568 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 2569
WiredHome 125:7a0b70f56550 2570
WiredHome 19:3f82c1161fd2 2571 /// Get the color name (string) for a DOS color.
WiredHome 19:3f82c1161fd2 2572 ///
WiredHome 125:7a0b70f56550 2573 /// @code
WiredHome 125:7a0b70f56550 2574 /// printf("color is %s\n", DOSColorNames(12));
WiredHome 125:7a0b70f56550 2575 /// @endcode
WiredHome 125:7a0b70f56550 2576 ///
WiredHome 72:ecffe56af969 2577 /// @param[in] i is the color, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 2578 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 2579 /// or NULL if the index is out of bounds.
WiredHome 19:3f82c1161fd2 2580 ///
WiredHome 19:3f82c1161fd2 2581 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 2582
WiredHome 125:7a0b70f56550 2583
WiredHome 55:dfbabef7003e 2584 /// Advanced method indicating the start of a graphics stream.
WiredHome 55:dfbabef7003e 2585 ///
WiredHome 55:dfbabef7003e 2586 /// This is called prior to a stream of pixel data being sent.
WiredHome 55:dfbabef7003e 2587 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 2588 /// class in order to prepare the hardware to accept the streaming
WiredHome 55:dfbabef7003e 2589 /// data.
WiredHome 55:dfbabef7003e 2590 ///
WiredHome 106:c80828f5dea4 2591 /// Following this command, a series of See @ref _putp() commands can
WiredHome 55:dfbabef7003e 2592 /// be used to send individual pixels to the screen.
WiredHome 55:dfbabef7003e 2593 ///
WiredHome 106:c80828f5dea4 2594 /// To conclude the graphics stream, See @ref _EndGraphicsStream should
WiredHome 55:dfbabef7003e 2595 /// be callled.
WiredHome 55:dfbabef7003e 2596 ///
WiredHome 55:dfbabef7003e 2597 /// @returns error code.
WiredHome 55:dfbabef7003e 2598 ///
WiredHome 55:dfbabef7003e 2599 virtual RetCode_t _StartGraphicsStream(void);
WiredHome 125:7a0b70f56550 2600
WiredHome 55:dfbabef7003e 2601
WiredHome 55:dfbabef7003e 2602 /// Advanced method to put a single color pixel to the screen.
WiredHome 55:dfbabef7003e 2603 ///
WiredHome 55:dfbabef7003e 2604 /// This method may be called as many times as necessary after
WiredHome 106:c80828f5dea4 2605 /// See @ref _StartGraphicsStream() is called, and it should be followed
WiredHome 55:dfbabef7003e 2606 /// by _EndGraphicsStream.
WiredHome 55:dfbabef7003e 2607 ///
WiredHome 125:7a0b70f56550 2608 /// @code
WiredHome 125:7a0b70f56550 2609 /// _putp(DOSColor(12));
WiredHome 125:7a0b70f56550 2610 /// @endcode
WiredHome 125:7a0b70f56550 2611 ///
WiredHome 72:ecffe56af969 2612 /// @param[in] pixel is a color value to be put on the screen.
WiredHome 55:dfbabef7003e 2613 /// @returns error code.
WiredHome 55:dfbabef7003e 2614 ///
WiredHome 55:dfbabef7003e 2615 virtual RetCode_t _putp(color_t pixel);
WiredHome 125:7a0b70f56550 2616
WiredHome 55:dfbabef7003e 2617
WiredHome 55:dfbabef7003e 2618 /// Advanced method indicating the end of a graphics stream.
WiredHome 55:dfbabef7003e 2619 ///
WiredHome 55:dfbabef7003e 2620 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 55:dfbabef7003e 2621 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 2622 /// class in order to stop the hardware from accept the streaming
WiredHome 55:dfbabef7003e 2623 /// data.
WiredHome 55:dfbabef7003e 2624 ///
WiredHome 55:dfbabef7003e 2625 /// @returns error code.
WiredHome 55:dfbabef7003e 2626 ///
WiredHome 55:dfbabef7003e 2627 virtual RetCode_t _EndGraphicsStream(void);
WiredHome 19:3f82c1161fd2 2628
WiredHome 125:7a0b70f56550 2629
WiredHome 57:bd53a9e165a1 2630 /// Set the SPI port frequency (in Hz).
WiredHome 57:bd53a9e165a1 2631 ///
WiredHome 66:468a11f05580 2632 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 66:468a11f05580 2633 /// its capabilities. The RA8875 can accept writes via SPI faster
WiredHome 66:468a11f05580 2634 /// than a read can be performed. The frequency set by this API
WiredHome 66:468a11f05580 2635 /// is for the SPI writes. It will automatically reduce the SPI
WiredHome 66:468a11f05580 2636 /// clock rate when a read is performed, and restore it for the
WiredHome 68:ab08efabfc88 2637 /// next write. Alternately, the 2nd parameters permits setting
WiredHome 68:ab08efabfc88 2638 /// the read speed rather than letting it compute it automatically.
WiredHome 57:bd53a9e165a1 2639 ///
WiredHome 66:468a11f05580 2640 /// @note The primary effect of this is to recover more CPU cycles
WiredHome 66:468a11f05580 2641 /// for your application code. Keep in mind that when more than
WiredHome 66:468a11f05580 2642 /// one command is sent to the display controller, that it
WiredHome 66:468a11f05580 2643 /// will wait for the controller to finish the prior command.
WiredHome 66:468a11f05580 2644 /// In this case, the performance is limited by the RA8875.
WiredHome 57:bd53a9e165a1 2645 ///
WiredHome 72:ecffe56af969 2646 /// @param[in] Hz is the frequency in Hz, tested range includes the
WiredHome 66:468a11f05580 2647 /// range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
WiredHome 66:468a11f05580 2648 /// outside this range will be accepted, but operation may
WiredHome 76:c981284eb513 2649 /// be unreliable. This depends partially on your hardware design
WiredHome 76:c981284eb513 2650 /// and the wires connecting the display module.
WiredHome 76:c981284eb513 2651 /// The default value is 5,000,000, which should work for most
WiredHome 76:c981284eb513 2652 /// applications as a starting point.
WiredHome 72:ecffe56af969 2653 /// @param[in] Hz2 is an optional parameter and will set the read
WiredHome 68:ab08efabfc88 2654 /// speed independently of the write speed.
WiredHome 106:c80828f5dea4 2655 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 57:bd53a9e165a1 2656 ///
WiredHome 68:ab08efabfc88 2657 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ, unsigned long Hz2 = 0);
WiredHome 125:7a0b70f56550 2658
WiredHome 125:7a0b70f56550 2659
WiredHome 72:ecffe56af969 2660 /// This method captures the specified area as a 24-bit bitmap file.
WiredHome 72:ecffe56af969 2661 ///
WiredHome 72:ecffe56af969 2662 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 2663 /// 24-bit format.
WiredHome 72:ecffe56af969 2664 ///
WiredHome 73:f22a18707b5e 2665 /// This method will interrogate the current display setting and
WiredHome 73:f22a18707b5e 2666 /// create a bitmap based on those settings. For instance, if
WiredHome 73:f22a18707b5e 2667 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 73:f22a18707b5e 2668 /// if there is some other operation in effect (transparent mode).
WiredHome 73:f22a18707b5e 2669 ///
WiredHome 149:c62c4b2d6a15 2670 /// If the idle callback is registered, it will be activated passing
WiredHome 149:c62c4b2d6a15 2671 /// a parameter indicating the percent complete, which may be of value.
WiredHome 149:c62c4b2d6a15 2672 ///
WiredHome 72:ecffe56af969 2673 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 2674 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 2675 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 2676 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 2677 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 72:ecffe56af969 2678 /// @return success or error code.
WiredHome 72:ecffe56af969 2679 ///
WiredHome 72:ecffe56af969 2680 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP);
WiredHome 125:7a0b70f56550 2681
WiredHome 72:ecffe56af969 2682
WiredHome 96:40b74dd3695b 2683 /// This method captures the specified area as a 24-bit bitmap file
WiredHome 96:40b74dd3695b 2684 /// and delivers it to the previously attached callback.
WiredHome 96:40b74dd3695b 2685 ///
WiredHome 96:40b74dd3695b 2686 /// Even though this is a 16-bit display, the stored image is in
WiredHome 96:40b74dd3695b 2687 /// 24-bit format.
WiredHome 96:40b74dd3695b 2688 ///
WiredHome 96:40b74dd3695b 2689 /// This method will interrogate the current display setting and
WiredHome 96:40b74dd3695b 2690 /// create a bitmap based on those settings. For instance, if
WiredHome 96:40b74dd3695b 2691 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 96:40b74dd3695b 2692 /// if there is some other operation in effect (transparent mode), it
WiredHome 96:40b74dd3695b 2693 /// will return the blended image.
WiredHome 96:40b74dd3695b 2694 ///
WiredHome 149:c62c4b2d6a15 2695 /// If the idle callback is registered, it will be activated passing
WiredHome 149:c62c4b2d6a15 2696 /// a parameter indicating the percent complete, which may be of value.
WiredHome 149:c62c4b2d6a15 2697 ///
WiredHome 96:40b74dd3695b 2698 /// @param[in] x is the left edge of the region to capture
WiredHome 96:40b74dd3695b 2699 /// @param[in] y is the top edge of the region to capture
WiredHome 96:40b74dd3695b 2700 /// @param[in] w is the width of the region to capture
WiredHome 96:40b74dd3695b 2701 /// @param[in] h is the height of the region to capture.
WiredHome 96:40b74dd3695b 2702 /// @return success or error code.
WiredHome 96:40b74dd3695b 2703 ///
WiredHome 96:40b74dd3695b 2704 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h);
WiredHome 125:7a0b70f56550 2705
WiredHome 96:40b74dd3695b 2706
WiredHome 96:40b74dd3695b 2707 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 2708 ///
WiredHome 96:40b74dd3695b 2709 /// This method attaches a simple c-compatible callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 2710 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 2711 /// BMP file to be created is passed to this callback.
WiredHome 96:40b74dd3695b 2712 ///
WiredHome 123:2f45e80fec5f 2713 /// @param callback is the optional callback function. Without a callback function
WiredHome 123:2f45e80fec5f 2714 /// it will unregister the handler.
WiredHome 96:40b74dd3695b 2715 ///
WiredHome 123:2f45e80fec5f 2716 void AttachPrintHandler(PrintCallback_T callback = NULL) { c_callback = callback; }
WiredHome 96:40b74dd3695b 2717
WiredHome 125:7a0b70f56550 2718
WiredHome 96:40b74dd3695b 2719 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 2720 ///
WiredHome 96:40b74dd3695b 2721 /// This method attaches a c++ class method as a callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 2722 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 2723 /// BMP file to be created is passed to this callback.
WiredHome 96:40b74dd3695b 2724 ///
WiredHome 96:40b74dd3695b 2725 /// @param object is the class hosting the callback function.
WiredHome 102:fc60bfa0199f 2726 /// @param method is the callback method in the object to activate.
WiredHome 96:40b74dd3695b 2727 ///
WiredHome 96:40b74dd3695b 2728 template <class T>
WiredHome 102:fc60bfa0199f 2729 void AttachPrintHandler(T *object, RetCode_t (T::*method)(void)) {
WiredHome 102:fc60bfa0199f 2730 obj_callback = (FPointerDummy *)object;
WiredHome 108:7415c405ee08 2731 method_callback = (uint32_t (FPointerDummy::*)(uint32_t, uint8_t *, uint16_t))method;
WiredHome 96:40b74dd3695b 2732 }
WiredHome 96:40b74dd3695b 2733
WiredHome 125:7a0b70f56550 2734
WiredHome 72:ecffe56af969 2735 /// This method captures the specified area as a 24-bit bitmap file,
WiredHome 72:ecffe56af969 2736 /// including the option of layer selection.
WiredHome 72:ecffe56af969 2737 ///
WiredHome 125:7a0b70f56550 2738 /// @note This method is deprecated as the alternate PrintScreen API
WiredHome 74:686faa218914 2739 /// automatically examines the display layer configuration.
WiredHome 74:686faa218914 2740 /// Therefore, calls to this API will ignore the layer parameter
WiredHome 74:686faa218914 2741 /// and automatically execute the other method.
WiredHome 74:686faa218914 2742 ///
WiredHome 72:ecffe56af969 2743 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 2744 /// 24-bit format.
WiredHome 72:ecffe56af969 2745 ///
WiredHome 72:ecffe56af969 2746 /// @param[in] layer is 0 or 1 to select the layer to extract.
WiredHome 72:ecffe56af969 2747 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 2748 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 2749 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 2750 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 2751 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 72:ecffe56af969 2752 /// @return success or error code.
WiredHome 72:ecffe56af969 2753 ///
WiredHome 72:ecffe56af969 2754 RetCode_t PrintScreen(uint16_t layer, loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP);
WiredHome 125:7a0b70f56550 2755
WiredHome 72:ecffe56af969 2756
WiredHome 123:2f45e80fec5f 2757 /// idle callback registration.
WiredHome 123:2f45e80fec5f 2758 ///
WiredHome 125:7a0b70f56550 2759 /// This method attaches a simple c-compatible callback of type IdleCallback_T.
WiredHome 123:2f45e80fec5f 2760 /// Then, at any time when the display driver is waiting, it will call the
WiredHome 123:2f45e80fec5f 2761 /// registered function. This is probably most useful if you want to service
WiredHome 123:2f45e80fec5f 2762 /// a watchdog, when you may have called an API that will "hang" waiting
WiredHome 123:2f45e80fec5f 2763 /// on the user.
WiredHome 123:2f45e80fec5f 2764 ///
WiredHome 149:c62c4b2d6a15 2765 /// @code
WiredHome 149:c62c4b2d6a15 2766 /// RetCode_t myIdle_handler(RA8875::IdleReason_T reason, uint16_t param)
WiredHome 149:c62c4b2d6a15 2767 /// {
WiredHome 149:c62c4b2d6a15 2768 /// static uint16_t lastProgress = 0xFFFF;
WiredHome 149:c62c4b2d6a15 2769 ///
WiredHome 149:c62c4b2d6a15 2770 /// if (reason == RA8875::progress && param != lastProgress) {
WiredHome 149:c62c4b2d6a15 2771 /// printf("Progress %3d%%\r\n", param);
WiredHome 149:c62c4b2d6a15 2772 /// lastProgress = progress;
WiredHome 149:c62c4b2d6a15 2773 /// }
WiredHome 149:c62c4b2d6a15 2774 /// return noerror;
WiredHome 149:c62c4b2d6a15 2775 /// }
WiredHome 149:c62c4b2d6a15 2776 ///
WiredHome 149:c62c4b2d6a15 2777 /// ...
WiredHome 149:c62c4b2d6a15 2778 /// lcd.AttachIdleHandler(myIdle_handler);
WiredHome 149:c62c4b2d6a15 2779 /// ...
WiredHome 149:c62c4b2d6a15 2780 /// RetCode_t r = lcd.PrintScreen(0,0,LCD_W,LCD_H,"/local/print.bmp");
WiredHome 149:c62c4b2d6a15 2781 /// if (r ...)
WiredHome 149:c62c4b2d6a15 2782 /// @endcode
WiredHome 149:c62c4b2d6a15 2783 ///
WiredHome 149:c62c4b2d6a15 2784 ///
WiredHome 123:2f45e80fec5f 2785 /// @param callback is the idle callback function. Without a callback function
WiredHome 123:2f45e80fec5f 2786 /// it will unregister the handler.
WiredHome 123:2f45e80fec5f 2787 ///
WiredHome 123:2f45e80fec5f 2788 void AttachIdleHandler(IdleCallback_T callback = NULL) { idle_callback = callback; }
WiredHome 57:bd53a9e165a1 2789
WiredHome 133:e36dcfc2d756 2790
WiredHome 19:3f82c1161fd2 2791 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 2792 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 2793 void ClearPerformance();
WiredHome 19:3f82c1161fd2 2794
WiredHome 66:468a11f05580 2795 /// Count idle time.
WiredHome 66:468a11f05580 2796 ///
WiredHome 72:ecffe56af969 2797 /// @param[in] t is the amount of idle time to accumulate.
WiredHome 66:468a11f05580 2798 ///
WiredHome 66:468a11f05580 2799 void CountIdleTime(uint32_t t);
WiredHome 66:468a11f05580 2800
WiredHome 19:3f82c1161fd2 2801 /// Report the performance metrics for drawing functions using
WiredHome 41:2956a0a221e5 2802 /// the available serial channel.
WiredHome 41:2956a0a221e5 2803 ///
WiredHome 72:ecffe56af969 2804 /// @param[in,out] pc is the serial channel to write to.
WiredHome 41:2956a0a221e5 2805 ///
WiredHome 41:2956a0a221e5 2806 void ReportPerformance(Serial & pc);
WiredHome 19:3f82c1161fd2 2807 #endif
WiredHome 19:3f82c1161fd2 2808
hexley 54:e117ad10fba6 2809
WiredHome 19:3f82c1161fd2 2810 private:
WiredHome 124:1690a7ae871c 2811 /// Touch panel parameters - common to both resistive and capacitive
WiredHome 124:1690a7ae871c 2812
WiredHome 124:1690a7ae871c 2813 /// Data type to indicate which TP, if any, is in use.
WiredHome 124:1690a7ae871c 2814 typedef enum {
WiredHome 124:1690a7ae871c 2815 TP_NONE, ///< no touch panel in use
WiredHome 124:1690a7ae871c 2816 TP_RES, ///< resistive touch panel using RA8875
WiredHome 124:1690a7ae871c 2817 TP_CAP, ///< capacitive touch panel using FT5206
WiredHome 124:1690a7ae871c 2818 } WhichTP_T;
WiredHome 124:1690a7ae871c 2819
WiredHome 124:1690a7ae871c 2820 /// boolean flag set true when using Capacitive touch panel, and false
WiredHome 124:1690a7ae871c 2821 /// for resistive.
WiredHome 124:1690a7ae871c 2822 WhichTP_T useTouchPanel; ///< Indicates which TP is selected for use.
WiredHome 124:1690a7ae871c 2823
WiredHome 124:1690a7ae871c 2824 /// Touch State used by TouchPanelReadable. See @ref TouchCode_t.
WiredHome 124:1690a7ae871c 2825 TouchCode_t touchState;
WiredHome 124:1690a7ae871c 2826
WiredHome 124:1690a7ae871c 2827 ////////////////// Start of Capacitive Touch Panel parameters
WiredHome 124:1690a7ae871c 2828
WiredHome 124:1690a7ae871c 2829 uint8_t getTouchPositions(void);
WiredHome 124:1690a7ae871c 2830 void TouchPanelISR(void);
WiredHome 124:1690a7ae871c 2831 uint16_t numberOfTouchPoints;
WiredHome 124:1690a7ae871c 2832 uint8_t gesture; ///< Holds the reported gesture information.
WiredHome 124:1690a7ae871c 2833
WiredHome 124:1690a7ae871c 2834 /// Touch Information data structure
WiredHome 124:1690a7ae871c 2835 typedef struct {
WiredHome 124:1690a7ae871c 2836 uint8_t touchID; ///< Contains the touch ID, which is the "order" of touch, from 0 to n-1
WiredHome 124:1690a7ae871c 2837 TouchCode_t touchCode; ///< Contains the touch code; no_touch, touch, held, release
WiredHome 124:1690a7ae871c 2838 point_t coordinates; ///< Contains the X,Y coordinate of the touch
WiredHome 124:1690a7ae871c 2839 } touchInfo_T;
WiredHome 124:1690a7ae871c 2840
WiredHome 124:1690a7ae871c 2841 touchInfo_T touchInfo[5]; /// Contains the actual touch information in an array from 0 to n-1
WiredHome 124:1690a7ae871c 2842
WiredHome 155:b3f225ae572c 2843 #if MBED_VERSION >= MBED_ENCODE_VERSION(5,8,0)
WiredHome 155:b3f225ae572c 2844 Thread eventThread;
WiredHome 155:b3f225ae572c 2845 EventQueue queue;
WiredHome 155:b3f225ae572c 2846 #endif
WiredHome 124:1690a7ae871c 2847 InterruptIn * m_irq;
WiredHome 124:1690a7ae871c 2848 I2C * m_i2c;
WiredHome 124:1690a7ae871c 2849 int m_addr;
WiredHome 124:1690a7ae871c 2850 uint8_t data[2];
WiredHome 124:1690a7ae871c 2851
WiredHome 124:1690a7ae871c 2852 bool panelTouched;
WiredHome 124:1690a7ae871c 2853 void writeRegister8(uint8_t reg, uint8_t val);
WiredHome 124:1690a7ae871c 2854 uint8_t readRegister8(uint8_t reg);
WiredHome 124:1690a7ae871c 2855
WiredHome 124:1690a7ae871c 2856
WiredHome 124:1690a7ae871c 2857 ////////////////// Start of Resistive Touch Panel parameters
WiredHome 124:1690a7ae871c 2858
WiredHome 124:1690a7ae871c 2859 /// Resistive Touch Panel register name definitions
WiredHome 77:9206c13aa527 2860 #define TPCR0 0x70
WiredHome 77:9206c13aa527 2861 #define TPCR1 0x71
WiredHome 77:9206c13aa527 2862 #define TPXH 0x72
WiredHome 77:9206c13aa527 2863 #define TPYH 0x73
WiredHome 77:9206c13aa527 2864 #define TPXYL 0x74
WiredHome 77:9206c13aa527 2865 #define INTC1 0xF0
WiredHome 77:9206c13aa527 2866 #define INTC2 0xF1
hexley 54:e117ad10fba6 2867
hexley 54:e117ad10fba6 2868 /// Specify the default settings for the Touch Panel, where different from the chip defaults
WiredHome 77:9206c13aa527 2869 #define TP_MODE_DEFAULT TP_MODE_AUTO
WiredHome 77:9206c13aa527 2870 #define TP_DEBOUNCE_DEFAULT TP_DEBOUNCE_ON
WiredHome 77:9206c13aa527 2871 #define TP_ADC_CLKDIV_DEFAULT TP_ADC_CLKDIV_8
hexley 54:e117ad10fba6 2872
WiredHome 77:9206c13aa527 2873 #define TP_ADC_SAMPLE_DEFAULT_CLKS TP_ADC_SAMPLE_8192_CLKS
hexley 54:e117ad10fba6 2874
hexley 54:e117ad10fba6 2875 /// Other Touch Panel params
WiredHome 77:9206c13aa527 2876 #define TPBUFSIZE 16 // Depth of the averaging buffers for x and y data
hexley 54:e117ad10fba6 2877
WiredHome 83:7bad0068cca0 2878 // Needs both a ticker and a timer. (could have created a timer from the ticker, but this is easier).
WiredHome 83:7bad0068cca0 2879 // on a touch, the timer is reset.
WiredHome 83:7bad0068cca0 2880 // the ticker monitors the timer to see if it has been a long time since
WiredHome 83:7bad0068cca0 2881 // a touch, and if so, it then clears the sample counter so it doesn't get partial old
WiredHome 83:7bad0068cca0 2882 // and partial new.
WiredHome 83:7bad0068cca0 2883
WiredHome 83:7bad0068cca0 2884 /// Touch Panel ticker
WiredHome 83:7bad0068cca0 2885 Ticker touchTicker;
WiredHome 83:7bad0068cca0 2886
WiredHome 83:7bad0068cca0 2887 /// Touch Panel timer
WiredHome 83:7bad0068cca0 2888 Timer touchTimer;
WiredHome 83:7bad0068cca0 2889
WiredHome 83:7bad0068cca0 2890 /// keeps track of which sample we're collecting to filter out the noise.
WiredHome 83:7bad0068cca0 2891 int touchSample;
WiredHome 83:7bad0068cca0 2892
WiredHome 83:7bad0068cca0 2893 /// Private function for touch ticker callback.
WiredHome 83:7bad0068cca0 2894 void _TouchTicker(void);
WiredHome 83:7bad0068cca0 2895
WiredHome 77:9206c13aa527 2896 /// Touch Panel calibration matrix.
WiredHome 77:9206c13aa527 2897 tpMatrix_t tpMatrix;
hexley 54:e117ad10fba6 2898
WiredHome 157:1565f38ca44b 2899 /// RESISTIVE TP: The fully qualified filename for the RESISTIVE touch panel configuration settings.
WiredHome 157:1565f38ca44b 2900 const char * tpFQFN;
WiredHome 157:1565f38ca44b 2901
WiredHome 157:1565f38ca44b 2902 /// RESISTIVE TP: The text message shown to the user during the calibration process.
WiredHome 157:1565f38ca44b 2903 const char * tpCalMessage;
WiredHome 157:1565f38ca44b 2904
WiredHome 157:1565f38ca44b 2905 /// Internal method that performs the TS Cal when the user has so-configured it
WiredHome 157:1565f38ca44b 2906 RetCode_t _internal_ts_cal();
WiredHome 157:1565f38ca44b 2907
WiredHome 157:1565f38ca44b 2908
WiredHome 124:1690a7ae871c 2909 ////////////////// End of Touch Panel parameters
WiredHome 124:1690a7ae871c 2910
WiredHome 124:1690a7ae871c 2911
WiredHome 29:422616aa04bd 2912 /// Internal function to put a character using the built-in (internal) font engine
WiredHome 29:422616aa04bd 2913 ///
WiredHome 101:e0aad446094a 2914 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 2915 /// @returns the character put.
WiredHome 29:422616aa04bd 2916 ///
WiredHome 29:422616aa04bd 2917 int _internal_putc(int c);
WiredHome 29:422616aa04bd 2918
WiredHome 29:422616aa04bd 2919 /// Internal function to put a character using the external font engine
WiredHome 29:422616aa04bd 2920 ///
WiredHome 101:e0aad446094a 2921 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 2922 /// @returns the character put.
WiredHome 29:422616aa04bd 2923 ///
WiredHome 29:422616aa04bd 2924 int _external_putc(int c);
WiredHome 29:422616aa04bd 2925
WiredHome 101:e0aad446094a 2926 /// Internal function to get the actual width of a character when using the external font engine
WiredHome 101:e0aad446094a 2927 ///
WiredHome 101:e0aad446094a 2928 /// @param[in] c is the character to get the width.
WiredHome 101:e0aad446094a 2929 /// @returns the width in pixels of the character. zero if not found.
WiredHome 101:e0aad446094a 2930 ///
WiredHome 101:e0aad446094a 2931 int _external_getCharWidth(int c);
WiredHome 101:e0aad446094a 2932
WiredHome 133:e36dcfc2d756 2933 /// Write color to an RGB register set
WiredHome 133:e36dcfc2d756 2934 ///
WiredHome 133:e36dcfc2d756 2935 /// This API takes a color value, and writes it into the specified
WiredHome 133:e36dcfc2d756 2936 /// color registers, which are a trio of 3 registers. The actual
WiredHome 133:e36dcfc2d756 2937 /// trio write is performed based on whether the display is configured
WiredHome 133:e36dcfc2d756 2938 /// for 8 or 16 bits per pixel.
WiredHome 133:e36dcfc2d756 2939 ///
WiredHome 133:e36dcfc2d756 2940 /// @param[in] regAddr is the register address starting the trio
WiredHome 133:e36dcfc2d756 2941 /// @param[in] color is the color to write
WiredHome 133:e36dcfc2d756 2942 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 133:e36dcfc2d756 2943 ///
WiredHome 133:e36dcfc2d756 2944 RetCode_t _writeColorTrio(uint8_t regAddr, color_t color);
WiredHome 133:e36dcfc2d756 2945
WiredHome 133:e36dcfc2d756 2946 /// Read color from an RGB register set
WiredHome 133:e36dcfc2d756 2947 ///
WiredHome 133:e36dcfc2d756 2948 /// This API reads a color value from a trio of registers. The actual
WiredHome 133:e36dcfc2d756 2949 /// trio write is performed based on whether the display is configured
WiredHome 133:e36dcfc2d756 2950 /// for 8 or 16 bits per pixel.
WiredHome 133:e36dcfc2d756 2951 ///
WiredHome 133:e36dcfc2d756 2952 /// @param[in] regAddr is the register address starting the trio
WiredHome 133:e36dcfc2d756 2953 /// @returns color_t value
WiredHome 133:e36dcfc2d756 2954 ///
WiredHome 133:e36dcfc2d756 2955 color_t _readColorTrio(uint8_t regAddr);
WiredHome 133:e36dcfc2d756 2956
WiredHome 133:e36dcfc2d756 2957
WiredHome 105:4f116006ba1f 2958 /// Convert a 16-bit color value to an 8-bit value
WiredHome 105:4f116006ba1f 2959 ///
WiredHome 105:4f116006ba1f 2960 /// @param[in] c16 is the 16-bit color value to convert.
WiredHome 105:4f116006ba1f 2961 /// @returns 8-bit color value.
WiredHome 105:4f116006ba1f 2962 ///
WiredHome 105:4f116006ba1f 2963 uint8_t _cvt16to8(color_t c16);
WiredHome 105:4f116006ba1f 2964
WiredHome 105:4f116006ba1f 2965 /// Convert an 8-bit color value to a 16-bit value
WiredHome 105:4f116006ba1f 2966 ///
WiredHome 105:4f116006ba1f 2967 /// @param[in] c8 is the 8-bit color value to convert.
WiredHome 105:4f116006ba1f 2968 /// @returns 16-bit color value.
WiredHome 105:4f116006ba1f 2969 ///
WiredHome 105:4f116006ba1f 2970 color_t _cvt8to16(uint8_t c8);
WiredHome 105:4f116006ba1f 2971
WiredHome 19:3f82c1161fd2 2972 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 2973 ///
WiredHome 72:ecffe56af969 2974 /// @param[in] chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 2975 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 2976 /// the pin selection is the invert of this.
WiredHome 106:c80828f5dea4 2977 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 19:3f82c1161fd2 2978 ///
WiredHome 79:544eb4964795 2979 RetCode_t _select(bool chipsel);
WiredHome 19:3f82c1161fd2 2980
WiredHome 66:468a11f05580 2981 /// Wait while the status register indicates the controller is busy.
WiredHome 66:468a11f05580 2982 ///
WiredHome 72:ecffe56af969 2983 /// @param[in] mask is the mask of bits to monitor.
WiredHome 66:468a11f05580 2984 /// @returns true if a normal exit.
WiredHome 66:468a11f05580 2985 /// @returns false if a timeout exit.
WiredHome 66:468a11f05580 2986 ///
WiredHome 66:468a11f05580 2987 bool _WaitWhileBusy(uint8_t mask);
WiredHome 66:468a11f05580 2988
WiredHome 66:468a11f05580 2989 /// Wait while the the register anded with the mask is true.
WiredHome 66:468a11f05580 2990 ///
WiredHome 72:ecffe56af969 2991 /// @param[in] reg is the register to monitor
WiredHome 72:ecffe56af969 2992 /// @param[in] mask is the bit mask to monitor
WiredHome 66:468a11f05580 2993 /// @returns true if it was a normal exit
WiredHome 66:468a11f05580 2994 /// @returns false if it was a timeout that caused the exit.
WiredHome 66:468a11f05580 2995 ///
WiredHome 66:468a11f05580 2996 bool _WaitWhileReg(uint8_t reg, uint8_t mask);
WiredHome 66:468a11f05580 2997
WiredHome 68:ab08efabfc88 2998 /// set the spi port to either the write or the read speed.
WiredHome 68:ab08efabfc88 2999 ///
WiredHome 68:ab08efabfc88 3000 /// This is a private API used to toggle between the write
WiredHome 68:ab08efabfc88 3001 /// and the read speed for the SPI port to the RA8875, since
WiredHome 68:ab08efabfc88 3002 /// it can accept writes faster than reads.
WiredHome 68:ab08efabfc88 3003 ///
WiredHome 72:ecffe56af969 3004 /// @param[in] writeSpeed when true selects the write frequency,
WiredHome 68:ab08efabfc88 3005 /// and when false it selects the read frequency.
WiredHome 68:ab08efabfc88 3006 ///
WiredHome 68:ab08efabfc88 3007 void _setWriteSpeed(bool writeSpeed);
WiredHome 68:ab08efabfc88 3008
WiredHome 19:3f82c1161fd2 3009 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 3010 ///
WiredHome 72:ecffe56af969 3011 /// @param[in] data is the value to write.
WiredHome 19:3f82c1161fd2 3012 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 3013 /// in while shifting out.
WiredHome 19:3f82c1161fd2 3014 ///
WiredHome 79:544eb4964795 3015 unsigned char _spiwrite(unsigned char data);
WiredHome 19:3f82c1161fd2 3016
WiredHome 19:3f82c1161fd2 3017 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 3018 ///
WiredHome 19:3f82c1161fd2 3019 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 3020 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 3021 ///
WiredHome 19:3f82c1161fd2 3022 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 3023 /// in while shifting out.
WiredHome 19:3f82c1161fd2 3024 ///
WiredHome 79:544eb4964795 3025 unsigned char _spiread();
WiredHome 19:3f82c1161fd2 3026
WiredHome 75:ca78388cfd77 3027 const uint8_t * pKeyMap;
WiredHome 75:ca78388cfd77 3028
WiredHome 19:3f82c1161fd2 3029 SPI spi; ///< spi port
WiredHome 68:ab08efabfc88 3030 bool spiWriteSpeed; ///< indicates if the current mode is write or read
WiredHome 68:ab08efabfc88 3031 unsigned long spiwritefreq; ///< saved write freq
WiredHome 66:468a11f05580 3032 unsigned long spireadfreq; ///< saved read freq
WiredHome 19:3f82c1161fd2 3033 DigitalOut cs; ///< chip select pin, assumed active low
WiredHome 19:3f82c1161fd2 3034 DigitalOut res; ///< reset pin, assumed active low
WiredHome 90:d113d71ae4f0 3035
WiredHome 105:4f116006ba1f 3036 // display metrics to avoid lengthy spi read queries
WiredHome 105:4f116006ba1f 3037 uint8_t screenbpp; ///< configured bits per pixel
WiredHome 90:d113d71ae4f0 3038 dim_t screenwidth; ///< configured screen width
WiredHome 90:d113d71ae4f0 3039 dim_t screenheight; ///< configured screen height
WiredHome 111:efe436c43aba 3040 rect_t windowrect; ///< window commands are held here for speed of access
WiredHome 90:d113d71ae4f0 3041 bool portraitmode; ///< set true when in portrait mode (w,h are reversed)
WiredHome 90:d113d71ae4f0 3042
WiredHome 19:3f82c1161fd2 3043 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 98:ecebed9b80b2 3044 uint8_t extFontHeight; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 3045 uint8_t extFontWidth; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 3046
WiredHome 90:d113d71ae4f0 3047 loc_t cursor_x, cursor_y; ///< used for external fonts only
WiredHome 19:3f82c1161fd2 3048
WiredHome 19:3f82c1161fd2 3049 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 3050 typedef enum
WiredHome 19:3f82c1161fd2 3051 {
WiredHome 19:3f82c1161fd2 3052 PRF_CLS,
WiredHome 41:2956a0a221e5 3053 PRF_DRAWPIXEL,
WiredHome 41:2956a0a221e5 3054 PRF_PIXELSTREAM,
WiredHome 109:7b94f06f085b 3055 PRF_BOOLSTREAM,
WiredHome 41:2956a0a221e5 3056 PRF_READPIXEL,
WiredHome 41:2956a0a221e5 3057 PRF_READPIXELSTREAM,
WiredHome 19:3f82c1161fd2 3058 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 3059 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 3060 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 3061 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 3062 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 3063 PRF_DRAWELLIPSE,
WiredHome 131:5bd6ba2ee4a1 3064 PRF_BLOCKMOVE,
WiredHome 19:3f82c1161fd2 3065 METRICCOUNT
WiredHome 19:3f82c1161fd2 3066 } method_e;
WiredHome 19:3f82c1161fd2 3067 unsigned long metrics[METRICCOUNT];
WiredHome 75:ca78388cfd77 3068 unsigned long idletime_usec;
WiredHome 19:3f82c1161fd2 3069 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 3070 Timer performance;
WiredHome 19:3f82c1161fd2 3071 #endif
WiredHome 96:40b74dd3695b 3072
WiredHome 96:40b74dd3695b 3073 RetCode_t _printCallback(RA8875::filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 3074
WiredHome 96:40b74dd3695b 3075 FILE * _printFH; ///< PrintScreen file handle
WiredHome 96:40b74dd3695b 3076
WiredHome 96:40b74dd3695b 3077 RetCode_t privateCallback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 3078 if (c_callback != NULL) {
WiredHome 96:40b74dd3695b 3079 return (*c_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 3080 }
WiredHome 96:40b74dd3695b 3081 else {
WiredHome 96:40b74dd3695b 3082 if (obj_callback != NULL && method_callback != NULL) {
WiredHome 96:40b74dd3695b 3083 return (obj_callback->*method_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 3084 }
WiredHome 96:40b74dd3695b 3085 }
WiredHome 96:40b74dd3695b 3086 return noerror;
WiredHome 96:40b74dd3695b 3087 }
WiredHome 96:40b74dd3695b 3088
WiredHome 96:40b74dd3695b 3089 RetCode_t (* c_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 3090 FPointerDummy *obj_callback;
WiredHome 96:40b74dd3695b 3091 RetCode_t (FPointerDummy::*method_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 149:c62c4b2d6a15 3092 RetCode_t (* idle_callback)(IdleReason_T reason, uint16_t param);
WiredHome 19:3f82c1161fd2 3093 };
WiredHome 19:3f82c1161fd2 3094
WiredHome 96:40b74dd3695b 3095
WiredHome 19:3f82c1161fd2 3096 //} // namespace
WiredHome 19:3f82c1161fd2 3097
WiredHome 19:3f82c1161fd2 3098 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 3099
WiredHome 23:a50ded45dbaf 3100
WiredHome 23:a50ded45dbaf 3101 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 3102 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 3103 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 3104 // / / / / / / / /
WiredHome 23:a50ded45dbaf 3105 // / / / /___ / /__________ / /
WiredHome 23:a50ded45dbaf 3106 // / / / ____/ /__________ / / /
WiredHome 23:a50ded45dbaf 3107 // / / / / / / / /
WiredHome 23:a50ded45dbaf 3108 // / / / /__________ ___________/ / / /
WiredHome 23:a50ded45dbaf 3109 // /__/ /_____________/ /_____________/ /__/
WiredHome 23:a50ded45dbaf 3110
WiredHome 23:a50ded45dbaf 3111 #include "WebColors.h"
WiredHome 23:a50ded45dbaf 3112 #include <algorithm>
WiredHome 23:a50ded45dbaf 3113
WiredHome 23:a50ded45dbaf 3114 extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 3115
WiredHome 23:a50ded45dbaf 3116 /// This activates a small set of tests for the graphics library.
WiredHome 23:a50ded45dbaf 3117 ///
WiredHome 23:a50ded45dbaf 3118 /// Call this API and pass it the reference to the display class.
WiredHome 23:a50ded45dbaf 3119 /// It will then run a series of tests. It accepts interaction via
WiredHome 23:a50ded45dbaf 3120 /// stdin to switch from automatic test mode to manual, run a specific
WiredHome 23:a50ded45dbaf 3121 /// test, or to exit the test mode.
WiredHome 23:a50ded45dbaf 3122 ///
WiredHome 72:ecffe56af969 3123 /// @param[in] lcd is a reference to the display class.
WiredHome 72:ecffe56af969 3124 /// @param[in] pc is a reference to a serial interface, typically the USB to PC.
WiredHome 23:a50ded45dbaf 3125 ///
WiredHome 23:a50ded45dbaf 3126 void RunTestSet(RA8875 & lcd, Serial & pc);
WiredHome 23:a50ded45dbaf 3127
WiredHome 23:a50ded45dbaf 3128
WiredHome 23:a50ded45dbaf 3129 // To enable the test code, uncomment this section, or copy the
WiredHome 23:a50ded45dbaf 3130 // necessary pieces to your "main()".
WiredHome 23:a50ded45dbaf 3131 //
WiredHome 23:a50ded45dbaf 3132 // #include "mbed.h"
WiredHome 23:a50ded45dbaf 3133 // #include "RA8875.h"
WiredHome 23:a50ded45dbaf 3134 // RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 23:a50ded45dbaf 3135 // Serial pc(USBTX, USBRX);
WiredHome 23:a50ded45dbaf 3136 // extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 3137 // int main()
WiredHome 23:a50ded45dbaf 3138 // {
WiredHome 23:a50ded45dbaf 3139 // pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 23:a50ded45dbaf 3140 // pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 23:a50ded45dbaf 3141 //
WiredHome 23:a50ded45dbaf 3142 // pc.printf("Turning on display\r\n");
WiredHome 101:e0aad446094a 3143 // lcd.init();
WiredHome 23:a50ded45dbaf 3144 // lcd.Reset();
WiredHome 23:a50ded45dbaf 3145 // lcd.Power(true); // display power is on, but the backlight is independent
WiredHome 23:a50ded45dbaf 3146 // lcd.Backlight(0.5);
WiredHome 23:a50ded45dbaf 3147 // RunTestSet(lcd, pc);
WiredHome 23:a50ded45dbaf 3148 // }
WiredHome 23:a50ded45dbaf 3149
WiredHome 23:a50ded45dbaf 3150 #endif // TESTENABLE
WiredHome 23:a50ded45dbaf 3151
WiredHome 56:7a85d226ad0d 3152 #endif