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

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

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

Offline Help Manual (Windows chm)

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

Committer:
WiredHome
Date:
Sun Jul 28 01:33:02 2019 +0000
Revision:
178:ae472eb22740
Parent:
177:d8e65c0e268a
Child:
181:0032d1b8f5d4
Install handler before enabling IRQ; Eliminate duplicate initialisations; Speedup ThickLine using rectangles and triangles; Add triangle method using points; Improve mbed version adaptation of callback; Added some debug info.

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