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:
Sun Apr 04 20:14:06 2021 +0000
Revision:
209:08fc22dea762
Parent:
207:82f336e5c021
Fix a long-standing defect in the FT5206 where it reported 'touch' code even for hold and release events.

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