This is the David Smart RA8875 Library with mods for working with FRDM-K64F

Committer:
lamell
Date:
Tue Mar 10 21:28:18 2020 -0400
Revision:
199:08eb9e55567b
Parent:
198:18d25c15a7b5
Child:
200:05ccd555a538
Subtle changes in the way the library behaves.

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