Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more
Revision 14:2db7065edbec, committed 2015-10-12
- Comitter:
- displaymodule
- Date:
- Mon Oct 12 08:35:35 2015 +0000
- Parent:
- 13:6ff2649b6c27
- Commit message:
- Important updates, compatible with the new mbed library?more platforms support. Recommended updates.
Changed in this revision
--- a/DmTftHX8353C.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftHX8353C.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -10,9 +10,15 @@
NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
********************************************************************************************/
-#include "DmTftHX8353C.h"
+ //Tested on NUCLEO-F401RE, LPCXpresso11U68 platform.
-DmTftHX8353C::DmTftHX8353C(uint8_t mosi, uint8_t clk, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(128,160) {
+#include "DmTftHX8353C.h"
+#if defined (DM_TOOLCHAIN_ARDUINO)
+DmTftHX8353C::DmTftHX8353C(uint8_t mosi, uint8_t clk, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(128,160)
+#elif defined (DM_TOOLCHAIN_MBED)
+DmTftHX8353C::DmTftHX8353C(PinName mosi, PinName clk, PinName cs, PinName dc, PinName rst) : DmTftBase(128,160)
+#endif
+{
_mosi = mosi;
_clk = clk;
_cs = cs;
@@ -150,11 +156,11 @@
pinMode(_dc,OUTPUT);
pinMode(_rst,OUTPUT);
#elif defined (DM_TOOLCHAIN_MBED)
- _pinMOSI = new DigitalOut((PinName)_mosi);
- _pinCLK = new DigitalOut((PinName)_clk);
- _pinCS = new DigitalOut((PinName)_cs);
- _pinDC = new DigitalOut((PinName)_dc);
- _pinRST = new DigitalOut((PinName)_rst);
+ _pinMOSI = new DigitalOut(_mosi);
+ _pinCLK = new DigitalOut(_clk);
+ _pinCS = new DigitalOut(_cs);
+ _pinDC = new DigitalOut(_dc);
+ _pinRST = new DigitalOut(_rst);
#endif
sbi(_pinRST, _bitmaskRST);
--- a/DmTftHX8353C.h Fri Sep 18 14:59:13 2015 +0000 +++ b/DmTftHX8353C.h Mon Oct 12 08:35:35 2015 +0000 @@ -21,7 +21,7 @@ #if defined (DM_TOOLCHAIN_ARDUINO) DmTftHX8353C(uint8_t mosi=D2, uint8_t clk=D3, uint8_t cs=D4, uint8_t dc=D5, uint8_t rst=D6); #elif defined (DM_TOOLCHAIN_MBED) - DmTftHX8353C(uint8_t mosi=D2, uint8_t clk=D3, uint8_t cs=D4, uint8_t dc=SPECIAL_D5, uint8_t rst=D6); + DmTftHX8353C(PinName mosi, PinName clk, PinName cs, PinName dc, PinName rst); #endif virtual ~DmTftHX8353C(); virtual void init(void); @@ -33,13 +33,15 @@ virtual void sendCommand(uint8_t index); virtual void sendData(uint16_t data); - uint8_t _mosi, _clk, _cs, _dc, _rst; + static const uint16_t _width; static const uint16_t _height; #if defined (DM_TOOLCHAIN_ARDUINO) + uint8_t _mosi, _clk, _cs, _dc, _rst; regtype *_pinDC, *_pinRST, *_pinMOSI, *_pinCLK; regsize _bitmaskDC, _bitmaskRST, _bitmaskMOSI, _bitmaskCLK; #elif defined (DM_TOOLCHAIN_MBED) + PinName _mosi, _clk, _cs, _dc, _rst; DigitalOut* _pinDC, *_pinRST, *_pinMOSI, *_pinCLK; #endif };
--- a/DmTftIli9325.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftIli9325.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -9,17 +9,25 @@
THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
********************************************************************************************/
+
+ //Tested on NUCLEO-F401RE, LPCXpresso11U68 platform.
+
#include "DmTftIli9325.h"
-DmTftIli9325::DmTftIli9325(uint8_t wr, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(240, 320) {
- _wr = wr;
- _cs = cs;
- _dc = dc;
- _rst = rst;
+#if defined (DM_TOOLCHAIN_ARDUINO)
+DmTftIli9325::DmTftIli9325(uint8_t wr, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(240, 320)
+#elif defined (DM_TOOLCHAIN_MBED)
+DmTftIli9325::DmTftIli9325(PinName wr, PinName cs, PinName dc, PinName rst) : DmTftBase(240, 320)
+#endif
+{
+ _wr = wr;
+ _cs = cs;
+ _dc = dc;
+ _rst = rst;
}
DmTftIli9325::~DmTftIli9325() {
-#if defined (DM_TOOLCHAIN_MBED)
+#if defined (DM_TOOLCHAIN_MBED)
delete _pinRST;
delete _pinCS;
delete _pinWR;
@@ -30,14 +38,15 @@
_pinWR = NULL;
_pinDC = NULL;
_virtualPortD = NULL;
-#endif
+#endif
}
void DmTftIli9325::writeBus(uint8_t data) {
#if defined (DM_TOOLCHAIN_ARDUINO)
PORTD = data;
#elif defined (DM_TOOLCHAIN_MBED)
- *_virtualPortD = data;
+ *_virtualPortD = data;
+ //if(data & 0x10)
#endif
pulse_low(_pinWR, _bitmaskWR);
}
@@ -109,23 +118,28 @@
pinMode(_wr, OUTPUT);
pinMode(_dc,OUTPUT);
#elif defined (DM_TOOLCHAIN_MBED)
- _pinRST = new DigitalOut((PinName)_rst);
- _pinCS = new DigitalOut((PinName)_cs);
- _pinWR = new DigitalOut((PinName)_wr);
- _pinDC = new DigitalOut((PinName)_dc);
- _virtualPortD = new BusOut(D0, D1, D2, D3, D4, SPECIAL_D5, D6, D7);
+ _pinRST = new DigitalOut(_rst);
+ _pinCS = new DigitalOut(_cs);
+ _pinWR = new DigitalOut(_wr);
+ _pinDC = new DigitalOut(_dc);
+ _virtualPortD = new BusOut(D0, D1, D2, D3, D4, SPECIAL_D5, D6, D7); // LPC15XX_H
#endif
sbi(_pinRST, _bitmaskRST);
+
delay(5);
cbi(_pinRST, _bitmaskRST);
+
delay(15);
sbi(_pinRST, _bitmaskRST);
sbi(_pinCS, _bitmaskCS);
sbi(_pinWR, _bitmaskWR);
+
delay(15);
cbi(_pinCS, _bitmaskCS);
+
+
sendCommand(0xE5); sendData(0x78F0);
sendCommand(0x01); sendData(0x0100);
sendCommand(0x02); sendData(0x0700);
--- a/DmTftIli9325.h Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftIli9325.h Mon Oct 12 08:35:35 2015 +0000
@@ -18,7 +18,11 @@
class DmTftIli9325 : public DmTftBase
{
public:
+#if defined (DM_TOOLCHAIN_ARDUINO)
DmTftIli9325(uint8_t wr=A4, uint8_t cs=A3, uint8_t dc=A5, uint8_t rst=A2);
+#elif defined (DM_TOOLCHAIN_MBED)
+ DmTftIli9325(PinName wr, PinName cs, PinName dc, PinName rst);
+#endif
virtual ~DmTftIli9325();
virtual void init(void);
private:
@@ -29,16 +33,18 @@
virtual void sendCommand(uint8_t index);
virtual void sendData(uint16_t data);
- uint8_t _wr, _cs, _dc, _rst;
+
static const uint16_t _width;
static const uint16_t _height;
#if defined (DM_TOOLCHAIN_ARDUINO)
+ uint8_t _wr, _cs, _dc, _rst;
regtype *_pinDC, *_pinRST, *_pinWR;
regsize _bitmaskDC, _bitmaskRST, _bitmaskWR;
#elif defined (DM_TOOLCHAIN_MBED)
+ PinName _wr, _cs, _dc, _rst;
DigitalOut* _pinDC, *_pinRST, *_pinWR;
- BusOut *_virtualPortD;
-#endif
+ BusOut * _virtualPortD;
+#endif
};
#endif
--- a/DmTftIli9341.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftIli9341.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -10,31 +10,28 @@
NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
********************************************************************************************/
+//Tested on NUCLEO-F401RE, LPCXpresso11U68, LPCXpresso824-MAX platform.
+
#include "DmTftIli9341.h"
#if defined (DM_TOOLCHAIN_ARDUINO)
DmTftIli9341::DmTftIli9341(uint8_t cs, uint8_t dc)
+:DmTftBase(240, 320)
#elif defined (DM_TOOLCHAIN_MBED)
-DmTftIli9341::DmTftIli9341(uint8_t cs, uint8_t dc, uint8_t miso, uint8_t mosi, uint8_t clk)
+DmTftIli9341::DmTftIli9341(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk)
+:DmTftBase(240, 320), spi(mosi, miso, clk)
#endif
-: DmTftBase(240, 320){
+{
_cs = cs;
_dc = dc;
-#if defined (DM_TOOLCHAIN_MBED)
- _miso = miso;
- _mosi = mosi;
- _clk = clk;
-#endif
}
DmTftIli9341::~DmTftIli9341() {
#if defined (DM_TOOLCHAIN_MBED)
delete _pinCS;
delete _pinDC;
-delete _spi;
_pinCS = NULL;
_pinDC = NULL;
-_spi = NULL;
#endif
}
@@ -44,34 +41,27 @@
SPDR = data; // SPI Data Register
while(!(SPSR & _BV(SPIF))); // SPI Status Register Wait for transmission to finish
#elif defined (DM_TOOLCHAIN_MBED)
- _spi->write(data);
+ spi.write(data);
#endif
}
void DmTftIli9341::sendCommand(uint8_t index) {
- // cbi(_pinCS, _bitmaskCS);
cbi(_pinDC, _bitmaskDC);
-
writeBus(index);
- // sbi(_pinCS, _bitmaskCS);
}
void DmTftIli9341::send8BitData(uint8_t data) {
- //cbi(_pinCS, _bitmaskCS);
sbi(_pinDC, _bitmaskDC);
writeBus(data);
- //sbi(_pinCS, _bitmaskCS);
}
void DmTftIli9341::sendData(uint16_t data) {
uint8_t dh = data>>8;
uint8_t dl = data&0xff;
- //cbi(_pinCS, _bitmaskCS);
sbi(_pinDC, _bitmaskDC);
writeBus(dh);
writeBus(dl);
- //sbi(_pinCS, _bitmaskCS);
}
void DmTftIli9341::setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
@@ -104,13 +94,12 @@
SPI.setDataMode(SPI_MODE0);
_spiSettings = SPCR;
#elif defined (DM_TOOLCHAIN_MBED)
- _pinCS = new DigitalOut((PinName)_cs);
- _pinDC = new DigitalOut((PinName)_dc);
+ _pinCS = new DigitalOut(_cs);
+ _pinDC = new DigitalOut(_dc);
sbi(_pinCS, _bitmaskCS);
-
- _spi = new SPI((PinName)_mosi, (PinName)_miso, (PinName)_clk);
- _spi->format(8,0);
- _spi->frequency(8000000); // Max SPI speed for display is 10 and for 17 for LPC15xx
+
+ spi.format(8,0);
+ spi.frequency(8000000); // Max SPI speed for display is 10 and for 17 for LPC15xx
#endif
cbi(_pinCS, _bitmaskCS);
delay(135); // This much delay needed??
--- a/DmTftIli9341.h Fri Sep 18 14:59:13 2015 +0000 +++ b/DmTftIli9341.h Mon Oct 12 08:35:35 2015 +0000 @@ -21,7 +21,7 @@ #if defined (DM_TOOLCHAIN_ARDUINO) DmTftIli9341(uint8_t cs, uint8_t dc); #elif defined (DM_TOOLCHAIN_MBED) - DmTftIli9341(uint8_t cs=D10, uint8_t dc=D9, uint8_t miso=D12, uint8_t mosi=D11, uint8_t clk=D13); + DmTftIli9341(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk); #endif virtual ~DmTftIli9341(); virtual void init(void); @@ -33,17 +33,18 @@ virtual void sendCommand(uint8_t index); virtual void sendData(uint16_t data); - uint8_t _cs, _dc; + static const uint16_t _width; static const uint16_t _height; #if defined (DM_TOOLCHAIN_ARDUINO) + uint8_t _cs, _dc; regtype *_pinDC; regsize _bitmaskDC; uint8_t _spiSettings; #elif defined (DM_TOOLCHAIN_MBED) - uint8_t _miso, _mosi, _clk; + PinName _cs, _dc; DigitalOut *_pinDC; - SPI *_spi; + SPI spi; #endif };
--- a/DmTftRa8875.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftRa8875.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -13,23 +13,21 @@
/* Notice:
The panel resolution should be config in DmTftRa8875::init() function.
RA8875Size size = RA8875_480x272 or RA8875Size size = RA8875_800x480;
+
+ Tested on NUCLEO-F401RE, LPCXpresso11U68, LPCXpresso824-MAX platform.
*/
#include "DmTftRa8875.h"
#if defined (DM_TOOLCHAIN_ARDUINO)
DmTftRa8875::DmTftRa8875(uint8_t cs, uint8_t sel)
+: DmTftBase(480, 272)
#elif defined (DM_TOOLCHAIN_MBED)
-DmTftRa8875::DmTftRa8875(uint8_t cs, uint8_t sel, uint8_t miso, uint8_t mosi, uint8_t clk)
+DmTftRa8875::DmTftRa8875(PinName cs, PinName sel, PinName mosi, PinName miso, PinName clk)
+: DmTftBase(480, 272), spi(mosi, miso, clk)
#endif
- : DmTftBase(480, 272)
{
_cs = cs;
_sel = sel;
-#if defined (DM_TOOLCHAIN_MBED)
- _miso = miso;
- _mosi = mosi;
- _clk = clk;
-#endif
}
DmTftRa8875::~DmTftRa8875()
@@ -37,11 +35,9 @@
#if defined (DM_TOOLCHAIN_MBED)
delete _pinCS;
delete _pinSEL;
- delete _spi;
_pinCS = NULL;
_pinSEL = NULL;
- _spi = NULL;
#endif
}
@@ -62,7 +58,7 @@
SPDR = data; // SPI Data Register
while(!(SPSR & _BV(SPIF))); // SPI Status Register Wait for transmission to finish
#elif defined (DM_TOOLCHAIN_MBED)
- _spi->write(data);
+ spi.write(data);
#endif
}
@@ -74,7 +70,7 @@
while(!(SPSR & _BV(SPIF))); // SPI Status Register Wait for transmission to finish
return SPDR;
#elif defined (DM_TOOLCHAIN_MBED)
- return _spi->write(0x00); // dummy byte to read
+ return spi.write(0x00); // dummy byte to read
#endif
}
@@ -185,7 +181,7 @@
void DmTftRa8875::init(void)
{
// DM_TFT43_108 = RA8875_480x272; DM_TFT50_111 = RA8875_800x480
- RA8875Size size = RA8875_800x480;
+ RA8875Size size = RA8875_480x272;
setTextColor(BLACK, WHITE);
#if defined (DM_TOOLCHAIN_ARDUINO)
@@ -205,15 +201,26 @@
SPI.setDataMode(SPI_MODE0);
_spiSettings = SPCR;
#elif defined (DM_TOOLCHAIN_MBED)
- _pinCS = new DigitalOut((PinName)_cs);
- _pinSEL = new DigitalOut((PinName)_sel);
+ _pinCS = new DigitalOut(_cs);
+ _pinSEL = new DigitalOut(_sel);
sbi(_pinSEL, _bitmaskSEL); // w25 control by MCU
sbi(_pinCS, _bitmaskCS);
- _spi = new SPI((PinName)_mosi, (PinName)_miso, (PinName)_clk);
- _spi->format(8,3);
- _spi->frequency(2000000); // Max SPI speed for display is 10 and for 17 for LPC15xx
+
+#ifdef TARGET_LPC824 // for LPCXpresso824-MAX
+ spi.format(8,3);
+ spi.frequency(8000000);
+#elif TARGET_LPC11U6X // for LPCXpresso11U68
+ spi.format(8,3);
+ spi.frequency(2000000);
+#elif TARGET_NUCLEO_F401RE // for NUCLEO-F401RE
+ spi.format(8,0);
+ spi.frequency(8000000);
+#else
+ spi.format(8,3);
+ spi.frequency(2000000); // Max SPI speed for display is 10 and for 17 for LPC15xx
+#endif
softReset();
#endif
--- a/DmTftRa8875.h Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftRa8875.h Mon Oct 12 08:35:35 2015 +0000
@@ -26,7 +26,7 @@
#if defined (DM_TOOLCHAIN_ARDUINO)
DmTftRa8875(uint8_t cs=D10, uint8_t sel=D9);
#elif defined (DM_TOOLCHAIN_MBED)
- DmTftRa8875(uint8_t cs=D10, uint8_t sel=D9, uint8_t miso=D12, uint8_t mosi=D11, uint8_t clk=D13);
+ DmTftRa8875(PinName cs, PinName sel, PinName mosi, PinName miso, PinName clk);
#endif
virtual ~DmTftRa8875();
virtual void init();
@@ -99,15 +99,16 @@
uint16_t _fgColor;
enum RA8875Size _size;
+
+#if defined (DM_TOOLCHAIN_ARDUINO)
uint8_t _cs, _sel;
-#if defined (DM_TOOLCHAIN_ARDUINO)
regtype *_pinSEL;
regsize _bitmaskSEL;
uint8_t _spiSettings;
#elif defined (DM_TOOLCHAIN_MBED)
- uint8_t _miso, _mosi, _clk;
+ PinName _cs, _sel;
DigitalOut *_pinSEL;
- SPI *_spi;
+ SPI spi;
#endif
};
--- a/DmTftS6D0164.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftS6D0164.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -10,9 +10,16 @@
NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
********************************************************************************************/
+ //Tested on NUCLEO-F401RE, LPCXpresso11U68 platform.
+
#include "DmTftS6D0164.h"
-DmTftS6D0164::DmTftS6D0164(uint8_t wr, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(176, 220) {
+#if defined (DM_TOOLCHAIN_ARDUINO)
+DmTftS6D0164::DmTftS6D0164(uint8_t wr, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(176, 220)
+#elif defined (DM_TOOLCHAIN_MBED)
+DmTftS6D0164::DmTftS6D0164(PinName wr, PinName cs, PinName dc, PinName rst) : DmTftBase(176, 220)
+#endif
+{
_wr = wr;
_cs = cs;
_dc = dc;
@@ -110,10 +117,10 @@
pinMode(_wr, OUTPUT);
pinMode(_dc,OUTPUT);
#elif defined (DM_TOOLCHAIN_MBED)
- _pinRST = new DigitalOut((PinName)_rst);
- _pinCS = new DigitalOut((PinName)_cs);
- _pinWR = new DigitalOut((PinName)_wr);
- _pinDC = new DigitalOut((PinName)_dc);
+ _pinRST = new DigitalOut(_rst);
+ _pinCS = new DigitalOut(_cs);
+ _pinWR = new DigitalOut(_wr);
+ _pinDC = new DigitalOut(_dc);
_virtualPortD = new BusOut(D0, D1, D2, D3, D4, SPECIAL_D5, D6, D7);
#endif
--- a/DmTftS6D0164.h Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftS6D0164.h Mon Oct 12 08:35:35 2015 +0000
@@ -18,7 +18,11 @@
class DmTftS6D0164 : public DmTftBase
{
public:
+#if defined (DM_TOOLCHAIN_ARDUINO)
DmTftS6D0164(uint8_t wr=A4, uint8_t cs=A3, uint8_t dc=A5, uint8_t rst=A2);
+#elif defined (DM_TOOLCHAIN_MBED)
+ DmTftS6D0164(PinName wr=A4, PinName cs=A3, PinName dc=A5, PinName rst=A2);
+#endif
virtual ~DmTftS6D0164();
virtual void init(void);
private:
@@ -29,13 +33,14 @@
virtual void sendCommand(uint8_t index);
virtual void sendData(uint16_t data);
- uint8_t _wr, _cs, _dc, _rst;
static const uint16_t _width;
static const uint16_t _height;
#if defined (DM_TOOLCHAIN_ARDUINO)
+ uint8_t _wr, _cs, _dc, _rst;
regtype *_pinDC, *_pinRST, *_pinWR;
regsize _bitmaskDC, _bitmaskRST, _bitmaskWR;
#elif defined (DM_TOOLCHAIN_MBED)
+ PinName _wr, _cs, _dc, _rst;
DigitalOut* _pinDC, *_pinRST, *_pinWR;
BusOut *_virtualPortD;
#endif
--- a/DmTftSsd2119.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTftSsd2119.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -10,31 +10,28 @@
NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
********************************************************************************************/
+//Tested on NUCLEO-F401RE, LPCXpresso11U68, LPCXpresso824-MAX platform.
+
#include "DmTftSsd2119.h"
#if defined (DM_TOOLCHAIN_ARDUINO)
DmTftSsd2119::DmTftSsd2119(uint8_t cs, uint8_t dc)
+:DmTftBase(320, 240)
#elif defined (DM_TOOLCHAIN_MBED)
-DmTftSsd2119::DmTftSsd2119(uint8_t cs, uint8_t dc, uint8_t miso, uint8_t mosi, uint8_t clk)
+DmTftSsd2119::DmTftSsd2119(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk)
+:DmTftBase(320, 240), spi(mosi, miso, clk)
#endif
-: DmTftBase(320, 240){ // Display is in landscape mode by default width: 320, height: 240
+{
_cs = cs;
_dc = dc;
-#if defined (DM_TOOLCHAIN_MBED)
- _miso = miso;
- _mosi = mosi;
- _clk = clk;
-#endif
}
DmTftSsd2119::~DmTftSsd2119() {
#if defined (DM_TOOLCHAIN_MBED)
delete _pinCS;
delete _pinDC;
-delete _spi;
_pinCS = NULL;
_pinDC = NULL;
-_spi = NULL;
#endif
}
@@ -44,13 +41,12 @@
SPDR = data; // SPI Data Register
while(!(SPSR & _BV(SPIF))); // SPI Status Register Wait for transmission to finish
#elif defined (DM_TOOLCHAIN_MBED)
- _spi->write(data);
+ spi.write(data);
#endif
}
void DmTftSsd2119::sendCommand(uint8_t index) {
cbi(_pinDC, _bitmaskDC);
-
writeBus(0x00);
writeBus(index);
}
@@ -127,13 +123,12 @@
SPI.setDataMode(SPI_MODE0);
_spiSettings = SPCR;
#elif defined (DM_TOOLCHAIN_MBED)
- _pinCS = new DigitalOut((PinName)_cs);
- _pinDC = new DigitalOut((PinName)_dc);
+ _pinCS = new DigitalOut(_cs);
+ _pinDC = new DigitalOut(_dc);
sbi(_pinCS, _bitmaskCS);
- _spi = new SPI((PinName)_mosi, (PinName)_miso, (PinName)_clk);
- _spi->format(8,0);
- _spi->frequency(8000000); // Max SPI speed for display is 10 and for 17 for LPC15xx
+ spi.format(8,0);
+ spi.frequency(6000000);
#endif
cbi(_pinCS, _bitmaskCS);
delay(135); // This much delay needed??
@@ -196,8 +191,8 @@
sendCommand(0x27); // Analog setting
sendData(0x0078);
-// sendCommand(0x12); // Sleep mode
-// sendData(0xD999);
+//sendCommand(0x12); // Sleep mode
+//sendData(0xD999);
// SET WINDOW
sendCommand(0x4E); // Ram Address Set
--- a/DmTftSsd2119.h Fri Sep 18 14:59:13 2015 +0000 +++ b/DmTftSsd2119.h Mon Oct 12 08:35:35 2015 +0000 @@ -21,7 +21,7 @@ #if defined (DM_TOOLCHAIN_ARDUINO) DmTftSsd2119(uint8_t cs, uint8_t dc); #elif defined (DM_TOOLCHAIN_MBED) - DmTftSsd2119(uint8_t cs=D10, uint8_t dc=D9, uint8_t miso=D12, uint8_t mosi=D11, uint8_t clk=D13); + DmTftSsd2119(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk); #endif virtual ~DmTftSsd2119(); virtual void init(void); @@ -36,17 +36,18 @@ virtual void sendCommand(uint8_t index); - uint8_t _cs, _dc; + static const uint16_t _width; static const uint16_t _height; #if defined (DM_TOOLCHAIN_ARDUINO) + uint8_t _cs, _dc; regtype *_pinDC; regsize _bitmaskDC; uint8_t _spiSettings; #elif defined (DM_TOOLCHAIN_MBED) - uint8_t _miso, _mosi, _clk; + PinName _cs, _dc; DigitalOut *_pinDC; - SPI *_spi; + SPI spi; #endif };
--- a/DmTouch.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTouch.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -9,7 +9,7 @@
THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
********************************************************************************************/
-// Tested with Xpt2046
+// Tested with Xpt2046 and RA8875
#include "DmTouch.h"
#include "DmTouchCalibration.h"
@@ -21,11 +21,10 @@
// spiMode - How to read SPI-data, Software, Hardware or Auto
// useIrq - Enable IRQ or disable IRQ
DmTouch::DmTouch(Display disp, SpiMode spiMode, bool useIrq)
-
#elif defined (DM_TOOLCHAIN_MBED)
// disp - which display is used
// spiMode - How to read SPI-data, Software, Hardware or Auto
-DmTouch::DmTouch(Display disp, SpiMode spiMode)
+DmTouch::DmTouch(Display disp, PinName mosi, PinName miso, PinName clk)
#endif
{
_disp = disp;
@@ -104,22 +103,6 @@
_touch_id = IC_2046;
break;
}
-
- if (spiMode == DmTouch::Hardware) {
- _hardwareSpi = true;
- } else if (spiMode == DmTouch::Software) {
- _hardwareSpi = false;
- }
-
-#if defined(DM_TOOLCHAIN_ARDUINO)
- if (!useIrq) {
- _irq = -1;
- }
-#elif defined (DM_TOOLCHAIN_MBED)
- if(_touch_id != IC_8875) {
- _irq = -1;
- }
-#endif
setCalibrationMatrix(DmTouchCalibration::getDefaultCalibrationData(disp));
@@ -151,22 +134,21 @@
_bitmaskMISO = digitalPinToBitMask(_miso);
}
#elif defined (DM_TOOLCHAIN_MBED)
- _pinCS = new DigitalOut((PinName)_cs);
+ _pinCS = new DigitalOut(_cs);
if (_hardwareSpi) {
sbi(_pinCS, _bitmaskCS);
_spi = new SPI((PinName)_mosi, (PinName)_miso, (PinName)_clk);
_spi->format(8,0);
- _spi->frequency(2000000); // Max SPI speed
- //cbi(_pinCS, _bitmaskCS);
+ _spi->frequency(2000000); // Max SPI speed
} else {
- _pinCLK = new DigitalOut((PinName)_clk);
- _pinMISO = new DigitalIn((PinName)_miso);
- _pinMOSI = new DigitalOut((PinName)_mosi);
+ _pinCLK = new DigitalOut(_clk);
+ _pinMISO = new DigitalIn(_miso);
+ _pinMOSI = new DigitalOut(_mosi);
sbi(_pinCLK, _bitmaskCLK);
}
#endif
- if (_irq != -1) { // We will use Touch IRQ
+ if (_irq != NC) { // We will use Touch IRQ
enableIrq();
}
}
@@ -240,6 +222,11 @@
spiWrite(0x04);
sbi(_pinCS, _bitmaskCS);
}
+ else{
+ cbi(_pinCS, _bitmaskCS);
+ spiWrite(0x80); // Enable PENIRQ
+ sbi(_pinCS, _bitmaskCS);
+ }
}
void DmTouch::spiWrite(uint8_t data) {
--- a/DmTouch.h Fri Sep 18 14:59:13 2015 +0000 +++ b/DmTouch.h Mon Oct 12 08:35:35 2015 +0000 @@ -45,7 +45,7 @@ #if defined (DM_TOOLCHAIN_ARDUINO) DmTouch(Display disp, SpiMode spiMode=Auto, bool useIrq=true); #elif defined (DM_TOOLCHAIN_MBED) - DmTouch(Display disp, SpiMode spiMode=Hardware); + DmTouch(Display disp, PinName mosi=D11, PinName miso=D12, PinName clk=D13); #endif void init(); void readTouchData(uint16_t& posX, uint16_t& posY, bool& touching); @@ -75,15 +75,15 @@ bool _hardwareSpi; uint8_t _samplesPerMeasurement; CalibrationMatrix _calibrationMatrix; - uint8_t _cs, _clk, _mosi, _miso; - int8_t _irq; uint16_t _touch_id; #if defined (DM_TOOLCHAIN_ARDUINO) + uint8_t _cs, _clk, _mosi, _miso,_irq;; regtype *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_pinMISO, *_pinIrq; regsize _bitmaskDC, _bitmaskCS, _bitmaskCLK, _bitmaskMOSI, _bitmaskMISO, _bitmaskIrq; uint8_t _spiSettings; #elif defined (DM_TOOLCHAIN_MBED) + PinName _cs, _clk, _mosi, _miso, _irq; DigitalOut *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_led; DigitalIn *_pinMISO, *_pinIrq; SPI *_spi;
--- a/DmTpFt6x06.cpp Fri Sep 18 14:59:13 2015 +0000
+++ b/DmTpFt6x06.cpp Mon Oct 12 08:35:35 2015 +0000
@@ -36,7 +36,7 @@
}
if (!useIrq) {
- _irq = -1;
+ _irq = NC;
}
#if defined (DM_TOOLCHAIN_MBED)
_i2c = &i2c;
@@ -213,4 +213,3 @@
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
-
--- a/DmTpFt6x06.h Fri Sep 18 14:59:13 2015 +0000 +++ b/DmTpFt6x06.h Mon Oct 12 08:35:35 2015 +0000 @@ -62,15 +62,15 @@ uint8_t readRegister8(uint8_t reg); void writeRegister8(uint8_t reg, uint8_t val); void enableIrq(); +#if defined (DM_TOOLCHAIN_ARDUINO) int8_t _irq; -#if defined (DM_TOOLCHAIN_ARDUINO) regtype *_pinIrq; regsize _bitmaskIrq; #elif defined (DM_TOOLCHAIN_MBED) + PinName _irq; long map(long x, long in_min, long in_max, long out_min, long out_max); DigitalIn *_pinIrq; I2C *_i2c; #endif }; #endif -
DisplayModule 1.8" TFT with SPI Interface
DisplayModule 2.2" TFT with 8-bit interface
DisplayModule 2.8" 240x320 Touch TFT with 8-bit Interface
DisplayModule 2.4" 240x320 Touch TFT with 8-bit Interface
DisplayModule 2.8" 240x320 TFT LCD With Resistive Touch - SPI, 4MB Flash
DisplayModule 3.5" 320x240 TFT LCD With Resistive Touch - SPI, 4MB Flash
DisplayModule 4.3" 480x272 Arduino TFT Shield With Touch And SPI Interface
DisplayModule 5.0" 800x480 Arduino TFT Shield With Touch And SPI Interface
DisplayModule 2.8" 240x320 TFT With Capacitive Touch