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:
Mon May 25 16:08:50 2020 +0000
Revision:
206:83edda283d90
Parent:
203:704df2dbd3e6
Child:
207:82f336e5c021
Pick up a change in the touch ISR to pick up the final release.

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 198:9b6851107426 5 /// can support displays up to 800 x 480 pixels x 16-bit color and has an integrated
WiredHome 198:9b6851107426 6 /// 2D graphics engine which significantly unburdens the hosting cpu. The 2D engine
WiredHome 198:9b6851107426 7 /// handles many drawing primitives; such as line, rectangle, triangle, circles, and
WiredHome 198:9b6851107426 8 /// each either filled or unfilled. Further, it supports fonts - both internal and
WiredHome 198:9b6851107426 9 /// with specific formats of external font roms.
WiredHome 167:8aa3fb2a5a31 10 ///
WiredHome 182:8832d03a2a29 11 /// @image html Example_Program.png "Image of an Example Program"
WiredHome 182:8832d03a2a29 12 ///
WiredHome 198:9b6851107426 13 /// In more detail:
WiredHome 198:9b6851107426 14 ///
WiredHome 190:3132b7dfad82 15 /// Aside from 800 x 480 pixel displays, another common implementation is
WiredHome 190:3132b7dfad82 16 /// 480 x 272 x 16 with two layers. The two layers can be exchanged, or blended
WiredHome 198:9b6851107426 17 /// in various ways (transparency, OR, AND, and more).
WiredHome 167:8aa3fb2a5a31 18 ///
WiredHome 190:3132b7dfad82 19 /// It is not a display for video-speed animations, and maybe could hold its own
WiredHome 198:9b6851107426 20 /// as a slow picture frame, at least when using the SPI interface. How the
WiredHome 198:9b6851107426 21 /// performance differs using I2C, 8-bit parallel or 16-bit parallel has not
WiredHome 198:9b6851107426 22 /// been evaluated. Certainly the parallel interface option would be expected to be
WiredHome 198:9b6851107426 23 /// a lot faster.
WiredHome 167:8aa3fb2a5a31 24 ///
WiredHome 198:9b6851107426 25 /// What it is good at is performing as a basic display for appliances or simple
WiredHome 190:3132b7dfad82 26 /// home automation, and because of the built-in capability to draw lines, circles,
WiredHome 190:3132b7dfad82 27 /// ellipses, rectangles, rounded rectangles, and triangles, it does a lot of the
WiredHome 167:8aa3fb2a5a31 28 /// work that your host micro would otherwise be doing, and in many cases it does
WiredHome 167:8aa3fb2a5a31 29 /// it much faster.
WiredHome 78:faf49c381591 30 ///
WiredHome 167:8aa3fb2a5a31 31 /// While it is good to know about Bresenham's algorithm (to draw a line) and how
WiredHome 190:3132b7dfad82 32 /// to implement it in software, this controller simplifies things -
WiredHome 190:3132b7dfad82 33 /// You just give it (x1,y1), (x2,y2) and tell it to draw a line.
WiredHome 167:8aa3fb2a5a31 34 /// Without the hardware acceleration built into the RA8875, the host would have to
WiredHome 167:8aa3fb2a5a31 35 /// compute every point, set the graphics cursor to that point, and fill in that
WiredHome 167:8aa3fb2a5a31 36 /// point with the target color. A diagonal line of some length might take 100
WiredHome 198:9b6851107426 37 /// transactions instead of just a few. Other drawing primitives are similarly easy.
WiredHome 167:8aa3fb2a5a31 38 ///
WiredHome 190:3132b7dfad82 39 /// It has some built-in fonts, which can be enhanced with optional font-chips, and
WiredHome 198:9b6851107426 40 /// with the software font engine that is part of this library. Instructions are provided
WiredHome 198:9b6851107426 41 /// to convert most any True Type Font into the data structures suitable for this display.
WiredHome 198:9b6851107426 42 /// The user of this library is expected to respect the copyright of those fonts (there
WiredHome 198:9b6851107426 43 /// are open-source fonts that can be found on the web).
WiredHome 167:8aa3fb2a5a31 44 ///
WiredHome 167:8aa3fb2a5a31 45 /// To round out the features, this library offers the ability to render Bitmap (BMP),
WiredHome 198:9b6851107426 46 /// Icon (ICO), Joint Photographic Experts Group (JPG), and Graphics Interchange Format
WiredHome 190:3132b7dfad82 47 /// (GIF) images. These are implemented primarily in software, taking advantage of the
WiredHome 198:9b6851107426 48 /// hardware acceleration where it can. There are some limitations, based on available
WiredHome 198:9b6851107426 49 /// memory.
WiredHome 167:8aa3fb2a5a31 50 ///
WiredHome 190:3132b7dfad82 51 /// When you are satisfied with what appears on screen, there is a PrintScreen method
WiredHome 198:9b6851107426 52 /// to pull that image back out of the display RAM and write it to a file system as a
WiredHome 198:9b6851107426 53 /// BitMap image.
WiredHome 198:9b6851107426 54 ///
WiredHome 198:9b6851107426 55 ///
WiredHome 198:9b6851107426 56 /// The RA8875 has an integrated PWM, commonly used for backlight brightness, keypad scanning
WiredHome 198:9b6851107426 57 /// (for a 4 x 5 matrix) and an integrated resistive touch-panel support. Support for capacitive
WiredHome 198:9b6851107426 58 /// touch screens is also integrated in this library, in a manner that makes the resistive and
WiredHome 198:9b6851107426 59 /// capacitive interfaces nearly API identical. The capacitive touch support was crafted to
WiredHome 198:9b6851107426 60 /// interface with either the FT5206 or the GSL1680 controller chips (two popular controllers
WiredHome 198:9b6851107426 61 /// commonly integrated with the RA8875).
WiredHome 101:e0aad446094a 62 ///
WiredHome 198:9b6851107426 63 /// Recent Changes:
WiredHome 198:9b6851107426 64 /// * @ref RA8875::SelectDrawingLayer() returns the previously selected layer, making restore quicker.
WiredHome 198:9b6851107426 65 /// * @ref RA8875::SetGraphicsOrientation() has been improved to support 0 deg (typical landscape),
WiredHome 198:9b6851107426 66 /// 90 deg, 180 deg, and 270 deg, and this includes bitmap and soft-font presentation,
WiredHome 198:9b6851107426 67 /// as well as touch support and to return the previous angle.
WiredHome 198:9b6851107426 68 /// * @ref RA8875::SetBackgroundTransparencyColor() returns the previous color value, making
WiredHome 198:9b6851107426 69 /// restore quicker.
WiredHome 198:9b6851107426 70 /// * @ref RA8875::SetWindow() accepts a rect_t, or an (x1,y1, x2,y2) point-pair, rather than a
WiredHome 198:9b6851107426 71 /// point-pair and a width,height. This makes it much more consisten with all other APIs.
WiredHome 198:9b6851107426 72 /// * @ref RA8875::SetLayerMode() returns the previous layer mode.
WiredHome 198:9b6851107426 73 /// * @ref RA8875::SetTextCursor() returns the previous cursor.
WiredHome 198:9b6851107426 74 /// * @ref RA8875::background() returns the previous color.
WiredHome 198:9b6851107426 75 /// * @ref RA8875::foreground() returns the previous color.
WiredHome 198:9b6851107426 76
WiredHome 167:8aa3fb2a5a31 77 /// Here's a few hints to get started:
WiredHome 167:8aa3fb2a5a31 78 /// * @ref Display_Config
WiredHome 167:8aa3fb2a5a31 79 /// * @ref Touch_Panel
WiredHome 167:8aa3fb2a5a31 80 /// * @ref Hardwired_KeyPad
WiredHome 167:8aa3fb2a5a31 81 /// * @ref Example_Program
WiredHome 167:8aa3fb2a5a31 82 /// * @ref Wiring_Diagram
WiredHome 182:8832d03a2a29 83 /// * @ref External_Resources
WiredHome 167:8aa3fb2a5a31 84 /// * @ref Future_Plans
WiredHome 167:8aa3fb2a5a31 85 ///
WiredHome 198:9b6851107426 86 /// @todo Integrate the touch as a runtime linkable feature, which can then eliminate
WiredHome 198:9b6851107426 87 /// the huge memory footprint for the GSL1680 firmware when it is not needed.
WiredHome 196:56820026701b 88 /// @todo Move the global enums into the class (e.g. NOFILL becomes RA8875::NOFILL) to
WiredHome 196:56820026701b 89 /// avoid namespace clashes.
WiredHome 198:9b6851107426 90 /// @todo Integrate access to an installed font-rom.
WiredHome 167:8aa3fb2a5a31 91 /// @todo Figure out how to "init()" in the constructor. I ran into some issues if
WiredHome 167:8aa3fb2a5a31 92 /// the display was instantiated before main(), and the code would not run,
WiredHome 167:8aa3fb2a5a31 93 /// thus the exposure and activation of the init() function. If the constructor
WiredHome 167:8aa3fb2a5a31 94 /// was within main(), then it seemed to work as expected.
WiredHome 198:9b6851107426 95 /// @todo Add Scroll support for text in a window.
WiredHome 198:9b6851107426 96 /// @todo Add Hardware reset signal - testing to date indicates it is not needed.
WiredHome 196:56820026701b 97 /// @todo Add APIs for the 2nd RA8875 PWM channel. If the frequency can be independently
WiredHome 198:9b6851107426 98 /// controlled, it could be used as a simple sound channel (beeper).
WiredHome 198:9b6851107426 99 /// @todo Find out if 4-wire SPI can leverage 16-bit mode, and if so, how does the
WiredHome 198:9b6851107426 100 /// performance change?
WiredHome 78:faf49c381591 101 ///
WiredHome 167:8aa3fb2a5a31 102 /// @note As the author of this library, let me state that I am not affiliated with
WiredHome 190:3132b7dfad82 103 /// Raio (silicon provider of the RA8875), or with BuyDisplay.com (where a lot
WiredHome 190:3132b7dfad82 104 /// of these displays can be purchased), I am simply a very satisfied customer
WiredHome 167:8aa3fb2a5a31 105 /// of the technology of the RA8875 chip.
WiredHome 167:8aa3fb2a5a31 106 ///
WiredHome 196:56820026701b 107 /// @copyright Copyright © 2012-2020 by Smartware Computing, all rights reserved.
WiredHome 198:9b6851107426 108 /// This library is predominantly that of Smartware Computing, however some
WiredHome 198:9b6851107426 109 /// portions integrate the work of others. Where the contribution of
WiredHome 190:3132b7dfad82 110 /// others was listed as copyright, that copyright is maintained, even as a
WiredHome 167:8aa3fb2a5a31 111 /// derivative work may have been created for better integration in this library.
WiredHome 167:8aa3fb2a5a31 112 /// See @ref Copyright_References.
WiredHome 167:8aa3fb2a5a31 113 ///
WiredHome 167:8aa3fb2a5a31 114 /// @page Copyright_References Copyright References
WiredHome 190:3132b7dfad82 115 ///
WiredHome 167:8aa3fb2a5a31 116 /// Following are links to the known copyright references. If I overlooked any, it was
WiredHome 167:8aa3fb2a5a31 117 /// unintentional - please let me know so I can update it. Some portions of the code
WiredHome 167:8aa3fb2a5a31 118 /// have been acquired from the cloud, and where any copyright information was available,
WiredHome 167:8aa3fb2a5a31 119 /// it was preserved.
WiredHome 167:8aa3fb2a5a31 120 ///
WiredHome 167:8aa3fb2a5a31 121 /// * @ref GraphicDisplay_Copyright
WiredHome 167:8aa3fb2a5a31 122 /// * @ref TextDisplay_Copyright
WiredHome 167:8aa3fb2a5a31 123 /// * @ref TinyJPEGDecompressor_Copyright
WiredHome 167:8aa3fb2a5a31 124 /// * @ref RA8875::TouchPanelComputeCalibration
WiredHome 167:8aa3fb2a5a31 125 ///
WiredHome 167:8aa3fb2a5a31 126 /// @page Display_Config Display Configuration
WiredHome 78:faf49c381591 127 ///
WiredHome 78:faf49c381591 128 /// This section details basics for bringing the display online. At a minimum,
WiredHome 167:8aa3fb2a5a31 129 /// the display is instantiated, after which nearly any of the available commands
WiredHome 78:faf49c381591 130 /// may be issued.
WiredHome 78:faf49c381591 131 ///
WiredHome 182:8832d03a2a29 132 /// @image html RA8875_Display.png "Schematic Representation of the Display"
WiredHome 182:8832d03a2a29 133 ///
WiredHome 78:faf49c381591 134 /// During the instantiation, the display is powered on, cleared, and the backlight
WiredHome 78:faf49c381591 135 /// is energized. Additionally, the keypad and touchscreen features are activated.
WiredHome 190:3132b7dfad82 136 /// It is important to keep in mind that the keypad has its default mapping,
WiredHome 190:3132b7dfad82 137 /// a resistive touchscreen does not yet have the calibration matrix configured,
WiredHome 167:8aa3fb2a5a31 138 /// and the RA8875::init() function is required to configure other important options
WiredHome 167:8aa3fb2a5a31 139 /// like the display resolution.
WiredHome 190:3132b7dfad82 140 ///
WiredHome 190:3132b7dfad82 141 /// @code
WiredHome 78:faf49c381591 142 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 81:01da2e34283d 143 /// lcd.init();
WiredHome 78:faf49c381591 144 /// lcd.foreground(Blue);
WiredHome 78:faf49c381591 145 /// lcd.line(0,0, 479,271);
WiredHome 78:faf49c381591 146 /// ...
WiredHome 78:faf49c381591 147 /// @endcode
WiredHome 78:faf49c381591 148 ///
WiredHome 167:8aa3fb2a5a31 149 /// @section RA8875_Capabilities Basic Capabilities
WiredHome 167:8aa3fb2a5a31 150 /// @subsection RA8875_Resolution Display Resolution
WiredHome 167:8aa3fb2a5a31 151 /// There are two very common display resolutions that use the RA8875:
WiredHome 167:8aa3fb2a5a31 152 /// * 480 x 272 pixels
WiredHome 167:8aa3fb2a5a31 153 /// * 800 x 480 pixels
WiredHome 167:8aa3fb2a5a31 154 ///
WiredHome 167:8aa3fb2a5a31 155 /// @subsection RA8875_Layers Display Layers
WiredHome 190:3132b7dfad82 156 /// The RA8875 Controller, depending on the resolution and color depth, can support
WiredHome 167:8aa3fb2a5a31 157 /// multiple display layers.
WiredHome 167:8aa3fb2a5a31 158 ///
WiredHome 167:8aa3fb2a5a31 159 /// * 1 Layer - when the color depth is 16 bits per pixel
WiredHome 167:8aa3fb2a5a31 160 /// * 2 Layers - when the color depth is 8 bits per pixel and the resolution is 480 x 272.
WiredHome 78:faf49c381591 161 ///
WiredHome 167:8aa3fb2a5a31 162 /// @page Touch_Panel Touch Panel
WiredHome 167:8aa3fb2a5a31 163 ///
WiredHome 167:8aa3fb2a5a31 164 /// There is support for various touch panel interfaces.
WiredHome 190:3132b7dfad82 165 /// * @ref Resistive_Touch_Panel - native control for a resistive touch panel.
WiredHome 167:8aa3fb2a5a31 166 /// There are a few steps to enable this interface.
WiredHome 182:8832d03a2a29 167 ///
WiredHome 182:8832d03a2a29 168 /// For the Capacitive Touch controllers, an I2C interface is required.
WiredHome 182:8832d03a2a29 169 ///
WiredHome 182:8832d03a2a29 170 /// @image html RA8875_Touch.png "Schematic Representation of the Touch Interface"
WiredHome 182:8832d03a2a29 171 ///
WiredHome 190:3132b7dfad82 172 /// * @ref CapSense_FT5206 - FT5206 capacitive touch controller, integrated in
WiredHome 167:8aa3fb2a5a31 173 /// several popular RA8875-based displays. See @ref Capacitive_Touch_Panel.
WiredHome 190:3132b7dfad82 174 /// * @ref CapSense_GSL1680 - GSL1680 capacitive touch controller, integrated in
WiredHome 167:8aa3fb2a5a31 175 /// several popular RA8875-based displays. See @ref Capacitive_Touch_Panel.
WiredHome 167:8aa3fb2a5a31 176 ///
WiredHome 182:8832d03a2a29 177 /// @page MicroSD_Interface Micro SD Interface
WiredHome 182:8832d03a2a29 178 ///
WiredHome 182:8832d03a2a29 179 /// Several of the displays from BuyDisplay.com include the option for a Micro SD
WiredHome 182:8832d03a2a29 180 /// card adapter. This is not tied in to the RA8875 controller, it is just provided
WiredHome 182:8832d03a2a29 181 /// as a convenience to the display product.
WiredHome 182:8832d03a2a29 182 ///
WiredHome 182:8832d03a2a29 183 /// @image html RA8875_MicroSD.png "Schematic Representation of the Micro SD Interface"
WiredHome 78:faf49c381591 184 ///
WiredHome 167:8aa3fb2a5a31 185 ///
WiredHome 167:8aa3fb2a5a31 186 /// @page Hardwired_KeyPad Hardwired Keypad
WiredHome 167:8aa3fb2a5a31 187 ///
WiredHome 167:8aa3fb2a5a31 188 /// The RA8875 controller supports a hardwired matrix of keys, which can be used to
WiredHome 167:8aa3fb2a5a31 189 /// easily monitor for up to 20 keys (4 x 5 matrix). It is quite flexible, so these
WiredHome 190:3132b7dfad82 190 /// could be a set of independent functions, or they could be wired as a simple
WiredHome 167:8aa3fb2a5a31 191 /// calculator or telephone style of keypad.
WiredHome 167:8aa3fb2a5a31 192 ///
WiredHome 182:8832d03a2a29 193 /// @image html RA8875_Keypad.png "Schematic Representation of the Keypad Interface"
WiredHome 182:8832d03a2a29 194 ///
WiredHome 167:8aa3fb2a5a31 195 /// Various parameters can be configured, such as the scan rate, using @ref RA8875::KeypadInit().
WiredHome 167:8aa3fb2a5a31 196 /// The keypad has a default keypad mapping, but there is an API that permits
WiredHome 167:8aa3fb2a5a31 197 /// installing a custom @ref RA8875::SetKeyMap().
WiredHome 78:faf49c381591 198 ///
WiredHome 167:8aa3fb2a5a31 199 /// @page Resistive_Touch_Panel Resistive Touch Panel
WiredHome 167:8aa3fb2a5a31 200 ///
WiredHome 167:8aa3fb2a5a31 201 /// The RA8875 controller supports a native resistive touchscreen interface than can
WiredHome 190:3132b7dfad82 202 /// track a single touch-point.
WiredHome 78:faf49c381591 203 ///
WiredHome 167:8aa3fb2a5a31 204 /// If your display has this option, you can easily accept touch input, but it comes with
WiredHome 167:8aa3fb2a5a31 205 /// some additional requirements - calibration being the primary concern.
WiredHome 167:8aa3fb2a5a31 206 ///
WiredHome 167:8aa3fb2a5a31 207 /// @section Touch_Panel_Enable Touch Panel Enable
WiredHome 167:8aa3fb2a5a31 208 ///
WiredHome 190:3132b7dfad82 209 /// @ref RA8875::TouchPanelInit() has two forms - one fully automatic, and more controlled.
WiredHome 167:8aa3fb2a5a31 210 /// See the APIs for details.
WiredHome 167:8aa3fb2a5a31 211 ///
WiredHome 167:8aa3fb2a5a31 212 /// @section Touch_Panel_Calibration
WiredHome 190:3132b7dfad82 213 ///
WiredHome 190:3132b7dfad82 214 /// The touch panel is not initially calibrated on startup. The application should
WiredHome 78:faf49c381591 215 /// provide a means to activate the calibration process, and that should not require
WiredHome 78:faf49c381591 216 /// the touchscreen as it may not yet be usable. Alternately, a calibration matrix
WiredHome 78:faf49c381591 217 /// can be loaded from non-volatile and installed.
WiredHome 78:faf49c381591 218 ///
WiredHome 167:8aa3fb2a5a31 219 /// @page Capacitive_Touch_Panel Capacitive Touch Panel
WiredHome 167:8aa3fb2a5a31 220 ///
WiredHome 167:8aa3fb2a5a31 221 /// Common to many of the commercially available display modules that use the RA8875 is
WiredHome 167:8aa3fb2a5a31 222 /// an option for a capacitive sense touch screen [Cap Sense] There are two known Cap Sense
WiredHome 167:8aa3fb2a5a31 223 /// controllers that this library can work with:
WiredHome 167:8aa3fb2a5a31 224 ///
WiredHome 167:8aa3fb2a5a31 225 /// * @ref CapSense_FT5206.
WiredHome 167:8aa3fb2a5a31 226 /// * @ref CapSense_GSL1680.
WiredHome 190:3132b7dfad82 227 ///
WiredHome 167:8aa3fb2a5a31 228 /// @page CapSense_FT5206 Capacitive Sense - FT5206 Controller
WiredHome 167:8aa3fb2a5a31 229 ///
WiredHome 167:8aa3fb2a5a31 230 /// This is the more common controller. It supports up to 5 simultaneous touch point
WiredHome 167:8aa3fb2a5a31 231 /// tracking.
WiredHome 167:8aa3fb2a5a31 232 ///
WiredHome 167:8aa3fb2a5a31 233 /// @page CapSense_GSL1680 Capacitive Sense - GSL1680 Controller
WiredHome 167:8aa3fb2a5a31 234 ///
WiredHome 167:8aa3fb2a5a31 235 /// This is the less common controller. It supports either 5 or 10 simultaneous touch point
WiredHome 167:8aa3fb2a5a31 236 /// tracking, depending on the firmware installed in the controller.
WiredHome 167:8aa3fb2a5a31 237 ///
WiredHome 182:8832d03a2a29 238
WiredHome 182:8832d03a2a29 239
WiredHome 167:8aa3fb2a5a31 240 /// @page Example_Program Example Program
WiredHome 167:8aa3fb2a5a31 241 ///
WiredHome 167:8aa3fb2a5a31 242 /// This is just a small sample of what can be done, and what it can look like:
WiredHome 167:8aa3fb2a5a31 243 /// @image html Example_Program.png "Example Program"
WiredHome 78:faf49c381591 244 ///
WiredHome 167:8aa3fb2a5a31 245 /// @code
WiredHome 167:8aa3fb2a5a31 246 /// // Small test program
WiredHome 167:8aa3fb2a5a31 247 /// #include "mbed.h" // Working: v146, not fully working: v147
WiredHome 167:8aa3fb2a5a31 248 /// #include "RA8875.h" // Working: v149
WiredHome 167:8aa3fb2a5a31 249 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 190:3132b7dfad82 250 ///
WiredHome 167:8aa3fb2a5a31 251 /// int main()
WiredHome 167:8aa3fb2a5a31 252 /// {
WiredHome 167:8aa3fb2a5a31 253 /// lcd.init(480,272,16,100);
WiredHome 167:8aa3fb2a5a31 254 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 167:8aa3fb2a5a31 255 /// lcd.circle( 400,25, 25, BrightRed);
WiredHome 167:8aa3fb2a5a31 256 /// lcd.fillcircle( 400,25, 15, RGB(128,255,128));
WiredHome 167:8aa3fb2a5a31 257 /// lcd.ellipse( 440,75, 35,20, BrightBlue);
WiredHome 167:8aa3fb2a5a31 258 /// lcd.fillellipse( 440,75, 25,10, Blue);
WiredHome 167:8aa3fb2a5a31 259 /// lcd.triangle( 440,100, 475,110, 450,125, Magenta);
WiredHome 167:8aa3fb2a5a31 260 /// lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
WiredHome 167:8aa3fb2a5a31 261 /// lcd.rect( 400,130, 475,155, Brown);
WiredHome 167:8aa3fb2a5a31 262 /// lcd.fillrect( 405,135, 470,150, Pink);
WiredHome 167:8aa3fb2a5a31 263 /// lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
WiredHome 167:8aa3fb2a5a31 264 /// lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
WiredHome 167:8aa3fb2a5a31 265 /// lcd.line( 430,200, 460,230, RGB(0,255,0));
WiredHome 190:3132b7dfad82 266 /// for (int i=0; i<=30; i+=5)
WiredHome 167:8aa3fb2a5a31 267 /// lcd.pixel(435+i,200+i, White);
WiredHome 167:8aa3fb2a5a31 268 /// }
WiredHome 167:8aa3fb2a5a31 269 /// @endcode
WiredHome 78:faf49c381591 270 ///
WiredHome 182:8832d03a2a29 271
WiredHome 182:8832d03a2a29 272
WiredHome 167:8aa3fb2a5a31 273 /// @page Wiring_Diagram Example Wiring Diagram
WiredHome 167:8aa3fb2a5a31 274 ///
WiredHome 190:3132b7dfad82 275 /// This library was crafted around the 4-Wire SPI interface. This was the chosen
WiredHome 190:3132b7dfad82 276 /// interface method in order to balance the requirements of the host micro IO with
WiredHome 167:8aa3fb2a5a31 277 /// the capability of this display. Alternatives include: 3-Wire SPI, I2C, 8-bit and
WiredHome 167:8aa3fb2a5a31 278 /// 16-bit parallel.
WiredHome 190:3132b7dfad82 279 ///
WiredHome 190:3132b7dfad82 280 /// @section Schematic_Basic Basic Schematic
WiredHome 182:8832d03a2a29 281 ///
WiredHome 182:8832d03a2a29 282 /// The basic schematic should be the most portable to any system that has SPI support.
WiredHome 190:3132b7dfad82 283 ///
WiredHome 182:8832d03a2a29 284 /// @image html RA8875_display_schematic.png "Basic Display support"
WiredHome 182:8832d03a2a29 285 ///
WiredHome 182:8832d03a2a29 286 /// @section Schematic_DisplayTouch Display with Capacitive Touch
WiredHome 182:8832d03a2a29 287 ///
WiredHome 182:8832d03a2a29 288 /// A more advanced schematic - this with the I2C interface connecting to the Capacitive
WiredHome 182:8832d03a2a29 289 /// Touch controller. Note that this requires additional IO pins.
WiredHome 182:8832d03a2a29 290 ///
WiredHome 182:8832d03a2a29 291 /// @image html RA8875_captouch_wiring.png "Display and Capacitive Touch support"
WiredHome 182:8832d03a2a29 292 ///
WiredHome 182:8832d03a2a29 293 /// @section Schematic_DisplayTouchMicroSD Display with Capacitive Touch and micro SD
WiredHome 182:8832d03a2a29 294 ///
WiredHome 190:3132b7dfad82 295 /// The most advanced schematic - taking advantage of the display, the capacitive touch
WiredHome 190:3132b7dfad82 296 /// controller, and the peripheral support for a micro SD card on some of the display
WiredHome 182:8832d03a2a29 297 /// modules.
WiredHome 182:8832d03a2a29 298 ///
WiredHome 182:8832d03a2a29 299 /// @note There are online indications that the RA8875 has a defect in its SPI interface
WiredHome 182:8832d03a2a29 300 /// where it will not release the MISO pin. If this pin is shared with the micro SD
WiredHome 190:3132b7dfad82 301 /// port, then it could interfere with successful read/write of the files.
WiredHome 182:8832d03a2a29 302 /// The easiest solution is to put that interface on a separate SPI port.
WiredHome 182:8832d03a2a29 303 ///
WiredHome 182:8832d03a2a29 304 /// @image html RA8875_display_full.png "Display, Touch, and micro SD support"
WiredHome 167:8aa3fb2a5a31 305 ///
WiredHome 182:8832d03a2a29 306 /// @page External_Resources External Resources
WiredHome 182:8832d03a2a29 307 ///
WiredHome 190:3132b7dfad82 308 /// There are many websites with information on the RA8875 Display. This partial list
WiredHome 182:8832d03a2a29 309 /// may be helpful:
WiredHome 182:8832d03a2a29 310 ///
WiredHome 190:3132b7dfad82 311 /// * <a href="https://os.mbed.com/components/RA8875-Based-Display/">RA8875 Library</a>
WiredHome 182:8832d03a2a29 312 /// on the <a href="https://os.mbed.com/">mbed site</a><br/>
WiredHome 182:8832d03a2a29 313 /// This page has **a lot** of detail, schematices, sample programs, instructions to
WiredHome 182:8832d03a2a29 314 /// create your own fonts, and more...
WiredHome 182:8832d03a2a29 315 /// * <a href="https://os.mbed.com/search/?q=RA8875">RA8875 search on the mbed site</a><br/>
WiredHome 182:8832d03a2a29 316 /// Many more links, discussions, questions and answers, and more...
WiredHome 182:8832d03a2a29 317 /// * <a href="https://www.buydisplay.com/">Buy Display</a> site<br/>
WiredHome 182:8832d03a2a29 318 /// Where you can find many inexpensive displays, some with the **RA8875** controller
WiredHome 182:8832d03a2a29 319 /// (which this library supports), and others using different controllers (thus not
WiredHome 182:8832d03a2a29 320 /// supported by this library).
WiredHome 182:8832d03a2a29 321 /// * <a href="https://github.com/sumotoy/RA8875/wiki/Fix-compatibility-with-other-SPI-devices">SPI Bug notes</a><br/>
WiredHome 182:8832d03a2a29 322 /// A link to a site that discusses a SPI bug on the RA8875. [I have not verified this
WiredHome 182:8832d03a2a29 323 /// bug]
WiredHome 182:8832d03a2a29 324 /// * <a href="https://www.google.com/search?safe=on&source=hp&ei=1oN1XP6hEsPq_AbZlKMw&q=RA8875">RA8875 - Google</a><br/>
WiredHome 182:8832d03a2a29 325 /// Because new things show up all the time.
WiredHome 182:8832d03a2a29 326 /// * <a href="https://www.bing.com/search?q=RA8875">RA8875 - Bing</a><br/>
WiredHome 182:8832d03a2a29 327 /// And you want to look in more than one place.
WiredHome 182:8832d03a2a29 328 ///
WiredHome 182:8832d03a2a29 329 /// @image html RA8875_display_full.png "Example Wiring Diagram"
WiredHome 182:8832d03a2a29 330 ///
WiredHome 182:8832d03a2a29 331
WiredHome 182:8832d03a2a29 332
WiredHome 167:8aa3fb2a5a31 333 /// @page Future_Plans Future Plans
WiredHome 167:8aa3fb2a5a31 334 ///
WiredHome 167:8aa3fb2a5a31 335 /// Following are some notions of future plans. This does not mean they will all be
WiredHome 167:8aa3fb2a5a31 336 /// implemented, just consider them as things I'm thinking about. If you have a suggestion,
WiredHome 167:8aa3fb2a5a31 337 /// please send it to me.
WiredHome 167:8aa3fb2a5a31 338 ///
WiredHome 167:8aa3fb2a5a31 339 /// - Change the return values for several functions. Most functions return @ref RA8875::RetCode_t,
WiredHome 167:8aa3fb2a5a31 340 /// but would benefit from returning a data type related to that function. For example,
WiredHome 198:9b6851107426 341 /// @ref RA8875::SelectDrawingLayer() should return the current drawing layer even as a new
WiredHome 167:8aa3fb2a5a31 342 /// layer is defined. This can facilitate switching back and forth between configurations.
WiredHome 198:9b6851107426 343 ///
WiredHome 198:9b6851107426 344 /// Review the API for these (and other) functions for this change:
WiredHome 167:8aa3fb2a5a31 345 /// - @ref RA8875::SelectUserFont()
WiredHome 167:8aa3fb2a5a31 346 /// - @ref RA8875::SetLayerTransparency()
WiredHome 167:8aa3fb2a5a31 347 /// - @ref RA8875::SetTextCursorControl()
WiredHome 167:8aa3fb2a5a31 348 /// - @ref RA8875::SetTextFont()
WiredHome 167:8aa3fb2a5a31 349 /// - @ref RA8875::SetTextFontControl()
WiredHome 167:8aa3fb2a5a31 350 /// - @ref RA8875::SetTextFontSize()
WiredHome 167:8aa3fb2a5a31 351 /// - @ref RA8875::Backlight()
WiredHome 167:8aa3fb2a5a31 352 ///
WiredHome 190:3132b7dfad82 353 /// - Change the title-case of the functions to be consistent. Because this was adapted
WiredHome 167:8aa3fb2a5a31 354 /// from parts of several different libraries, it isn't very consistently titled.
WiredHome 167:8aa3fb2a5a31 355 ///
WiredHome 190:3132b7dfad82 356 /// - Change names of some of the functions to be more consistent. Why are some Set*
WiredHome 167:8aa3fb2a5a31 357 /// and others are Select*. The layer commands SetDrawingLayer and GetDrawingLayer do
WiredHome 167:8aa3fb2a5a31 358 /// not need 'Drawing' in them.
WiredHome 167:8aa3fb2a5a31 359 ///
WiredHome 190:3132b7dfad82 360 /// - Improve the PrintScreen method. There are two functions - one that accepts a filename,
WiredHome 167:8aa3fb2a5a31 361 /// and a second more experimental version that could pipe the image stream back to
WiredHome 167:8aa3fb2a5a31 362 /// a calling process. This could be used, for example, to send the image over a
WiredHome 167:8aa3fb2a5a31 363 /// network interface. The intended side effect is that there is then only a single
WiredHome 167:8aa3fb2a5a31 364 /// PrintScreen method with either an internal helper (for file system access) or
WiredHome 167:8aa3fb2a5a31 365 /// a callback for the user handled process.
WiredHome 101:e0aad446094a 366 ///
WiredHome 182:8832d03a2a29 367 /// - Add support for the hardware reset pin
WiredHome 182:8832d03a2a29 368 ///
WiredHome 190:3132b7dfad82 369 /// - Figure out how to "init()" in the constructor when it is not in main(). I ran into
WiredHome 190:3132b7dfad82 370 /// some issues if the display was instantiated before main(), and the code would not
WiredHome 190:3132b7dfad82 371 /// run, thus the exposure and activation of the init() function. If the instantiation
WiredHome 190:3132b7dfad82 372 /// is within main(), then it seemed to work as expected.
WiredHome 182:8832d03a2a29 373 ///
WiredHome 190:3132b7dfad82 374 /// - Add Scroll support for text.
WiredHome 182:8832d03a2a29 375 ///
WiredHome 190:3132b7dfad82 376 /// - Add high level objects - x-y graph, meter, buttons, ... but these will probably be
WiredHome 182:8832d03a2a29 377 /// best served in another class, since they may not be needed for many uses.
WiredHome 182:8832d03a2a29 378 ///
WiredHome 19:3f82c1161fd2 379 #ifndef RA8875_H
WiredHome 19:3f82c1161fd2 380 #define RA8875_H
WiredHome 19:3f82c1161fd2 381 #include <mbed.h>
WiredHome 19:3f82c1161fd2 382
WiredHome 77:9206c13aa527 383 #include "RA8875_Regs.h"
WiredHome 165:695c24cc5197 384 #include "RA8875_Touch_FT5206.h"
WiredHome 165:695c24cc5197 385 #include "RA8875_Touch_GSL1680.h"
WiredHome 19:3f82c1161fd2 386 #include "GraphicsDisplay.h"
WiredHome 19:3f82c1161fd2 387
WiredHome 41:2956a0a221e5 388 #define RA8875_DEFAULT_SPI_FREQ 5000000
WiredHome 19:3f82c1161fd2 389
WiredHome 156:4bdb2772128d 390 #ifndef MBED_ENCODE_VERSION
WiredHome 181:0032d1b8f5d4 391 #define MBED_MAJOR_VERSION 2
WiredHome 181:0032d1b8f5d4 392 #define MBED_MINOR_VERSION 0
WiredHome 181:0032d1b8f5d4 393 #define MBED_PATCH_VERSION MBED_LIBRARY_VERSION
WiredHome 156:4bdb2772128d 394 #define MBED_ENCODE_VERSION(major, minor, patch) ((major)*10000 + (minor)*100 + (patch))
WiredHome 156:4bdb2772128d 395 #endif
WiredHome 156:4bdb2772128d 396
WiredHome 198:9b6851107426 397 #if defined(__GNUC__) || defined(__clang__)
WiredHome 198:9b6851107426 398 #define DEPRECATED(msg) __attribute__((deprecated(msg)))
WiredHome 198:9b6851107426 399 #elif defined(_MSC_VER)
WiredHome 198:9b6851107426 400 #define DEPRECATED __declspec(deprecated)
WiredHome 198:9b6851107426 401 #else
WiredHome 198:9b6851107426 402 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
WiredHome 198:9b6851107426 403 #define DEPRECATED
WiredHome 198:9b6851107426 404 #endif
WiredHome 198:9b6851107426 405
WiredHome 19:3f82c1161fd2 406 // Define this to enable code that monitors the performance of various
WiredHome 19:3f82c1161fd2 407 // graphics commands.
WiredHome 78:faf49c381591 408 //#define PERF_METRICS
WiredHome 19:3f82c1161fd2 409
WiredHome 23:a50ded45dbaf 410 // What better place for some test code than in here and the companion
WiredHome 23:a50ded45dbaf 411 // .cpp file. See also the bottom of this file.
WiredHome 99:66edf771373a 412 //#define TESTENABLE
WiredHome 19:3f82c1161fd2 413
WiredHome 167:8aa3fb2a5a31 414 /// @page PredefinedColors Predefined Colors
WiredHome 167:8aa3fb2a5a31 415 ///
WiredHome 167:8aa3fb2a5a31 416 /// Keep in mind that the color scheme shown here is unlikely to precisely match
WiredHome 198:9b6851107426 417 /// that on the actual display. The perceived color is additionally affected by
WiredHome 198:9b6851107426 418 /// other attributes, such as the polarizer, backlight brightness, liquid crystal
WiredHome 198:9b6851107426 419 /// fluid properties, viewing angle, and more...
WiredHome 167:8aa3fb2a5a31 420 ///
WiredHome 190:3132b7dfad82 421 /// These are the predefined colors that are typically used where any @ref color_t
WiredHome 167:8aa3fb2a5a31 422 /// variable is applied.
WiredHome 167:8aa3fb2a5a31 423 ///
WiredHome 167:8aa3fb2a5a31 424 /// <blockquote>
WiredHome 167:8aa3fb2a5a31 425 /// <table>
WiredHome 167:8aa3fb2a5a31 426 /// <tr>
WiredHome 167:8aa3fb2a5a31 427 /// <td bgcolor='#000000'>&nbsp;</td><td>@ref Black</td>
WiredHome 167:8aa3fb2a5a31 428 /// <td bgcolor='#0000BB'>&nbsp;</td><td>@ref Blue</td>
WiredHome 167:8aa3fb2a5a31 429 /// <td bgcolor='#00BB00'>&nbsp;</td><td>@ref Green</td>
WiredHome 167:8aa3fb2a5a31 430 /// <td bgcolor='#00BBBB'>&nbsp;</td><td>@ref Cyan</td>
WiredHome 167:8aa3fb2a5a31 431 /// </tr>
WiredHome 167:8aa3fb2a5a31 432 /// <tr>
WiredHome 167:8aa3fb2a5a31 433 /// <td bgcolor='#BB0000'>&nbsp;</td><td>@ref Red</td>
WiredHome 167:8aa3fb2a5a31 434 /// <td bgcolor='#BB00BB'>&nbsp;</td><td>@ref Magenta</td>
WiredHome 167:8aa3fb2a5a31 435 /// <td bgcolor='#3F3F3F'>&nbsp;</td><td>@ref Brown</td>
WiredHome 167:8aa3fb2a5a31 436 /// <td bgcolor='#BBBBBB'>&nbsp;</td><td>@ref Gray</td>
WiredHome 167:8aa3fb2a5a31 437 /// </tr>
WiredHome 167:8aa3fb2a5a31 438 /// <tr>
WiredHome 167:8aa3fb2a5a31 439 /// <td bgcolor='#555555'>&nbsp;</td><td>@ref Charcoal</td>
WiredHome 167:8aa3fb2a5a31 440 /// <td bgcolor='#0000FF'>&nbsp;</td><td>@ref BrightBlue</td>
WiredHome 167:8aa3fb2a5a31 441 /// <td bgcolor='#00FF00'>&nbsp;</td><td>@ref BrightGreen</td>
WiredHome 167:8aa3fb2a5a31 442 /// <td bgcolor='#00FFFF'>&nbsp;</td><td>@ref BrightCyan</td>
WiredHome 167:8aa3fb2a5a31 443 /// </tr>
WiredHome 167:8aa3fb2a5a31 444 /// <tr>
WiredHome 198:9b6851107426 445 /// <td bgcolor='#FF0000'>&nbsp;</td><td>@ref BrightRed</td>
WiredHome 167:8aa3fb2a5a31 446 /// <td bgcolor='#FF5555'>&nbsp;</td><td>@ref Orange</td>
WiredHome 167:8aa3fb2a5a31 447 /// <td bgcolor='#FF55FF'>&nbsp;</td><td>@ref Pink</td>
WiredHome 167:8aa3fb2a5a31 448 /// <td bgcolor='#BBBB00'>&nbsp;</td><td>@ref Yellow</td>
WiredHome 167:8aa3fb2a5a31 449 /// </tr>
WiredHome 167:8aa3fb2a5a31 450 /// <tr>
WiredHome 198:9b6851107426 451 /// <td bgcolor='#FFFF00'>&nbsp;</td><td>@ref BrightYellow</td>
WiredHome 198:9b6851107426 452 /// <td bgcolor='#FFFFFF'>&nbsp;</td><td>@ref White</td>
WiredHome 167:8aa3fb2a5a31 453 /// <td bgcolor='#00003F'>&nbsp;</td><td>@ref DarkBlue </td>
WiredHome 167:8aa3fb2a5a31 454 /// <td bgcolor='#003F00'>&nbsp;</td><td>@ref DarkGreen</td>
WiredHome 167:8aa3fb2a5a31 455 /// </tr>
WiredHome 167:8aa3fb2a5a31 456 /// <tr>
WiredHome 198:9b6851107426 457 /// <td bgcolor='#003F3F'>&nbsp;</td><td>@ref DarkCyan </td>
WiredHome 198:9b6851107426 458 /// <td bgcolor='#3F0000'>&nbsp;</td><td>@ref DarkRed </td>
WiredHome 167:8aa3fb2a5a31 459 /// <td bgcolor='#3F003F'>&nbsp;</td><td>@ref DarkMagenta</td>
WiredHome 167:8aa3fb2a5a31 460 /// <td bgcolor='#3F3F00'>&nbsp;</td><td>@ref DarkBrown </td>
WiredHome 198:9b6851107426 461 /// </tr>
WiredHome 198:9b6851107426 462 /// <tr>
WiredHome 167:8aa3fb2a5a31 463 /// <td bgcolor='#3F3F3F'>&nbsp;</td><td>@ref DarkGray </td>
WiredHome 167:8aa3fb2a5a31 464 /// <td bgcolor='#FFFFFF'>&nbsp;</td><td>&nbsp;</td>
WiredHome 198:9b6851107426 465 /// <td bgcolor='#FFFFFF'>&nbsp;</td><td>&nbsp;</td>
WiredHome 198:9b6851107426 466 /// <td bgcolor='#FFFFFF'>&nbsp;</td><td>&nbsp;</td>
WiredHome 167:8aa3fb2a5a31 467 /// </tr>
WiredHome 167:8aa3fb2a5a31 468 /// </table>
WiredHome 167:8aa3fb2a5a31 469 /// </blockquote>
WiredHome 167:8aa3fb2a5a31 470 ///
WiredHome 167:8aa3fb2a5a31 471
WiredHome 185:cb7591a43f44 472 #define Black (color_t)(RGB(0,0,0))
WiredHome 185:cb7591a43f44 473 #define Blue (color_t)(RGB(0,0,187))
WiredHome 185:cb7591a43f44 474 #define Green (color_t)(RGB(0,187,0))
WiredHome 185:cb7591a43f44 475 #define Cyan (color_t)(RGB(0,187,187))
WiredHome 185:cb7591a43f44 476 #define Red (color_t)(RGB(187,0,0))
WiredHome 185:cb7591a43f44 477 #define Magenta (color_t)(RGB(187,0,187))
WiredHome 185:cb7591a43f44 478 #define Brown (color_t)(RGB(63,63,0))
WiredHome 185:cb7591a43f44 479 #define Gray (color_t)(RGB(187,187,187))
WiredHome 185:cb7591a43f44 480 #define Charcoal (color_t)(RGB(85,85,85))
WiredHome 185:cb7591a43f44 481 #define BrightBlue (color_t)(RGB(0,0,255))
WiredHome 185:cb7591a43f44 482 #define BrightGreen (color_t)(RGB(0,255,0))
WiredHome 185:cb7591a43f44 483 #define BrightCyan (color_t)(RGB(0,255,255))
WiredHome 185:cb7591a43f44 484 #define BrightRed (color_t)(RGB(255,0,0))
WiredHome 185:cb7591a43f44 485 #define Orange (color_t)(RGB(255,85,85))
WiredHome 185:cb7591a43f44 486 #define Pink (color_t)(RGB(255,85,255))
WiredHome 185:cb7591a43f44 487 #define Yellow (color_t)(RGB(187,187,0))
WiredHome 186:910fc2335c45 488 #define BrightYellow (color_t)(RGB(255,255,0))
WiredHome 185:cb7591a43f44 489 #define White (color_t)(RGB(255,255,255))
WiredHome 20:6e2e4a8372eb 490
WiredHome 185:cb7591a43f44 491 #define DarkBlue (color_t)(RGB(0,0,63))
WiredHome 185:cb7591a43f44 492 #define DarkGreen (color_t)(RGB(0,63,0))
WiredHome 185:cb7591a43f44 493 #define DarkCyan (color_t)(RGB(0,63,63))
WiredHome 185:cb7591a43f44 494 #define DarkRed (color_t)(RGB(63,0,0))
WiredHome 185:cb7591a43f44 495 #define DarkMagenta (color_t)(RGB(63,0,63))
WiredHome 185:cb7591a43f44 496 #define DarkBrown (color_t)(RGB(63,63,0))
WiredHome 185:cb7591a43f44 497 #define DarkGray (color_t)(RGB(63,63,63))
WiredHome 61:8f3153bf0baa 498
WiredHome 202:a22cbc04f332 499 #define RAmin(a,b) ((a<b)?a:b)
WiredHome 202:a22cbc04f332 500 #define RAmax(a,b) ((a>b)?a:b)
WiredHome 82:f7d300f26540 501
WiredHome 19:3f82c1161fd2 502
WiredHome 19:3f82c1161fd2 503 //namespace SW_graphics
WiredHome 19:3f82c1161fd2 504 //{
WiredHome 19:3f82c1161fd2 505
WiredHome 96:40b74dd3695b 506 class FPointerDummy; // used by the callback methods.
WiredHome 24:8ca861acf12d 507
WiredHome 21:3c1efb192927 508 /// This is a graphics library for the Raio RA8875 Display Controller chip
WiredHome 21:3c1efb192927 509 /// attached to a 4-wire SPI interface.
WiredHome 21:3c1efb192927 510 ///
WiredHome 56:7a85d226ad0d 511 /// It offers both primitive and high level APIs.
WiredHome 56:7a85d226ad0d 512 ///
WiredHome 21:3c1efb192927 513 /// Central to this API is a coordinate system, where the origin (0,0) is in
WiredHome 56:7a85d226ad0d 514 /// the top-left corner of the display, and the width (x) extends positive to the
WiredHome 56:7a85d226ad0d 515 /// right and the height (y) extends positive toward the bottom.
WiredHome 21:3c1efb192927 516 ///
WiredHome 125:7a0b70f56550 517 /// @note As there are both graphics and text commands, one must take care to use
WiredHome 21:3c1efb192927 518 /// the proper coordinate system for each. Some of the text APIs are in units
WiredHome 29:422616aa04bd 519 /// of column and row, which is measured in character positions (and dependent
WiredHome 56:7a85d226ad0d 520 /// on the font size), where other text APIs permit pixel level positioning.
WiredHome 56:7a85d226ad0d 521 ///
WiredHome 56:7a85d226ad0d 522 /// @code
WiredHome 56:7a85d226ad0d 523 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 524 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 525 ///
WiredHome 56:7a85d226ad0d 526 /// int main()
WiredHome 56:7a85d226ad0d 527 /// {
WiredHome 81:01da2e34283d 528 /// lcd.init();
WiredHome 56:7a85d226ad0d 529 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 530 /// lcd.circle( 400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 531 /// lcd.fillcircle( 400,25, 15, RGB(128,255,128));
WiredHome 56:7a85d226ad0d 532 /// lcd.ellipse( 440,75, 35,20, BrightBlue);
WiredHome 56:7a85d226ad0d 533 /// lcd.fillellipse( 440,75, 25,10, Blue);
WiredHome 56:7a85d226ad0d 534 /// lcd.triangle( 440,100, 475,110, 450,125, Magenta);
WiredHome 56:7a85d226ad0d 535 /// lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
WiredHome 56:7a85d226ad0d 536 /// lcd.rect( 400,130, 475,155, Brown);
WiredHome 56:7a85d226ad0d 537 /// lcd.fillrect( 405,135, 470,150, Pink);
WiredHome 56:7a85d226ad0d 538 /// lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
WiredHome 56:7a85d226ad0d 539 /// lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
WiredHome 56:7a85d226ad0d 540 /// lcd.line( 430,200, 460,230, RGB(0,255,0));
WiredHome 190:3132b7dfad82 541 /// for (int i=0; i<=30; i+=5)
WiredHome 56:7a85d226ad0d 542 /// lcd.pixel(435+i,200+i, White);
WiredHome 56:7a85d226ad0d 543 /// }
WiredHome 56:7a85d226ad0d 544 /// @endcode
WiredHome 29:422616aa04bd 545 ///
WiredHome 19:3f82c1161fd2 546 class RA8875 : public GraphicsDisplay
WiredHome 19:3f82c1161fd2 547 {
WiredHome 190:3132b7dfad82 548 public:
WiredHome 190:3132b7dfad82 549 /// Vertical alignment attribute. Used to align one rect against another.
WiredHome 190:3132b7dfad82 550 /// @ref AlignRectInRect
WiredHome 190:3132b7dfad82 551 typedef enum {
WiredHome 190:3132b7dfad82 552 top, ///< vertically align to the top
WiredHome 190:3132b7dfad82 553 middle, ///< vertically align to the middle
WiredHome 190:3132b7dfad82 554 bottom ///< vertically align to the bottom
WiredHome 190:3132b7dfad82 555 } valign_t;
WiredHome 190:3132b7dfad82 556
WiredHome 190:3132b7dfad82 557 /// Horizontal alignment attribute. Used to align one rect against another.
WiredHome 190:3132b7dfad82 558 /// @ref AlignRectInRect
WiredHome 190:3132b7dfad82 559 typedef enum {
WiredHome 190:3132b7dfad82 560 left, ///< horizontally align to the left
WiredHome 190:3132b7dfad82 561 center, ///< horizontally align to the center
WiredHome 190:3132b7dfad82 562 right ///< horizontally align to the right
WiredHome 190:3132b7dfad82 563 } halign_t;
WiredHome 190:3132b7dfad82 564
WiredHome 167:8aa3fb2a5a31 565 /// cursor type argument for @ref SetTextCursorControl()
WiredHome 53:86d24b9480b9 566 typedef enum
WiredHome 53:86d24b9480b9 567 {
WiredHome 53:86d24b9480b9 568 NOCURSOR, ///< cursor is hidden
WiredHome 167:8aa3fb2a5a31 569 IBEAM, ///< I Beam '|' cursor
WiredHome 167:8aa3fb2a5a31 570 UNDER, ///< Underscore '_' cursor
WiredHome 53:86d24b9480b9 571 BLOCK ///< Block cursor
WiredHome 53:86d24b9480b9 572 } cursor_t;
WiredHome 53:86d24b9480b9 573
WiredHome 167:8aa3fb2a5a31 574 /// font type selection argument for @ref SetTextFont()
WiredHome 19:3f82c1161fd2 575 typedef enum
WiredHome 19:3f82c1161fd2 576 {
WiredHome 31:c72e12cd5c67 577 ISO8859_1, ///< ISO8859-1 font
WiredHome 31:c72e12cd5c67 578 ISO8859_2, ///< ISO8859-2 font
WiredHome 31:c72e12cd5c67 579 ISO8859_3, ///< ISO8859-3 font
WiredHome 31:c72e12cd5c67 580 ISO8859_4 ///< ISO8859-4 font
WiredHome 19:3f82c1161fd2 581 } font_t;
WiredHome 190:3132b7dfad82 582
WiredHome 167:8aa3fb2a5a31 583 /// alignment control argument for @ref SetTextFontControl()
WiredHome 19:3f82c1161fd2 584 typedef enum
WiredHome 19:3f82c1161fd2 585 {
WiredHome 31:c72e12cd5c67 586 align_none, ///< align - none
WiredHome 31:c72e12cd5c67 587 align_full ///< align - full
WiredHome 190:3132b7dfad82 588 } alignment_t;
WiredHome 190:3132b7dfad82 589
WiredHome 167:8aa3fb2a5a31 590 /// Font Horizontal Scale factor - 1, 2, 3 4 for @ref SetTextFontSize(), @ref GetTextFontSize()
WiredHome 40:04aa280dfa39 591 typedef int HorizontalScale;
WiredHome 190:3132b7dfad82 592
WiredHome 167:8aa3fb2a5a31 593 /// Font Vertical Scale factor - 1, 2, 3, 4 for @ref SetTextFontSize(), @ref GetTextFontSize()
WiredHome 40:04aa280dfa39 594 typedef int VerticalScale;
WiredHome 19:3f82c1161fd2 595
WiredHome 167:8aa3fb2a5a31 596 /// Clear screen region option for @ref clsw()
WiredHome 19:3f82c1161fd2 597 typedef enum
WiredHome 19:3f82c1161fd2 598 {
WiredHome 31:c72e12cd5c67 599 FULLWINDOW, ///< Full screen
WiredHome 31:c72e12cd5c67 600 ACTIVEWINDOW ///< active window/region
WiredHome 19:3f82c1161fd2 601 } Region_t;
WiredHome 167:8aa3fb2a5a31 602
WiredHome 167:8aa3fb2a5a31 603 /// Layer Display Mode argument for @ref SetLayerMode, @ref GetLayerMode
WiredHome 53:86d24b9480b9 604 typedef enum
WiredHome 53:86d24b9480b9 605 {
WiredHome 61:8f3153bf0baa 606 ShowLayer0, ///< Only layer 0 is visible, layer 1 is hidden (default)
WiredHome 56:7a85d226ad0d 607 ShowLayer1, ///< Only layer 1 is visible, layer 0 is hidden
WiredHome 53:86d24b9480b9 608 LightenOverlay, ///< Lighten-overlay mode
WiredHome 53:86d24b9480b9 609 TransparentMode, ///< Transparent mode
WiredHome 53:86d24b9480b9 610 BooleanOR, ///< Boolean OR mode
WiredHome 53:86d24b9480b9 611 BooleanAND, ///< Boolean AND mode
WiredHome 53:86d24b9480b9 612 FloatingWindow ///< Floating Window mode
WiredHome 53:86d24b9480b9 613 } LayerMode_T;
WiredHome 190:3132b7dfad82 614
hexley 54:e117ad10fba6 615 /// Touch Panel modes
hexley 54:e117ad10fba6 616 typedef enum
hexley 54:e117ad10fba6 617 {
hexley 54:e117ad10fba6 618 TP_Auto, ///< Auto touch detection mode
hexley 54:e117ad10fba6 619 TP_Manual, ///< Manual touch detection mode
hexley 54:e117ad10fba6 620 } tpmode_t;
WiredHome 96:40b74dd3695b 621
WiredHome 167:8aa3fb2a5a31 622 /// PrintScreen callback commands for the user code @ref PrintCallback_T()
WiredHome 96:40b74dd3695b 623 typedef enum
WiredHome 96:40b74dd3695b 624 {
WiredHome 96:40b74dd3695b 625 OPEN, ///< command to open the file. cast uint32_t * to the buffer to get the total size to be written.
WiredHome 96:40b74dd3695b 626 WRITE, ///< command to write some data, buffer points to the data and the size is in bytes.
WiredHome 96:40b74dd3695b 627 CLOSE, ///< command to close the file
WiredHome 96:40b74dd3695b 628 } filecmd_t;
WiredHome 96:40b74dd3695b 629
WiredHome 96:40b74dd3695b 630 /// print screen callback
WiredHome 96:40b74dd3695b 631 ///
WiredHome 190:3132b7dfad82 632 /// The special form of the print screen will pass one blob at a time
WiredHome 149:c62c4b2d6a15 633 /// to the callback. There are basic commands declaring that the stream
WiredHome 96:40b74dd3695b 634 /// can be opened, a block written, and the stream closed. There is
WiredHome 96:40b74dd3695b 635 /// also a command to communicate the total size being delivered.
WiredHome 96:40b74dd3695b 636 ///
WiredHome 149:c62c4b2d6a15 637 /// If the idle callback is registered, it will be activated passing
WiredHome 149:c62c4b2d6a15 638 /// a parameter indicating the percent complete, which may be of value.
WiredHome 149:c62c4b2d6a15 639 ///
WiredHome 96:40b74dd3695b 640 /// @code
WiredHome 96:40b74dd3695b 641 /// lcd.PrintScreen(x,y,w,h,callback);
WiredHome 190:3132b7dfad82 642 /// ...
WiredHome 96:40b74dd3695b 643 /// void callback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 644 /// switch(cmd) {
WiredHome 96:40b74dd3695b 645 /// case OPEN:
WiredHome 96:40b74dd3695b 646 /// pc.printf("About to write %u bytes\r\n", *(uint32_t *)buffer);
WiredHome 96:40b74dd3695b 647 /// fh = fopen("file.bmp", "w+b");
WiredHome 96:40b74dd3695b 648 /// break;
WiredHome 96:40b74dd3695b 649 /// case WRITE:
WiredHome 96:40b74dd3695b 650 /// fwrite(buffer, size, fh);
WiredHome 96:40b74dd3695b 651 /// break;
WiredHome 96:40b74dd3695b 652 /// case CLOSE:
WiredHome 96:40b74dd3695b 653 /// fclose(fh);
WiredHome 96:40b74dd3695b 654 /// break;
WiredHome 96:40b74dd3695b 655 /// default:
WiredHome 96:40b74dd3695b 656 /// pc.printf("Unexpected callback %d\r\n", cmd);
WiredHome 96:40b74dd3695b 657 /// break;
WiredHome 96:40b74dd3695b 658 /// }
WiredHome 96:40b74dd3695b 659 /// }
WiredHome 96:40b74dd3695b 660 /// @endcode
WiredHome 96:40b74dd3695b 661 ///
WiredHome 106:c80828f5dea4 662 /// @param cmd is the command to execute. See @ref filecmd_t.
WiredHome 96:40b74dd3695b 663 /// @param buffer is a pointer to the buffer being passed.
WiredHome 96:40b74dd3695b 664 /// @param size is the number of bytes in the buffer.
WiredHome 167:8aa3fb2a5a31 665 /// @returns @ref RetCode_t value.
WiredHome 96:40b74dd3695b 666 ///
WiredHome 96:40b74dd3695b 667 typedef RetCode_t (* PrintCallback_T)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 190:3132b7dfad82 668
WiredHome 167:8aa3fb2a5a31 669 /// Idle reason provided in the Idle Callback @ref IdleCallback_T()
WiredHome 123:2f45e80fec5f 670 typedef enum {
WiredHome 123:2f45e80fec5f 671 unknown, ///< reason has not been assigned (this should not happen)
WiredHome 123:2f45e80fec5f 672 status_wait, ///< driver is polling the status register while busy
WiredHome 123:2f45e80fec5f 673 command_wait, ///< driver is polling the command register while busy
WiredHome 123:2f45e80fec5f 674 getc_wait, ///< user has called the getc function
WiredHome 123:2f45e80fec5f 675 touch_wait, ///< user has called the touch function
WiredHome 149:c62c4b2d6a15 676 touchcal_wait, ///< driver is performing a touch calibration
WiredHome 149:c62c4b2d6a15 677 progress, ///< communicates progress
WiredHome 123:2f45e80fec5f 678 } IdleReason_T;
WiredHome 190:3132b7dfad82 679
WiredHome 190:3132b7dfad82 680 /// Idle Callback
WiredHome 190:3132b7dfad82 681 ///
WiredHome 190:3132b7dfad82 682 /// This defines the interface for an idle callback. That is, when the
WiredHome 125:7a0b70f56550 683 /// driver is held up, pending some event, it can call a previously registered
WiredHome 123:2f45e80fec5f 684 /// idle function. This could be most useful for servicing a watchdog.
WiredHome 123:2f45e80fec5f 685 ///
WiredHome 123:2f45e80fec5f 686 /// The user code, which is notified via this API, can force the idle
WiredHome 123:2f45e80fec5f 687 /// to abort, by returning the external_abort value back to the driver.
WiredHome 125:7a0b70f56550 688 /// It is important to note that the abort could leave the driver in
WiredHome 125:7a0b70f56550 689 /// an undesireable state, so this should be used with care.
WiredHome 125:7a0b70f56550 690 ///
WiredHome 125:7a0b70f56550 691 /// @note Should it be called the BusyCallback? It is true, that it will
WiredHome 125:7a0b70f56550 692 /// call this function when the RA8875 is busy, but this is also
WiredHome 125:7a0b70f56550 693 /// when the CPU is largely idle.
WiredHome 125:7a0b70f56550 694 ///
WiredHome 125:7a0b70f56550 695 /// @code
WiredHome 149:c62c4b2d6a15 696 /// RetCode_t myIdle_handler(RA8875::IdleReason_T reason, uint16_t param)
WiredHome 125:7a0b70f56550 697 /// {
WiredHome 125:7a0b70f56550 698 /// idleFlasher = !idleFlasher;
WiredHome 125:7a0b70f56550 699 /// if (it_has_been_too_long())
WiredHome 125:7a0b70f56550 700 /// return external_abort;
WiredHome 125:7a0b70f56550 701 /// else
WiredHome 125:7a0b70f56550 702 /// return noerror;
WiredHome 125:7a0b70f56550 703 /// }
WiredHome 125:7a0b70f56550 704 /// @endcode
WiredHome 125:7a0b70f56550 705 ///
WiredHome 125:7a0b70f56550 706 /// @param reason informs the callback why it is idle.
WiredHome 149:c62c4b2d6a15 707 /// @param param is a 2nd parameter, which is used for certain reason codes
WiredHome 149:c62c4b2d6a15 708 /// for 'progress' reason code, param ranges from 0 to 100 (percent)
WiredHome 167:8aa3fb2a5a31 709 /// @returns @ref RetCode_t value.
WiredHome 123:2f45e80fec5f 710 ///
WiredHome 190:3132b7dfad82 711 typedef RetCode_t (* IdleCallback_T)(IdleReason_T reason, uint16_t param);
WiredHome 190:3132b7dfad82 712
WiredHome 190:3132b7dfad82 713 /// Basic constructor for a display based on the RAiO RA8875
WiredHome 125:7a0b70f56550 714 /// display controller, which can be used with no touchscreen,
WiredHome 125:7a0b70f56550 715 /// or the RA8875 managed resistive touchscreen.
WiredHome 124:1690a7ae871c 716 ///
WiredHome 124:1690a7ae871c 717 /// This constructor differs from the alternate by supportting
WiredHome 124:1690a7ae871c 718 /// either No Touch Screen, or the RA8875 built-in resistive
WiredHome 125:7a0b70f56550 719 /// touch screen. If the application requires the use of the
WiredHome 190:3132b7dfad82 720 /// capacitive touchscreen, the alternate constructor must
WiredHome 125:7a0b70f56550 721 /// be used.
WiredHome 19:3f82c1161fd2 722 ///
WiredHome 61:8f3153bf0baa 723 /// This configures the registers and calls the @ref init method.
WiredHome 61:8f3153bf0baa 724 ///
WiredHome 56:7a85d226ad0d 725 /// @code
WiredHome 56:7a85d226ad0d 726 /// #include "RA8875.h"
WiredHome 56:7a85d226ad0d 727 /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
WiredHome 56:7a85d226ad0d 728 ///
WiredHome 56:7a85d226ad0d 729 /// int main()
WiredHome 56:7a85d226ad0d 730 /// {
WiredHome 157:1565f38ca44b 731 /// lcd.init(); // defaults for 480x272x16 at low brightness
WiredHome 56:7a85d226ad0d 732 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 56:7a85d226ad0d 733 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 734 /// }
WiredHome 56:7a85d226ad0d 735 /// @endcode
WiredHome 56:7a85d226ad0d 736 ///
WiredHome 72:ecffe56af969 737 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 72:ecffe56af969 738 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 72:ecffe56af969 739 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 72:ecffe56af969 740 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 19:3f82c1161fd2 741 /// active low chip select for the display controller.
WiredHome 190:3132b7dfad82 742 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 190:3132b7dfad82 743 /// active low reset input on the display controller -
WiredHome 19:3f82c1161fd2 744 /// but this is not currently used.
WiredHome 72:ecffe56af969 745 /// @param[in] name is a text name for this object, which will permit
WiredHome 72:ecffe56af969 746 /// capturing stdout to puts() and printf() directly to it.
WiredHome 19:3f82c1161fd2 747 ///
WiredHome 190:3132b7dfad82 748 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 124:1690a7ae871c 749 const char * name = "lcd");
WiredHome 190:3132b7dfad82 750
WiredHome 190:3132b7dfad82 751
WiredHome 190:3132b7dfad82 752 /// Constructor for a display based on the RAiO RA8875 display controller
WiredHome 165:695c24cc5197 753 /// (using the FT5206 Capacitive TouchScreen Controller)
WiredHome 124:1690a7ae871c 754 ///
WiredHome 125:7a0b70f56550 755 /// @code
WiredHome 125:7a0b70f56550 756 /// #include "RA8875.h"
WiredHome 197:853d08e2fb53 757 /// RA8875 lcd(p5,p6,p7,p12,NC, p9,p10,p13, "tft");
WiredHome 190:3132b7dfad82 758 ///
WiredHome 125:7a0b70f56550 759 /// int main()
WiredHome 125:7a0b70f56550 760 /// {
WiredHome 125:7a0b70f56550 761 /// lcd.init();
WiredHome 125:7a0b70f56550 762 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 125:7a0b70f56550 763 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 125:7a0b70f56550 764 /// TouchCode_t tp = lcd.TouchPanelReadable();
WiredHome 125:7a0b70f56550 765 /// if (tp == touch)
WiredHome 125:7a0b70f56550 766 /// ...
WiredHome 125:7a0b70f56550 767 /// }
WiredHome 125:7a0b70f56550 768 /// @endcode
WiredHome 125:7a0b70f56550 769 ///
WiredHome 124:1690a7ae871c 770 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 124:1690a7ae871c 771 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 124:1690a7ae871c 772 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 124:1690a7ae871c 773 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 124:1690a7ae871c 774 /// active low chip select for the display controller.
WiredHome 190:3132b7dfad82 775 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 190:3132b7dfad82 776 /// active low reset input on the display controller -
WiredHome 124:1690a7ae871c 777 /// but this is not currently used.
WiredHome 124:1690a7ae871c 778 /// @param[in] sda is the I2C Serial Data pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 779 /// @param[in] scl is the I2C Serial Clock pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 780 /// @param[in] irq is the Interrupt Request pin you are wiring to the FT5206.
WiredHome 124:1690a7ae871c 781 /// @param[in] name is a text name for this object, which will permit
WiredHome 124:1690a7ae871c 782 /// capturing stdout to puts() and printf() directly to it.
WiredHome 124:1690a7ae871c 783 ///
WiredHome 190:3132b7dfad82 784 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 124:1690a7ae871c 785 PinName sda, PinName scl, PinName irq, const char * name = "lcd");
WiredHome 190:3132b7dfad82 786
WiredHome 190:3132b7dfad82 787
WiredHome 190:3132b7dfad82 788 /// Constructor for a display based on the RAiO RA8875 display controller
WiredHome 165:695c24cc5197 789 /// (using the GSL1680 Capacitive TouchScreen Controller)
WiredHome 165:695c24cc5197 790 ///
WiredHome 165:695c24cc5197 791 /// @code
WiredHome 165:695c24cc5197 792 /// #include "RA8875.h"
WiredHome 197:853d08e2fb53 793 /// RA8875 lcd(p5,p6,p7,p12,NC, p9,p10,p13,p14, "tft");
WiredHome 190:3132b7dfad82 794 ///
WiredHome 165:695c24cc5197 795 /// int main()
WiredHome 165:695c24cc5197 796 /// {
WiredHome 165:695c24cc5197 797 /// lcd.init();
WiredHome 165:695c24cc5197 798 /// lcd.printf("printing 3 x 2 = %d", 3*2);
WiredHome 165:695c24cc5197 799 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 165:695c24cc5197 800 /// TouchCode_t tp = lcd.TouchPanelReadable();
WiredHome 165:695c24cc5197 801 /// if (tp == touch)
WiredHome 165:695c24cc5197 802 /// ...
WiredHome 165:695c24cc5197 803 /// }
WiredHome 165:695c24cc5197 804 /// @endcode
WiredHome 165:695c24cc5197 805 ///
WiredHome 165:695c24cc5197 806 /// @param[in] mosi is the SPI master out slave in pin on the mbed.
WiredHome 165:695c24cc5197 807 /// @param[in] miso is the SPI master in slave out pin on the mbed.
WiredHome 165:695c24cc5197 808 /// @param[in] sclk is the SPI shift clock pin on the mbed.
WiredHome 165:695c24cc5197 809 /// @param[in] csel is the DigitalOut pin on the mbed to use as the
WiredHome 165:695c24cc5197 810 /// active low chip select for the display controller.
WiredHome 190:3132b7dfad82 811 /// @param[in] reset is the DigitalOut pin on the mbed to use as the
WiredHome 190:3132b7dfad82 812 /// active low reset input on the display controller -
WiredHome 165:695c24cc5197 813 /// but this is not currently used.
WiredHome 165:695c24cc5197 814 /// @param[in] sda is the I2C Serial Data pin you are wiring to the GSL1680.
WiredHome 165:695c24cc5197 815 /// @param[in] scl is the I2C Serial Clock pin you are wiring to the GSL1680.
WiredHome 165:695c24cc5197 816 /// @param[in] wake is the wake control pin you are wiring to the GSL1680.
WiredHome 165:695c24cc5197 817 /// @param[in] irq is the Interrupt Request pin you are wiring to the GSL1680.
WiredHome 165:695c24cc5197 818 /// @param[in] name is a text name for this object, which will permit
WiredHome 165:695c24cc5197 819 /// capturing stdout to puts() and printf() directly to it.
WiredHome 165:695c24cc5197 820 ///
WiredHome 190:3132b7dfad82 821 RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset,
WiredHome 165:695c24cc5197 822 PinName sda, PinName scl, PinName wake, PinName irq, const char * name = "lcd");
WiredHome 190:3132b7dfad82 823
WiredHome 190:3132b7dfad82 824
WiredHome 45:679c2fb8480c 825 // Destructor doesn't have much to do as this would typically be created
WiredHome 45:679c2fb8480c 826 // at startup, and not at runtime.
WiredHome 19:3f82c1161fd2 827 //~RA8875();
WiredHome 190:3132b7dfad82 828
WiredHome 79:544eb4964795 829 /// Initialize the driver.
WiredHome 79:544eb4964795 830 ///
WiredHome 190:3132b7dfad82 831 /// The RA8875 can control typical displays from the 480x272 to 800x480, and it supports 8 or 16-bit color.
WiredHome 190:3132b7dfad82 832 /// It also supports 2 graphics layers, but it cannot support 2 layers at the maximum color depth and
WiredHome 190:3132b7dfad82 833 /// screen size. When configured under 480x400, it will support both 16-bit color depth and 2 drawing layers.
WiredHome 132:a5d7a8541683 834 /// Above 480x400 it support either 16-bit color, or 2 layers, but not both.
WiredHome 132:a5d7a8541683 835 ///
WiredHome 132:a5d7a8541683 836 /// Typical of the displays that are readily purchased, you will find 480x272 and 800x480 resolutions.
WiredHome 106:c80828f5dea4 837 ///
WiredHome 198:9b6851107426 838 /// @param[in] width in pixels in landscape orientation to configure the display for.
WiredHome 198:9b6851107426 839 /// This parameter is optional and the default is 480.
WiredHome 198:9b6851107426 840 /// @param[in] height in pixels in landscape orientation to configure the display for.
WiredHome 198:9b6851107426 841 /// This parameter is optional and the default is 272.
WiredHome 81:01da2e34283d 842 /// @param[in] color_bpp can be either 8 or 16, but must be consistent
WiredHome 81:01da2e34283d 843 /// with the width and height parameters. This parameter is optional
WiredHome 81:01da2e34283d 844 /// and the default is 16.
WiredHome 131:5bd6ba2ee4a1 845 /// @param[in] poweron defines if the display should be initialized into the power-on or off state.
WiredHome 132:a5d7a8541683 846 /// If power is non-zero(on), the backlight is set to this value. This parameter is optional
WiredHome 157:1565f38ca44b 847 /// and the default is 40 (on at a low brightness level because many users power
WiredHome 157:1565f38ca44b 848 /// the module from their PC USB port and it often cannot support the curent
WiredHome 157:1565f38ca44b 849 /// required for full brightness). See @ref Power.
WiredHome 81:01da2e34283d 850 /// @param[in] keypadon defines if the keypad support should be enabled. This parameter is optional
WiredHome 106:c80828f5dea4 851 /// and the default is true (enabled). See @ref KeypadInit.
WiredHome 190:3132b7dfad82 852 /// @param[in] touchscreeenon defines if the touchscreen support should be enabled.
WiredHome 132:a5d7a8541683 853 /// This parameter is optional and the default is true (enabled). See @ref TouchPanelInit.
WiredHome 190:3132b7dfad82 854 /// - If the constructor was called with support for the capacitive driver, this
WiredHome 124:1690a7ae871c 855 /// parameter causes the driver to initialize.
WiredHome 124:1690a7ae871c 856 /// - If the constructor was called without support for the capacitive driver, this
WiredHome 124:1690a7ae871c 857 /// parameter is used to enable and initialize the resistive touchscreen driver.
WiredHome 167:8aa3fb2a5a31 858 /// @returns @ref RetCode_t value.
WiredHome 79:544eb4964795 859 ///
WiredHome 190:3132b7dfad82 860 RetCode_t init(int width = 480, int height = 272, int color_bpp = 16,
WiredHome 157:1565f38ca44b 861 uint8_t poweron = 40, bool keypadon = true, bool touchscreeenon = true);
WiredHome 124:1690a7ae871c 862
WiredHome 125:7a0b70f56550 863
WiredHome 167:8aa3fb2a5a31 864 /// Get a pointer to the text string representing the RetCode_t
WiredHome 79:544eb4964795 865 ///
WiredHome 79:544eb4964795 866 /// This method returns a pointer to a text string that matches the
WiredHome 106:c80828f5dea4 867 /// code. See @ref RetCode_t.
WiredHome 79:544eb4964795 868 ///
WiredHome 79:544eb4964795 869 /// @param[in] code is the return value from RetCode_t to look up.
WiredHome 79:544eb4964795 870 /// @returns a pointer to the text message representing code. If code
WiredHome 79:544eb4964795 871 /// is not a valid value, then it returns the text for bad_parameter;
WiredHome 125:7a0b70f56550 872 ///
WiredHome 79:544eb4964795 873 const char * GetErrorMessage(RetCode_t code);
WiredHome 190:3132b7dfad82 874
WiredHome 190:3132b7dfad82 875
WiredHome 50:2c4f474a2453 876 /// Select the drawing layer for subsequent commands.
WiredHome 43:3becae133285 877 ///
WiredHome 190:3132b7dfad82 878 /// If the screen configuration is 480 x 272, or if it is 800 x 480
WiredHome 190:3132b7dfad82 879 /// and 8-bit color, the the display supports two layers, which can
WiredHome 43:3becae133285 880 /// be independently drawn on and shown. Additionally, complex
WiredHome 43:3becae133285 881 /// operations involving both layers are permitted.
WiredHome 43:3becae133285 882 ///
WiredHome 142:6e9bff59878a 883 /// @attention If the current display configuration does not support
WiredHome 142:6e9bff59878a 884 /// multiple layers, then layer 0 will be selected.
WiredHome 142:6e9bff59878a 885 ///
WiredHome 56:7a85d226ad0d 886 /// @code
WiredHome 56:7a85d226ad0d 887 /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
WiredHome 56:7a85d226ad0d 888 /// lcd.rect(400,130, 475,155,Brown);
WiredHome 56:7a85d226ad0d 889 /// lcd.SelectDrawingLayer(1);
WiredHome 56:7a85d226ad0d 890 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 891 /// wait(1);
WiredHome 56:7a85d226ad0d 892 /// lcd.SetLayerMode(ShowLayer1);
WiredHome 56:7a85d226ad0d 893 /// @endcode
WiredHome 56:7a85d226ad0d 894 ///
WiredHome 61:8f3153bf0baa 895 /// @attention The user manual refers to Layer 1 and Layer 2, however the
WiredHome 61:8f3153bf0baa 896 /// actual register values are value 0 and 1. This API as well as
WiredHome 61:8f3153bf0baa 897 /// others that reference the layers use the values 0 and 1 for
WiredHome 61:8f3153bf0baa 898 /// cleaner iteration in the code.
WiredHome 43:3becae133285 899 ///
WiredHome 190:3132b7dfad82 900 /// @param[in] layer is 0 or 1 to select the layer for subsequent
WiredHome 61:8f3153bf0baa 901 /// commands.
WiredHome 198:9b6851107426 902 /// @returns previous drawing layer.
WiredHome 198:9b6851107426 903 ///
WiredHome 198:9b6851107426 904 virtual uint16_t SelectDrawingLayer(uint16_t layer);
WiredHome 190:3132b7dfad82 905
WiredHome 190:3132b7dfad82 906
WiredHome 61:8f3153bf0baa 907 /// Get the currently active drawing layer.
WiredHome 61:8f3153bf0baa 908 ///
WiredHome 61:8f3153bf0baa 909 /// This returns a value, 0 or 1, based on the screen configuration
WiredHome 61:8f3153bf0baa 910 /// and the currently active drawing layer.
WiredHome 61:8f3153bf0baa 911 ///
WiredHome 61:8f3153bf0baa 912 /// @code
WiredHome 61:8f3153bf0baa 913 /// uint16_t prevLayer = lcd.GetDrawingLayer();
WiredHome 61:8f3153bf0baa 914 /// lcd.SelectDrawingLayer(x);
WiredHome 61:8f3153bf0baa 915 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 61:8f3153bf0baa 916 /// lcd.SelectDrawingLayer(prevLayer);
WiredHome 61:8f3153bf0baa 917 /// @endcode
WiredHome 61:8f3153bf0baa 918 ///
WiredHome 61:8f3153bf0baa 919 /// @attention The user manual refers to Layer 1 and Layer 2, however the
WiredHome 61:8f3153bf0baa 920 /// actual register values are value 0 and 1. This API as well as
WiredHome 61:8f3153bf0baa 921 /// others that reference the layers use the values 0 and 1 for
WiredHome 61:8f3153bf0baa 922 /// cleaner iteration in the code.
WiredHome 61:8f3153bf0baa 923 ///
WiredHome 61:8f3153bf0baa 924 /// @returns the current drawing layer; 0 or 1.
WiredHome 190:3132b7dfad82 925 ///
WiredHome 142:6e9bff59878a 926 virtual uint16_t GetDrawingLayer(void);
WiredHome 190:3132b7dfad82 927
WiredHome 190:3132b7dfad82 928
WiredHome 44:207594dece70 929 /// Set the Layer presentation mode.
WiredHome 44:207594dece70 930 ///
WiredHome 44:207594dece70 931 /// This sets the presentation mode for layers, and permits showing
WiredHome 44:207594dece70 932 /// a single layer, or applying a mode where the two layers
WiredHome 44:207594dece70 933 /// are combined using one of the hardware methods.
WiredHome 44:207594dece70 934 ///
WiredHome 61:8f3153bf0baa 935 /// Refer to the RA8875 data sheet for full details.
WiredHome 61:8f3153bf0baa 936 ///
WiredHome 56:7a85d226ad0d 937 /// @code
WiredHome 56:7a85d226ad0d 938 /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
WiredHome 56:7a85d226ad0d 939 /// lcd.rect(400,130, 475,155,Brown);
WiredHome 56:7a85d226ad0d 940 /// lcd.SelectDrawingLayer(1);
WiredHome 56:7a85d226ad0d 941 /// lcd.circle(400,25, 25, BrightRed);
WiredHome 56:7a85d226ad0d 942 /// wait(1);
WiredHome 56:7a85d226ad0d 943 /// lcd.SetLayerMode(ShowLayer1);
WiredHome 56:7a85d226ad0d 944 /// @endcode
WiredHome 56:7a85d226ad0d 945 ///
WiredHome 72:ecffe56af969 946 /// @param[in] mode sets the mode in the Layer Transparency Register.
WiredHome 198:9b6851107426 947 /// @returns @ref LayerMode_T as the previous layer value.
WiredHome 198:9b6851107426 948 ///
WiredHome 198:9b6851107426 949 LayerMode_T SetLayerMode(LayerMode_T mode);
WiredHome 190:3132b7dfad82 950
WiredHome 190:3132b7dfad82 951
WiredHome 82:f7d300f26540 952 /// Get the Layer presentation mode.
WiredHome 82:f7d300f26540 953 ///
WiredHome 106:c80828f5dea4 954 /// This gets the current layer mode. See @ref LayerMode_T.
WiredHome 82:f7d300f26540 955 ///
WiredHome 82:f7d300f26540 956 /// @returns layer mode.
WiredHome 82:f7d300f26540 957 ///
WiredHome 82:f7d300f26540 958 LayerMode_T GetLayerMode(void);
WiredHome 190:3132b7dfad82 959
WiredHome 190:3132b7dfad82 960
WiredHome 44:207594dece70 961 /// Set the layer transparency for each layer.
WiredHome 44:207594dece70 962 ///
WiredHome 44:207594dece70 963 /// Set the transparency, where the range of values is
WiredHome 44:207594dece70 964 /// from zero (fully visible) to eight (fully transparent).
WiredHome 44:207594dece70 965 /// The input value is automatically limited to this range.
WiredHome 44:207594dece70 966 ///
WiredHome 56:7a85d226ad0d 967 /// @code
WiredHome 56:7a85d226ad0d 968 /// // draw something on each layer, then step-fade across
WiredHome 56:7a85d226ad0d 969 /// display.SetLayerMode(RA8875::TransparentMode);
WiredHome 56:7a85d226ad0d 970 /// for (i=0; i<=8; i++) {
WiredHome 56:7a85d226ad0d 971 /// display.SetLayerTransparency(i, 8-i);
WiredHome 197:853d08e2fb53 972 /// wait_us(200000);
WiredHome 56:7a85d226ad0d 973 /// }
WiredHome 56:7a85d226ad0d 974 /// @endcode
WiredHome 56:7a85d226ad0d 975 ///
WiredHome 72:ecffe56af969 976 /// @param[in] layer1 sets the layer 1 transparency.
WiredHome 72:ecffe56af969 977 /// @param[in] layer2 sets the layer 2 transparency.
WiredHome 167:8aa3fb2a5a31 978 /// @returns @ref RetCode_t value.
WiredHome 190:3132b7dfad82 979 ///
WiredHome 44:207594dece70 980 RetCode_t SetLayerTransparency(uint8_t layer1, uint8_t layer2);
WiredHome 190:3132b7dfad82 981
WiredHome 190:3132b7dfad82 982
WiredHome 53:86d24b9480b9 983 /// Set the background color register used for transparency.
WiredHome 53:86d24b9480b9 984 ///
WiredHome 53:86d24b9480b9 985 /// This command sets the background color registers that are used
WiredHome 53:86d24b9480b9 986 /// in the transparent color operations involving the layers.
WiredHome 190:3132b7dfad82 987 ///
WiredHome 72:ecffe56af969 988 /// @param[in] color is optional and expressed in 16-bit format. If not
WiredHome 53:86d24b9480b9 989 /// supplied, a default of Black is used.
WiredHome 198:9b6851107426 990 /// @returns @ref color_t as the previous color value.
WiredHome 198:9b6851107426 991 ///
WiredHome 198:9b6851107426 992 color_t SetBackgroundTransparencyColor(color_t color = RGB(0,0,0));
WiredHome 190:3132b7dfad82 993
WiredHome 190:3132b7dfad82 994
WiredHome 73:f22a18707b5e 995 /// Get the background color value used for transparency.
WiredHome 73:f22a18707b5e 996 ///
WiredHome 73:f22a18707b5e 997 /// This command reads the background color registers that define
WiredHome 73:f22a18707b5e 998 /// the transparency color for operations involving layers.
WiredHome 73:f22a18707b5e 999 ///
WiredHome 73:f22a18707b5e 1000 /// @returns the color.
WiredHome 73:f22a18707b5e 1001 ///
WiredHome 73:f22a18707b5e 1002 color_t GetBackgroundTransparencyColor(void);
WiredHome 190:3132b7dfad82 1003
WiredHome 190:3132b7dfad82 1004
WiredHome 190:3132b7dfad82 1005 /// Initialize theTouch Panel controller with default values
hexley 54:e117ad10fba6 1006 ///
WiredHome 78:faf49c381591 1007 /// This activates the simplified touch panel init, which may work for
WiredHome 78:faf49c381591 1008 /// most uses. The alternate API is available if fine-grained control
WiredHome 124:1690a7ae871c 1009 /// of the numerous settings of the resistive panel is needed.
WiredHome 78:faf49c381591 1010 ///
WiredHome 157:1565f38ca44b 1011 /// Additionally, for an even simpler interface for most RESISTIVE
WiredHome 157:1565f38ca44b 1012 /// touch use cases, the init() method can perform the calibration.
WiredHome 157:1565f38ca44b 1013 ///
WiredHome 167:8aa3fb2a5a31 1014 /// @returns @ref RetCode_t value.
WiredHome 56:7a85d226ad0d 1015 ///
hexley 54:e117ad10fba6 1016 RetCode_t TouchPanelInit(void);
WiredHome 190:3132b7dfad82 1017
WiredHome 190:3132b7dfad82 1018
hexley 54:e117ad10fba6 1019 /// Initialize the Touch Panel controller with detailed settings.
hexley 54:e117ad10fba6 1020 ///
WiredHome 78:faf49c381591 1021 /// This is the detailed touch panel init, which provides the ability
WiredHome 124:1690a7ae871c 1022 /// to set nearly every option.
WiredHome 124:1690a7ae871c 1023 ///
WiredHome 124:1690a7ae871c 1024 /// @note If the capacitive touch panel was constructed, this behaves
WiredHome 124:1690a7ae871c 1025 /// the same as the simplified version.
WiredHome 78:faf49c381591 1026 ///
hexley 54:e117ad10fba6 1027 /// @param[in] bTpEnable Touch Panel enable/disable control:
hexley 54:e117ad10fba6 1028 /// - TP_ENABLE: enable the touch panel
hexley 54:e117ad10fba6 1029 /// - TP_DISABLE: disable the touch panel
WiredHome 56:7a85d226ad0d 1030 /// @param[in] bTpAutoManual Touch Panel operating mode:
hexley 54:e117ad10fba6 1031 /// - TP_MODE_AUTO: automatic capture
hexley 54:e117ad10fba6 1032 /// - TP_MODE_MANUAL: manual capture
WiredHome 56:7a85d226ad0d 1033 /// @param[in] bTpDebounce Debounce circuit enable for touch panel interrupt:
hexley 54:e117ad10fba6 1034 /// - TP_DEBOUNCE_OFF: disable the debounce circuit
WiredHome 190:3132b7dfad82 1035 /// - TP_DEBOUNCE_ON: enable the debounce circuit
WiredHome 56:7a85d226ad0d 1036 /// @param[in] bTpManualMode When Manual Mode is selected, this sets the mode:
WiredHome 190:3132b7dfad82 1037 /// - TP_MANUAL_IDLE: touch panel is idle
WiredHome 190:3132b7dfad82 1038 /// - TP_MANUAL_WAIT: wait for touch panel event
WiredHome 190:3132b7dfad82 1039 /// - TP_MANUAL_LATCH_X: latch X data
WiredHome 190:3132b7dfad82 1040 /// - TP_MANUAL_LATCH_Y: latch Y data
WiredHome 56:7a85d226ad0d 1041 /// @param[in] bTpAdcClkDiv Sets the ADC clock as a fraction of the System CLK:
WiredHome 190:3132b7dfad82 1042 /// - TP_ADC_CLKDIV_1: Use CLK
WiredHome 190:3132b7dfad82 1043 /// - TP_ADC_CLKDIV_2: Use CLK/2
WiredHome 190:3132b7dfad82 1044 /// - TP_ADC_CLKDIV_4: Use CLK/4
WiredHome 190:3132b7dfad82 1045 /// - TP_ADC_CLKDIV_8: Use CLK/8
WiredHome 190:3132b7dfad82 1046 /// - TP_ADC_CLKDIV_16: Use CLK/16
WiredHome 190:3132b7dfad82 1047 /// - TP_ADC_CLKDIV_32: Use CLK/32
WiredHome 190:3132b7dfad82 1048 /// - TP_ADC_CLKDIV_64: Use CLK/64
WiredHome 190:3132b7dfad82 1049 /// - TP_ADC_CLKDIV_128: Use CLK/128
WiredHome 56:7a85d226ad0d 1050 /// @param[in] bTpAdcSampleTime Touch Panel sample time delay before ADC data is ready:
WiredHome 190:3132b7dfad82 1051 /// - TP_ADC_SAMPLE_512_CLKS: Wait 512 system clocks
WiredHome 190:3132b7dfad82 1052 /// - TP_ADC_SAMPLE_1024_CLKS: Wait 1024 system clocks
WiredHome 190:3132b7dfad82 1053 /// - TP_ADC_SAMPLE_2048_CLKS: Wait 2048 system clocks
WiredHome 190:3132b7dfad82 1054 /// - TP_ADC_SAMPLE_4096_CLKS: Wait 4096 system clocks
WiredHome 190:3132b7dfad82 1055 /// - TP_ADC_SAMPLE_8192_CLKS: Wait 8192 system clocks
WiredHome 190:3132b7dfad82 1056 /// - TP_ADC_SAMPLE_16384_CLKS: Wait 16384 system clocks
WiredHome 190:3132b7dfad82 1057 /// - TP_ADC_SAMPLE_32768_CLKS: Wait 32768 system clocks
hexley 54:e117ad10fba6 1058 /// - TP_ADC_SAMPLE_65536_CLKS: Wait 65536 system clocks
WiredHome 190:3132b7dfad82 1059 /// @returns @ref RetCode_t value.
WiredHome 190:3132b7dfad82 1060 ///
WiredHome 190:3132b7dfad82 1061 RetCode_t TouchPanelInit(uint8_t bTpEnable, uint8_t bTpAutoManual, uint8_t bTpDebounce,
WiredHome 78:faf49c381591 1062 uint8_t bTpManualMode, uint8_t bTpAdcClkDiv, uint8_t bTpAdcSampleTime);
WiredHome 190:3132b7dfad82 1063
WiredHome 190:3132b7dfad82 1064
WiredHome 123:2f45e80fec5f 1065 /// Get the screen calibrated point of touch.
WiredHome 123:2f45e80fec5f 1066 ///
WiredHome 123:2f45e80fec5f 1067 /// This method determines if there is a touch and if so it will provide
WiredHome 123:2f45e80fec5f 1068 /// the screen-relative touch coordinates. This method can be used in
WiredHome 190:3132b7dfad82 1069 /// a manner similar to Serial.readable(), to determine if there was a
WiredHome 123:2f45e80fec5f 1070 /// touch and indicate that - but not care about the coordinates. Alternately,
WiredHome 123:2f45e80fec5f 1071 /// if a valid pointer to a point_t is provided, then if a touch is detected
WiredHome 190:3132b7dfad82 1072 /// the point_t will be populated with data.
WiredHome 123:2f45e80fec5f 1073 ///
WiredHome 123:2f45e80fec5f 1074 /// @code
WiredHome 123:2f45e80fec5f 1075 /// Timer t;
WiredHome 123:2f45e80fec5f 1076 /// t.start();
WiredHome 123:2f45e80fec5f 1077 /// do {
WiredHome 123:2f45e80fec5f 1078 /// point_t point = {0, 0};
WiredHome 123:2f45e80fec5f 1079 /// if (display.TouchPanelReadable(&point)) {
WiredHome 123:2f45e80fec5f 1080 /// display.pixel(point, Red);
WiredHome 123:2f45e80fec5f 1081 /// }
WiredHome 123:2f45e80fec5f 1082 /// } while (t.read_ms() < 30000);
WiredHome 123:2f45e80fec5f 1083 /// @endcode
WiredHome 123:2f45e80fec5f 1084 ///
WiredHome 190:3132b7dfad82 1085 /// @param[out] TouchPoint is a pointer to a point_t, which is set as the touch point,
WiredHome 202:a22cbc04f332 1086 /// if a touch is registered. The coordinate system is based on the
WiredHome 202:a22cbc04f332 1087 /// graphics orientation (@ref SetGraphicsOrientation(), @ref GetGraphicsOrientation())
WiredHome 123:2f45e80fec5f 1088 /// @returns a value indicating the state of the touch,
WiredHome 123:2f45e80fec5f 1089 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 123:2f45e80fec5f 1090 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 123:2f45e80fec5f 1091 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 1092 /// - held: held after touch, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 1093 /// - release: indicates a release, touch coordinates are returned.
WiredHome 123:2f45e80fec5f 1094 ///
WiredHome 123:2f45e80fec5f 1095 TouchCode_t TouchPanelReadable(point_t * TouchPoint = NULL);
WiredHome 123:2f45e80fec5f 1096
WiredHome 125:7a0b70f56550 1097
WiredHome 124:1690a7ae871c 1098 /// Get the reported touch gesture, if any.
WiredHome 190:3132b7dfad82 1099 ///
WiredHome 124:1690a7ae871c 1100 /// If it could detect a gesture, it will return a value based on
WiredHome 132:a5d7a8541683 1101 /// the interpreted gesture.
WiredHome 124:1690a7ae871c 1102 ///
WiredHome 124:1690a7ae871c 1103 /// Valid gesture values are:
WiredHome 124:1690a7ae871c 1104 /// @li 0x00 No gesture
WiredHome 132:a5d7a8541683 1105 /// @li 0x48 Zoom in
WiredHome 132:a5d7a8541683 1106 /// @li 0x49 Zoom out
WiredHome 132:a5d7a8541683 1107 ///
WiredHome 132:a5d7a8541683 1108 /// The following gestures are defined in the FT5206 specification, but
WiredHome 132:a5d7a8541683 1109 /// do not appear to work.
WiredHome 124:1690a7ae871c 1110 /// @li 0x10 Move up
WiredHome 124:1690a7ae871c 1111 /// @li 0x14 Move left
WiredHome 124:1690a7ae871c 1112 /// @li 0x18 Move down
WiredHome 124:1690a7ae871c 1113 /// @li 0x1C Move right
WiredHome 124:1690a7ae871c 1114 ///
WiredHome 124:1690a7ae871c 1115 /// @returns gesture information.
WiredHome 124:1690a7ae871c 1116 ///
WiredHome 124:1690a7ae871c 1117 uint8_t TouchGesture(void) { return gesture; }
WiredHome 190:3132b7dfad82 1118
WiredHome 123:2f45e80fec5f 1119
WiredHome 124:1690a7ae871c 1120 /// Get the count of registered touches.
WiredHome 124:1690a7ae871c 1121 ///
WiredHome 124:1690a7ae871c 1122 /// @returns count of touch points to communicate; 0 to 5.
WiredHome 124:1690a7ae871c 1123 ///
WiredHome 124:1690a7ae871c 1124 int TouchCount(void) { return numberOfTouchPoints; }
WiredHome 125:7a0b70f56550 1125
WiredHome 190:3132b7dfad82 1126
WiredHome 124:1690a7ae871c 1127 /// Get the count of possible touch channels.
WiredHome 124:1690a7ae871c 1128 ///
WiredHome 124:1690a7ae871c 1129 /// @returns count of touch channels supported by the hardware.
WiredHome 124:1690a7ae871c 1130 ///
WiredHome 124:1690a7ae871c 1131 int TouchChannels(void);
WiredHome 125:7a0b70f56550 1132
WiredHome 190:3132b7dfad82 1133
WiredHome 124:1690a7ae871c 1134 /// Get the Touch ID value for a specified touch channel.
WiredHome 124:1690a7ae871c 1135 ///
WiredHome 124:1690a7ae871c 1136 /// Touch ID is a tracking number based on the order of the touch
WiredHome 190:3132b7dfad82 1137 /// detections. The first touch is ID 0, the next is ID 1, and
WiredHome 124:1690a7ae871c 1138 /// so on. If the first touch is lifted (no touch), the touch count
WiredHome 124:1690a7ae871c 1139 /// decrements, and the remaining touch is communicated on
WiredHome 124:1690a7ae871c 1140 /// touch channel zero, even as the Touch ID remains as originally
WiredHome 190:3132b7dfad82 1141 /// reported (1 in this example). In this way, it is easy to track
WiredHome 132:a5d7a8541683 1142 /// a specific touch.
WiredHome 124:1690a7ae871c 1143 ///
WiredHome 124:1690a7ae871c 1144 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 1145 /// presently reported as touched.
WiredHome 124:1690a7ae871c 1146 ///
WiredHome 166:53fd4a876dac 1147 /// @param[in] channel is the touch channel, from 0 to 4, or 0 to TouchChannels()-1
WiredHome 124:1690a7ae871c 1148 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 1149 /// @returns the touch ID, or 15 if you get the ID for an untouched channel.
WiredHome 124:1690a7ae871c 1150 /// @returns 0 if an invalid channel is queried.
WiredHome 124:1690a7ae871c 1151 ///
WiredHome 166:53fd4a876dac 1152 uint8_t TouchID(uint8_t channel = 0);
WiredHome 190:3132b7dfad82 1153
WiredHome 124:1690a7ae871c 1154 /// Get the Touch Code for a touch channel.
WiredHome 124:1690a7ae871c 1155 ///
WiredHome 124:1690a7ae871c 1156 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 1157 /// presently reported as touched.
WiredHome 124:1690a7ae871c 1158 ///
WiredHome 166:53fd4a876dac 1159 /// @param[in] channel is the touch channel, from 0 to 4, or 0 to TouchChannels()-1
WiredHome 124:1690a7ae871c 1160 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 1161 /// @returns the touch code (@ref TouchCode_t).
WiredHome 124:1690a7ae871c 1162 /// @returns channel 0 information if an invalid channel is queried.
WiredHome 124:1690a7ae871c 1163 ///
WiredHome 166:53fd4a876dac 1164 TouchCode_t TouchCode(uint8_t channel = 0);
WiredHome 124:1690a7ae871c 1165
WiredHome 125:7a0b70f56550 1166
WiredHome 124:1690a7ae871c 1167 /// Get the coordinates for a touch channel.
WiredHome 124:1690a7ae871c 1168 ///
WiredHome 124:1690a7ae871c 1169 /// This returns the (X,Y) coordinates for a touch channel.
WiredHome 132:a5d7a8541683 1170 ///
WiredHome 124:1690a7ae871c 1171 ///
WiredHome 124:1690a7ae871c 1172 /// It is possible to query the data for a channel that is not
WiredHome 124:1690a7ae871c 1173 /// presently reported as touched.
WiredHome 124:1690a7ae871c 1174 ///
WiredHome 166:53fd4a876dac 1175 /// @param[in] channel is an optional touch channel, from 0 to 4, or 0 to TouchChannels()-1.
WiredHome 124:1690a7ae871c 1176 /// It defaults to 0, in case the user is not interested in multi-touch.
WiredHome 124:1690a7ae871c 1177 /// @returns the coordinates as a point_t structure.
WiredHome 124:1690a7ae871c 1178 /// @returns channel 0 information if an invalid channel is queried.
WiredHome 124:1690a7ae871c 1179 ///
WiredHome 166:53fd4a876dac 1180 point_t TouchCoordinates(uint8_t channel = 0);
WiredHome 190:3132b7dfad82 1181
WiredHome 131:5bd6ba2ee4a1 1182
WiredHome 79:544eb4964795 1183 /// Poll the TouchPanel and on a touch event return the a to d filtered x, y coordinates.
hexley 54:e117ad10fba6 1184 ///
WiredHome 78:faf49c381591 1185 /// This method reads the touch controller, which has a 10-bit range for each the
WiredHome 79:544eb4964795 1186 /// x and the y axis.
WiredHome 79:544eb4964795 1187 ///
WiredHome 79:544eb4964795 1188 /// @note The returned values are not in display (pixel) units but are in analog to
WiredHome 79:544eb4964795 1189 /// digital converter units.
WiredHome 190:3132b7dfad82 1190 ///
WiredHome 190:3132b7dfad82 1191 /// @note This API is usually not needed and is likely to be deprecated.
WiredHome 190:3132b7dfad82 1192 /// See @ref TouchPanelComputeCalibration.
WiredHome 106:c80828f5dea4 1193 /// See @ref TouchPanelReadable.
WiredHome 190:3132b7dfad82 1194 ///
WiredHome 79:544eb4964795 1195 /// @param[out] x is the x scale a/d value.
WiredHome 79:544eb4964795 1196 /// @param[out] y is the y scale a/d value.
WiredHome 83:7bad0068cca0 1197 /// @returns a value indicating the state of the touch,
WiredHome 83:7bad0068cca0 1198 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 1199 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 1200 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 83:7bad0068cca0 1201 /// - held: held after touch, touch coordinates are returned.
WiredHome 83:7bad0068cca0 1202 /// - release: indicates a release, touch coordinates are returned.
WiredHome 56:7a85d226ad0d 1203 ///
WiredHome 83:7bad0068cca0 1204 TouchCode_t TouchPanelA2DFiltered(int *x, int *y);
hexley 54:e117ad10fba6 1205
WiredHome 125:7a0b70f56550 1206
WiredHome 79:544eb4964795 1207 /// Poll the TouchPanel and on a touch event return the a to d raw x, y coordinates.
hexley 54:e117ad10fba6 1208 ///
WiredHome 78:faf49c381591 1209 /// This method reads the touch controller, which has a 10-bit range for each the
WiredHome 78:faf49c381591 1210 /// x and the y axis. A number of samples of the raw data are taken, filtered,
WiredHome 190:3132b7dfad82 1211 /// and the results are returned.
WiredHome 78:faf49c381591 1212 ///
WiredHome 79:544eb4964795 1213 /// @note The returned values are not in display (pixel) units but are in analog to
WiredHome 79:544eb4964795 1214 /// digital converter units.
WiredHome 190:3132b7dfad82 1215 ///
WiredHome 190:3132b7dfad82 1216 /// @note This API is usually not needed and is likely to be deprecated.
WiredHome 190:3132b7dfad82 1217 /// See @ref TouchPanelComputeCalibration.
WiredHome 106:c80828f5dea4 1218 /// See @ref TouchPanelReadable.
WiredHome 190:3132b7dfad82 1219 ///
WiredHome 79:544eb4964795 1220 /// @param[out] x is the x scale a/d value.
WiredHome 79:544eb4964795 1221 /// @param[out] y is the y scale a/d value.
WiredHome 83:7bad0068cca0 1222 /// @returns a value indicating the state of the touch,
WiredHome 83:7bad0068cca0 1223 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 1224 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 83:7bad0068cca0 1225 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 83:7bad0068cca0 1226 /// - held: held after touch, touch coordinates are returned.
WiredHome 83:7bad0068cca0 1227 /// - release: indicates a release, touch coordinates are returned.
WiredHome 83:7bad0068cca0 1228 ///
WiredHome 83:7bad0068cca0 1229 TouchCode_t TouchPanelA2DRaw(int *x, int *y);
WiredHome 125:7a0b70f56550 1230
WiredHome 190:3132b7dfad82 1231
WiredHome 85:022bba13c5c4 1232 /// Wait for a touch panel touch and return it.
WiredHome 190:3132b7dfad82 1233 ///
WiredHome 85:022bba13c5c4 1234 /// This method is similar to Serial.getc() in that it will wait for a touch
WiredHome 85:022bba13c5c4 1235 /// and then return. In order to extract the coordinates of the touch, a
WiredHome 85:022bba13c5c4 1236 /// valid pointer to a point_t must be provided.
WiredHome 85:022bba13c5c4 1237 ///
WiredHome 85:022bba13c5c4 1238 /// @note There is no timeout on this function, so its use is not recommended.
WiredHome 85:022bba13c5c4 1239 ///
WiredHome 85:022bba13c5c4 1240 /// @code
WiredHome 85:022bba13c5c4 1241 /// Timer t;
WiredHome 85:022bba13c5c4 1242 /// t.start();
WiredHome 85:022bba13c5c4 1243 /// do {
WiredHome 85:022bba13c5c4 1244 /// point_t point = {0, 0};
WiredHome 85:022bba13c5c4 1245 /// display.TouchPanelGet(&point); // hangs here until touch
WiredHome 85:022bba13c5c4 1246 /// display.pixel(point, Red);
WiredHome 85:022bba13c5c4 1247 /// } while (t.read_ms() < 30000);
WiredHome 85:022bba13c5c4 1248 /// @endcode
WiredHome 85:022bba13c5c4 1249 ///
WiredHome 85:022bba13c5c4 1250 /// @param[out] TouchPoint is the touch point, if a touch is registered.
WiredHome 85:022bba13c5c4 1251 /// @returns a value indicating the state of the touch,
WiredHome 85:022bba13c5c4 1252 /// - no_cal: no calibration matrix is available, touch coordinates are not returned.
WiredHome 85:022bba13c5c4 1253 /// - no_touch: no touch is detected, touch coordinates are not returned.
WiredHome 85:022bba13c5c4 1254 /// - touch: touch is detected, touch coordinates are returned.
WiredHome 85:022bba13c5c4 1255 /// - held: held after touch, touch coordinates are returned.
WiredHome 85:022bba13c5c4 1256 /// - release: indicates a release, touch coordinates are returned.
WiredHome 85:022bba13c5c4 1257 ///
WiredHome 85:022bba13c5c4 1258 TouchCode_t TouchPanelGet(point_t * TouchPoint);
WiredHome 85:022bba13c5c4 1259
WiredHome 83:7bad0068cca0 1260
WiredHome 157:1565f38ca44b 1261 /// Configuration Option for the Resistive Touch Panel Calibration.
WiredHome 157:1565f38ca44b 1262 ///
WiredHome 157:1565f38ca44b 1263 /// This method is only useful for the resistive touchscreen.
WiredHome 157:1565f38ca44b 1264 ///
WiredHome 157:1565f38ca44b 1265 /// Also, this method is optional - the user can take all of the responsibility
WiredHome 157:1565f38ca44b 1266 /// in their code, or for simplicity sake, this API can be used prior
WiredHome 157:1565f38ca44b 1267 /// to the init method.
WiredHome 157:1565f38ca44b 1268 ///
WiredHome 157:1565f38ca44b 1269 /// @code
WiredHome 157:1565f38ca44b 1270 /// RA8875 lcd(p5, p6, p7, p12, NC);
WiredHome 157:1565f38ca44b 1271 /// ...
WiredHome 190:3132b7dfad82 1272 /// LocalFileSystem local();
WiredHome 157:1565f38ca44b 1273 /// // Be sure you previously mounted the "/sd" file system to put the cal there.
WiredHome 157:1565f38ca44b 1274 /// lcd.ResTouchPanelCfg("/sd/tpcal.cfg", "Touch '+' to calibrate the touch panel");
WiredHome 157:1565f38ca44b 1275 ///
WiredHome 190:3132b7dfad82 1276 /// // Only if the touch panel is enabled, AND is configured as the resistive
WiredHome 157:1565f38ca44b 1277 /// // panel will the prior command be useful.
WiredHome 198:9b6851107426 1278 /// lcd.init(LCD_PHYS_W,LCD_PHYS_H,LCD_C,40, false, true);
WiredHome 157:1565f38ca44b 1279 ///
WiredHome 157:1565f38ca44b 1280 /// @endcode
WiredHome 157:1565f38ca44b 1281 ///
WiredHome 157:1565f38ca44b 1282 /// @param[in] tpFQFN is a pointer to a fully qualified read-write accessible
WiredHome 157:1565f38ca44b 1283 /// filename where the calibration is held.
WiredHome 157:1565f38ca44b 1284 /// @param[in] tpCalMessage is an optional pointer to a message shown to the
WiredHome 190:3132b7dfad82 1285 /// user in the calibration process.
WiredHome 157:1565f38ca44b 1286 /// - If this parameter is not included, a default message will be shown.
WiredHome 157:1565f38ca44b 1287 /// - If this parameter points to a NULL string, no message is shown.
WiredHome 157:1565f38ca44b 1288 /// - If this parameter points to a non-NULL string, that string will be shown.
WiredHome 157:1565f38ca44b 1289 ///
WiredHome 157:1565f38ca44b 1290 void ResTouchPanelCfg(const char * tpFQFN = NULL, const char * tpCalMessage = NULL);
WiredHome 157:1565f38ca44b 1291
WiredHome 157:1565f38ca44b 1292
WiredHome 77:9206c13aa527 1293 /// Calibrate the touch panel.
WiredHome 77:9206c13aa527 1294 ///
WiredHome 77:9206c13aa527 1295 /// This method accepts two lists - one list is target points in ,
WiredHome 190:3132b7dfad82 1296 /// display coordinates and the other is a lit of raw touch coordinate
WiredHome 77:9206c13aa527 1297 /// values. It generates a calibration matrix for later use. This
WiredHome 77:9206c13aa527 1298 /// matrix is also accessible to the calling API, which may store
WiredHome 77:9206c13aa527 1299 /// the matrix in persistent memory and then install the calibration
WiredHome 77:9206c13aa527 1300 /// matrix on the next power cycle. By doing so, it can avoid the
WiredHome 77:9206c13aa527 1301 /// need to calibrate on every power cycle.
WiredHome 77:9206c13aa527 1302 ///
WiredHome 81:01da2e34283d 1303 /// @note The methods "TouchPanelComputeCalibration", "TouchPanelReadable", and
WiredHome 77:9206c13aa527 1304 /// indirectly the "TouchPanelSetMatrix" methods are all derived
WiredHome 77:9206c13aa527 1305 /// from a program by Carlos E. Vidales. See the copyright note
WiredHome 77:9206c13aa527 1306 /// for further details. See also the article
WiredHome 77:9206c13aa527 1307 /// http://www.embedded.com/design/system-integration/4023968/How-To-Calibrate-Touch-Screens
WiredHome 77:9206c13aa527 1308 ///
WiredHome 167:8aa3fb2a5a31 1309 /// @copyright Copyright &copy; 2001, Carlos E. Vidales. All rights reserved.
WiredHome 190:3132b7dfad82 1310 /// This sample program was written and put in the public domain
WiredHome 190:3132b7dfad82 1311 /// by Carlos E. Vidales. The program is provided "as is"
WiredHome 78:faf49c381591 1312 /// without warranty of any kind, either expressed or implied.
WiredHome 78:faf49c381591 1313 /// If you choose to use the program within your own products
WiredHome 78:faf49c381591 1314 /// you do so at your own risk, and assume the responsibility
WiredHome 78:faf49c381591 1315 /// for servicing, repairing or correcting the program should
WiredHome 78:faf49c381591 1316 /// it prove defective in any manner.
WiredHome 190:3132b7dfad82 1317 /// You may copy and distribute the program's source code in any
WiredHome 78:faf49c381591 1318 /// medium, provided that you also include in each copy an
WiredHome 78:faf49c381591 1319 /// appropriate copyright notice and disclaimer of warranty.
WiredHome 78:faf49c381591 1320 /// You may also modify this program and distribute copies of
WiredHome 190:3132b7dfad82 1321 /// it provided that you include prominent notices stating
WiredHome 78:faf49c381591 1322 /// that you changed the file(s) and the date of any change,
WiredHome 190:3132b7dfad82 1323 /// and that you do not charge any royalties or licenses for
WiredHome 78:faf49c381591 1324 /// its use.
WiredHome 77:9206c13aa527 1325 ///
WiredHome 190:3132b7dfad82 1326 /// @param[in] display is a pointer to a set of 3 points, which
WiredHome 77:9206c13aa527 1327 /// are in display units of measure. These are the targets
WiredHome 77:9206c13aa527 1328 /// the calibration was aiming for.
WiredHome 77:9206c13aa527 1329 /// @param[in] screen is a pointer to a set of 3 points, which
WiredHome 77:9206c13aa527 1330 /// are in touchscreen units of measure. These are the
WiredHome 77:9206c13aa527 1331 /// registered touches.
WiredHome 190:3132b7dfad82 1332 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 190:3132b7dfad82 1333 /// as a result of the calibration. This can be saved in
WiredHome 77:9206c13aa527 1334 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 167:8aa3fb2a5a31 1335 /// @returns @ref RetCode_t value.
WiredHome 77:9206c13aa527 1336 ///
WiredHome 81:01da2e34283d 1337 RetCode_t TouchPanelComputeCalibration(point_t display[3], point_t screen[3], tpMatrix_t * matrix);
WiredHome 81:01da2e34283d 1338
WiredHome 81:01da2e34283d 1339
WiredHome 81:01da2e34283d 1340 /// Perform the touch panel calibration process.
WiredHome 81:01da2e34283d 1341 ///
WiredHome 81:01da2e34283d 1342 /// This method provides the easy "shortcut" to calibrating the touch panel.
WiredHome 81:01da2e34283d 1343 /// The process will automatically generate the calibration points, present
WiredHome 81:01da2e34283d 1344 /// the targets on-screen, detect the touches, compute the calibration
WiredHome 81:01da2e34283d 1345 /// matrix, and optionally provide the calibration matrix to the calling code
WiredHome 81:01da2e34283d 1346 /// for persistence in non-volatile memory.
WiredHome 81:01da2e34283d 1347 ///
WiredHome 190:3132b7dfad82 1348 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 190:3132b7dfad82 1349 /// as a result of the calibration. This can be saved in
WiredHome 81:01da2e34283d 1350 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 167:8aa3fb2a5a31 1351 /// @returns @ref RetCode_t value.
WiredHome 81:01da2e34283d 1352 ///
WiredHome 85:022bba13c5c4 1353 RetCode_t TouchPanelCalibrate(tpMatrix_t * matrix = NULL);
WiredHome 81:01da2e34283d 1354
WiredHome 125:7a0b70f56550 1355
WiredHome 81:01da2e34283d 1356 /// Perform the touch panel calibration process.
WiredHome 81:01da2e34283d 1357 ///
WiredHome 81:01da2e34283d 1358 /// This method provides the easy "shortcut" to calibrating the touch panel.
WiredHome 81:01da2e34283d 1359 /// The process will automatically generate the calibration points, present
WiredHome 81:01da2e34283d 1360 /// the targets on-screen, detect the touches, compute the calibration
WiredHome 81:01da2e34283d 1361 /// matrix, and optionally provide the calibration matrix to the calling code
WiredHome 81:01da2e34283d 1362 /// for persistence in non-volatile memory.
WiredHome 81:01da2e34283d 1363 ///
WiredHome 81:01da2e34283d 1364 /// @param[in] msg is a text message to present on the screen during the
WiredHome 81:01da2e34283d 1365 /// calibration process.
WiredHome 190:3132b7dfad82 1366 /// @param[out] matrix is an optional parameter to hold the calibration matrix
WiredHome 190:3132b7dfad82 1367 /// as a result of the calibration. This can be saved in
WiredHome 81:01da2e34283d 1368 /// non-volatile memory to recover the calibration after a power fail.
WiredHome 88:bfddef6ec836 1369 /// @param[in] maxwait_s is the maximum number of seconds to wait for a touch
WiredHome 88:bfddef6ec836 1370 /// calibration. If no touch panel installed, it then reports
WiredHome 155:b3f225ae572c 1371 /// touch_cal_timeout. Default: 30 s.
WiredHome 167:8aa3fb2a5a31 1372 /// @returns @ref RetCode_t value.
WiredHome 81:01da2e34283d 1373 ///
WiredHome 155:b3f225ae572c 1374 RetCode_t TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix = NULL, int maxwait_s = 30);
WiredHome 77:9206c13aa527 1375
WiredHome 125:7a0b70f56550 1376
WiredHome 157:1565f38ca44b 1377 /// Set the calibration matrix for the resistive touch panel.
WiredHome 77:9206c13aa527 1378 ///
WiredHome 77:9206c13aa527 1379 /// This method is used to set the calibration matrix for the touch panel. After
WiredHome 106:c80828f5dea4 1380 /// performing the calibration (See @ref TouchPanelComputeCalibration), the matrix can be stored.
WiredHome 77:9206c13aa527 1381 /// On a subsequence power cycle, the matrix may be restored from non-volatile and
WiredHome 77:9206c13aa527 1382 /// passed in to this method. It will then be held to perform the corrections when
WiredHome 77:9206c13aa527 1383 /// reading the touch panel point.
WiredHome 77:9206c13aa527 1384 ///
WiredHome 78:faf49c381591 1385 /// @code
WiredHome 78:faf49c381591 1386 /// FILE * fh = fopen("/local/tpmatrix.cfg", "r");
WiredHome 78:faf49c381591 1387 /// if (fh) {
WiredHome 78:faf49c381591 1388 /// tpMatrix_t matrix;
WiredHome 78:faf49c381591 1389 /// if (fread(fh, &matrix, sizeof(tpMatrix_t))) {
WiredHome 78:faf49c381591 1390 /// lcd.TouchPanelSetMatrix(&matrix);
WiredHome 78:faf49c381591 1391 /// }
WiredHome 78:faf49c381591 1392 /// fclose(fh);
WiredHome 78:faf49c381591 1393 /// }
WiredHome 78:faf49c381591 1394 /// @endcode
WiredHome 190:3132b7dfad82 1395 ///
WiredHome 77:9206c13aa527 1396 /// @param[in] matrix is a pointer to the touch panel calibration matrix.
WiredHome 167:8aa3fb2a5a31 1397 /// @returns @ref RetCode_t value.
WiredHome 77:9206c13aa527 1398 ///
WiredHome 190:3132b7dfad82 1399 ///
WiredHome 77:9206c13aa527 1400 RetCode_t TouchPanelSetMatrix(tpMatrix_t * matrix);
WiredHome 157:1565f38ca44b 1401
WiredHome 157:1565f38ca44b 1402 /// Get the calibration matrix for the resistive touch panel.
WiredHome 157:1565f38ca44b 1403 ///
WiredHome 157:1565f38ca44b 1404 /// This method returns a const pointer to the matrix. If this matrix has
WiredHome 157:1565f38ca44b 1405 /// not be set, with either the TouchPanelSetMatrix API or the calibration
WiredHome 157:1565f38ca44b 1406 /// process, the results are indeterminate.
WiredHome 157:1565f38ca44b 1407 ///
WiredHome 157:1565f38ca44b 1408 /// return const tpMatrix_t pointer
WiredHome 190:3132b7dfad82 1409 ///
WiredHome 157:1565f38ca44b 1410 const tpMatrix_t * TouchPanelGetMatrix();
WiredHome 125:7a0b70f56550 1411
WiredHome 75:ca78388cfd77 1412 #if 0
hexley 54:e117ad10fba6 1413 /// Append interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 1414 ///
hexley 54:e117ad10fba6 1415 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 1416 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 1417 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 1418 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 1419 /// - RA8875_INT_BTE: BTE process complete interrupt
WiredHome 190:3132b7dfad82 1420 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
WiredHome 56:7a85d226ad0d 1421 /// @param[in] fptr is a callback function to handle the interrupt event.
WiredHome 56:7a85d226ad0d 1422 /// @returns none
hexley 54:e117ad10fba6 1423 ///
hexley 54:e117ad10fba6 1424 void AppendISR(uint8_t bISRType, void(*fptr)(void));
hexley 54:e117ad10fba6 1425
hexley 54:e117ad10fba6 1426 /// Unappend interrupt handler for specific RA8875 interrupt source
hexley 54:e117ad10fba6 1427 ///
hexley 54:e117ad10fba6 1428 /// @param[in] bISRType Interrupt Source, should be:
hexley 54:e117ad10fba6 1429 /// - RA8875_INT_KEYSCAN: KEYCAN interrupt
hexley 54:e117ad10fba6 1430 /// - RA8875_INT_DMA: DMA interrupt
hexley 54:e117ad10fba6 1431 /// - RA8875_INT_TP: Touch panel interrupt
hexley 54:e117ad10fba6 1432 /// - RA8875_INT_BTE: BTE process complete interrupt
WiredHome 190:3132b7dfad82 1433 /// - RA8875_INT_BTEMCU_FONTWR: Multi-purpose interrupt (see spec sheet)
hexley 54:e117ad10fba6 1434 /// @return none
hexley 54:e117ad10fba6 1435 ///
hexley 54:e117ad10fba6 1436 void UnAppendISR(uint8_t bISRType);
WiredHome 75:ca78388cfd77 1437 #endif
WiredHome 77:9206c13aa527 1438
WiredHome 125:7a0b70f56550 1439
WiredHome 71:dcac8efd842d 1440 /// Initialize the keypad interface on the RA8875 controller.
WiredHome 71:dcac8efd842d 1441 ///
WiredHome 71:dcac8efd842d 1442 /// Enables the keypad subsystem. It will scan the 4 x 5 matrix
WiredHome 182:8832d03a2a29 1443 /// and make available key presses. See also @ref SetKeyMap().
WiredHome 71:dcac8efd842d 1444 ///
WiredHome 71:dcac8efd842d 1445 /// @note See section 5-13 of RAIO RA8875 data sheet for more details.
WiredHome 125:7a0b70f56550 1446 /// @note When using the display from buy-display.com, be sure that
WiredHome 71:dcac8efd842d 1447 /// the option for the keypad is configured on the hardware.
WiredHome 71:dcac8efd842d 1448 ///
WiredHome 71:dcac8efd842d 1449 /// All parameters are optional.
WiredHome 76:c981284eb513 1450 /// @param[in] scanEnable when true, enables the key scan function (default: true).
WiredHome 76:c981284eb513 1451 /// @param[in] longDetect when true, additionally enables the long key held detection (default: false).
WiredHome 71:dcac8efd842d 1452 /// @param[in] sampleTime setting (range: 0 - 3, default: 0).
WiredHome 71:dcac8efd842d 1453 /// @param[in] scanFrequency setting (range: 0 - 7, default: 0).
WiredHome 71:dcac8efd842d 1454 /// @param[in] longTimeAdjustment (range: 0 - 3, default: 0).
WiredHome 76:c981284eb513 1455 /// @param[in] interruptEnable when true, enables interrupts from keypress (default: false).
WiredHome 76:c981284eb513 1456 /// @param[in] wakeupEnable when true, activates the wakeup function (default: false).
WiredHome 71:dcac8efd842d 1457 ///
WiredHome 167:8aa3fb2a5a31 1458 /// @returns @ref RetCode_t value.
WiredHome 71:dcac8efd842d 1459 ///
WiredHome 190:3132b7dfad82 1460 RetCode_t KeypadInit(bool scanEnable = true, bool longDetect = false,
WiredHome 190:3132b7dfad82 1461 uint8_t sampleTime = 0, uint8_t scanFrequency = 0,
WiredHome 71:dcac8efd842d 1462 uint8_t longTimeAdjustment = 0,
WiredHome 71:dcac8efd842d 1463 bool interruptEnable = false, bool wakeupEnable = false);
WiredHome 71:dcac8efd842d 1464
WiredHome 125:7a0b70f56550 1465
WiredHome 75:ca78388cfd77 1466 /// Create Key Code definitions for the key matrix.
WiredHome 75:ca78388cfd77 1467 ///
WiredHome 75:ca78388cfd77 1468 /// This API provides a table of 22 key-code assignments for the matrix of keys.
WiredHome 182:8832d03a2a29 1469 /// See also KeypadInit().
WiredHome 75:ca78388cfd77 1470 /// This can be used to translate the keys 1 - 20 into some other value, as
WiredHome 75:ca78388cfd77 1471 /// well as to communicate the "no key" (zero) and "error state" (21).
WiredHome 75:ca78388cfd77 1472 ///
WiredHome 75:ca78388cfd77 1473 /// In this way, a keypad could easily emulate a piece of a keyboard, transforming
WiredHome 75:ca78388cfd77 1474 /// 0 - 20 into the values 0, '0', '1', '2', '3', '4', '5', '6', '7', '8',
WiredHome 125:7a0b70f56550 1475 /// '9', '+', '-', '*' , '/', '=', '(bs)', '(cr)', and so on...
WiredHome 75:ca78388cfd77 1476 ///
WiredHome 75:ca78388cfd77 1477 /// @code
WiredHome 75:ca78388cfd77 1478 /// // Return Value by Row, Column Example reassignment
WiredHome 190:3132b7dfad82 1479 /// // Column 0 1 2 3 4
WiredHome 75:ca78388cfd77 1480 /// // +-------------------------+ +-------------------------+
WiredHome 76:c981284eb513 1481 /// // Row 0 | 1 2 3 4 5 | | '7' '8' '9' ',' '<-' |
WiredHome 75:ca78388cfd77 1482 /// // 1 | 6 7 8 9 10 | | '4' '5' '6' '/' '-' |
WiredHome 75:ca78388cfd77 1483 /// // 2 | 11 12 13 14 15 | | '1' '2' '3' '*' '+' |
WiredHome 76:c981284eb513 1484 /// // 3 | 16 17 18 19 20 | | '0' '.' '(' ')' '\n' |
WiredHome 75:ca78388cfd77 1485 /// // +-------------------------+ +-------------------------+
WiredHome 75:ca78388cfd77 1486 /// // Return value 0 = No Key pressed
WiredHome 75:ca78388cfd77 1487 /// // Return value 21 = Error
WiredHome 190:3132b7dfad82 1488 /// const uint8_t CodeList[22] =
WiredHome 190:3132b7dfad82 1489 /// {0, '7', '8', '9', ',', '\h',
WiredHome 77:9206c13aa527 1490 /// '4', '5', '6', '/', '-',
WiredHome 77:9206c13aa527 1491 /// '1', '2', '3', '*', '+',
WiredHome 190:3132b7dfad82 1492 /// '0', '.', '(', ')', '\n',
WiredHome 77:9206c13aa527 1493 /// '\x1b'};
WiredHome 77:9206c13aa527 1494 /// lcd.SetKeyMap(CodeList);
WiredHome 75:ca78388cfd77 1495 /// @endcode
WiredHome 190:3132b7dfad82 1496 ///
WiredHome 190:3132b7dfad82 1497 /// @param[in] CodeList is a pointer to an always available byte-array
WiredHome 190:3132b7dfad82 1498 /// where the first 22 bytes are used as the transformation
WiredHome 75:ca78388cfd77 1499 /// from raw code to your reassigned value.
WiredHome 75:ca78388cfd77 1500 /// If CodeList is NULL, the original raw value key map is
WiredHome 75:ca78388cfd77 1501 /// restored.
WiredHome 167:8aa3fb2a5a31 1502 /// @returns @ref RetCode_t value.
WiredHome 75:ca78388cfd77 1503 ///
WiredHome 75:ca78388cfd77 1504 RetCode_t SetKeyMap(const uint8_t * CodeList = NULL);
WiredHome 75:ca78388cfd77 1505
WiredHome 125:7a0b70f56550 1506
WiredHome 71:dcac8efd842d 1507 /// Determine if a key has been hit
WiredHome 71:dcac8efd842d 1508 ///
WiredHome 71:dcac8efd842d 1509 /// @returns true if a key has been hit
WiredHome 71:dcac8efd842d 1510 ///
WiredHome 75:ca78388cfd77 1511 bool readable();
WiredHome 71:dcac8efd842d 1512
WiredHome 125:7a0b70f56550 1513
WiredHome 71:dcac8efd842d 1514 /// Blocking read of the keypad.
WiredHome 71:dcac8efd842d 1515 ///
WiredHome 125:7a0b70f56550 1516 /// @note: This is a blocking read, so it is important to first call _kbhit()
WiredHome 71:dcac8efd842d 1517 /// to avoid hanging your processes.
WiredHome 71:dcac8efd842d 1518 ///
WiredHome 71:dcac8efd842d 1519 /// A keypad connected to the RA8875 is connected in a matrix of 4 rows and 5 columns.
WiredHome 75:ca78388cfd77 1520 /// When pressed, this method will return a code in the range of 1 through 20, reserving
WiredHome 75:ca78388cfd77 1521 /// the value 0 to indicate that no key is pressed.
WiredHome 71:dcac8efd842d 1522 ///
WiredHome 71:dcac8efd842d 1523 /// Additionally, if configured to detect a "long press", bit 7 will be set to indicate
WiredHome 71:dcac8efd842d 1524 /// this. In this situation, first a "normal press" would be detected and signaled and
WiredHome 71:dcac8efd842d 1525 /// soon after that a "long press" of the same key would be detected and communicated.
WiredHome 71:dcac8efd842d 1526 ///
WiredHome 75:ca78388cfd77 1527 /// @return 8-bit where bit 7 indicates a long press. The remaining bits indicate the
WiredHome 75:ca78388cfd77 1528 /// keypress using 0 = no key pressed, 1 - 20 = the key pressed.
WiredHome 71:dcac8efd842d 1529 ///
WiredHome 75:ca78388cfd77 1530 uint8_t getc();
WiredHome 190:3132b7dfad82 1531
WiredHome 190:3132b7dfad82 1532
WiredHome 190:3132b7dfad82 1533 /// Align one rectangle against another.
WiredHome 190:3132b7dfad82 1534 ///
WiredHome 190:3132b7dfad82 1535 /// This will accept a rectangle to align and align it against another rectangle.
WiredHome 190:3132b7dfad82 1536 /// It would be most typical if the rectangle to align is smaller than the reference rectangle.
WiredHome 190:3132b7dfad82 1537 ///
WiredHome 190:3132b7dfad82 1538 /// @param[in] toAlign is a rectangular region to align against another.
WiredHome 190:3132b7dfad82 1539 /// @param[in] inRect is a rectangle to align against.
WiredHome 190:3132b7dfad82 1540 /// @param[in] v specifies the vertical alignment - top, middle, bottom.
WiredHome 190:3132b7dfad82 1541 /// @param[in] h specified the horizontal alignment - left, center, right.
WiredHome 190:3132b7dfad82 1542 /// @returns a new rectangle, the size of the toAlign.
WiredHome 190:3132b7dfad82 1543 ///
WiredHome 190:3132b7dfad82 1544 rect_t AlignRectInRect(rect_t toAlign, rect_t inRect, valign_t v, halign_t h);
WiredHome 190:3132b7dfad82 1545
WiredHome 82:f7d300f26540 1546 /// Determine if a point is within a rectangle.
WiredHome 82:f7d300f26540 1547 ///
WiredHome 82:f7d300f26540 1548 /// @param[in] rect is a rectangular region to use.
WiredHome 82:f7d300f26540 1549 /// @param[in] p is a point to analyze to see if it is within the rect.
WiredHome 82:f7d300f26540 1550 /// @returns true if p is within rect.
WiredHome 82:f7d300f26540 1551 ///
WiredHome 82:f7d300f26540 1552 bool Intersect(rect_t rect, point_t p);
WiredHome 82:f7d300f26540 1553
WiredHome 131:5bd6ba2ee4a1 1554 /// Determine if a rectangle intersects another rectangle.
WiredHome 131:5bd6ba2ee4a1 1555 ///
WiredHome 131:5bd6ba2ee4a1 1556 /// @param[in] rect1 is a rectangular region.
WiredHome 131:5bd6ba2ee4a1 1557 /// @param[in] rect2 is a second rectangular region.
WiredHome 147:3494792458d9 1558 /// @returns true if any part of rect2 intersects rect1.
WiredHome 131:5bd6ba2ee4a1 1559 ///
WiredHome 131:5bd6ba2ee4a1 1560 bool Intersect(rect_t rect1, rect_t rect2);
WiredHome 190:3132b7dfad82 1561
WiredHome 147:3494792458d9 1562 /// Determine if a rectangle intersects another rectangle and provides
WiredHome 147:3494792458d9 1563 /// the area of intersection.
WiredHome 147:3494792458d9 1564 ///
WiredHome 147:3494792458d9 1565 /// @code
WiredHome 147:3494792458d9 1566 /// +---------------------+
WiredHome 147:3494792458d9 1567 /// | rect1 |
WiredHome 147:3494792458d9 1568 /// | |
WiredHome 147:3494792458d9 1569 /// | +------------------+
WiredHome 147:3494792458d9 1570 /// | | rect3 | |
WiredHome 147:3494792458d9 1571 /// | | | |
WiredHome 147:3494792458d9 1572 /// +---------------------+ |
WiredHome 147:3494792458d9 1573 /// | rect2 |
WiredHome 147:3494792458d9 1574 /// +------------------+
WiredHome 147:3494792458d9 1575 /// @endcode
WiredHome 147:3494792458d9 1576 ///
WiredHome 190:3132b7dfad82 1577 /// @note that the first parameter is a pointer to a rect and the
WiredHome 147:3494792458d9 1578 ///
WiredHome 147:3494792458d9 1579 /// @param[inout] pRect1 is a pointer to a rectangular region, and returns
WiredHome 147:3494792458d9 1580 /// the area of intersection.
WiredHome 147:3494792458d9 1581 /// @param[in] pRect2 is a pointer to a second rectangular region.
WiredHome 147:3494792458d9 1582 /// @returns true if pRect1 and pRect2 intersect and pRect1 is written with
WiredHome 147:3494792458d9 1583 /// the rectangle describing the intersection.
WiredHome 147:3494792458d9 1584 ///
WiredHome 167:8aa3fb2a5a31 1585 bool Intersect(rect_t * pRect1, const rect_t * pRect2);
WiredHome 190:3132b7dfad82 1586
WiredHome 190:3132b7dfad82 1587
WiredHome 38:38d503b4fad6 1588 /// Write a command to the display with a word of data.
WiredHome 38:38d503b4fad6 1589 ///
WiredHome 38:38d503b4fad6 1590 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 1591 ///
WiredHome 72:ecffe56af969 1592 /// @param[in] command is the command to write.
WiredHome 72:ecffe56af969 1593 /// @param[in] data is data to be written to the command register.
WiredHome 167:8aa3fb2a5a31 1594 /// @returns @ref RetCode_t value.
WiredHome 38:38d503b4fad6 1595 ///
WiredHome 38:38d503b4fad6 1596 RetCode_t WriteCommandW(uint8_t command, uint16_t data);
WiredHome 38:38d503b4fad6 1597
WiredHome 125:7a0b70f56550 1598
WiredHome 19:3f82c1161fd2 1599 /// Write a command to the display
WiredHome 19:3f82c1161fd2 1600 ///
WiredHome 19:3f82c1161fd2 1601 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1602 ///
WiredHome 72:ecffe56af969 1603 /// @param[in] command is the command to write.
WiredHome 72:ecffe56af969 1604 /// @param[in] data is optional data to be written to the command register
WiredHome 19:3f82c1161fd2 1605 /// and only occurs if the data is in the range [0 - 0xFF].
WiredHome 167:8aa3fb2a5a31 1606 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 1607 ///
WiredHome 32:0e4f2ae512e2 1608 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
WiredHome 125:7a0b70f56550 1609
WiredHome 190:3132b7dfad82 1610
WiredHome 38:38d503b4fad6 1611 /// Write a data word to the display
WiredHome 38:38d503b4fad6 1612 ///
WiredHome 38:38d503b4fad6 1613 /// This is a high level command, and may invoke several primitives.
WiredHome 38:38d503b4fad6 1614 ///
WiredHome 72:ecffe56af969 1615 /// @param[in] data is the data to write.
WiredHome 167:8aa3fb2a5a31 1616 /// @returns @ref RetCode_t value.
WiredHome 38:38d503b4fad6 1617 ///
WiredHome 38:38d503b4fad6 1618 RetCode_t WriteDataW(uint16_t data);
WiredHome 125:7a0b70f56550 1619
WiredHome 190:3132b7dfad82 1620
WiredHome 19:3f82c1161fd2 1621 /// Write a data byte to the display
WiredHome 19:3f82c1161fd2 1622 ///
WiredHome 19:3f82c1161fd2 1623 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1624 ///
WiredHome 72:ecffe56af969 1625 /// @param[in] data is the data to write.
WiredHome 167:8aa3fb2a5a31 1626 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 1627 ///
WiredHome 32:0e4f2ae512e2 1628 virtual RetCode_t WriteData(unsigned char data);
WiredHome 125:7a0b70f56550 1629
WiredHome 190:3132b7dfad82 1630
WiredHome 19:3f82c1161fd2 1631 /// Read a command register
WiredHome 19:3f82c1161fd2 1632 ///
WiredHome 72:ecffe56af969 1633 /// @param[in] command is the command register to read.
WiredHome 19:3f82c1161fd2 1634 /// @returns the value read from the register.
WiredHome 19:3f82c1161fd2 1635 ///
WiredHome 19:3f82c1161fd2 1636 unsigned char ReadCommand(unsigned char command);
WiredHome 136:224e03d5c31f 1637
WiredHome 136:224e03d5c31f 1638
WiredHome 136:224e03d5c31f 1639 /// Read a word from a command register
WiredHome 136:224e03d5c31f 1640 ///
WiredHome 136:224e03d5c31f 1641 /// @param[in] command is the command register to read.
WiredHome 136:224e03d5c31f 1642 /// @returns the value read from the register.
WiredHome 136:224e03d5c31f 1643 ///
WiredHome 136:224e03d5c31f 1644 uint16_t ReadCommandW(unsigned char command);
WiredHome 190:3132b7dfad82 1645
WiredHome 190:3132b7dfad82 1646
WiredHome 41:2956a0a221e5 1647 /// Read a data byte from the display
WiredHome 19:3f82c1161fd2 1648 ///
WiredHome 19:3f82c1161fd2 1649 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1650 ///
WiredHome 19:3f82c1161fd2 1651 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 1652 ///
WiredHome 19:3f82c1161fd2 1653 unsigned char ReadData(void);
WiredHome 125:7a0b70f56550 1654
WiredHome 190:3132b7dfad82 1655
WiredHome 41:2956a0a221e5 1656 /// Read a word from the display
WiredHome 41:2956a0a221e5 1657 ///
WiredHome 41:2956a0a221e5 1658 /// This is a high level command, and may invoke several primitives.
WiredHome 41:2956a0a221e5 1659 ///
WiredHome 41:2956a0a221e5 1660 /// @returns data that was read.
WiredHome 41:2956a0a221e5 1661 ///
WiredHome 41:2956a0a221e5 1662 uint16_t ReadDataW(void);
WiredHome 41:2956a0a221e5 1663
WiredHome 125:7a0b70f56550 1664
WiredHome 19:3f82c1161fd2 1665 /// Read the display status
WiredHome 19:3f82c1161fd2 1666 ///
WiredHome 19:3f82c1161fd2 1667 /// This is a high level command, and may invoke several primitives.
WiredHome 19:3f82c1161fd2 1668 ///
WiredHome 19:3f82c1161fd2 1669 /// @returns data that was read.
WiredHome 19:3f82c1161fd2 1670 ///
WiredHome 19:3f82c1161fd2 1671 unsigned char ReadStatus(void);
WiredHome 19:3f82c1161fd2 1672
WiredHome 125:7a0b70f56550 1673
WiredHome 19:3f82c1161fd2 1674 /// get the width in pixels of the currently active font
WiredHome 19:3f82c1161fd2 1675 ///
WiredHome 19:3f82c1161fd2 1676 /// @returns font width in pixels.
WiredHome 190:3132b7dfad82 1677 ///
WiredHome 37:f19b7e7449dc 1678 dim_t fontwidth(void);
WiredHome 190:3132b7dfad82 1679
WiredHome 125:7a0b70f56550 1680
WiredHome 19:3f82c1161fd2 1681 /// get the height in pixels of the currently active font
WiredHome 19:3f82c1161fd2 1682 ///
WiredHome 19:3f82c1161fd2 1683 /// @returns font height in pixels.
WiredHome 190:3132b7dfad82 1684 ///
WiredHome 37:f19b7e7449dc 1685 dim_t fontheight(void);
WiredHome 125:7a0b70f56550 1686
WiredHome 190:3132b7dfad82 1687
WiredHome 19:3f82c1161fd2 1688 /// get the number of colums based on the currently active font
WiredHome 19:3f82c1161fd2 1689 ///
WiredHome 19:3f82c1161fd2 1690 /// @returns number of columns.
WiredHome 190:3132b7dfad82 1691 ///
WiredHome 19:3f82c1161fd2 1692 virtual int columns(void);
WiredHome 19:3f82c1161fd2 1693
WiredHome 125:7a0b70f56550 1694
WiredHome 19:3f82c1161fd2 1695 /// get the number of rows based on the currently active font
WiredHome 19:3f82c1161fd2 1696 ///
WiredHome 19:3f82c1161fd2 1697 /// @returns number of rows.
WiredHome 190:3132b7dfad82 1698 ///
WiredHome 19:3f82c1161fd2 1699 virtual int rows(void);
WiredHome 19:3f82c1161fd2 1700
WiredHome 125:7a0b70f56550 1701
WiredHome 19:3f82c1161fd2 1702 /// get the screen width in pixels
WiredHome 19:3f82c1161fd2 1703 ///
WiredHome 19:3f82c1161fd2 1704 /// @returns screen width in pixels.
WiredHome 19:3f82c1161fd2 1705 ///
WiredHome 38:38d503b4fad6 1706 virtual dim_t width(void);
WiredHome 19:3f82c1161fd2 1707
WiredHome 125:7a0b70f56550 1708
WiredHome 19:3f82c1161fd2 1709 /// get the screen height in pixels
WiredHome 19:3f82c1161fd2 1710 ///
WiredHome 19:3f82c1161fd2 1711 /// @returns screen height in pixels.
WiredHome 19:3f82c1161fd2 1712 ///
WiredHome 38:38d503b4fad6 1713 virtual dim_t height(void);
WiredHome 19:3f82c1161fd2 1714
WiredHome 125:7a0b70f56550 1715
WiredHome 43:3becae133285 1716 /// get the color depth in bits per pixel.
WiredHome 43:3becae133285 1717 ///
WiredHome 43:3becae133285 1718 /// @returns 8 or 16 only.
WiredHome 43:3becae133285 1719 ///
WiredHome 43:3becae133285 1720 virtual dim_t color_bpp(void);
WiredHome 43:3becae133285 1721
WiredHome 19:3f82c1161fd2 1722 /// Set cursor position based on the current font size.
WiredHome 190:3132b7dfad82 1723 ///
WiredHome 72:ecffe56af969 1724 /// @param[in] column is the horizontal position in character positions
WiredHome 72:ecffe56af969 1725 /// @param[in] row is the vertical position in character positions
WiredHome 198:9b6851107426 1726 /// @returns @ref point_t value that was the last location.
WiredHome 198:9b6851107426 1727 ///
WiredHome 198:9b6851107426 1728 virtual point_t locate(textloc_t column, textloc_t row);
WiredHome 19:3f82c1161fd2 1729
WiredHome 190:3132b7dfad82 1730 /// Enable word-wrap in _puts()
WiredHome 190:3132b7dfad82 1731 ///
WiredHome 190:3132b7dfad82 1732 /// @todo Consider adding a method to define the word-delimiters, which could then
WiredHome 190:3132b7dfad82 1733 /// include user-selection of characters (e.g. ' ', '-', ';', and so on).
WiredHome 190:3132b7dfad82 1734 ///
WiredHome 190:3132b7dfad82 1735 /// @param[in] _wordwrap when true controls _puts() to wrap on word-boundary, which
WiredHome 190:3132b7dfad82 1736 /// is delimited by 'space' character or 'cr' 'lf' sequences.
WiredHome 190:3132b7dfad82 1737 /// @returns previous wordwrap setting to permit an easy restore.
WiredHome 190:3132b7dfad82 1738 ///
WiredHome 190:3132b7dfad82 1739 bool SetWordWrap(bool _wordwrap);
WiredHome 190:3132b7dfad82 1740
WiredHome 125:7a0b70f56550 1741
WiredHome 19:3f82c1161fd2 1742 /// Prepare the controller to write text to the screen by positioning
WiredHome 19:3f82c1161fd2 1743 /// the cursor.
WiredHome 19:3f82c1161fd2 1744 ///
WiredHome 202:a22cbc04f332 1745 /// @note If the cursor location is not valid (not on-screen), the
WiredHome 202:a22cbc04f332 1746 /// cursor is not set and no error is generated.
WiredHome 202:a22cbc04f332 1747 ///
WiredHome 56:7a85d226ad0d 1748 /// @code
WiredHome 56:7a85d226ad0d 1749 /// lcd.SetTextCursor(100, 25);
WiredHome 56:7a85d226ad0d 1750 /// lcd.puts("Hello");
WiredHome 56:7a85d226ad0d 1751 /// @endcode
WiredHome 56:7a85d226ad0d 1752 ///
WiredHome 72:ecffe56af969 1753 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 1754 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 198:9b6851107426 1755 /// @returns @ref point_t value with the prior cursor position.
WiredHome 198:9b6851107426 1756 ///
WiredHome 198:9b6851107426 1757 point_t SetTextCursor(loc_t x, loc_t y);
WiredHome 29:422616aa04bd 1758
WiredHome 125:7a0b70f56550 1759
WiredHome 103:7e0464ca6c5c 1760 /// Prepare the controller to write text to the screen by positioning
WiredHome 103:7e0464ca6c5c 1761 /// the cursor.
WiredHome 103:7e0464ca6c5c 1762 ///
WiredHome 202:a22cbc04f332 1763 /// @note If the cursor location is not valid (not on-screen), the
WiredHome 202:a22cbc04f332 1764 /// cursor is not set.
WiredHome 202:a22cbc04f332 1765 ///
WiredHome 103:7e0464ca6c5c 1766 /// @code
WiredHome 103:7e0464ca6c5c 1767 /// point_t point = {100, 25};
WiredHome 103:7e0464ca6c5c 1768 /// lcd.SetTextCursor(point);
WiredHome 103:7e0464ca6c5c 1769 /// lcd.puts("Hello");
WiredHome 103:7e0464ca6c5c 1770 /// @endcode
WiredHome 103:7e0464ca6c5c 1771 ///
WiredHome 103:7e0464ca6c5c 1772 /// @param[in] p is the x:y point in pixels from the top-left.
WiredHome 198:9b6851107426 1773 /// @returns @ref point_t value with the prior cursor position.
WiredHome 198:9b6851107426 1774 ///
WiredHome 198:9b6851107426 1775 point_t SetTextCursor(point_t p);
WiredHome 103:7e0464ca6c5c 1776
WiredHome 125:7a0b70f56550 1777
WiredHome 37:f19b7e7449dc 1778 /// Get the current cursor position in pixels.
WiredHome 37:f19b7e7449dc 1779 ///
WiredHome 56:7a85d226ad0d 1780 /// @code
WiredHome 56:7a85d226ad0d 1781 /// point_t point = GetTextCursor();
WiredHome 56:7a85d226ad0d 1782 /// if (point.x > 100 && point.y > 150)
WiredHome 56:7a85d226ad0d 1783 /// //...
WiredHome 56:7a85d226ad0d 1784 /// @endcode
WiredHome 56:7a85d226ad0d 1785 ///
WiredHome 37:f19b7e7449dc 1786 /// @returns cursor position.
WiredHome 37:f19b7e7449dc 1787 ///
WiredHome 37:f19b7e7449dc 1788 point_t GetTextCursor(void);
WiredHome 190:3132b7dfad82 1789
WiredHome 125:7a0b70f56550 1790
WiredHome 29:422616aa04bd 1791 /// Get the current cursor horizontal position in pixels.
WiredHome 29:422616aa04bd 1792 ///
WiredHome 29:422616aa04bd 1793 /// @returns cursor position horizontal offset.
WiredHome 29:422616aa04bd 1794 ///
WiredHome 37:f19b7e7449dc 1795 loc_t GetTextCursor_X(void);
WiredHome 29:422616aa04bd 1796
WiredHome 125:7a0b70f56550 1797
WiredHome 29:422616aa04bd 1798 /// Get the current cursor vertical position in pixels.
WiredHome 29:422616aa04bd 1799 ///
WiredHome 29:422616aa04bd 1800 /// @returns cursor position vertical offset.
WiredHome 29:422616aa04bd 1801 ///
WiredHome 37:f19b7e7449dc 1802 loc_t GetTextCursor_Y(void);
WiredHome 29:422616aa04bd 1803
WiredHome 125:7a0b70f56550 1804
WiredHome 23:a50ded45dbaf 1805 /// Configure additional Cursor Control settings.
WiredHome 23:a50ded45dbaf 1806 ///
WiredHome 190:3132b7dfad82 1807 /// This API lets you modify other cursor control settings;
WiredHome 190:3132b7dfad82 1808 /// Cursor visible/hidden, Cursor blink/normal,
WiredHome 23:a50ded45dbaf 1809 /// Cursor I-Beam/underscore/box.
WiredHome 23:a50ded45dbaf 1810 ///
WiredHome 72:ecffe56af969 1811 /// @param[in] cursor can be set to NOCURSOR (default), IBEAM,
WiredHome 24:8ca861acf12d 1812 /// UNDER, or BLOCK.
WiredHome 72:ecffe56af969 1813 /// @param[in] blink can be set to true or false (default false)
WiredHome 167:8aa3fb2a5a31 1814 /// @returns @ref RetCode_t value.
WiredHome 23:a50ded45dbaf 1815 ///
WiredHome 24:8ca861acf12d 1816 RetCode_t SetTextCursorControl(cursor_t cursor = NOCURSOR, bool blink = false);
WiredHome 125:7a0b70f56550 1817
WiredHome 190:3132b7dfad82 1818
WiredHome 98:ecebed9b80b2 1819 /// Select the built-in ISO 8859-X font to use next.
WiredHome 19:3f82c1161fd2 1820 ///
WiredHome 19:3f82c1161fd2 1821 /// Supported fonts: ISO 8859-1, -2, -3, -4
WiredHome 19:3f82c1161fd2 1822 ///
WiredHome 125:7a0b70f56550 1823 /// @note This only modifies the choice of font from the RA8875 internal
WiredHome 98:ecebed9b80b2 1824 /// fonts.
WiredHome 98:ecebed9b80b2 1825 ///
WiredHome 72:ecffe56af969 1826 /// @param[in] font selects the font for the subsequent text rendering.
WiredHome 19:3f82c1161fd2 1827 ///
WiredHome 19:3f82c1161fd2 1828 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1829 /// the command is not executed.
WiredHome 167:8aa3fb2a5a31 1830 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 1831 ///
WiredHome 19:3f82c1161fd2 1832 RetCode_t SetTextFont(font_t font = ISO8859_1);
WiredHome 190:3132b7dfad82 1833
WiredHome 125:7a0b70f56550 1834
WiredHome 202:a22cbc04f332 1835 /// Translate an (x,y) orientation in the display hardware coordinates
WiredHome 202:a22cbc04f332 1836 /// into (x,y) coordinates given the current orientation.
WiredHome 202:a22cbc04f332 1837 ///
WiredHome 202:a22cbc04f332 1838 /// @param[in] x is the hardware x coordinate
WiredHome 202:a22cbc04f332 1839 /// @param[in] y is the hardware y coordinate
WiredHome 202:a22cbc04f332 1840 /// @returns the translated coordinates as a point
WiredHome 202:a22cbc04f332 1841 ///
WiredHome 202:a22cbc04f332 1842 point_t TranslateOrientation(loc_t x, loc_t y);
WiredHome 202:a22cbc04f332 1843
WiredHome 202:a22cbc04f332 1844
WiredHome 191:0fad2e45e196 1845 /// Gets the display orientation
WiredHome 197:853d08e2fb53 1846 ///
WiredHome 197:853d08e2fb53 1847
WiredHome 191:0fad2e45e196 1848 /// @returns the basic display orientationas an @ref orientation_t value.
WiredHome 191:0fad2e45e196 1849 ///
WiredHome 198:9b6851107426 1850 orientation_t GetGraphicsOrientation();
WiredHome 198:9b6851107426 1851
WiredHome 198:9b6851107426 1852 /// Sets the basic graphics orientation.
WiredHome 84:e102021864b5 1853 ///
WiredHome 84:e102021864b5 1854 /// @note This command does not let you "merge" text onto an existing
WiredHome 84:e102021864b5 1855 /// image, since it reuses the memory for the new orientation.
WiredHome 84:e102021864b5 1856 /// Therefore, it is recommended that you issue a cls() prior
WiredHome 84:e102021864b5 1857 /// to sending text to the screen, or you end with a blended
WiredHome 84:e102021864b5 1858 /// image that is probably not as intended.
WiredHome 84:e102021864b5 1859 ///
WiredHome 125:7a0b70f56550 1860 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1861 ///
WiredHome 191:0fad2e45e196 1862 /// @note more sophisticated control of drawings with rotated text may
WiredHome 191:0fad2e45e196 1863 /// be achieved by direct control of the registers. See the RA8875
WiredHome 191:0fad2e45e196 1864 /// datasheet.
WiredHome 191:0fad2e45e196 1865 ///
WiredHome 84:e102021864b5 1866 /// @code
WiredHome 84:e102021864b5 1867 /// lcd.cls();
WiredHome 198:9b6851107426 1868 /// lcd.SetGraphicsOrientation(RA8875::normal);
WiredHome 84:e102021864b5 1869 /// lcd.puts(30,30, "Normal Landscape");
WiredHome 197:853d08e2fb53 1870 /// wait_us(2500000);
WiredHome 190:3132b7dfad82 1871 ///
WiredHome 84:e102021864b5 1872 /// lcd.cls();
WiredHome 198:9b6851107426 1873 /// lcd.SetGraphicsOrientation(RA8875::rotate_90);
WiredHome 84:e102021864b5 1874 /// lcd.puts(30,30, "Rotated 90 Text\r\n");
WiredHome 197:853d08e2fb53 1875 /// wait_us(2500000);
WiredHome 190:3132b7dfad82 1876 ///
WiredHome 84:e102021864b5 1877 /// lcd.cls();
WiredHome 198:9b6851107426 1878 /// lcd.SetGraphicsOrientation(RA8875::rotate_180);
WiredHome 84:e102021864b5 1879 /// lcd.puts(30,30, "Rotated 180 Text\r\n");
WiredHome 197:853d08e2fb53 1880 /// wait_us(2500000);
WiredHome 190:3132b7dfad82 1881 ///
WiredHome 84:e102021864b5 1882 /// lcd.cls();
WiredHome 198:9b6851107426 1883 /// lcd.SetGraphicsOrientation(RA8875::rotate_270);
WiredHome 84:e102021864b5 1884 /// lcd.puts(30,30, "Rotated 270 Text\r\n");
WiredHome 197:853d08e2fb53 1885 /// wait_us(2500000);
WiredHome 84:e102021864b5 1886 /// @endcode
WiredHome 84:e102021864b5 1887 ///
WiredHome 84:e102021864b5 1888 /// @param[in] angle defaults to normal, but can be rotated
WiredHome 84:e102021864b5 1889 /// - normal | rotate_0
WiredHome 84:e102021864b5 1890 /// - rotate_90 (clockwise)
WiredHome 84:e102021864b5 1891 /// - rotate_180
WiredHome 84:e102021864b5 1892 /// - rotate_270 (clockwise)
WiredHome 167:8aa3fb2a5a31 1893 /// @returns @ref RetCode_t value.
WiredHome 84:e102021864b5 1894 ///
WiredHome 198:9b6851107426 1895 orientation_t SetGraphicsOrientation(orientation_t angle = normal);
WiredHome 198:9b6851107426 1896
WiredHome 198:9b6851107426 1897 /// Sets the text orientation - Normal or 90 degree.
WiredHome 198:9b6851107426 1898 ///
WiredHome 198:9b6851107426 1899 /// @attention This command is experimental.
WiredHome 198:9b6851107426 1900 ///
WiredHome 198:9b6851107426 1901 /// @note This command does not let you "merge" text onto an existing
WiredHome 198:9b6851107426 1902 /// image, since it reuses the memory for the new orientation.
WiredHome 198:9b6851107426 1903 /// Therefore, it is recommended that you issue a cls() prior
WiredHome 198:9b6851107426 1904 /// to sending text to the screen, or you end with a blended
WiredHome 198:9b6851107426 1905 /// image that is probably not as intended.
WiredHome 198:9b6851107426 1906 ///
WiredHome 198:9b6851107426 1907 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 198:9b6851107426 1908 ///
WiredHome 198:9b6851107426 1909 /// @code
WiredHome 198:9b6851107426 1910 /// lcd.cls();
WiredHome 198:9b6851107426 1911 /// lcd.SetTextFontOrientation(RA8875::normal);
WiredHome 198:9b6851107426 1912 /// lcd.puts(30,30, "Normal Landscape");
WiredHome 198:9b6851107426 1913 /// wait_us(2500000);
WiredHome 198:9b6851107426 1914 ///
WiredHome 198:9b6851107426 1915 /// lcd.cls();
WiredHome 198:9b6851107426 1916 /// lcd.SetTextFontOrientation(RA8875::rotate_90);
WiredHome 198:9b6851107426 1917 /// lcd.puts(30,30, "Rotated 90 Text\r\n");
WiredHome 198:9b6851107426 1918 /// wait_us(2500000);
WiredHome 198:9b6851107426 1919 ///
WiredHome 198:9b6851107426 1920 /// lcd.cls();
WiredHome 198:9b6851107426 1921 /// lcd.SetTextFontOrientation(RA8875::rotate_180);
WiredHome 198:9b6851107426 1922 /// lcd.puts(30,30, "Rotated 180 Text\r\n");
WiredHome 198:9b6851107426 1923 /// wait_us(2500000);
WiredHome 198:9b6851107426 1924 ///
WiredHome 198:9b6851107426 1925 /// lcd.cls();
WiredHome 198:9b6851107426 1926 /// lcd.SetTextFontOrientation(RA8875::rotate_270);
WiredHome 198:9b6851107426 1927 /// lcd.puts(30,30, "Rotated 270 Text\r\n");
WiredHome 198:9b6851107426 1928 /// wait_us(2500000);
WiredHome 198:9b6851107426 1929 /// @endcode
WiredHome 198:9b6851107426 1930 ///
WiredHome 198:9b6851107426 1931 /// @param[in] angle defaults to normal, but can be rotated
WiredHome 198:9b6851107426 1932 /// - normal | rotate_0
WiredHome 198:9b6851107426 1933 /// - rotate_90 (sets the 90 degree display bit)
WiredHome 198:9b6851107426 1934 /// - rotate_180
WiredHome 198:9b6851107426 1935 /// - rotate_270 (sets the 90 degree display bit)
WiredHome 198:9b6851107426 1936 /// @returns @ref RetCode_t value.
WiredHome 198:9b6851107426 1937 ///
WiredHome 198:9b6851107426 1938 orientation_t SetTextFontOrientation(orientation_t angle);
WiredHome 190:3132b7dfad82 1939
WiredHome 125:7a0b70f56550 1940
WiredHome 19:3f82c1161fd2 1941 /// Control the font behavior.
WiredHome 19:3f82c1161fd2 1942 ///
WiredHome 19:3f82c1161fd2 1943 /// This command lets you make several modifications to any text that
WiredHome 56:7a85d226ad0d 1944 /// will be written to the screen.
WiredHome 19:3f82c1161fd2 1945 ///
WiredHome 125:7a0b70f56550 1946 /// @note This command only operates on the RA8875 internal fonts.
WiredHome 98:ecebed9b80b2 1947 ///
WiredHome 19:3f82c1161fd2 1948 /// Options can be combined:
WiredHome 19:3f82c1161fd2 1949 /// Default:
WiredHome 190:3132b7dfad82 1950 /// @li Full alignment disabled,
WiredHome 190:3132b7dfad82 1951 /// @li Font with Background color,
WiredHome 84:e102021864b5 1952 /// @li Font in normal orientiation, or rotated 90, 180, or 270 clockwise,
WiredHome 84:e102021864b5 1953 /// @li Horizontal scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1954 /// @li Vertical scale x 1, 2, 3, or 4
WiredHome 84:e102021864b5 1955 ///
WiredHome 84:e102021864b5 1956 /// @note alignment is a special mode for the fonts, when mixing half and
WiredHome 84:e102021864b5 1957 /// full fonts on one presentation. 'align_full' starts each full
WiredHome 84:e102021864b5 1958 /// character on an even alignment. See section 7-4-7 of the RA8875
WiredHome 84:e102021864b5 1959 /// specification.
WiredHome 190:3132b7dfad82 1960 ///
WiredHome 72:ecffe56af969 1961 /// @param[in] fillit defaults to FILL, but can be NOFILL
WiredHome 72:ecffe56af969 1962 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1963 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1964 /// @param[in] vScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 1965 /// and scales the font size by this amount.
WiredHome 72:ecffe56af969 1966 /// @param[in] alignment defaults to align_none, but can be
WiredHome 19:3f82c1161fd2 1967 /// align_full.
WiredHome 190:3132b7dfad82 1968 ///
WiredHome 19:3f82c1161fd2 1969 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 1970 /// the command is not executed.
WiredHome 167:8aa3fb2a5a31 1971 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 1972 ///
WiredHome 190:3132b7dfad82 1973 RetCode_t SetTextFontControl(fill_t fillit = FILL,
WiredHome 190:3132b7dfad82 1974 HorizontalScale hScale = 1,
WiredHome 190:3132b7dfad82 1975 VerticalScale vScale = 1,
WiredHome 19:3f82c1161fd2 1976 alignment_t alignment = align_none);
WiredHome 190:3132b7dfad82 1977
WiredHome 190:3132b7dfad82 1978
WiredHome 190:3132b7dfad82 1979 /// Control the font - to background fill or "ink-only"
WiredHome 190:3132b7dfad82 1980 ///
WiredHome 190:3132b7dfad82 1981 /// This command configures the font presentation to write
WiredHome 190:3132b7dfad82 1982 /// only the font "ink", or to write the ink and also overwrite
WiredHome 190:3132b7dfad82 1983 /// the background with the background color.
WiredHome 190:3132b7dfad82 1984 ///
WiredHome 190:3132b7dfad82 1985 /// @note This command applies only to the internal fonts not to user fonts
WiredHome 190:3132b7dfad82 1986 /// e.g. SelectUserFont(...) out of concerns for performance.
WiredHome 190:3132b7dfad82 1987 /// User fonts always write the character block as a continuous
WiredHome 190:3132b7dfad82 1988 /// stream (for efficiency). This precludes first reading the
WiredHome 190:3132b7dfad82 1989 /// character block before writing it. Alternately, addressing
WiredHome 190:3132b7dfad82 1990 /// individual pixels would also be a significant performance
WiredHome 190:3132b7dfad82 1991 /// impact.
WiredHome 190:3132b7dfad82 1992 ///
WiredHome 190:3132b7dfad82 1993 /// @param[in] fillit set to FILL will also write the background,
WiredHome 190:3132b7dfad82 1994 /// and set to NOFILL will write only the ink.
WiredHome 190:3132b7dfad82 1995 /// @returns the previous fill setting permitting easy restore.
WiredHome 190:3132b7dfad82 1996 ///
WiredHome 190:3132b7dfad82 1997 fill_t SetTextFontFill(fill_t fillit);
WiredHome 125:7a0b70f56550 1998
WiredHome 153:8a85efb3eb71 1999 /// Control the font size of the RA8875 rendered fonts.
WiredHome 19:3f82c1161fd2 2000 ///
WiredHome 19:3f82c1161fd2 2001 /// This command lets you set the font enlargement for both horizontal
WiredHome 190:3132b7dfad82 2002 /// and vertical, independent of the rotation, background, and
WiredHome 106:c80828f5dea4 2003 /// alignment. See @ref SetTextFontControl.
WiredHome 19:3f82c1161fd2 2004 ///
WiredHome 153:8a85efb3eb71 2005 /// @note This command operates on the RA8875 internal fonts.
WiredHome 153:8a85efb3eb71 2006 /// @note This command also operates on the selected soft font.
WiredHome 98:ecebed9b80b2 2007 ///
WiredHome 72:ecffe56af969 2008 /// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
WiredHome 19:3f82c1161fd2 2009 /// and scales the font size by this amount.
WiredHome 190:3132b7dfad82 2010 /// @param[in] vScale is an optional parameter that defaults to the hScale value,
WiredHome 40:04aa280dfa39 2011 /// but can be 1, 2, 3, or 4, and scales the font size by this amount.
WiredHome 40:04aa280dfa39 2012 ///
WiredHome 40:04aa280dfa39 2013 /// @code
WiredHome 40:04aa280dfa39 2014 /// lcd.SetTextFontSize(2); // Set the font to 2x normal size
WiredHome 56:7a85d226ad0d 2015 /// lcd.puts("Two times");
WiredHome 40:04aa280dfa39 2016 /// lcd.SetTextFontSize(2,3); // Set the font to 2x Width and 3x Height
WiredHome 56:7a85d226ad0d 2017 /// lcd.puts("2*2 3*h");
WiredHome 40:04aa280dfa39 2018 /// lcd.SetTextFontSize(); // Restore to normal size in both dimensions
WiredHome 56:7a85d226ad0d 2019 /// lcd.puts("normal");
WiredHome 153:8a85efb3eb71 2020 /// lcd.SelectUserFont(BPG_Arial63x63); // Large user font
WiredHome 153:8a85efb3eb71 2021 /// lcd.puts("B63x63"); // Show a sample
WiredHome 153:8a85efb3eb71 2022 /// lcd.SetTextFontSize(2); // Now twice as big
WiredHome 153:8a85efb3eb71 2023 /// lcd.puts("x2"); // Show a sample
WiredHome 40:04aa280dfa39 2024 /// @endcode
WiredHome 19:3f82c1161fd2 2025 ///
WiredHome 19:3f82c1161fd2 2026 /// @note if either hScale or vScale is outside of its permitted range,
WiredHome 19:3f82c1161fd2 2027 /// the command is not executed.
WiredHome 167:8aa3fb2a5a31 2028 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2029 ///
WiredHome 40:04aa280dfa39 2030 RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
WiredHome 127:db7f2c704693 2031
WiredHome 127:db7f2c704693 2032
WiredHome 127:db7f2c704693 2033 /// Get the text font size of the RA8875 internal fonts.
WiredHome 127:db7f2c704693 2034 ///
WiredHome 127:db7f2c704693 2035 /// This command lets you retrieve the current settings for the font
WiredHome 190:3132b7dfad82 2036 /// horizontal and vertical scale factors. The return value is
WiredHome 127:db7f2c704693 2037 /// one of the scale factors 1, 2, 3, or 4.
WiredHome 127:db7f2c704693 2038 ///
WiredHome 127:db7f2c704693 2039 /// @param[out] hScale is a pointer to memory where the horizontal scale factor
WiredHome 127:db7f2c704693 2040 /// will be written. If the pointer is null, that item will be ignored.
WiredHome 127:db7f2c704693 2041 /// @param[out] vScale is a pointer to memory where the vertical scale factor
WiredHome 127:db7f2c704693 2042 /// will be written. If the pointer is null, that item will be ignored.
WiredHome 167:8aa3fb2a5a31 2043 /// @returns @ref RetCode_t value.
WiredHome 127:db7f2c704693 2044 ///
WiredHome 127:db7f2c704693 2045 RetCode_t GetTextFontSize(HorizontalScale * hScale, VerticalScale * vScale);
WiredHome 125:7a0b70f56550 2046
WiredHome 202:a22cbc04f332 2047 /// Get the width of a string (or character) based on the current font.
WiredHome 19:3f82c1161fd2 2048 ///
WiredHome 190:3132b7dfad82 2049 /// @param[in] text is a pointer to a text string to evaluate.
WiredHome 190:3132b7dfad82 2050 /// @param[in] charOnly defaults to false, which computes over the whole string.
WiredHome 190:3132b7dfad82 2051 /// @returns width in pixels, given the selected font and scale.
WiredHome 190:3132b7dfad82 2052 ///
WiredHome 202:a22cbc04f332 2053 dim_t GetTextWidth(const char* text, bool charOnly = false);
WiredHome 202:a22cbc04f332 2054
WiredHome 202:a22cbc04f332 2055 /// Get the rectange of a string (or character) based on the current font.
WiredHome 202:a22cbc04f332 2056 ///
WiredHome 202:a22cbc04f332 2057 /// @note This computes the rect without considering wordwrap. It will
WiredHome 202:a22cbc04f332 2058 /// treat <cr> as a return to left margin and <lf> as a vertical
WiredHome 202:a22cbc04f332 2059 /// advance. It will also use the currently selected font metrics,
WiredHome 202:a22cbc04f332 2060 /// which includes proportional fonts.
WiredHome 202:a22cbc04f332 2061 ///
WiredHome 202:a22cbc04f332 2062 /// @param[in] text is a pointer to a text string to evaluate.
WiredHome 202:a22cbc04f332 2063 /// @param[in] charOnly defaults to false, which computes over the whole string.
WiredHome 202:a22cbc04f332 2064 /// @returns rectangle that holds this text, as a rect_t
WiredHome 202:a22cbc04f332 2065 ///
WiredHome 202:a22cbc04f332 2066 rect_t GetTextRect(const char* text, bool charOnly = false);
WiredHome 190:3132b7dfad82 2067
WiredHome 190:3132b7dfad82 2068 /// put a character on the screen.
WiredHome 190:3132b7dfad82 2069 ///
WiredHome 72:ecffe56af969 2070 /// @param[in] c is the character.
WiredHome 19:3f82c1161fd2 2071 /// @returns the character, or EOF if there is an error.
WiredHome 19:3f82c1161fd2 2072 ///
WiredHome 19:3f82c1161fd2 2073 virtual int _putc(int c);
WiredHome 19:3f82c1161fd2 2074
WiredHome 125:7a0b70f56550 2075
WiredHome 19:3f82c1161fd2 2076 /// Write string of text to the display
WiredHome 19:3f82c1161fd2 2077 ///
WiredHome 56:7a85d226ad0d 2078 /// @code
WiredHome 56:7a85d226ad0d 2079 /// lcd.puts("Test STring");
WiredHome 56:7a85d226ad0d 2080 /// @endcode
WiredHome 56:7a85d226ad0d 2081 ///
WiredHome 72:ecffe56af969 2082 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 2083 ///
WiredHome 19:3f82c1161fd2 2084 void puts(const char * string);
WiredHome 125:7a0b70f56550 2085
WiredHome 190:3132b7dfad82 2086
WiredHome 19:3f82c1161fd2 2087 /// Write string of text to the display at the specified location.
WiredHome 19:3f82c1161fd2 2088 ///
WiredHome 56:7a85d226ad0d 2089 /// @code
WiredHome 196:56820026701b 2090 /// const point_t pt = {10, 25};
WiredHome 196:56820026701b 2091 /// lcd.puts(pt, "Test STring");
WiredHome 196:56820026701b 2092 /// @endcode
WiredHome 196:56820026701b 2093 ///
WiredHome 196:56820026701b 2094 /// @param[in] pt is the x,y position as a point
WiredHome 196:56820026701b 2095 /// @param[in] string is the null terminated string to send to the display.
WiredHome 196:56820026701b 2096 ///
WiredHome 196:56820026701b 2097 void puts(point_t pt, const char * string);
WiredHome 196:56820026701b 2098
WiredHome 196:56820026701b 2099 /// Write string of text to the display at the specified location.
WiredHome 196:56820026701b 2100 ///
WiredHome 196:56820026701b 2101 /// @code
WiredHome 56:7a85d226ad0d 2102 /// lcd.puts(10,25, "Test STring");
WiredHome 56:7a85d226ad0d 2103 /// @endcode
WiredHome 56:7a85d226ad0d 2104 ///
WiredHome 72:ecffe56af969 2105 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 2106 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 72:ecffe56af969 2107 /// @param[in] string is the null terminated string to send to the display.
WiredHome 19:3f82c1161fd2 2108 ///
WiredHome 37:f19b7e7449dc 2109 void puts(loc_t x, loc_t y, const char * string);
WiredHome 190:3132b7dfad82 2110
WiredHome 125:7a0b70f56550 2111
WiredHome 19:3f82c1161fd2 2112 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 19:3f82c1161fd2 2113 /// the memory cursor.
WiredHome 19:3f82c1161fd2 2114 ///
WiredHome 72:ecffe56af969 2115 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 2116 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 167:8aa3fb2a5a31 2117 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2118 ///
WiredHome 37:f19b7e7449dc 2119 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y);
WiredHome 125:7a0b70f56550 2120
WiredHome 136:224e03d5c31f 2121 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 136:224e03d5c31f 2122 /// the memory cursor.
WiredHome 136:224e03d5c31f 2123 ///
WiredHome 136:224e03d5c31f 2124 /// @param[in] p is the point representing the cursor position to set
WiredHome 167:8aa3fb2a5a31 2125 /// @returns @ref RetCode_t value.
WiredHome 136:224e03d5c31f 2126 ///
WiredHome 136:224e03d5c31f 2127 virtual RetCode_t SetGraphicsCursor(point_t p);
WiredHome 190:3132b7dfad82 2128
WiredHome 136:224e03d5c31f 2129 /// Read the current graphics cursor position as a point.
WiredHome 136:224e03d5c31f 2130 ///
WiredHome 136:224e03d5c31f 2131 /// @returns the graphics cursor as a point.
WiredHome 136:224e03d5c31f 2132 ///
WiredHome 136:224e03d5c31f 2133 virtual point_t GetGraphicsCursor(void);
WiredHome 136:224e03d5c31f 2134
WiredHome 190:3132b7dfad82 2135
WiredHome 41:2956a0a221e5 2136 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 2137 /// the memory read cursor.
WiredHome 41:2956a0a221e5 2138 ///
WiredHome 72:ecffe56af969 2139 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 72:ecffe56af969 2140 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 167:8aa3fb2a5a31 2141 /// @returns @ref RetCode_t value.
WiredHome 41:2956a0a221e5 2142 ///
WiredHome 41:2956a0a221e5 2143 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
WiredHome 190:3132b7dfad82 2144
WiredHome 125:7a0b70f56550 2145
WiredHome 111:efe436c43aba 2146 /// Set the window, constraining where items are written to the screen.
WiredHome 111:efe436c43aba 2147 ///
WiredHome 111:efe436c43aba 2148 /// After setting the window, text and graphics are constrained to this
WiredHome 111:efe436c43aba 2149 /// window. Text will wrap from the right edge back to the left and down
WiredHome 111:efe436c43aba 2150 /// one row and from the bottom to the top. Graphics drawing will be clipped
WiredHome 111:efe436c43aba 2151 /// at the edge of the window.
WiredHome 111:efe436c43aba 2152 ///
WiredHome 111:efe436c43aba 2153 /// @note If the initial text write is outside the window, it will be shown
WiredHome 111:efe436c43aba 2154 /// where the cursor position it. Once the write hits the right edge of
WiredHome 111:efe436c43aba 2155 /// the defined window, it will then wrap back to the left edge. Once it
WiredHome 111:efe436c43aba 2156 /// hits the bottom, it wraps to the top of the window. For this reason,
WiredHome 111:efe436c43aba 2157 /// it is common to set the text cursor to the window.
WiredHome 19:3f82c1161fd2 2158 ///
WiredHome 111:efe436c43aba 2159 /// @code
WiredHome 111:efe436c43aba 2160 /// rect_t r = {10,10, 90,90};
WiredHome 198:9b6851107426 2161 /// r = lcd.SetWindow(r);
WiredHome 111:efe436c43aba 2162 /// lcd.SetTextCursor(r.p1.x, r.p1.y);
WiredHome 111:efe436c43aba 2163 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 198:9b6851107426 2164 /// lcd.SetWindow(r); restore to previous window setting
WiredHome 111:efe436c43aba 2165 /// @endcode
WiredHome 111:efe436c43aba 2166 ///
WiredHome 111:efe436c43aba 2167 /// @param[in] r is the rect_t used to set the window.
WiredHome 198:9b6851107426 2168 /// @returns the previous window definition.
WiredHome 198:9b6851107426 2169 ///
WiredHome 199:fb06805f447f 2170 virtual rect_t SetWindow(rect_t r);
WiredHome 125:7a0b70f56550 2171
WiredHome 111:efe436c43aba 2172 /// Set the window, constraining where items are written to the screen.
WiredHome 111:efe436c43aba 2173 ///
WiredHome 111:efe436c43aba 2174 /// After setting the window, text and graphics are constrained to this
WiredHome 111:efe436c43aba 2175 /// window. Text will wrap from the right edge back to the left and down
WiredHome 111:efe436c43aba 2176 /// one row and from the bottom to the top. Graphics drawing will be clipped
WiredHome 111:efe436c43aba 2177 /// at the edge of the window.
WiredHome 111:efe436c43aba 2178 ///
WiredHome 114:dbfb996bfbf3 2179 /// @note if no parameters are provided, it restores the window to full screen.
WiredHome 114:dbfb996bfbf3 2180 ///
WiredHome 111:efe436c43aba 2181 /// @note If the initial text write is outside the window, it will be shown
WiredHome 198:9b6851107426 2182 /// where the cursor positions it. Once the write hits the right edge of
WiredHome 111:efe436c43aba 2183 /// the defined window, it will then wrap back to the left edge. Once it
WiredHome 111:efe436c43aba 2184 /// hits the bottom, it wraps to the top of the window. For this reason,
WiredHome 111:efe436c43aba 2185 /// it is common to set the text cursor to the window.
WiredHome 19:3f82c1161fd2 2186 ///
WiredHome 56:7a85d226ad0d 2187 /// @code
WiredHome 198:9b6851107426 2188 /// lcd.SetWindow(10,10, 80,80);
WiredHome 111:efe436c43aba 2189 /// lcd.SetTextCursor(10,10);
WiredHome 56:7a85d226ad0d 2190 /// lcd.puts("012345678901234567890123456789012345678901234567890");
WiredHome 198:9b6851107426 2191 /// lcd.SetWindow(); restore to full screen
WiredHome 56:7a85d226ad0d 2192 /// @endcode
WiredHome 56:7a85d226ad0d 2193 ///
WiredHome 198:9b6851107426 2194 /// @param[in] x1 is the left edge in pixels.
WiredHome 198:9b6851107426 2195 /// @param[in] y1 is the top edge in pixels.
WiredHome 198:9b6851107426 2196 /// @param[in] x2 is the right edge in pixels.
WiredHome 198:9b6851107426 2197 /// @param[in] y2 is the bottom edge in pixels.
WiredHome 198:9b6851107426 2198 /// @returns the previous window definition.
WiredHome 198:9b6851107426 2199 ///
WiredHome 198:9b6851107426 2200 virtual rect_t SetWindow(loc_t x1 = 0, loc_t y1 = 0, loc_t x2 = (loc_t)-1, loc_t y2 = (loc_t)-1);
WiredHome 198:9b6851107426 2201
WiredHome 198:9b6851107426 2202 /// Get the current window setting, which constrains what is written to the screen.
WiredHome 198:9b6851107426 2203 ///
WiredHome 198:9b6851107426 2204 /// @returns the current window definition.
WiredHome 198:9b6851107426 2205 ///
WiredHome 198:9b6851107426 2206 virtual rect_t GetWindow();
WiredHome 190:3132b7dfad82 2207
WiredHome 125:7a0b70f56550 2208
WiredHome 61:8f3153bf0baa 2209 /// Clear either the specified layer, or the active layer.
WiredHome 19:3f82c1161fd2 2210 ///
WiredHome 61:8f3153bf0baa 2211 /// The behavior is to clear the whole screen for the specified
WiredHome 61:8f3153bf0baa 2212 /// layer. When not specified, the active drawing layer is cleared.
WiredHome 61:8f3153bf0baa 2213 /// This command can also be used to specifically clear either,
WiredHome 106:c80828f5dea4 2214 /// or both layers. See @ref clsw().
WiredHome 19:3f82c1161fd2 2215 ///
WiredHome 56:7a85d226ad0d 2216 /// @code
WiredHome 56:7a85d226ad0d 2217 /// lcd.cls();
WiredHome 56:7a85d226ad0d 2218 /// @endcode
WiredHome 56:7a85d226ad0d 2219 ///
WiredHome 72:ecffe56af969 2220 /// @param[in] layers is optional. If not provided, the active layer
WiredHome 61:8f3153bf0baa 2221 /// is cleared. If bit 0 is set, layer 0 is cleared, if bit
WiredHome 61:8f3153bf0baa 2222 /// 1 is set, layer 1 is cleared. If both are set, both layers
WiredHome 61:8f3153bf0baa 2223 /// are cleared. Any other value does not cause an action.
WiredHome 190:3132b7dfad82 2224 ///
WiredHome 167:8aa3fb2a5a31 2225 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2226 ///
WiredHome 61:8f3153bf0baa 2227 virtual RetCode_t cls(uint16_t layers = 0);
WiredHome 125:7a0b70f56550 2228
WiredHome 190:3132b7dfad82 2229
WiredHome 19:3f82c1161fd2 2230 /// Clear the screen, or clear only the active window.
WiredHome 19:3f82c1161fd2 2231 ///
WiredHome 190:3132b7dfad82 2232 /// The default behavior is to clear the whole screen. With the optional
WiredHome 19:3f82c1161fd2 2233 /// parameter, the action can be restricted to the active window, which
WiredHome 198:9b6851107426 2234 /// can be set with the See @ref SetWindow method.
WiredHome 19:3f82c1161fd2 2235 ///
WiredHome 56:7a85d226ad0d 2236 /// @code
WiredHome 198:9b6851107426 2237 /// lcd.SetWindow(20,20, 40,10);
WiredHome 56:7a85d226ad0d 2238 /// lcd.clsw();
WiredHome 56:7a85d226ad0d 2239 /// @endcode
WiredHome 56:7a85d226ad0d 2240 ///
WiredHome 72:ecffe56af969 2241 /// @param[in] region is an optional parameter that defaults to FULLWINDOW
WiredHome 19:3f82c1161fd2 2242 /// or may be set to ACTIVEWINDOW.
WiredHome 167:8aa3fb2a5a31 2243 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2244 ///
WiredHome 19:3f82c1161fd2 2245 RetCode_t clsw(RA8875::Region_t region = FULLWINDOW);
WiredHome 19:3f82c1161fd2 2246
WiredHome 125:7a0b70f56550 2247
WiredHome 19:3f82c1161fd2 2248 /// Set the background color.
WiredHome 19:3f82c1161fd2 2249 ///
WiredHome 72:ecffe56af969 2250 /// @param[in] color is expressed in 16-bit format.
WiredHome 198:9b6851107426 2251 /// @returns @ref color_t value as the previous background color.
WiredHome 198:9b6851107426 2252 ///
WiredHome 198:9b6851107426 2253 virtual color_t background(color_t color);
WiredHome 125:7a0b70f56550 2254
WiredHome 190:3132b7dfad82 2255
WiredHome 19:3f82c1161fd2 2256 /// Set the background color.
WiredHome 19:3f82c1161fd2 2257 ///
WiredHome 72:ecffe56af969 2258 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 2259 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 2260 /// @param[in] b is the blue element of the color.
WiredHome 198:9b6851107426 2261 /// @returns @ref color_t value as the previous background color.
WiredHome 198:9b6851107426 2262 ///
WiredHome 198:9b6851107426 2263 virtual color_t background(unsigned char r, unsigned char g, unsigned char b);
WiredHome 190:3132b7dfad82 2264
WiredHome 125:7a0b70f56550 2265
WiredHome 19:3f82c1161fd2 2266 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 2267 ///
WiredHome 72:ecffe56af969 2268 /// @param[in] color is expressed in 16-bit format.
WiredHome 198:9b6851107426 2269 /// @returns @ref color_t value as the previous background color.
WiredHome 198:9b6851107426 2270 ///
WiredHome 198:9b6851107426 2271 virtual color_t foreground(color_t color);
WiredHome 190:3132b7dfad82 2272
WiredHome 125:7a0b70f56550 2273
WiredHome 19:3f82c1161fd2 2274 /// Set the foreground color.
WiredHome 19:3f82c1161fd2 2275 ///
WiredHome 72:ecffe56af969 2276 /// @param[in] r is the red element of the color.
WiredHome 72:ecffe56af969 2277 /// @param[in] g is the green element of the color.
WiredHome 72:ecffe56af969 2278 /// @param[in] b is the blue element of the color.
WiredHome 198:9b6851107426 2279 /// @returns @ref color_t value as the previous background color.
WiredHome 198:9b6851107426 2280 ///
WiredHome 198:9b6851107426 2281 virtual color_t foreground(unsigned char r, unsigned char g, unsigned char b);
WiredHome 190:3132b7dfad82 2282
WiredHome 190:3132b7dfad82 2283
WiredHome 19:3f82c1161fd2 2284 /// Get the current foreground color value.
WiredHome 19:3f82c1161fd2 2285 ///
WiredHome 167:8aa3fb2a5a31 2286 /// @returns the current foreground color as @ref color_t.
WiredHome 19:3f82c1161fd2 2287 ///
WiredHome 37:f19b7e7449dc 2288 color_t GetForeColor(void);
WiredHome 190:3132b7dfad82 2289
WiredHome 190:3132b7dfad82 2290
WiredHome 198:9b6851107426 2291 /// Get the current background color value.
WiredHome 198:9b6851107426 2292 ///
WiredHome 198:9b6851107426 2293 /// @returns the current background color as @ref color_t.
WiredHome 198:9b6851107426 2294 ///
WiredHome 198:9b6851107426 2295 color_t GetBackColor(void);
WiredHome 198:9b6851107426 2296
WiredHome 198:9b6851107426 2297
WiredHome 87:ee2240581aa7 2298 /// Draw a pixel in the specified color.
WiredHome 87:ee2240581aa7 2299 ///
WiredHome 87:ee2240581aa7 2300 /// @note Unlike many other operations, this does not
WiredHome 87:ee2240581aa7 2301 /// set the forecolor!
WiredHome 87:ee2240581aa7 2302 ///
WiredHome 87:ee2240581aa7 2303 /// @param[in] p is the point_t defining the location.
WiredHome 167:8aa3fb2a5a31 2304 /// @param[in] color is expressed in 16-bit format.
WiredHome 167:8aa3fb2a5a31 2305 /// @returns @ref RetCode_t value.
WiredHome 87:ee2240581aa7 2306 ///
WiredHome 87:ee2240581aa7 2307 virtual RetCode_t pixel(point_t p, color_t color);
WiredHome 190:3132b7dfad82 2308
WiredHome 190:3132b7dfad82 2309
WiredHome 87:ee2240581aa7 2310 /// Draw a pixel in the current foreground color.
WiredHome 87:ee2240581aa7 2311 ///
WiredHome 87:ee2240581aa7 2312 /// @param[in] p is the point_t defining the location.
WiredHome 167:8aa3fb2a5a31 2313 /// @returns @ref RetCode_t value.
WiredHome 87:ee2240581aa7 2314 ///
WiredHome 87:ee2240581aa7 2315 virtual RetCode_t pixel(point_t p);
WiredHome 190:3132b7dfad82 2316
WiredHome 190:3132b7dfad82 2317
WiredHome 19:3f82c1161fd2 2318 /// Draw a pixel in the specified color.
WiredHome 19:3f82c1161fd2 2319 ///
WiredHome 41:2956a0a221e5 2320 /// @note Unlike many other operations, this does not
WiredHome 41:2956a0a221e5 2321 /// set the forecolor!
WiredHome 19:3f82c1161fd2 2322 ///
WiredHome 72:ecffe56af969 2323 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 2324 /// @param[in] y is the vertical offset to this pixel.
WiredHome 72:ecffe56af969 2325 /// @param[in] color defines the color for the pixel.
WiredHome 167:8aa3fb2a5a31 2326 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2327 ///
WiredHome 37:f19b7e7449dc 2328 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color);
WiredHome 190:3132b7dfad82 2329
WiredHome 190:3132b7dfad82 2330
WiredHome 19:3f82c1161fd2 2331 /// Draw a pixel in the current foreground color.
WiredHome 19:3f82c1161fd2 2332 ///
WiredHome 72:ecffe56af969 2333 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 2334 /// @param[in] y is the veritical offset to this pixel.
WiredHome 167:8aa3fb2a5a31 2335 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2336 ///
WiredHome 37:f19b7e7449dc 2337 virtual RetCode_t pixel(loc_t x, loc_t y);
WiredHome 190:3132b7dfad82 2338
WiredHome 190:3132b7dfad82 2339
WiredHome 41:2956a0a221e5 2340 /// Get a pixel from the display.
WiredHome 41:2956a0a221e5 2341 ///
WiredHome 72:ecffe56af969 2342 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 2343 /// @param[in] y is the vertical offset to this pixel.
WiredHome 167:8aa3fb2a5a31 2344 /// @returns the pixel. See @ref color_t
WiredHome 41:2956a0a221e5 2345 ///
WiredHome 41:2956a0a221e5 2346 virtual color_t getPixel(loc_t x, loc_t y);
WiredHome 190:3132b7dfad82 2347
WiredHome 190:3132b7dfad82 2348
WiredHome 136:224e03d5c31f 2349 /// Write an RGB565 stream of pixels to the display.
WiredHome 41:2956a0a221e5 2350 ///
WiredHome 72:ecffe56af969 2351 /// @param[in] p is a pointer to a color_t array to write.
WiredHome 72:ecffe56af969 2352 /// @param[in] count is the number of pixels to write.
WiredHome 72:ecffe56af969 2353 /// @param[in] x is the horizontal position on the display.
WiredHome 72:ecffe56af969 2354 /// @param[in] y is the vertical position on the display.
WiredHome 167:8aa3fb2a5a31 2355 /// @returns @ref RetCode_t value.
WiredHome 41:2956a0a221e5 2356 ///
WiredHome 41:2956a0a221e5 2357 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 190:3132b7dfad82 2358
WiredHome 190:3132b7dfad82 2359
WiredHome 41:2956a0a221e5 2360 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 2361 ///
WiredHome 72:ecffe56af969 2362 /// @param[in] p is a pointer to a color_t array to accept the stream.
WiredHome 72:ecffe56af969 2363 /// @param[in] count is the number of pixels to read.
WiredHome 72:ecffe56af969 2364 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 72:ecffe56af969 2365 /// @param[in] y is the vertical offset to this pixel.
WiredHome 167:8aa3fb2a5a31 2366 /// @returns @ref RetCode_t value.
WiredHome 41:2956a0a221e5 2367 ///
WiredHome 41:2956a0a221e5 2368 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
WiredHome 131:5bd6ba2ee4a1 2369
WiredHome 131:5bd6ba2ee4a1 2370
WiredHome 109:7b94f06f085b 2371 /// Write a boolean stream to the display.
WiredHome 109:7b94f06f085b 2372 ///
WiredHome 109:7b94f06f085b 2373 /// This takes a bit stream in memory and using the current color settings
WiredHome 109:7b94f06f085b 2374 /// it will stream it to the display. Along the way, each bit is translated
WiredHome 109:7b94f06f085b 2375 /// to either the foreground or background color value and then that pixel
WiredHome 109:7b94f06f085b 2376 /// is pushed onward.
WiredHome 109:7b94f06f085b 2377 ///
WiredHome 190:3132b7dfad82 2378 /// This is similar, but different, to the @ref pixelStream API, which is
WiredHome 109:7b94f06f085b 2379 /// given a stream of color values.
WiredHome 190:3132b7dfad82 2380 ///
WiredHome 153:8a85efb3eb71 2381 /// This is most often used for Soft Fonts, and for that reason, this method
WiredHome 190:3132b7dfad82 2382 /// will scale the presentation based on the selected font size.
WiredHome 153:8a85efb3eb71 2383 /// See @ref SetTextFontSize, So, users may want to SetTextFontSize(1) for
WiredHome 153:8a85efb3eb71 2384 /// 1:1 scaling.
WiredHome 190:3132b7dfad82 2385 ///
WiredHome 109:7b94f06f085b 2386 /// @param[in] x is the horizontal position on the display.
WiredHome 109:7b94f06f085b 2387 /// @param[in] y is the vertical position on the display.
WiredHome 109:7b94f06f085b 2388 /// @param[in] w is the width of the rectangular region to fill.
WiredHome 109:7b94f06f085b 2389 /// @param[in] h is the height of the rectangular region to fill.
WiredHome 109:7b94f06f085b 2390 /// @param[in] boolStream is the inline memory image from which to extract
WiredHome 109:7b94f06f085b 2391 /// the bitstream.
WiredHome 167:8aa3fb2a5a31 2392 /// @returns @ref RetCode_t value.
WiredHome 109:7b94f06f085b 2393 ///
WiredHome 109:7b94f06f085b 2394 virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream);
WiredHome 125:7a0b70f56550 2395
WiredHome 19:3f82c1161fd2 2396 /// Draw a line in the specified color
WiredHome 19:3f82c1161fd2 2397 ///
WiredHome 19:3f82c1161fd2 2398 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2399 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2400 ///
WiredHome 83:7bad0068cca0 2401 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 2402 /// @param[in] p2 is the point to end the line.
WiredHome 83:7bad0068cca0 2403 /// @param[in] color defines the foreground color.
WiredHome 167:8aa3fb2a5a31 2404 /// @returns @ref RetCode_t value.
WiredHome 83:7bad0068cca0 2405 ///
WiredHome 83:7bad0068cca0 2406 RetCode_t line(point_t p1, point_t p2, color_t color);
WiredHome 83:7bad0068cca0 2407
WiredHome 125:7a0b70f56550 2408
WiredHome 83:7bad0068cca0 2409 /// Draw a line
WiredHome 83:7bad0068cca0 2410 ///
WiredHome 83:7bad0068cca0 2411 /// Draws a line using the foreground color setting.
WiredHome 83:7bad0068cca0 2412 ///
WiredHome 83:7bad0068cca0 2413 /// @param[in] p1 is the point to start the line.
WiredHome 83:7bad0068cca0 2414 /// @param[in] p2 is the point to end the line.
WiredHome 167:8aa3fb2a5a31 2415 /// @returns @ref RetCode_t value.
WiredHome 83:7bad0068cca0 2416 ///
WiredHome 83:7bad0068cca0 2417 RetCode_t line(point_t p1, point_t p2);
WiredHome 125:7a0b70f56550 2418
WiredHome 190:3132b7dfad82 2419
WiredHome 83:7bad0068cca0 2420 /// Draw a line in the specified color
WiredHome 83:7bad0068cca0 2421 ///
WiredHome 83:7bad0068cca0 2422 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2423 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2424 ///
WiredHome 72:ecffe56af969 2425 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2426 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2427 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2428 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2429 /// @param[in] color defines the foreground color.
WiredHome 167:8aa3fb2a5a31 2430 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2431 ///
WiredHome 56:7a85d226ad0d 2432 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color);
WiredHome 19:3f82c1161fd2 2433
WiredHome 125:7a0b70f56550 2434
WiredHome 19:3f82c1161fd2 2435 /// Draw a line
WiredHome 19:3f82c1161fd2 2436 ///
WiredHome 19:3f82c1161fd2 2437 /// Draws a line using the foreground color setting.
WiredHome 19:3f82c1161fd2 2438 ///
WiredHome 72:ecffe56af969 2439 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2440 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2441 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2442 /// @param[in] y2 is the vertical end of the line.
WiredHome 167:8aa3fb2a5a31 2443 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2444 ///
WiredHome 37:f19b7e7449dc 2445 RetCode_t line(loc_t x1, loc_t y1, loc_t x2, loc_t y2);
WiredHome 19:3f82c1161fd2 2446
WiredHome 125:7a0b70f56550 2447
WiredHome 144:ba002c4b21b3 2448 /// Draw a thick line
WiredHome 144:ba002c4b21b3 2449 ///
WiredHome 144:ba002c4b21b3 2450 /// Draw a line of a specified thickness and color.
WiredHome 144:ba002c4b21b3 2451 ///
WiredHome 190:3132b7dfad82 2452 /// In order to draw a thick line, this draws filled circles using
WiredHome 190:3132b7dfad82 2453 /// and then draws the 'body' of the thick line using filled triangles. This
WiredHome 190:3132b7dfad82 2454 /// method makes it significantly faster than in prior versions.
WiredHome 190:3132b7dfad82 2455 ///
WiredHome 190:3132b7dfad82 2456 /// An older version of this library used Bresenham's algorithm to move the
WiredHome 190:3132b7dfad82 2457 /// center point of the circle along the line. As a result, this was much
WiredHome 190:3132b7dfad82 2458 /// slower than drawing a 1-pixel line which uses the hardware line drawing
WiredHome 190:3132b7dfad82 2459 /// algorithm.
WiredHome 144:ba002c4b21b3 2460 ///
WiredHome 144:ba002c4b21b3 2461 /// Drawing multiple parallel lines to create a thick line is faster,
WiredHome 144:ba002c4b21b3 2462 /// however the line drawing was not guaranteed to fill every pixel
WiredHome 144:ba002c4b21b3 2463 /// on the diagonals.
WiredHome 144:ba002c4b21b3 2464 ///
WiredHome 144:ba002c4b21b3 2465 /// @param[in] p1 is the point to start the line.
WiredHome 144:ba002c4b21b3 2466 /// @param[in] p2 is the point to end the line.
WiredHome 144:ba002c4b21b3 2467 /// @param[in] thickness is the line thickness.
WiredHome 144:ba002c4b21b3 2468 /// @param[in] color defines the foreground color.
WiredHome 167:8aa3fb2a5a31 2469 /// @returns @ref RetCode_t value.
WiredHome 190:3132b7dfad82 2470 ///
WiredHome 144:ba002c4b21b3 2471 RetCode_t ThickLine(point_t p1, point_t p2, dim_t thickness, color_t color);
WiredHome 144:ba002c4b21b3 2472
WiredHome 144:ba002c4b21b3 2473
WiredHome 190:3132b7dfad82 2474 /// Set the end-cap for ThickLines - square (default) or rounded.
WiredHome 190:3132b7dfad82 2475 ///
WiredHome 190:3132b7dfad82 2476 /// @param[in] roundCap when true causes the end-cap to be drawn as a filled circle.
WiredHome 190:3132b7dfad82 2477 /// @returns the previous end-cap setting, permitting easy restore.
WiredHome 190:3132b7dfad82 2478 ///
WiredHome 190:3132b7dfad82 2479 bool SetEndCap(bool roundCap);
WiredHome 190:3132b7dfad82 2480
WiredHome 190:3132b7dfad82 2481
WiredHome 19:3f82c1161fd2 2482 /// Draw a rectangle in the specified color
WiredHome 19:3f82c1161fd2 2483 ///
WiredHome 19:3f82c1161fd2 2484 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2485 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2486 ///
WiredHome 81:01da2e34283d 2487 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 2488 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 2489 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2490 /// @returns @ref RetCode_t value.
WiredHome 81:01da2e34283d 2491 ///
WiredHome 82:f7d300f26540 2492 RetCode_t rect(rect_t rect, color_t color, fill_t fillit = NOFILL);
WiredHome 190:3132b7dfad82 2493
WiredHome 125:7a0b70f56550 2494
WiredHome 125:7a0b70f56550 2495 /// Draw a filled rectangle in the specified color
WiredHome 81:01da2e34283d 2496 ///
WiredHome 81:01da2e34283d 2497 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 2498 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 2499 ///
WiredHome 81:01da2e34283d 2500 /// @param[in] rect defines the rectangle.
WiredHome 81:01da2e34283d 2501 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 2502 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2503 /// @returns @ref RetCode_t value.
WiredHome 81:01da2e34283d 2504 ///
WiredHome 81:01da2e34283d 2505 RetCode_t fillrect(rect_t rect, color_t color, fill_t fillit = FILL);
WiredHome 81:01da2e34283d 2506
WiredHome 125:7a0b70f56550 2507
WiredHome 81:01da2e34283d 2508 /// Draw a rectangle in the specified color
WiredHome 81:01da2e34283d 2509 ///
WiredHome 81:01da2e34283d 2510 /// @note As a side effect, this changes the current
WiredHome 81:01da2e34283d 2511 /// foreground color for subsequent operations.
WiredHome 81:01da2e34283d 2512 ///
WiredHome 72:ecffe56af969 2513 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2514 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2515 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2516 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2517 /// @param[in] color defines the foreground color.
WiredHome 81:01da2e34283d 2518 /// @param[in] fillit is optional to FILL the rectangle. default is FILL.
WiredHome 167:8aa3fb2a5a31 2519 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2520 ///
WiredHome 190:3132b7dfad82 2521 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 2522 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2523
WiredHome 125:7a0b70f56550 2524
WiredHome 19:3f82c1161fd2 2525 /// Draw a filled rectangle in the specified color
WiredHome 19:3f82c1161fd2 2526 ///
WiredHome 19:3f82c1161fd2 2527 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2528 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2529 ///
WiredHome 72:ecffe56af969 2530 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2531 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2532 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2533 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2534 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2535 /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 167:8aa3fb2a5a31 2536 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2537 ///
WiredHome 190:3132b7dfad82 2538 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 2539 color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2540
WiredHome 125:7a0b70f56550 2541
WiredHome 19:3f82c1161fd2 2542 /// Draw a rectangle
WiredHome 19:3f82c1161fd2 2543 ///
WiredHome 19:3f82c1161fd2 2544 /// Draws a rectangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2545 ///
WiredHome 72:ecffe56af969 2546 /// @param[in] x1 is the horizontal start of the line.
WiredHome 72:ecffe56af969 2547 /// @param[in] y1 is the vertical start of the line.
WiredHome 72:ecffe56af969 2548 /// @param[in] x2 is the horizontal end of the line.
WiredHome 72:ecffe56af969 2549 /// @param[in] y2 is the vertical end of the line.
WiredHome 72:ecffe56af969 2550 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2551 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2552 ///
WiredHome 190:3132b7dfad82 2553 RetCode_t rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 2554 fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2555
WiredHome 125:7a0b70f56550 2556
WiredHome 19:3f82c1161fd2 2557 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 2558 ///
WiredHome 21:3c1efb192927 2559 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2560 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2561 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2562 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 2563 ///
WiredHome 19:3f82c1161fd2 2564 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2565 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2566 ///
WiredHome 72:ecffe56af969 2567 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2568 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2569 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2570 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2571 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2572 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2573 /// is returned.
WiredHome 72:ecffe56af969 2574 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2575 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2576 /// is returned.
WiredHome 72:ecffe56af969 2577 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2578 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2579 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2580 ///
WiredHome 190:3132b7dfad82 2581 RetCode_t fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2582 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2583
WiredHome 125:7a0b70f56550 2584
WiredHome 107:f9ccffcb84f1 2585 /// Draw a filled rectangle with rounded corners using the specified color.
WiredHome 107:f9ccffcb84f1 2586 ///
WiredHome 107:f9ccffcb84f1 2587 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 107:f9ccffcb84f1 2588 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 107:f9ccffcb84f1 2589 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 107:f9ccffcb84f1 2590 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 107:f9ccffcb84f1 2591 ///
WiredHome 107:f9ccffcb84f1 2592 /// @note As a side effect, this changes the current
WiredHome 107:f9ccffcb84f1 2593 /// foreground color for subsequent operations.
WiredHome 107:f9ccffcb84f1 2594 ///
WiredHome 107:f9ccffcb84f1 2595 /// @param[in] r is the rectangle to draw.
WiredHome 107:f9ccffcb84f1 2596 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2597 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2598 /// is returned.
WiredHome 107:f9ccffcb84f1 2599 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2600 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2601 /// is returned.
WiredHome 107:f9ccffcb84f1 2602 /// @param[in] color defines the foreground color.
WiredHome 107:f9ccffcb84f1 2603 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2604 /// @returns @ref RetCode_t value.
WiredHome 107:f9ccffcb84f1 2605 ///
WiredHome 190:3132b7dfad82 2606 RetCode_t fillroundrect(rect_t r,
WiredHome 107:f9ccffcb84f1 2607 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = FILL);
WiredHome 107:f9ccffcb84f1 2608
WiredHome 125:7a0b70f56550 2609
WiredHome 107:f9ccffcb84f1 2610 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 107:f9ccffcb84f1 2611 ///
WiredHome 107:f9ccffcb84f1 2612 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 107:f9ccffcb84f1 2613 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 107:f9ccffcb84f1 2614 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 107:f9ccffcb84f1 2615 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 107:f9ccffcb84f1 2616 ///
WiredHome 107:f9ccffcb84f1 2617 /// @note As a side effect, this changes the current
WiredHome 107:f9ccffcb84f1 2618 /// foreground color for subsequent operations.
WiredHome 107:f9ccffcb84f1 2619 ///
WiredHome 107:f9ccffcb84f1 2620 /// @param[in] r is the rectangle to draw.
WiredHome 107:f9ccffcb84f1 2621 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2622 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2623 /// is returned.
WiredHome 107:f9ccffcb84f1 2624 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2625 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 107:f9ccffcb84f1 2626 /// is returned.
WiredHome 107:f9ccffcb84f1 2627 /// @param[in] color defines the foreground color.
WiredHome 107:f9ccffcb84f1 2628 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2629 /// @returns @ref RetCode_t value.
WiredHome 107:f9ccffcb84f1 2630 ///
WiredHome 190:3132b7dfad82 2631 RetCode_t roundrect(rect_t r,
WiredHome 107:f9ccffcb84f1 2632 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 107:f9ccffcb84f1 2633
WiredHome 125:7a0b70f56550 2634
WiredHome 19:3f82c1161fd2 2635 /// Draw a rectangle with rounded corners using the specified color.
WiredHome 19:3f82c1161fd2 2636 ///
WiredHome 21:3c1efb192927 2637 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2638 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2639 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2640 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 21:3c1efb192927 2641 ///
WiredHome 19:3f82c1161fd2 2642 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2643 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2644 ///
WiredHome 72:ecffe56af969 2645 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2646 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2647 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2648 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2649 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2650 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2651 /// is returned.
WiredHome 72:ecffe56af969 2652 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2653 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2654 /// is returned.
WiredHome 72:ecffe56af969 2655 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2656 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2657 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2658 ///
WiredHome 190:3132b7dfad82 2659 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2660 dim_t radius1, dim_t radius2, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2661
WiredHome 125:7a0b70f56550 2662
WiredHome 19:3f82c1161fd2 2663 /// Draw a rectangle with rounded corners.
WiredHome 19:3f82c1161fd2 2664 ///
WiredHome 21:3c1efb192927 2665 /// This draws a rounded rectangle. A numbers of checks are made on the values,
WiredHome 21:3c1efb192927 2666 /// and it could reduce this to drawing a line (if either x1 == x2, or y1 == y2),
WiredHome 21:3c1efb192927 2667 /// or a single point (x1 == x2 && y1 == y2). If the radius parameters are
WiredHome 21:3c1efb192927 2668 /// > 1/2 the length of that side (width or height), an error value is returned.
WiredHome 19:3f82c1161fd2 2669 ///
WiredHome 72:ecffe56af969 2670 /// @param[in] x1 is the horizontal start of the line and must be <= x2.
WiredHome 72:ecffe56af969 2671 /// @param[in] y1 is the vertical start of the line and must be <= y2.
WiredHome 72:ecffe56af969 2672 /// @param[in] x2 is the horizontal end of the line and must be >= x1.
WiredHome 72:ecffe56af969 2673 /// @param[in] y2 is the vertical end of the line and must be >= y1.
WiredHome 72:ecffe56af969 2674 /// @param[in] radius1 defines the horizontal radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2675 /// that this value < 1/2 the width of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2676 /// is returned.
WiredHome 72:ecffe56af969 2677 /// @param[in] radius2 defines the vertical radius of the curved corner. Take care
WiredHome 190:3132b7dfad82 2678 /// that this value < 1/2 the height of the rectangle, or bad_parameter
WiredHome 21:3c1efb192927 2679 /// is returned.
WiredHome 72:ecffe56af969 2680 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2681 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2682 ///
WiredHome 190:3132b7dfad82 2683 RetCode_t roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2684 dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2685
WiredHome 125:7a0b70f56550 2686
WiredHome 19:3f82c1161fd2 2687 /// Draw a triangle in the specified color.
WiredHome 19:3f82c1161fd2 2688 ///
WiredHome 19:3f82c1161fd2 2689 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2690 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2691 ///
WiredHome 178:ae472eb22740 2692 /// @param[in] p1 is point 1.
WiredHome 178:ae472eb22740 2693 /// @param[in] p2 is point 2.
WiredHome 178:ae472eb22740 2694 /// @param[in] p3 is point 3.
WiredHome 178:ae472eb22740 2695 /// @param[in] color defines the foreground color.
WiredHome 178:ae472eb22740 2696 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 178:ae472eb22740 2697 /// @returns @ref RetCode_t value.
WiredHome 178:ae472eb22740 2698 ///
WiredHome 178:ae472eb22740 2699 RetCode_t filltriangle(point_t p1, point_t p2, point_t p3, color_t color, fill_t fillit = FILL);
WiredHome 178:ae472eb22740 2700
WiredHome 178:ae472eb22740 2701 /// Draw a triangle in the specified color.
WiredHome 178:ae472eb22740 2702 ///
WiredHome 178:ae472eb22740 2703 /// @note As a side effect, this changes the current
WiredHome 178:ae472eb22740 2704 /// foreground color for subsequent operations.
WiredHome 178:ae472eb22740 2705 ///
WiredHome 178:ae472eb22740 2706 /// @param[in] p1 is point 1.
WiredHome 178:ae472eb22740 2707 /// @param[in] p2 is point 2.
WiredHome 178:ae472eb22740 2708 /// @param[in] p3 is point 3.
WiredHome 178:ae472eb22740 2709 /// @param[in] color defines the foreground color.
WiredHome 178:ae472eb22740 2710 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 178:ae472eb22740 2711 /// @returns @ref RetCode_t value.
WiredHome 178:ae472eb22740 2712 ///
WiredHome 178:ae472eb22740 2713 RetCode_t triangle(point_t p1, point_t p2, point_t p3, color_t color, fill_t fillit = NOFILL);
WiredHome 190:3132b7dfad82 2714
WiredHome 178:ae472eb22740 2715 /// Draw a triangle in the specified color.
WiredHome 178:ae472eb22740 2716 ///
WiredHome 178:ae472eb22740 2717 /// @note As a side effect, this changes the current
WiredHome 178:ae472eb22740 2718 /// foreground color for subsequent operations.
WiredHome 178:ae472eb22740 2719 ///
WiredHome 72:ecffe56af969 2720 /// @param[in] x1 is the horizontal for point 1.
WiredHome 190:3132b7dfad82 2721 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2722 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2723 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2724 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2725 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2726 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2727 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2728 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2729 ///
WiredHome 190:3132b7dfad82 2730 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2731 loc_t x3, loc_t y3, color_t color, fill_t fillit = NOFILL);
WiredHome 190:3132b7dfad82 2732
WiredHome 125:7a0b70f56550 2733
WiredHome 19:3f82c1161fd2 2734 /// Draw a filled triangle in the specified color.
WiredHome 19:3f82c1161fd2 2735 ///
WiredHome 19:3f82c1161fd2 2736 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2737 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2738 ///
WiredHome 72:ecffe56af969 2739 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2740 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2741 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2742 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2743 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2744 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2745 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2746 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2747 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2748 ///
WiredHome 190:3132b7dfad82 2749 RetCode_t filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2750 loc_t x3, loc_t y3, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2751
WiredHome 125:7a0b70f56550 2752
WiredHome 19:3f82c1161fd2 2753 /// Draw a triangle
WiredHome 19:3f82c1161fd2 2754 ///
WiredHome 19:3f82c1161fd2 2755 /// Draws a triangle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2756 ///
WiredHome 72:ecffe56af969 2757 /// @param[in] x1 is the horizontal for point 1.
WiredHome 72:ecffe56af969 2758 /// @param[in] y1 is the vertical for point 1.
WiredHome 72:ecffe56af969 2759 /// @param[in] x2 is the horizontal for point 2.
WiredHome 72:ecffe56af969 2760 /// @param[in] y2 is the vertical for point 2.
WiredHome 72:ecffe56af969 2761 /// @param[in] x3 is the horizontal for point 3.
WiredHome 72:ecffe56af969 2762 /// @param[in] y3 is the vertical for point 3.
WiredHome 72:ecffe56af969 2763 /// @param[in] fillit is optional to FILL the rectangle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2764 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2765 ///
WiredHome 190:3132b7dfad82 2766 RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 2767 loc_t x3, loc_t y3, fill_t fillit = NOFILL);
WiredHome 190:3132b7dfad82 2768
WiredHome 83:7bad0068cca0 2769
WiredHome 83:7bad0068cca0 2770 /// Draw a circle using the specified color.
WiredHome 83:7bad0068cca0 2771 ///
WiredHome 83:7bad0068cca0 2772 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2773 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2774 ///
WiredHome 83:7bad0068cca0 2775 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2776 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 2777 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2778 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2779 /// @returns @ref RetCode_t value.
WiredHome 83:7bad0068cca0 2780 ///
WiredHome 83:7bad0068cca0 2781 RetCode_t circle(point_t p, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 2782
WiredHome 125:7a0b70f56550 2783
WiredHome 83:7bad0068cca0 2784 /// Draw a filled circle using the specified color.
WiredHome 83:7bad0068cca0 2785 ///
WiredHome 83:7bad0068cca0 2786 /// @note As a side effect, this changes the current
WiredHome 83:7bad0068cca0 2787 /// foreground color for subsequent operations.
WiredHome 83:7bad0068cca0 2788 ///
WiredHome 83:7bad0068cca0 2789 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2790 /// @param[in] radius defines the size of the circle.
WiredHome 83:7bad0068cca0 2791 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2792 /// @param[in] fillit is optional to FILL the circle. default is FILL.
WiredHome 167:8aa3fb2a5a31 2793 /// @returns @ref RetCode_t value.
WiredHome 83:7bad0068cca0 2794 ///
WiredHome 83:7bad0068cca0 2795 RetCode_t fillcircle(point_t p, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 83:7bad0068cca0 2796
WiredHome 125:7a0b70f56550 2797
WiredHome 83:7bad0068cca0 2798 /// Draw a circle.
WiredHome 83:7bad0068cca0 2799 ///
WiredHome 83:7bad0068cca0 2800 /// Draws a circle using the foreground color setting.
WiredHome 83:7bad0068cca0 2801 ///
WiredHome 83:7bad0068cca0 2802 /// @param[in] p defines the center of the circle.
WiredHome 83:7bad0068cca0 2803 /// @param[in] radius defines the size of the circle.
WiredHome 125:7a0b70f56550 2804 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2805 /// @returns @ref RetCode_t value.
WiredHome 83:7bad0068cca0 2806 ///
WiredHome 83:7bad0068cca0 2807 RetCode_t circle(point_t p, dim_t radius, fill_t fillit = NOFILL);
WiredHome 83:7bad0068cca0 2808
WiredHome 125:7a0b70f56550 2809
WiredHome 19:3f82c1161fd2 2810 /// Draw a circle using the specified color.
WiredHome 19:3f82c1161fd2 2811 ///
WiredHome 19:3f82c1161fd2 2812 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2813 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2814 ///
WiredHome 72:ecffe56af969 2815 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2816 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2817 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 2818 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2819 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2820 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2821 ///
WiredHome 37:f19b7e7449dc 2822 RetCode_t circle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2823
WiredHome 125:7a0b70f56550 2824
WiredHome 19:3f82c1161fd2 2825 /// Draw a filled circle using the specified color.
WiredHome 19:3f82c1161fd2 2826 ///
WiredHome 19:3f82c1161fd2 2827 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2828 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2829 ///
WiredHome 72:ecffe56af969 2830 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2831 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2832 /// @param[in] radius defines the size of the circle.
WiredHome 72:ecffe56af969 2833 /// @param[in] color defines the foreground color.
WiredHome 125:7a0b70f56550 2834 /// @param[in] fillit is optional to FILL the circle. default is FILL.
WiredHome 167:8aa3fb2a5a31 2835 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2836 ///
WiredHome 37:f19b7e7449dc 2837 RetCode_t fillcircle(loc_t x, loc_t y, dim_t radius, color_t color, fill_t fillit = FILL);
WiredHome 19:3f82c1161fd2 2838
WiredHome 125:7a0b70f56550 2839
WiredHome 19:3f82c1161fd2 2840 /// Draw a circle.
WiredHome 19:3f82c1161fd2 2841 ///
WiredHome 19:3f82c1161fd2 2842 /// Draws a circle using the foreground color setting.
WiredHome 19:3f82c1161fd2 2843 ///
WiredHome 72:ecffe56af969 2844 /// @param[in] x is the horizontal center of the circle.
WiredHome 72:ecffe56af969 2845 /// @param[in] y is the vertical center of the circle.
WiredHome 72:ecffe56af969 2846 /// @param[in] radius defines the size of the circle.
WiredHome 125:7a0b70f56550 2847 /// @param[in] fillit is optional to FILL the circle. default is NOFILL.
WiredHome 167:8aa3fb2a5a31 2848 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2849 ///
WiredHome 37:f19b7e7449dc 2850 RetCode_t circle(loc_t x, loc_t y, dim_t radius, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2851
WiredHome 19:3f82c1161fd2 2852 /// Draw an Ellipse using the specified color
WiredHome 19:3f82c1161fd2 2853 ///
WiredHome 19:3f82c1161fd2 2854 /// @note As a side effect, this changes the current
WiredHome 19:3f82c1161fd2 2855 /// foreground color for subsequent operations.
WiredHome 19:3f82c1161fd2 2856 ///
WiredHome 72:ecffe56af969 2857 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2858 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2859 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2860 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2861 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2862 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 167:8aa3fb2a5a31 2863 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2864 ///
WiredHome 190:3132b7dfad82 2865 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 19:3f82c1161fd2 2866 color_t color, fill_t fillit = NOFILL);
WiredHome 19:3f82c1161fd2 2867
WiredHome 125:7a0b70f56550 2868
WiredHome 25:9556a3a9b7cc 2869 /// Draw a filled Ellipse using the specified color
WiredHome 25:9556a3a9b7cc 2870 ///
WiredHome 25:9556a3a9b7cc 2871 /// @note As a side effect, this changes the current
WiredHome 25:9556a3a9b7cc 2872 /// foreground color for subsequent operations.
WiredHome 25:9556a3a9b7cc 2873 ///
WiredHome 72:ecffe56af969 2874 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2875 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2876 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2877 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2878 /// @param[in] color defines the foreground color.
WiredHome 72:ecffe56af969 2879 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 167:8aa3fb2a5a31 2880 /// @returns @ref RetCode_t value.
WiredHome 25:9556a3a9b7cc 2881 ///
WiredHome 190:3132b7dfad82 2882 RetCode_t fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2,
WiredHome 25:9556a3a9b7cc 2883 color_t color, fill_t fillit = FILL);
WiredHome 25:9556a3a9b7cc 2884
WiredHome 125:7a0b70f56550 2885
WiredHome 19:3f82c1161fd2 2886 /// Draw an Ellipse
WiredHome 19:3f82c1161fd2 2887 ///
WiredHome 19:3f82c1161fd2 2888 /// Draws it using the foreground color setting.
WiredHome 19:3f82c1161fd2 2889 ///
WiredHome 72:ecffe56af969 2890 /// @param[in] x is the horizontal center of the ellipse.
WiredHome 72:ecffe56af969 2891 /// @param[in] y is the vertical center of the ellipse.
WiredHome 72:ecffe56af969 2892 /// @param[in] radius1 defines the horizontal radius of the ellipse.
WiredHome 72:ecffe56af969 2893 /// @param[in] radius2 defines the vertical radius of the ellipse.
WiredHome 72:ecffe56af969 2894 /// @param[in] fillit defines whether the circle is filled or not.
WiredHome 167:8aa3fb2a5a31 2895 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 2896 ///
WiredHome 37:f19b7e7449dc 2897 RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
WiredHome 190:3132b7dfad82 2898
WiredHome 125:7a0b70f56550 2899
WiredHome 131:5bd6ba2ee4a1 2900
WiredHome 131:5bd6ba2ee4a1 2901 /// Block Move
WiredHome 131:5bd6ba2ee4a1 2902 ///
WiredHome 131:5bd6ba2ee4a1 2903 /// The Block Move API activates the RA8875 Block Transfer Engine. Due to the complex
WiredHome 131:5bd6ba2ee4a1 2904 /// set of possible operations, the user should read the related sections of the
WiredHome 131:5bd6ba2ee4a1 2905 /// RA8875 user manual.
WiredHome 131:5bd6ba2ee4a1 2906 ///
WiredHome 131:5bd6ba2ee4a1 2907 /// Some operations may require that other registers are configured, such as the
WiredHome 131:5bd6ba2ee4a1 2908 /// foreground and background color registers, and others. Those must be set
WiredHome 131:5bd6ba2ee4a1 2909 /// outside of this API.
WiredHome 131:5bd6ba2ee4a1 2910 ///
WiredHome 138:61e93bed397e 2911 /// @code
WiredHome 167:8aa3fb2a5a31 2912 /// // Block Move Demo
WiredHome 190:3132b7dfad82 2913 ///
WiredHome 154:ad2450fc3dc3 2914 /// // Calibrate the resistive touch screen, and store the data on the
WiredHome 154:ad2450fc3dc3 2915 /// // local file system.
WiredHome 154:ad2450fc3dc3 2916 /// //
WiredHome 154:ad2450fc3dc3 2917 /// void CalibrateTS(void)
WiredHome 154:ad2450fc3dc3 2918 /// {
WiredHome 154:ad2450fc3dc3 2919 /// FILE * fh;
WiredHome 154:ad2450fc3dc3 2920 /// tpMatrix_t matrix;
WiredHome 154:ad2450fc3dc3 2921 /// RetCode_t r;
WiredHome 154:ad2450fc3dc3 2922 /// Timer testperiod;
WiredHome 190:3132b7dfad82 2923 ///
WiredHome 154:ad2450fc3dc3 2924 /// r = lcd.TouchPanelCalibrate("Calibrate the touch panel", &matrix);
WiredHome 154:ad2450fc3dc3 2925 /// if (r == noerror) {
WiredHome 154:ad2450fc3dc3 2926 /// fh = fopen("/local/tpcal.cfg", "wb");
WiredHome 154:ad2450fc3dc3 2927 /// if (fh) {
WiredHome 198:9b6851107426 2928 /// fwrite(&matrix, sizeof(tpMatrix_t), 1, fh);
WiredHome 198:9b6851107426 2929 /// fclose(fh);
WiredHome 198:9b6851107426 2930 /// printf(" tp cal written.\r\n");
WiredHome 154:ad2450fc3dc3 2931 /// lcd.cls();
WiredHome 154:ad2450fc3dc3 2932 /// } else {
WiredHome 154:ad2450fc3dc3 2933 /// printf(" couldn't open tpcal file.\r\n");
WiredHome 154:ad2450fc3dc3 2934 /// }
WiredHome 154:ad2450fc3dc3 2935 /// } else {
WiredHome 154:ad2450fc3dc3 2936 /// printf("error return: %d\r\n", r);
WiredHome 154:ad2450fc3dc3 2937 /// }
WiredHome 154:ad2450fc3dc3 2938 /// lcd.cls();
WiredHome 154:ad2450fc3dc3 2939 /// }
WiredHome 190:3132b7dfad82 2940 ///
WiredHome 154:ad2450fc3dc3 2941 /// // Try to load a previous resistive touch screen calibration from storage. If it
WiredHome 154:ad2450fc3dc3 2942 /// // doesn't exist, activate the touch screen calibration process.
WiredHome 154:ad2450fc3dc3 2943 /// //
WiredHome 154:ad2450fc3dc3 2944 /// void InitTS(void)
WiredHome 154:ad2450fc3dc3 2945 /// {
WiredHome 154:ad2450fc3dc3 2946 /// FILE * fh;
WiredHome 154:ad2450fc3dc3 2947 /// tpMatrix_t matrix;
WiredHome 190:3132b7dfad82 2948 ///
WiredHome 154:ad2450fc3dc3 2949 /// fh = fopen("/local/tpcal.cfg", "rb");
WiredHome 154:ad2450fc3dc3 2950 /// if (fh) {
WiredHome 154:ad2450fc3dc3 2951 /// fread(&matrix, sizeof(tpMatrix_t), 1, fh);
WiredHome 154:ad2450fc3dc3 2952 /// fclose(fh);
WiredHome 154:ad2450fc3dc3 2953 /// lcd.TouchPanelSetMatrix(&matrix);
WiredHome 154:ad2450fc3dc3 2954 /// printf(" tp cal loaded.\r\n");
WiredHome 154:ad2450fc3dc3 2955 /// } else {
WiredHome 154:ad2450fc3dc3 2956 /// CalibrateTS();
WiredHome 154:ad2450fc3dc3 2957 /// }
WiredHome 154:ad2450fc3dc3 2958 /// }
WiredHome 154:ad2450fc3dc3 2959 ///
WiredHome 138:61e93bed397e 2960 /// int main()
WiredHome 138:61e93bed397e 2961 /// {
WiredHome 138:61e93bed397e 2962 /// point_t src;
WiredHome 138:61e93bed397e 2963 /// point_t dst;
WiredHome 138:61e93bed397e 2964 /// TouchCode_t touch;
WiredHome 138:61e93bed397e 2965 /// const dim_t RECT_W = 100;
WiredHome 138:61e93bed397e 2966 /// const dim_t RECT_H = 100;
WiredHome 190:3132b7dfad82 2967 ///
WiredHome 138:61e93bed397e 2968 /// pc.baud(460800); //I like a snappy terminal, so crank it up!
WiredHome 138:61e93bed397e 2969 /// pc.printf("\r\nRA8875 BTE Move Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 198:9b6851107426 2970 /// lcd.init(LCD_PHYS_W,LCD_PHYS_H,LCD_C, BL_NORM);
WiredHome 138:61e93bed397e 2971 /// lcd.TouchPanelInit();
WiredHome 138:61e93bed397e 2972 /// #ifndef CAP_TOUCH
WiredHome 138:61e93bed397e 2973 /// InitTS(); // Calibration for resistive touch panel
WiredHome 138:61e93bed397e 2974 /// #endif
WiredHome 190:3132b7dfad82 2975 ///
WiredHome 138:61e93bed397e 2976 /// RetCode_t r = lcd.RenderImageFile(0,0,"/local/fullscrn.jpg");
WiredHome 138:61e93bed397e 2977 /// if (r) pc.printf(" Error: %d; %s\r\n", r, lcd.GetErrorMessage(r));
WiredHome 138:61e93bed397e 2978 /// while (1) {
WiredHome 138:61e93bed397e 2979 /// touch = lcd.TouchPanelReadable();
WiredHome 138:61e93bed397e 2980 /// if (touch) {
WiredHome 138:61e93bed397e 2981 /// point_t xy = lcd.TouchCoordinates();
WiredHome 138:61e93bed397e 2982 /// TouchCode_t t = lcd.TouchCode();
WiredHome 190:3132b7dfad82 2983 ///
WiredHome 138:61e93bed397e 2984 /// if (t == touch) {
WiredHome 198:9b6851107426 2985 /// src = ComputeTopLeftOfRect(xy, RECT_W/2, RECT_H/2, LCD_PHYS_W, LCD_PHYS_H);
WiredHome 138:61e93bed397e 2986 /// } else if (t == release) {
WiredHome 198:9b6851107426 2987 /// dst = ComputeTopLeftOfRect(xy, RECT_W/2, RECT_H/2, LCD_PHYS_W, LCD_PHYS_H);
WiredHome 138:61e93bed397e 2988 /// r = lcd.BlockMove(0,0,dst, 0,0,src, RECT_W,RECT_H, 0x2, 0xC);
WiredHome 138:61e93bed397e 2989 /// }
WiredHome 138:61e93bed397e 2990 /// }
WiredHome 138:61e93bed397e 2991 /// }
WiredHome 138:61e93bed397e 2992 /// }
WiredHome 138:61e93bed397e 2993 /// @endcode
WiredHome 138:61e93bed397e 2994 ///
WiredHome 139:99ec74e3273f 2995 /// @param[in] dstLayer layer [5B.7]. layer value is 0 or 1 representing layer 1 and 2.
WiredHome 131:5bd6ba2ee4a1 2996 /// @param[in] dstDataSelect [50.5] defines the destination data type 0: block, 1: linear.
WiredHome 131:5bd6ba2ee4a1 2997 /// @param[in] dstPoint [58-5B] is a point_t defining the destination coordinate.
WiredHome 139:99ec74e3273f 2998 /// @param[in] srcLayer layer [57.7]. layer value is 0 or 1 representing layer 1 and 2.
WiredHome 131:5bd6ba2ee4a1 2999 /// @param[in] srcDataSelect [50.6] defines the source data type 0: block, 1: linear.
WiredHome 131:5bd6ba2ee4a1 3000 /// @param[in] srcPoint [54-57] is a point_t defining the source coordinate.
WiredHome 131:5bd6ba2ee4a1 3001 /// @param[in] bte_width [5C-5D]. operation width.
WiredHome 131:5bd6ba2ee4a1 3002 /// @param[in] bte_height [5E-5F]. operation height.
WiredHome 190:3132b7dfad82 3003 /// @param[in] bte_op_code [51.3-0] defines the raster operation function
WiredHome 131:5bd6ba2ee4a1 3004 /// (write/read/move/...)
WiredHome 131:5bd6ba2ee4a1 3005 /// @param[in] bte_rop_code [51.7-4] defines what type of BTE operation to perform
WiredHome 131:5bd6ba2ee4a1 3006 /// (what is placed at the destination)
WiredHome 167:8aa3fb2a5a31 3007 /// @returns @ref RetCode_t value.
WiredHome 131:5bd6ba2ee4a1 3008 ///
WiredHome 131:5bd6ba2ee4a1 3009 RetCode_t BlockMove(uint8_t dstLayer, uint8_t dstDataSelect, point_t dstPoint,
WiredHome 131:5bd6ba2ee4a1 3010 uint8_t srcLayer, uint8_t srcDataSelect, point_t srcPoint,
WiredHome 137:9e09f6081ef1 3011 dim_t bte_width, dim_t bte_height,
WiredHome 131:5bd6ba2ee4a1 3012 uint8_t bte_op_code, uint8_t bte_rop_code);
WiredHome 131:5bd6ba2ee4a1 3013
WiredHome 131:5bd6ba2ee4a1 3014
WiredHome 19:3f82c1161fd2 3015 /// Control display power
WiredHome 19:3f82c1161fd2 3016 ///
WiredHome 72:ecffe56af969 3017 /// @param[in] on when set to true will turn on the display, when false it is turned off.
WiredHome 167:8aa3fb2a5a31 3018 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 3019 ///
WiredHome 19:3f82c1161fd2 3020 RetCode_t Power(bool on);
WiredHome 19:3f82c1161fd2 3021
WiredHome 125:7a0b70f56550 3022
WiredHome 19:3f82c1161fd2 3023 /// Reset the display controller via the Software Reset interface.
WiredHome 19:3f82c1161fd2 3024 ///
WiredHome 167:8aa3fb2a5a31 3025 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 3026 ///
WiredHome 19:3f82c1161fd2 3027 RetCode_t Reset(void);
WiredHome 190:3132b7dfad82 3028
WiredHome 125:7a0b70f56550 3029
WiredHome 19:3f82c1161fd2 3030 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 3031 ///
WiredHome 190:3132b7dfad82 3032 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 3033 /// API can be used to set the brightness.
WiredHome 190:3132b7dfad82 3034 ///
WiredHome 72:ecffe56af969 3035 /// @param[in] brightness ranges from 0 (off) to 255 (full on)
WiredHome 167:8aa3fb2a5a31 3036 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 3037 ///
WiredHome 131:5bd6ba2ee4a1 3038 RetCode_t Backlight_u8(uint8_t brightness);
WiredHome 125:7a0b70f56550 3039
WiredHome 190:3132b7dfad82 3040
WiredHome 86:e86b355940f4 3041 /// Get backlight brightness.
WiredHome 86:e86b355940f4 3042 ///
WiredHome 86:e86b355940f4 3043 /// @returns backlight setting from 0 (off) to 255 (full on).
WiredHome 190:3132b7dfad82 3044 ///
WiredHome 86:e86b355940f4 3045 uint8_t GetBacklight_u8(void);
WiredHome 86:e86b355940f4 3046
WiredHome 19:3f82c1161fd2 3047 /// Set backlight brightness.
WiredHome 19:3f82c1161fd2 3048 ///
WiredHome 190:3132b7dfad82 3049 /// When the built-in PWM is used to control the backlight, this
WiredHome 19:3f82c1161fd2 3050 /// API can be used to set the brightness.
WiredHome 190:3132b7dfad82 3051 ///
WiredHome 72:ecffe56af969 3052 /// @param[in] brightness ranges from 0.0 (off) to 1.0 (full on)
WiredHome 167:8aa3fb2a5a31 3053 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 3054 ///
WiredHome 19:3f82c1161fd2 3055 RetCode_t Backlight(float brightness);
WiredHome 19:3f82c1161fd2 3056
WiredHome 125:7a0b70f56550 3057
WiredHome 86:e86b355940f4 3058 /// Get backlight brightness.
WiredHome 86:e86b355940f4 3059 ///
WiredHome 86:e86b355940f4 3060 /// @returns backlight setting from 0 (off) to 1.0 (full on).
WiredHome 190:3132b7dfad82 3061 ///
WiredHome 86:e86b355940f4 3062 float GetBacklight(void);
WiredHome 86:e86b355940f4 3063
WiredHome 125:7a0b70f56550 3064
WiredHome 98:ecebed9b80b2 3065 /// Select a User Font for all subsequent text.
WiredHome 98:ecebed9b80b2 3066 ///
WiredHome 98:ecebed9b80b2 3067 /// @note Tool to create the fonts is accessible from its creator
WiredHome 190:3132b7dfad82 3068 /// available at http://www.mikroe.com.
WiredHome 98:ecebed9b80b2 3069 /// For version 1.2.0.0, choose the "Export for TFT and new GLCD"
WiredHome 98:ecebed9b80b2 3070 /// format.
WiredHome 98:ecebed9b80b2 3071 ///
WiredHome 98:ecebed9b80b2 3072 /// @param[in] font is a pointer to a specially formed font resource.
WiredHome 167:8aa3fb2a5a31 3073 /// @returns @ref RetCode_t value.
WiredHome 98:ecebed9b80b2 3074 ///
WiredHome 98:ecebed9b80b2 3075 virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
WiredHome 98:ecebed9b80b2 3076
WiredHome 127:db7f2c704693 3077 /// Get the currently selected user font.
WiredHome 127:db7f2c704693 3078 ///
WiredHome 127:db7f2c704693 3079 /// @returns a pointer to the font, or null, if no user font is selected.
WiredHome 127:db7f2c704693 3080 ///
WiredHome 127:db7f2c704693 3081 virtual const uint8_t * GetUserFont(void) { return font; }
WiredHome 19:3f82c1161fd2 3082
WiredHome 167:8aa3fb2a5a31 3083 /// Get the @ref color_t value from a DOS color index.
WiredHome 167:8aa3fb2a5a31 3084 ///
WiredHome 167:8aa3fb2a5a31 3085 /// See @ref PredefinedColors, @ref color_t.
WiredHome 190:3132b7dfad82 3086 ///
WiredHome 125:7a0b70f56550 3087 /// @code
WiredHome 125:7a0b70f56550 3088 /// color_t color = DOSColor(12);
WiredHome 125:7a0b70f56550 3089 /// @endcode
WiredHome 125:7a0b70f56550 3090 ///
WiredHome 167:8aa3fb2a5a31 3091 /// @param[in] i is the color index, in the range 0 to 15;
WiredHome 190:3132b7dfad82 3092 /// @returns the @ref color_t value of the selected index,
WiredHome 167:8aa3fb2a5a31 3093 /// or 0 (@ref Black) if the index is out of bounds.
WiredHome 19:3f82c1161fd2 3094 ///
WiredHome 19:3f82c1161fd2 3095 color_t DOSColor(int i);
WiredHome 19:3f82c1161fd2 3096
WiredHome 125:7a0b70f56550 3097
WiredHome 167:8aa3fb2a5a31 3098 /// Get the color name (string) from a DOS color index.
WiredHome 167:8aa3fb2a5a31 3099 ///
WiredHome 167:8aa3fb2a5a31 3100 /// See @ref PredefinedColors, @ref color_t.
WiredHome 190:3132b7dfad82 3101 ///
WiredHome 125:7a0b70f56550 3102 /// @code
WiredHome 125:7a0b70f56550 3103 /// printf("color is %s\n", DOSColorNames(12));
WiredHome 125:7a0b70f56550 3104 /// @endcode
WiredHome 125:7a0b70f56550 3105 ///
WiredHome 167:8aa3fb2a5a31 3106 /// @param[in] i is the color index, in the range 0 to 15;
WiredHome 19:3f82c1161fd2 3107 /// @returns a pointer to a string with the color name,
WiredHome 19:3f82c1161fd2 3108 /// or NULL if the index is out of bounds.
WiredHome 190:3132b7dfad82 3109 ///
WiredHome 19:3f82c1161fd2 3110 const char * DOSColorNames(int i);
WiredHome 19:3f82c1161fd2 3111
WiredHome 125:7a0b70f56550 3112
WiredHome 55:dfbabef7003e 3113 /// Advanced method indicating the start of a graphics stream.
WiredHome 55:dfbabef7003e 3114 ///
WiredHome 55:dfbabef7003e 3115 /// This is called prior to a stream of pixel data being sent.
WiredHome 55:dfbabef7003e 3116 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 3117 /// class in order to prepare the hardware to accept the streaming
WiredHome 55:dfbabef7003e 3118 /// data.
WiredHome 55:dfbabef7003e 3119 ///
WiredHome 106:c80828f5dea4 3120 /// Following this command, a series of See @ref _putp() commands can
WiredHome 55:dfbabef7003e 3121 /// be used to send individual pixels to the screen.
WiredHome 55:dfbabef7003e 3122 ///
WiredHome 106:c80828f5dea4 3123 /// To conclude the graphics stream, See @ref _EndGraphicsStream should
WiredHome 167:8aa3fb2a5a31 3124 /// be called.
WiredHome 167:8aa3fb2a5a31 3125 ///
WiredHome 167:8aa3fb2a5a31 3126 /// @returns @ref RetCode_t value.
WiredHome 55:dfbabef7003e 3127 ///
WiredHome 55:dfbabef7003e 3128 virtual RetCode_t _StartGraphicsStream(void);
WiredHome 125:7a0b70f56550 3129
WiredHome 190:3132b7dfad82 3130
WiredHome 55:dfbabef7003e 3131 /// Advanced method to put a single color pixel to the screen.
WiredHome 55:dfbabef7003e 3132 ///
WiredHome 190:3132b7dfad82 3133 /// This method may be called as many times as necessary after
WiredHome 190:3132b7dfad82 3134 /// See @ref _StartGraphicsStream() is called, and it should be followed
WiredHome 55:dfbabef7003e 3135 /// by _EndGraphicsStream.
WiredHome 55:dfbabef7003e 3136 ///
WiredHome 125:7a0b70f56550 3137 /// @code
WiredHome 125:7a0b70f56550 3138 /// _putp(DOSColor(12));
WiredHome 125:7a0b70f56550 3139 /// @endcode
WiredHome 125:7a0b70f56550 3140 ///
WiredHome 72:ecffe56af969 3141 /// @param[in] pixel is a color value to be put on the screen.
WiredHome 167:8aa3fb2a5a31 3142 /// @returns @ref RetCode_t value.
WiredHome 55:dfbabef7003e 3143 ///
WiredHome 55:dfbabef7003e 3144 virtual RetCode_t _putp(color_t pixel);
WiredHome 125:7a0b70f56550 3145
WiredHome 190:3132b7dfad82 3146
WiredHome 55:dfbabef7003e 3147 /// Advanced method indicating the end of a graphics stream.
WiredHome 55:dfbabef7003e 3148 ///
WiredHome 55:dfbabef7003e 3149 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 55:dfbabef7003e 3150 /// This may cause register configuration changes in the derived
WiredHome 55:dfbabef7003e 3151 /// class in order to stop the hardware from accept the streaming
WiredHome 55:dfbabef7003e 3152 /// data.
WiredHome 55:dfbabef7003e 3153 ///
WiredHome 167:8aa3fb2a5a31 3154 /// @returns @ref RetCode_t value.
WiredHome 55:dfbabef7003e 3155 ///
WiredHome 55:dfbabef7003e 3156 virtual RetCode_t _EndGraphicsStream(void);
WiredHome 19:3f82c1161fd2 3157
WiredHome 125:7a0b70f56550 3158
WiredHome 57:bd53a9e165a1 3159 /// Set the SPI port frequency (in Hz).
WiredHome 57:bd53a9e165a1 3160 ///
WiredHome 66:468a11f05580 3161 /// This uses the mbed SPI driver, and is therefore dependent on
WiredHome 66:468a11f05580 3162 /// its capabilities. The RA8875 can accept writes via SPI faster
WiredHome 66:468a11f05580 3163 /// than a read can be performed. The frequency set by this API
WiredHome 66:468a11f05580 3164 /// is for the SPI writes. It will automatically reduce the SPI
WiredHome 190:3132b7dfad82 3165 /// clock rate when a read is performed, and restore it for the
WiredHome 68:ab08efabfc88 3166 /// next write. Alternately, the 2nd parameters permits setting
WiredHome 68:ab08efabfc88 3167 /// the read speed rather than letting it compute it automatically.
WiredHome 57:bd53a9e165a1 3168 ///
WiredHome 66:468a11f05580 3169 /// @note The primary effect of this is to recover more CPU cycles
WiredHome 66:468a11f05580 3170 /// for your application code. Keep in mind that when more than
WiredHome 66:468a11f05580 3171 /// one command is sent to the display controller, that it
WiredHome 66:468a11f05580 3172 /// will wait for the controller to finish the prior command.
WiredHome 66:468a11f05580 3173 /// In this case, the performance is limited by the RA8875.
WiredHome 57:bd53a9e165a1 3174 ///
WiredHome 72:ecffe56af969 3175 /// @param[in] Hz is the frequency in Hz, tested range includes the
WiredHome 66:468a11f05580 3176 /// range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
WiredHome 66:468a11f05580 3177 /// outside this range will be accepted, but operation may
WiredHome 76:c981284eb513 3178 /// be unreliable. This depends partially on your hardware design
WiredHome 76:c981284eb513 3179 /// and the wires connecting the display module.
WiredHome 76:c981284eb513 3180 /// The default value is 5,000,000, which should work for most
WiredHome 76:c981284eb513 3181 /// applications as a starting point.
WiredHome 72:ecffe56af969 3182 /// @param[in] Hz2 is an optional parameter and will set the read
WiredHome 68:ab08efabfc88 3183 /// speed independently of the write speed.
WiredHome 167:8aa3fb2a5a31 3184 /// @returns @ref RetCode_t value.
WiredHome 57:bd53a9e165a1 3185 ///
WiredHome 68:ab08efabfc88 3186 RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ, unsigned long Hz2 = 0);
WiredHome 125:7a0b70f56550 3187
WiredHome 125:7a0b70f56550 3188
WiredHome 72:ecffe56af969 3189 /// This method captures the specified area as a 24-bit bitmap file.
WiredHome 72:ecffe56af969 3190 ///
WiredHome 72:ecffe56af969 3191 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 3192 /// 24-bit format.
WiredHome 72:ecffe56af969 3193 ///
WiredHome 73:f22a18707b5e 3194 /// This method will interrogate the current display setting and
WiredHome 190:3132b7dfad82 3195 /// create a bitmap based on those settings. For instance, if
WiredHome 73:f22a18707b5e 3196 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 73:f22a18707b5e 3197 /// if there is some other operation in effect (transparent mode).
WiredHome 73:f22a18707b5e 3198 ///
WiredHome 149:c62c4b2d6a15 3199 /// If the idle callback is registered, it will be activated passing
WiredHome 149:c62c4b2d6a15 3200 /// a parameter indicating the percent complete, which may be of value.
WiredHome 149:c62c4b2d6a15 3201 ///
WiredHome 72:ecffe56af969 3202 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 3203 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 3204 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 3205 /// @param[in] h is the height of the region to capture.
WiredHome 163:17526689a3ed 3206 /// @param[in] Name_BMP is the filename to write the image to.
WiredHome 190:3132b7dfad82 3207 /// @param[in] bitsPerPixel is optional, defaults to 24, and only
WiredHome 163:17526689a3ed 3208 /// accepts the values 24, 8
WiredHome 164:76edd7d9cb68 3209 /// NOTE: The downscaling is CPU intensive, and the operation
WiredHome 164:76edd7d9cb68 3210 /// takes longer.
WiredHome 167:8aa3fb2a5a31 3211 /// @returns @ref RetCode_t value.
WiredHome 72:ecffe56af969 3212 ///
WiredHome 163:17526689a3ed 3213 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP, uint8_t bitsPerPixel = 24);
WiredHome 125:7a0b70f56550 3214
WiredHome 190:3132b7dfad82 3215
WiredHome 96:40b74dd3695b 3216 /// This method captures the specified area as a 24-bit bitmap file
WiredHome 96:40b74dd3695b 3217 /// and delivers it to the previously attached callback.
WiredHome 96:40b74dd3695b 3218 ///
WiredHome 96:40b74dd3695b 3219 /// Even though this is a 16-bit display, the stored image is in
WiredHome 96:40b74dd3695b 3220 /// 24-bit format.
WiredHome 96:40b74dd3695b 3221 ///
WiredHome 96:40b74dd3695b 3222 /// This method will interrogate the current display setting and
WiredHome 190:3132b7dfad82 3223 /// create a bitmap based on those settings. For instance, if
WiredHome 96:40b74dd3695b 3224 /// only layer 1 is visible, then the bitmap is only layer 1. However,
WiredHome 96:40b74dd3695b 3225 /// if there is some other operation in effect (transparent mode), it
WiredHome 96:40b74dd3695b 3226 /// will return the blended image.
WiredHome 96:40b74dd3695b 3227 ///
WiredHome 149:c62c4b2d6a15 3228 /// If the idle callback is registered, it will be activated passing
WiredHome 149:c62c4b2d6a15 3229 /// a parameter indicating the percent complete, which may be of value.
WiredHome 149:c62c4b2d6a15 3230 ///
WiredHome 96:40b74dd3695b 3231 /// @param[in] x is the left edge of the region to capture
WiredHome 96:40b74dd3695b 3232 /// @param[in] y is the top edge of the region to capture
WiredHome 96:40b74dd3695b 3233 /// @param[in] w is the width of the region to capture
WiredHome 96:40b74dd3695b 3234 /// @param[in] h is the height of the region to capture.
WiredHome 190:3132b7dfad82 3235 /// @param[in] bitsPerPixel is optional, defaults to 24, and only
WiredHome 164:76edd7d9cb68 3236 /// accepts the values 24, 8
WiredHome 164:76edd7d9cb68 3237 /// NOTE: The downscaling is CPU intensive, and the operation
WiredHome 164:76edd7d9cb68 3238 /// takes longer.
WiredHome 167:8aa3fb2a5a31 3239 /// @returns @ref RetCode_t value.
WiredHome 96:40b74dd3695b 3240 ///
WiredHome 164:76edd7d9cb68 3241 RetCode_t PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, uint8_t bitsPerPixel = 24);
WiredHome 125:7a0b70f56550 3242
WiredHome 190:3132b7dfad82 3243
WiredHome 96:40b74dd3695b 3244 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 3245 ///
WiredHome 96:40b74dd3695b 3246 /// This method attaches a simple c-compatible callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 3247 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 3248 /// BMP file to be created is passed to this callback.
WiredHome 190:3132b7dfad82 3249 ///
WiredHome 123:2f45e80fec5f 3250 /// @param callback is the optional callback function. Without a callback function
WiredHome 123:2f45e80fec5f 3251 /// it will unregister the handler.
WiredHome 96:40b74dd3695b 3252 ///
WiredHome 123:2f45e80fec5f 3253 void AttachPrintHandler(PrintCallback_T callback = NULL) { c_callback = callback; }
WiredHome 96:40b74dd3695b 3254
WiredHome 125:7a0b70f56550 3255
WiredHome 96:40b74dd3695b 3256 /// PrintScreen callback registration.
WiredHome 96:40b74dd3695b 3257 ///
WiredHome 96:40b74dd3695b 3258 /// This method attaches a c++ class method as a callback of type PrintCallback_T.
WiredHome 96:40b74dd3695b 3259 /// Then, the PrintScreen(x,y,w,h) method is called. Each chunk of data in the
WiredHome 96:40b74dd3695b 3260 /// BMP file to be created is passed to this callback.
WiredHome 190:3132b7dfad82 3261 ///
WiredHome 96:40b74dd3695b 3262 /// @param object is the class hosting the callback function.
WiredHome 102:fc60bfa0199f 3263 /// @param method is the callback method in the object to activate.
WiredHome 96:40b74dd3695b 3264 ///
WiredHome 96:40b74dd3695b 3265 template <class T>
WiredHome 190:3132b7dfad82 3266 void AttachPrintHandler(T *object, RetCode_t (T::*method)(void)) {
WiredHome 190:3132b7dfad82 3267 obj_callback = (FPointerDummy *)object;
WiredHome 108:7415c405ee08 3268 method_callback = (uint32_t (FPointerDummy::*)(uint32_t, uint8_t *, uint16_t))method;
WiredHome 96:40b74dd3695b 3269 }
WiredHome 96:40b74dd3695b 3270
WiredHome 125:7a0b70f56550 3271
WiredHome 72:ecffe56af969 3272 /// This method captures the specified area as a 24-bit bitmap file,
WiredHome 72:ecffe56af969 3273 /// including the option of layer selection.
WiredHome 72:ecffe56af969 3274 ///
WiredHome 125:7a0b70f56550 3275 /// @note This method is deprecated as the alternate PrintScreen API
WiredHome 74:686faa218914 3276 /// automatically examines the display layer configuration.
WiredHome 74:686faa218914 3277 /// Therefore, calls to this API will ignore the layer parameter
WiredHome 74:686faa218914 3278 /// and automatically execute the other method.
WiredHome 74:686faa218914 3279 ///
WiredHome 72:ecffe56af969 3280 /// Even though this is a 16-bit display, the stored image is in
WiredHome 72:ecffe56af969 3281 /// 24-bit format.
WiredHome 72:ecffe56af969 3282 ///
WiredHome 72:ecffe56af969 3283 /// @param[in] layer is 0 or 1 to select the layer to extract.
WiredHome 72:ecffe56af969 3284 /// @param[in] x is the left edge of the region to capture
WiredHome 72:ecffe56af969 3285 /// @param[in] y is the top edge of the region to capture
WiredHome 72:ecffe56af969 3286 /// @param[in] w is the width of the region to capture
WiredHome 72:ecffe56af969 3287 /// @param[in] h is the height of the region to capture.
WiredHome 72:ecffe56af969 3288 /// @param[out] Name_BMP is the filename to write the image to.
WiredHome 167:8aa3fb2a5a31 3289 /// @returns @ref RetCode_t value.
WiredHome 72:ecffe56af969 3290 ///
WiredHome 72:ecffe56af969 3291 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 3292
WiredHome 190:3132b7dfad82 3293
WiredHome 123:2f45e80fec5f 3294 /// idle callback registration.
WiredHome 123:2f45e80fec5f 3295 ///
WiredHome 125:7a0b70f56550 3296 /// This method attaches a simple c-compatible callback of type IdleCallback_T.
WiredHome 123:2f45e80fec5f 3297 /// Then, at any time when the display driver is waiting, it will call the
WiredHome 123:2f45e80fec5f 3298 /// registered function. This is probably most useful if you want to service
WiredHome 123:2f45e80fec5f 3299 /// a watchdog, when you may have called an API that will "hang" waiting
WiredHome 123:2f45e80fec5f 3300 /// on the user.
WiredHome 123:2f45e80fec5f 3301 ///
WiredHome 149:c62c4b2d6a15 3302 /// @code
WiredHome 149:c62c4b2d6a15 3303 /// RetCode_t myIdle_handler(RA8875::IdleReason_T reason, uint16_t param)
WiredHome 149:c62c4b2d6a15 3304 /// {
WiredHome 149:c62c4b2d6a15 3305 /// static uint16_t lastProgress = 0xFFFF;
WiredHome 149:c62c4b2d6a15 3306 ///
WiredHome 149:c62c4b2d6a15 3307 /// if (reason == RA8875::progress && param != lastProgress) {
WiredHome 149:c62c4b2d6a15 3308 /// printf("Progress %3d%%\r\n", param);
WiredHome 149:c62c4b2d6a15 3309 /// lastProgress = progress;
WiredHome 149:c62c4b2d6a15 3310 /// }
WiredHome 149:c62c4b2d6a15 3311 /// return noerror;
WiredHome 149:c62c4b2d6a15 3312 /// }
WiredHome 149:c62c4b2d6a15 3313 ///
WiredHome 149:c62c4b2d6a15 3314 /// ...
WiredHome 149:c62c4b2d6a15 3315 /// lcd.AttachIdleHandler(myIdle_handler);
WiredHome 149:c62c4b2d6a15 3316 /// ...
WiredHome 198:9b6851107426 3317 /// RetCode_t r = lcd.PrintScreen(0,0,LCD_PHYS_W,LCD_PHYS_H,"/local/print.bmp");
WiredHome 149:c62c4b2d6a15 3318 /// if (r ...)
WiredHome 149:c62c4b2d6a15 3319 /// @endcode
WiredHome 149:c62c4b2d6a15 3320 ///
WiredHome 149:c62c4b2d6a15 3321 ///
WiredHome 123:2f45e80fec5f 3322 /// @param callback is the idle callback function. Without a callback function
WiredHome 123:2f45e80fec5f 3323 /// it will unregister the handler.
WiredHome 123:2f45e80fec5f 3324 ///
WiredHome 123:2f45e80fec5f 3325 void AttachIdleHandler(IdleCallback_T callback = NULL) { idle_callback = callback; }
WiredHome 57:bd53a9e165a1 3326
WiredHome 133:e36dcfc2d756 3327
WiredHome 19:3f82c1161fd2 3328 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 3329 /// Clear the performance metrics to zero.
WiredHome 19:3f82c1161fd2 3330 void ClearPerformance();
WiredHome 190:3132b7dfad82 3331
WiredHome 66:468a11f05580 3332 /// Count idle time.
WiredHome 66:468a11f05580 3333 ///
WiredHome 72:ecffe56af969 3334 /// @param[in] t is the amount of idle time to accumulate.
WiredHome 66:468a11f05580 3335 ///
WiredHome 66:468a11f05580 3336 void CountIdleTime(uint32_t t);
WiredHome 190:3132b7dfad82 3337
WiredHome 19:3f82c1161fd2 3338 /// Report the performance metrics for drawing functions using
WiredHome 41:2956a0a221e5 3339 /// the available serial channel.
WiredHome 41:2956a0a221e5 3340 ///
WiredHome 72:ecffe56af969 3341 /// @param[in,out] pc is the serial channel to write to.
WiredHome 41:2956a0a221e5 3342 ///
WiredHome 41:2956a0a221e5 3343 void ReportPerformance(Serial & pc);
WiredHome 19:3f82c1161fd2 3344 #endif
WiredHome 19:3f82c1161fd2 3345
hexley 54:e117ad10fba6 3346
WiredHome 19:3f82c1161fd2 3347 private:
WiredHome 182:8832d03a2a29 3348 void InitAllMemberVars();
WiredHome 182:8832d03a2a29 3349
WiredHome 124:1690a7ae871c 3350 /// Touch panel parameters - common to both resistive and capacitive
WiredHome 190:3132b7dfad82 3351
WiredHome 124:1690a7ae871c 3352 /// Data type to indicate which TP, if any, is in use.
WiredHome 124:1690a7ae871c 3353 typedef enum {
WiredHome 124:1690a7ae871c 3354 TP_NONE, ///< no touch panel in use
WiredHome 124:1690a7ae871c 3355 TP_RES, ///< resistive touch panel using RA8875
WiredHome 165:695c24cc5197 3356 TP_FT5206, ///< Capacitive touch panel using FT5206
WiredHome 165:695c24cc5197 3357 TP_CAP=TP_FT5206, ///< DEPRECATED: used TP_CAP5206 for that chip-set
WiredHome 165:695c24cc5197 3358 TP_GSL1680, ///< Capacitive touch panel using GSL1680 chip
WiredHome 124:1690a7ae871c 3359 } WhichTP_T;
WiredHome 190:3132b7dfad82 3360
WiredHome 124:1690a7ae871c 3361 /// boolean flag set true when using Capacitive touch panel, and false
WiredHome 124:1690a7ae871c 3362 /// for resistive.
WiredHome 124:1690a7ae871c 3363 WhichTP_T useTouchPanel; ///< Indicates which TP is selected for use.
WiredHome 190:3132b7dfad82 3364
WiredHome 124:1690a7ae871c 3365 /// Touch State used by TouchPanelReadable. See @ref TouchCode_t.
WiredHome 124:1690a7ae871c 3366 TouchCode_t touchState;
WiredHome 124:1690a7ae871c 3367
WiredHome 124:1690a7ae871c 3368 ////////////////// Start of Capacitive Touch Panel parameters
WiredHome 190:3132b7dfad82 3369
WiredHome 162:a2d7f1988711 3370 int RoundUp(int value, int roundTo);
WiredHome 165:695c24cc5197 3371 uint8_t FT5206_TouchPositions(void);
WiredHome 165:695c24cc5197 3372 uint8_t FT5206_ReadRegU8(uint8_t reg);
WiredHome 165:695c24cc5197 3373 uint8_t GSL1680_TouchPositions(void);
WiredHome 165:695c24cc5197 3374 uint8_t GSL1680_ReadRegU8(uint8_t reg, uint8_t * buf, int count);
WiredHome 165:695c24cc5197 3375 RetCode_t FT5206_Init();
WiredHome 165:695c24cc5197 3376 RetCode_t GSL1680_Init();
WiredHome 198:9b6851107426 3377 void ReadResistive(); ///< Analyze the resistive touch
WiredHome 165:695c24cc5197 3378
WiredHome 124:1690a7ae871c 3379 void TouchPanelISR(void);
WiredHome 124:1690a7ae871c 3380 uint16_t numberOfTouchPoints;
WiredHome 165:695c24cc5197 3381 uint8_t gesture; ///< Holds the reported gesture information (which doesn't work well for the FT5206)
WiredHome 190:3132b7dfad82 3382
WiredHome 124:1690a7ae871c 3383 /// Touch Information data structure
WiredHome 124:1690a7ae871c 3384 typedef struct {
WiredHome 124:1690a7ae871c 3385 uint8_t touchID; ///< Contains the touch ID, which is the "order" of touch, from 0 to n-1
WiredHome 124:1690a7ae871c 3386 TouchCode_t touchCode; ///< Contains the touch code; no_touch, touch, held, release
WiredHome 124:1690a7ae871c 3387 point_t coordinates; ///< Contains the X,Y coordinate of the touch
WiredHome 124:1690a7ae871c 3388 } touchInfo_T;
WiredHome 124:1690a7ae871c 3389
WiredHome 166:53fd4a876dac 3390 touchInfo_T * touchInfo; /// Storage allocated by the constructor to contains the touch information
WiredHome 124:1690a7ae871c 3391
WiredHome 155:b3f225ae572c 3392 #if MBED_VERSION >= MBED_ENCODE_VERSION(5,8,0)
WiredHome 155:b3f225ae572c 3393 Thread eventThread;
WiredHome 155:b3f225ae572c 3394 EventQueue queue;
WiredHome 155:b3f225ae572c 3395 #endif
WiredHome 124:1690a7ae871c 3396 InterruptIn * m_irq;
WiredHome 124:1690a7ae871c 3397 I2C * m_i2c;
WiredHome 165:695c24cc5197 3398 int m_addr; /// I2C Address of the Cap Touch Controller
WiredHome 124:1690a7ae871c 3399
WiredHome 124:1690a7ae871c 3400 bool panelTouched;
WiredHome 190:3132b7dfad82 3401
WiredHome 124:1690a7ae871c 3402 ////////////////// Start of Resistive Touch Panel parameters
WiredHome 190:3132b7dfad82 3403
hexley 54:e117ad10fba6 3404 /// Specify the default settings for the Touch Panel, where different from the chip defaults
WiredHome 77:9206c13aa527 3405 #define TP_MODE_DEFAULT TP_MODE_AUTO
WiredHome 77:9206c13aa527 3406 #define TP_DEBOUNCE_DEFAULT TP_DEBOUNCE_ON
WiredHome 77:9206c13aa527 3407 #define TP_ADC_CLKDIV_DEFAULT TP_ADC_CLKDIV_8
hexley 54:e117ad10fba6 3408
WiredHome 77:9206c13aa527 3409 #define TP_ADC_SAMPLE_DEFAULT_CLKS TP_ADC_SAMPLE_8192_CLKS
hexley 54:e117ad10fba6 3410
hexley 54:e117ad10fba6 3411 /// Other Touch Panel params
WiredHome 77:9206c13aa527 3412 #define TPBUFSIZE 16 // Depth of the averaging buffers for x and y data
hexley 54:e117ad10fba6 3413
WiredHome 83:7bad0068cca0 3414 // Needs both a ticker and a timer. (could have created a timer from the ticker, but this is easier).
WiredHome 83:7bad0068cca0 3415 // on a touch, the timer is reset.
WiredHome 83:7bad0068cca0 3416 // the ticker monitors the timer to see if it has been a long time since
WiredHome 83:7bad0068cca0 3417 // a touch, and if so, it then clears the sample counter so it doesn't get partial old
WiredHome 83:7bad0068cca0 3418 // and partial new.
WiredHome 190:3132b7dfad82 3419
WiredHome 83:7bad0068cca0 3420 /// Touch Panel ticker
WiredHome 165:695c24cc5197 3421 /// This it bound to a timer to call the _TouchTicker() function periodically.
WiredHome 165:695c24cc5197 3422 ///
WiredHome 83:7bad0068cca0 3423 Ticker touchTicker;
WiredHome 190:3132b7dfad82 3424
WiredHome 83:7bad0068cca0 3425 /// Touch Panel timer
WiredHome 165:695c24cc5197 3426 /// Reset on a touch, to expire on a non-touch
WiredHome 165:695c24cc5197 3427 ///
WiredHome 165:695c24cc5197 3428 Timer timeSinceTouch;
WiredHome 190:3132b7dfad82 3429
WiredHome 83:7bad0068cca0 3430 /// keeps track of which sample we're collecting to filter out the noise.
WiredHome 83:7bad0068cca0 3431 int touchSample;
WiredHome 190:3132b7dfad82 3432
WiredHome 83:7bad0068cca0 3433 /// Private function for touch ticker callback.
WiredHome 83:7bad0068cca0 3434 void _TouchTicker(void);
WiredHome 190:3132b7dfad82 3435
WiredHome 77:9206c13aa527 3436 /// Touch Panel calibration matrix.
WiredHome 77:9206c13aa527 3437 tpMatrix_t tpMatrix;
hexley 54:e117ad10fba6 3438
WiredHome 157:1565f38ca44b 3439 /// RESISTIVE TP: The fully qualified filename for the RESISTIVE touch panel configuration settings.
WiredHome 157:1565f38ca44b 3440 const char * tpFQFN;
WiredHome 190:3132b7dfad82 3441
WiredHome 157:1565f38ca44b 3442 /// RESISTIVE TP: The text message shown to the user during the calibration process.
WiredHome 157:1565f38ca44b 3443 const char * tpCalMessage;
WiredHome 157:1565f38ca44b 3444
WiredHome 157:1565f38ca44b 3445 /// Internal method that performs the TS Cal when the user has so-configured it
WiredHome 157:1565f38ca44b 3446 RetCode_t _internal_ts_cal();
WiredHome 157:1565f38ca44b 3447
WiredHome 157:1565f38ca44b 3448
WiredHome 124:1690a7ae871c 3449 ////////////////// End of Touch Panel parameters
WiredHome 124:1690a7ae871c 3450
WiredHome 124:1690a7ae871c 3451
WiredHome 29:422616aa04bd 3452 /// Internal function to put a character using the built-in (internal) font engine
WiredHome 29:422616aa04bd 3453 ///
WiredHome 101:e0aad446094a 3454 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 3455 /// @returns the character put.
WiredHome 29:422616aa04bd 3456 ///
WiredHome 29:422616aa04bd 3457 int _internal_putc(int c);
WiredHome 190:3132b7dfad82 3458
WiredHome 29:422616aa04bd 3459 /// Internal function to put a character using the external font engine
WiredHome 29:422616aa04bd 3460 ///
WiredHome 101:e0aad446094a 3461 /// @param[in] c is the character to put to the screen.
WiredHome 29:422616aa04bd 3462 /// @returns the character put.
WiredHome 29:422616aa04bd 3463 ///
WiredHome 29:422616aa04bd 3464 int _external_putc(int c);
WiredHome 190:3132b7dfad82 3465
WiredHome 101:e0aad446094a 3466 /// Internal function to get the actual width of a character when using the external font engine
WiredHome 101:e0aad446094a 3467 ///
WiredHome 101:e0aad446094a 3468 /// @param[in] c is the character to get the width.
WiredHome 101:e0aad446094a 3469 /// @returns the width in pixels of the character. zero if not found.
WiredHome 101:e0aad446094a 3470 ///
WiredHome 101:e0aad446094a 3471 int _external_getCharWidth(int c);
WiredHome 190:3132b7dfad82 3472
WiredHome 133:e36dcfc2d756 3473 /// Write color to an RGB register set
WiredHome 133:e36dcfc2d756 3474 ///
WiredHome 133:e36dcfc2d756 3475 /// This API takes a color value, and writes it into the specified
WiredHome 133:e36dcfc2d756 3476 /// color registers, which are a trio of 3 registers. The actual
WiredHome 133:e36dcfc2d756 3477 /// trio write is performed based on whether the display is configured
WiredHome 133:e36dcfc2d756 3478 /// for 8 or 16 bits per pixel.
WiredHome 133:e36dcfc2d756 3479 ///
WiredHome 133:e36dcfc2d756 3480 /// @param[in] regAddr is the register address starting the trio
WiredHome 133:e36dcfc2d756 3481 /// @param[in] color is the color to write
WiredHome 167:8aa3fb2a5a31 3482 /// @returns @ref RetCode_t value.
WiredHome 133:e36dcfc2d756 3483 ///
WiredHome 133:e36dcfc2d756 3484 RetCode_t _writeColorTrio(uint8_t regAddr, color_t color);
WiredHome 190:3132b7dfad82 3485
WiredHome 133:e36dcfc2d756 3486 /// Read color from an RGB register set
WiredHome 133:e36dcfc2d756 3487 ///
WiredHome 133:e36dcfc2d756 3488 /// This API reads a color value from a trio of registers. The actual
WiredHome 133:e36dcfc2d756 3489 /// trio write is performed based on whether the display is configured
WiredHome 133:e36dcfc2d756 3490 /// for 8 or 16 bits per pixel.
WiredHome 133:e36dcfc2d756 3491 ///
WiredHome 133:e36dcfc2d756 3492 /// @param[in] regAddr is the register address starting the trio
WiredHome 133:e36dcfc2d756 3493 /// @returns color_t value
WiredHome 133:e36dcfc2d756 3494 ///
WiredHome 133:e36dcfc2d756 3495 color_t _readColorTrio(uint8_t regAddr);
WiredHome 190:3132b7dfad82 3496
WiredHome 190:3132b7dfad82 3497
WiredHome 105:4f116006ba1f 3498 /// Convert a 16-bit color value to an 8-bit value
WiredHome 105:4f116006ba1f 3499 ///
WiredHome 105:4f116006ba1f 3500 /// @param[in] c16 is the 16-bit color value to convert.
WiredHome 105:4f116006ba1f 3501 /// @returns 8-bit color value.
WiredHome 105:4f116006ba1f 3502 ///
WiredHome 105:4f116006ba1f 3503 uint8_t _cvt16to8(color_t c16);
WiredHome 105:4f116006ba1f 3504
WiredHome 105:4f116006ba1f 3505 /// Convert an 8-bit color value to a 16-bit value
WiredHome 105:4f116006ba1f 3506 ///
WiredHome 105:4f116006ba1f 3507 /// @param[in] c8 is the 8-bit color value to convert.
WiredHome 105:4f116006ba1f 3508 /// @returns 16-bit color value.
WiredHome 105:4f116006ba1f 3509 ///
WiredHome 105:4f116006ba1f 3510 color_t _cvt8to16(uint8_t c8);
WiredHome 190:3132b7dfad82 3511
WiredHome 19:3f82c1161fd2 3512 /// Select the peripheral to use it.
WiredHome 19:3f82c1161fd2 3513 ///
WiredHome 72:ecffe56af969 3514 /// @param[in] chipsel when true will select the peripheral, and when false
WiredHome 19:3f82c1161fd2 3515 /// will deselect the chip. This is the logical selection, and
WiredHome 19:3f82c1161fd2 3516 /// the pin selection is the invert of this.
WiredHome 167:8aa3fb2a5a31 3517 /// @returns @ref RetCode_t value.
WiredHome 19:3f82c1161fd2 3518 ///
WiredHome 79:544eb4964795 3519 RetCode_t _select(bool chipsel);
WiredHome 19:3f82c1161fd2 3520
WiredHome 66:468a11f05580 3521 /// Wait while the status register indicates the controller is busy.
WiredHome 66:468a11f05580 3522 ///
WiredHome 72:ecffe56af969 3523 /// @param[in] mask is the mask of bits to monitor.
WiredHome 66:468a11f05580 3524 /// @returns true if a normal exit.
WiredHome 66:468a11f05580 3525 /// @returns false if a timeout exit.
WiredHome 66:468a11f05580 3526 ///
WiredHome 66:468a11f05580 3527 bool _WaitWhileBusy(uint8_t mask);
WiredHome 66:468a11f05580 3528
WiredHome 66:468a11f05580 3529 /// Wait while the the register anded with the mask is true.
WiredHome 66:468a11f05580 3530 ///
WiredHome 72:ecffe56af969 3531 /// @param[in] reg is the register to monitor
WiredHome 72:ecffe56af969 3532 /// @param[in] mask is the bit mask to monitor
WiredHome 66:468a11f05580 3533 /// @returns true if it was a normal exit
WiredHome 66:468a11f05580 3534 /// @returns false if it was a timeout that caused the exit.
WiredHome 66:468a11f05580 3535 ///
WiredHome 66:468a11f05580 3536 bool _WaitWhileReg(uint8_t reg, uint8_t mask);
WiredHome 66:468a11f05580 3537
WiredHome 68:ab08efabfc88 3538 /// set the spi port to either the write or the read speed.
WiredHome 68:ab08efabfc88 3539 ///
WiredHome 68:ab08efabfc88 3540 /// This is a private API used to toggle between the write
WiredHome 68:ab08efabfc88 3541 /// and the read speed for the SPI port to the RA8875, since
WiredHome 68:ab08efabfc88 3542 /// it can accept writes faster than reads.
WiredHome 68:ab08efabfc88 3543 ///
WiredHome 72:ecffe56af969 3544 /// @param[in] writeSpeed when true selects the write frequency,
WiredHome 68:ab08efabfc88 3545 /// and when false it selects the read frequency.
WiredHome 68:ab08efabfc88 3546 ///
WiredHome 68:ab08efabfc88 3547 void _setWriteSpeed(bool writeSpeed);
WiredHome 68:ab08efabfc88 3548
WiredHome 19:3f82c1161fd2 3549 /// The most primitive - to write a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 3550 ///
WiredHome 72:ecffe56af969 3551 /// @param[in] data is the value to write.
WiredHome 19:3f82c1161fd2 3552 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 3553 /// in while shifting out.
WiredHome 19:3f82c1161fd2 3554 ///
WiredHome 79:544eb4964795 3555 unsigned char _spiwrite(unsigned char data);
WiredHome 190:3132b7dfad82 3556
WiredHome 19:3f82c1161fd2 3557 /// The most primitive - to read a data value to the SPI interface.
WiredHome 19:3f82c1161fd2 3558 ///
WiredHome 19:3f82c1161fd2 3559 /// This is really just a specialcase of the write command, where
WiredHome 19:3f82c1161fd2 3560 /// the value zero is written in order to read.
WiredHome 19:3f82c1161fd2 3561 ///
WiredHome 19:3f82c1161fd2 3562 /// @returns a value read from the port, since SPI is often shift
WiredHome 19:3f82c1161fd2 3563 /// in while shifting out.
WiredHome 19:3f82c1161fd2 3564 ///
WiredHome 79:544eb4964795 3565 unsigned char _spiread();
WiredHome 190:3132b7dfad82 3566
WiredHome 75:ca78388cfd77 3567 const uint8_t * pKeyMap;
WiredHome 190:3132b7dfad82 3568
WiredHome 19:3f82c1161fd2 3569 SPI spi; ///< spi port
WiredHome 68:ab08efabfc88 3570 bool spiWriteSpeed; ///< indicates if the current mode is write or read
WiredHome 68:ab08efabfc88 3571 unsigned long spiwritefreq; ///< saved write freq
WiredHome 66:468a11f05580 3572 unsigned long spireadfreq; ///< saved read freq
WiredHome 165:695c24cc5197 3573 DigitalOut cs; ///< RA8875 chip select pin, assumed active low
WiredHome 200:ae29b60d087c 3574 DigitalOut * res; ///< RA8875 reset pin, assumed active low
WiredHome 165:695c24cc5197 3575 DigitalOut * m_wake; ///< GSL1680 wake pin
WiredHome 190:3132b7dfad82 3576
WiredHome 105:4f116006ba1f 3577 // display metrics to avoid lengthy spi read queries
WiredHome 105:4f116006ba1f 3578 uint8_t screenbpp; ///< configured bits per pixel
WiredHome 198:9b6851107426 3579 dim_t virt_screenwidth; ///< configured screen width cached here for speed of access
WiredHome 198:9b6851107426 3580 dim_t virt_screenheight; ///< configured screen height cached here for speed of access
WiredHome 198:9b6851107426 3581 rect_t windowrect; ///< window rect cached here for speed of access
WiredHome 198:9b6851107426 3582 orientation_t screen_orientation; ///< configured graphic orientation cached here for speed of access
WiredHome 198:9b6851107426 3583 orientation_t text_orientation; ///< configured text orientation cached here for speed of access
WiredHome 190:3132b7dfad82 3584 bool wordwrap; ///< set true when wordwrap is in effect for _puts()
WiredHome 19:3f82c1161fd2 3585 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 98:ecebed9b80b2 3586 uint8_t extFontHeight; ///< computed from the font table when the user sets the font
WiredHome 98:ecebed9b80b2 3587 uint8_t extFontWidth; ///< computed from the font table when the user sets the font
WiredHome 190:3132b7dfad82 3588 bool roundCap; ///< draw round end cap on thick lines when set.
WiredHome 90:d113d71ae4f0 3589 loc_t cursor_x, cursor_y; ///< used for external fonts only
WiredHome 190:3132b7dfad82 3590
WiredHome 19:3f82c1161fd2 3591 #ifdef PERF_METRICS
WiredHome 19:3f82c1161fd2 3592 typedef enum
WiredHome 19:3f82c1161fd2 3593 {
WiredHome 19:3f82c1161fd2 3594 PRF_CLS,
WiredHome 41:2956a0a221e5 3595 PRF_DRAWPIXEL,
WiredHome 41:2956a0a221e5 3596 PRF_PIXELSTREAM,
WiredHome 109:7b94f06f085b 3597 PRF_BOOLSTREAM,
WiredHome 41:2956a0a221e5 3598 PRF_READPIXEL,
WiredHome 41:2956a0a221e5 3599 PRF_READPIXELSTREAM,
WiredHome 19:3f82c1161fd2 3600 PRF_DRAWLINE,
WiredHome 19:3f82c1161fd2 3601 PRF_DRAWRECTANGLE,
WiredHome 19:3f82c1161fd2 3602 PRF_DRAWROUNDEDRECTANGLE,
WiredHome 19:3f82c1161fd2 3603 PRF_DRAWTRIANGLE,
WiredHome 19:3f82c1161fd2 3604 PRF_DRAWCIRCLE,
WiredHome 19:3f82c1161fd2 3605 PRF_DRAWELLIPSE,
WiredHome 131:5bd6ba2ee4a1 3606 PRF_BLOCKMOVE,
WiredHome 182:8832d03a2a29 3607 METRICCOUNT = PRF_BLOCKMOVE
WiredHome 19:3f82c1161fd2 3608 } method_e;
WiredHome 19:3f82c1161fd2 3609 unsigned long metrics[METRICCOUNT];
WiredHome 75:ca78388cfd77 3610 unsigned long idletime_usec;
WiredHome 19:3f82c1161fd2 3611 void RegisterPerformance(method_e method);
WiredHome 19:3f82c1161fd2 3612 Timer performance;
WiredHome 19:3f82c1161fd2 3613 #endif
WiredHome 190:3132b7dfad82 3614
WiredHome 96:40b74dd3695b 3615 RetCode_t _printCallback(RA8875::filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 190:3132b7dfad82 3616
WiredHome 96:40b74dd3695b 3617 FILE * _printFH; ///< PrintScreen file handle
WiredHome 190:3132b7dfad82 3618
WiredHome 96:40b74dd3695b 3619 RetCode_t privateCallback(filecmd_t cmd, uint8_t * buffer, uint16_t size) {
WiredHome 96:40b74dd3695b 3620 if (c_callback != NULL) {
WiredHome 96:40b74dd3695b 3621 return (*c_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 3622 }
WiredHome 96:40b74dd3695b 3623 else {
WiredHome 96:40b74dd3695b 3624 if (obj_callback != NULL && method_callback != NULL) {
WiredHome 96:40b74dd3695b 3625 return (obj_callback->*method_callback)(cmd, buffer, size);
WiredHome 96:40b74dd3695b 3626 }
WiredHome 96:40b74dd3695b 3627 }
WiredHome 96:40b74dd3695b 3628 return noerror;
WiredHome 96:40b74dd3695b 3629 }
WiredHome 190:3132b7dfad82 3630
WiredHome 96:40b74dd3695b 3631 RetCode_t (* c_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 96:40b74dd3695b 3632 FPointerDummy *obj_callback;
WiredHome 96:40b74dd3695b 3633 RetCode_t (FPointerDummy::*method_callback)(filecmd_t cmd, uint8_t * buffer, uint16_t size);
WiredHome 149:c62c4b2d6a15 3634 RetCode_t (* idle_callback)(IdleReason_T reason, uint16_t param);
WiredHome 190:3132b7dfad82 3635
WiredHome 19:3f82c1161fd2 3636 };
WiredHome 19:3f82c1161fd2 3637
WiredHome 96:40b74dd3695b 3638
WiredHome 19:3f82c1161fd2 3639 //} // namespace
WiredHome 19:3f82c1161fd2 3640
WiredHome 19:3f82c1161fd2 3641 //using namespace SW_graphics;
WiredHome 19:3f82c1161fd2 3642
WiredHome 23:a50ded45dbaf 3643
WiredHome 23:a50ded45dbaf 3644 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 3645 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 3646 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 3647 // / / / / / / / /
WiredHome 23:a50ded45dbaf 3648 // / / / /___ / /__________ / /
WiredHome 23:a50ded45dbaf 3649 // / / / ____/ /__________ / / /
WiredHome 23:a50ded45dbaf 3650 // / / / / / / / /
WiredHome 23:a50ded45dbaf 3651 // / / / /__________ ___________/ / / /
WiredHome 23:a50ded45dbaf 3652 // /__/ /_____________/ /_____________/ /__/
WiredHome 23:a50ded45dbaf 3653
WiredHome 23:a50ded45dbaf 3654 #include "WebColors.h"
WiredHome 23:a50ded45dbaf 3655 #include <algorithm>
WiredHome 23:a50ded45dbaf 3656
WiredHome 23:a50ded45dbaf 3657 extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 3658
WiredHome 190:3132b7dfad82 3659 /// This activates a small set of tests for the graphics library.
WiredHome 23:a50ded45dbaf 3660 ///
WiredHome 23:a50ded45dbaf 3661 /// Call this API and pass it the reference to the display class.
WiredHome 23:a50ded45dbaf 3662 /// It will then run a series of tests. It accepts interaction via
WiredHome 23:a50ded45dbaf 3663 /// stdin to switch from automatic test mode to manual, run a specific
WiredHome 23:a50ded45dbaf 3664 /// test, or to exit the test mode.
WiredHome 23:a50ded45dbaf 3665 ///
WiredHome 72:ecffe56af969 3666 /// @param[in] lcd is a reference to the display class.
WiredHome 72:ecffe56af969 3667 /// @param[in] pc is a reference to a serial interface, typically the USB to PC.
WiredHome 23:a50ded45dbaf 3668 ///
WiredHome 23:a50ded45dbaf 3669 void RunTestSet(RA8875 & lcd, Serial & pc);
WiredHome 23:a50ded45dbaf 3670
WiredHome 23:a50ded45dbaf 3671
WiredHome 23:a50ded45dbaf 3672 // To enable the test code, uncomment this section, or copy the
WiredHome 23:a50ded45dbaf 3673 // necessary pieces to your "main()".
WiredHome 23:a50ded45dbaf 3674 //
WiredHome 23:a50ded45dbaf 3675 // #include "mbed.h"
WiredHome 23:a50ded45dbaf 3676 // #include "RA8875.h"
WiredHome 23:a50ded45dbaf 3677 // RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 23:a50ded45dbaf 3678 // Serial pc(USBTX, USBRX);
WiredHome 23:a50ded45dbaf 3679 // extern "C" void mbed_reset();
WiredHome 23:a50ded45dbaf 3680 // int main()
WiredHome 23:a50ded45dbaf 3681 // {
WiredHome 23:a50ded45dbaf 3682 // pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 23:a50ded45dbaf 3683 // pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 190:3132b7dfad82 3684 //
WiredHome 23:a50ded45dbaf 3685 // pc.printf("Turning on display\r\n");
WiredHome 101:e0aad446094a 3686 // lcd.init();
WiredHome 23:a50ded45dbaf 3687 // lcd.Reset();
WiredHome 23:a50ded45dbaf 3688 // lcd.Power(true); // display power is on, but the backlight is independent
WiredHome 23:a50ded45dbaf 3689 // lcd.Backlight(0.5);
WiredHome 23:a50ded45dbaf 3690 // RunTestSet(lcd, pc);
WiredHome 23:a50ded45dbaf 3691 // }
WiredHome 23:a50ded45dbaf 3692
WiredHome 23:a50ded45dbaf 3693 #endif // TESTENABLE
WiredHome 23:a50ded45dbaf 3694
WiredHome 56:7a85d226ad0d 3695 #endif