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:
Mon Nov 25 19:55:17 2019 +0000
Revision:
193:74f80834d59d
Parent:
191:0fad2e45e196
Child:
195:17e176dbd6eb
Improve debouncing of resistive touch.; Minor format changes for easier maintenance.

Who changed what in which revision?

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