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)

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Sun Jan 13 20:38:01 2019 +0000
Parent:
161:0215d0eec1a4
Child:
173:ae8198c82b88
Commit message:
Non-functional refactoring

Changed in this revision

RA8875.cpp Show annotated file Show diff for this revision Revisions of this file
RA8875.h Show annotated file Show diff for this revision Revisions of this file
--- a/RA8875.cpp	Sun Jan 13 19:02:36 2019 +0000
+++ b/RA8875.cpp	Sun Jan 13 20:38:01 2019 +0000
@@ -99,8 +99,10 @@
     "not enough ram",         ///< could not allocate ram for scanline
     "touch cal. timeout",     ///< calibration could not complete in time
     "external abort",         ///< during an idle callback, the user code initiated an abort
+    "touch cal defaulted",    ///< a user provided default calibration was installed 
 };
 
+
 RA8875::RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset, 
     const char *name)
     : GraphicsDisplay(name)
@@ -163,7 +165,7 @@
 //}
 
 
-RetCode_t RA8875::init(int width, int height, int color_bpp, uint8_t poweron, bool keypadon, bool touchscreenon)
+RetCode_t RA8875::init(dim_t width, dim_t height, uint8_t color_bpp, uint8_t poweron, bool keypadon, bool touchscreenon)
 {
     font = NULL;                                // no external font, use internal.
     pKeyMap = DefaultKeyMap;                    // set default key map
@@ -580,15 +582,15 @@
 }
 
 
-RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t data)
+RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t _data)
 {
-    WriteCommand(command, data & 0xFF);
-    WriteCommand(command+1, data >> 8);
+    WriteCommand(command, _data & 0xFF);
+    WriteCommand(command+1, _data >> 8);
     return noerror;
 }
 
 
-RetCode_t RA8875::WriteCommand(unsigned char command, unsigned int data)
+RetCode_t RA8875::WriteCommand(unsigned char command, unsigned int _data)
 {
 #ifdef PERF_METRICS
     if (commandsUsed[command] < 65535)
@@ -597,31 +599,31 @@
     _select(true);
     _spiwrite(0x80);            // RS:1 (Cmd/Status), RW:0 (Write)
     _spiwrite(command);
-    if (data <= 0xFF) {   // only if in the valid range
+    if (_data <= 0xFF) {   // only if in the valid range
         _spiwrite(0x00);
-        _spiwrite(data);
+        _spiwrite((uint8_t)_data);
     }
     _select(false);
     return noerror;
 }
 
 
-RetCode_t RA8875::WriteDataW(uint16_t data)
+RetCode_t RA8875::WriteDataW(uint16_t _data)
 {
     _select(true);
     _spiwrite(0x00);            // RS:0 (Data), RW:0 (Write)
-    _spiwrite(data & 0xFF);
-    _spiwrite(data >> 8);
+    _spiwrite(_data & 0xFF);
+    _spiwrite(_data >> 8);
     _select(false);
     return noerror;
 }
 
 
-RetCode_t RA8875::WriteData(unsigned char data)
+RetCode_t RA8875::WriteData(unsigned char _data)
 {
     _select(true);
     _spiwrite(0x00);            // RS:0 (Data), RW:0 (Write)
-    _spiwrite(data);
+    _spiwrite(_data);
     _select(false);
     return noerror;
 }
@@ -641,38 +643,38 @@
 
 unsigned char RA8875::ReadData(void)
 {
-    unsigned char data;
+    unsigned char _data;
 
     _select(true);
     _spiwrite(0x40);            // RS:0 (Data), RW:1 (Read)
-    data = _spiread();
+    _data = _spiread();
     _select(false);
-    return data;
+    return _data;
 }
 
 
 uint16_t RA8875::ReadDataW(void)
 {
-    uint16_t data;
+    uint16_t _data;
 
     _select(true);
     _spiwrite(0x40);            // RS:0 (Data), RW:1 (Read)
-    data  = _spiread();
-    data |= (_spiread() << 8);
+    _data  = _spiread();
+    _data |= (_spiread() << 8);
     _select(false);
-    return data;
+    return _data;
 }
 
 
 unsigned char RA8875::ReadStatus(void)
 {
-    unsigned char data;
+    unsigned char _data;
 
     _select(true);
     _spiwrite(0xC0);            // RS:1 (Cmd/Status), RW:1 (Read) (Read STSR)
-    data = _spiread();
+    _data = _spiread();
     _select(false);
-    return data;
+    return _data;
 }
 
 
@@ -945,10 +947,10 @@
 }
 
 
-RetCode_t RA8875::SetTextFont(RA8875::font_t font)
+RetCode_t RA8875::SetTextFont(RA8875::font_t _font)
 {
-    if (/*font >= RA8875::ISO8859_1 && */ font <= RA8875::ISO8859_4) {
-        WriteCommand(0x21, (unsigned int)(font));
+    if (/*_font >= RA8875::ISO8859_1 && */ _font <= RA8875::ISO8859_4) {
+        WriteCommand(0x21, (unsigned int)(_font));
         return noerror;
     } else {
         return bad_parameter;
@@ -1114,7 +1116,7 @@
             loc_t y;
             y = ReadCommand(0x2C) | (ReadCommand(0x2D) << 8);   // current y location
             y += fontheight();
-            if (y >= height())               // @TODO after bottom of active window, then scroll window?
+            if (y >= height())               /// @TODO presently wraps, might want to scroll instead
                 y = 0;
             WriteCommandW(0x2C, y);
         } else {
@@ -1329,7 +1331,7 @@
 RetCode_t RA8875::booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) 
 {
     PERFORMANCE_RESET;
-    const uint8_t * rowStream;
+    const uint8_t * rowStream = boolStream;
     rect_t restore = windowrect;
     window(x, y, w * fontScaleX, h * fontScaleY);       // Scale from font scale factors
     SetGraphicsCursor(x, y);
--- a/RA8875.h	Sun Jan 13 19:02:36 2019 +0000
+++ b/RA8875.h	Sun Jan 13 20:38:01 2019 +0000
@@ -419,7 +419,7 @@
     /// @returns noerror to allow the driver continue waiting.
     /// @returns external_abort if the pending action should be aborted.
     ///
-    typedef RetCode_t (* IdleCallback_T)(IdleReason_T reason, uint16_t param = 0);
+    typedef RetCode_t (* IdleCallback_T)(IdleReason_T reason, uint16_t param);
 
     /// Basic constructor for a display based on the RAiO RA8875 
     /// display controller, which can be used with no touchscreen,
@@ -534,7 +534,7 @@
     ///             parameter is used to enable and initialize the resistive touchscreen driver.
     /// @returns success/failure code. See @ref RetCode_t.
     ///
-    RetCode_t init(int width = 480, int height = 272, int color_bpp = 16, 
+    RetCode_t init(dim_t width = 480, dim_t height = 272, uint8_t color_bpp = 16, 
         uint8_t poweron = 40, bool keypadon = true, bool touchscreeenon = true);
 
 
@@ -1237,8 +1237,6 @@
     ///                +------------------+
     /// @endcode
     ///
-    /// @note that the first parameter is a pointer to a rect and the 
-    ///
     /// @param[inout] pRect1 is a pointer to a rectangular region, and returns
     ///             the area of intersection.
     /// @param[in] pRect2 is a pointer to a second rectangular region.