Driver Library for our displays

Dependents:   dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more

Revision:
14:2db7065edbec
Parent:
7:6cd8c36cbdb3
--- 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