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:
Fri Aug 02 02:12:26 2019 +0000
Revision:
181:0032d1b8f5d4
Parent:
178:ae472eb22740
Child:
182:8832d03a2a29
A bit of experimenting on rotation.

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