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:
Sat Mar 28 15:08:43 2020 +0000
Revision:
199:fb06805f447f
Parent:
198:9b6851107426
Child:
200:ae29b60d087c
Warning reduction

Who changed what in which revision?

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