Fork of Silabs MemoryLCD library

Dependents:   demoUI whrmDemoUI Host_Software_MAX32664GWEB_HR_EXTENDED Host_Software_MAX32664GWEC_SpO2_HR-_EXTE ... more

C++ library for Sharp Microelectronics 1.28 inch LCD TFT, LS013B7DH03, SPI bus. Forked from Silicon Labs MemoryLCD display driver.

Revision:
12:ca0bcb4777e9
Parent:
2:2f10f00fe56c
--- a/LS013B7DH03.cpp	Wed Aug 12 14:06:07 2015 +0000
+++ b/LS013B7DH03.cpp	Wed Jan 02 13:20:35 2019 +0300
@@ -29,9 +29,11 @@
  *
  ******************************************************************************/
 
+#include "../screen/LS013B7DH03.h"
+
 #include <mbed.h>
-#include "LS013B7DH03.h"
 #include "SPI.h"
+//#include "Peripherals.h"
 
 /* LS013B7DH03 SPI commands */
 #define LS013B7DH03_CMD_UPDATE     (0x01)
@@ -42,21 +44,30 @@
 
 namespace silabs {
 
-LS013B7DH03::LS013B7DH03(mbed::SPI * spi, DigitalOut * CS, DigitalOut * ExtCom, const char *name) : BufferedDisplay(name) {
+
+LS013B7DH03::LS013B7DH03(mbed::SPI * spi, DigitalOut * CS, const char *name) : BufferedDisplay( name )  {
 	//Save pointer to ChipSelect pin
 	_CS = CS;
 	_CS->write(0);
+	DigitalOut DISP(P6_6);
 
-	//Save pointer to ExtCom pin
-	_EXTCOM = ExtCom;
-	_EXTCOM->write(0);
+//Save pointer to ExtCom pin
+///	_EXTCOM = ExtCom;
+///	_EXTCOM->write(0);
+
+	DISP  = 0;
+	wait_ms(1);
+	DISP = 1;
 
 	//Save pointer to spi peripheral
 	_spi = spi;
+	//_spi->frequency(600000);
+	_spi->format( 8, 0 );
+
 	_internalEventCallback.attach(this, &LS013B7DH03::_cbHandler);
 
 	//Initialize
-	_spi->set_dma_usage((DMAUsage)DMA_USAGE_NEVER);
+	//_spi->set_dma_usage((DMAUsage)DMA_USAGE_NEVER);
 	_refreshCount = 0;
 	_lcdPolarity = 0;
 	_state = IDLE;
@@ -71,8 +82,8 @@
  * Call this function at 55 ~ 65 Hz to keep the display up-to-date.
  */
 void LS013B7DH03::toggle() {
-	_EXTCOM->write(!_EXTCOM->read());
-	_refreshCount++;
+//	_EXTCOM->write(!_EXTCOM->read());
+//	_refreshCount++;
 }
 
 /**
@@ -121,9 +132,9 @@
  */
 int LS013B7DH03::showDemo() {
 	for(uint32_t i = 0; i < DISPLAY_BUFFER_ELEMENTS; i+=2) {
-		_pixelBuffer[i] = 0x00FFF000;
+		_pixelBuffer[i] = 0x00555345;
 	}
-	memset((void*)_dirtyRows, 0xFF, sizeof(_dirtyRows));
+	memset((void*)_dirtyRows, 0x33, sizeof(_dirtyRows));
 
 	return LS013B7DH03_OK;
 }
@@ -168,12 +179,14 @@
 				_cmd[1] = (uint8_t)SWAP8(_rowCount + 1);
 				memcpy((void*)&(_cmd[2]), (const void*)&(_pixelBuffer[_rowCount*(DISPLAY_WIDTH/DISPLAY_BUFFER_TYPE_SIZE)]), DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE));
 
-				if(_spi->transfer((uint8_t*)_cmd, (2 + (DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE))) , (uint8_t*)NULL, 0, _internalEventCallback, SPI_EVENT_COMPLETE) != 0) {
+				if(_spi->write((const char*)_cmd, (2 + (DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE))) , (char*)NULL, 0/*, _internalEventCallback, SPI_EVENT_COMPLETE*/) != (2 + (DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE)))) {
 					// SPI is busy, with another transaction. This means the data to the LCD has been corrupted, so fail here.
 					_state = DONE;
-
+					//printf("Failed at _cbHandler\n");
 					// Make sure the handler is called again
 					_csTimeout.attach(this, &LS013B7DH03::_cbHandlerTimeout, 0.1f);
+				}else{	//sc...
+					_csTimeout.attach(this, &LS013B7DH03::_cbHandlerTimeout, 0.001f);
 				}
 
 				// Transaction is in progress, so update row state
@@ -189,24 +202,28 @@
 		// Done sending!
 		_cmd[1] = 0xFF;
 		_state = TRANSFERS_DONE;
-		if(_spi->transfer((uint8_t*)_cmd, 2, (uint8_t*)NULL, 0, _internalEventCallback, SPI_EVENT_COMPLETE) != 0) {
+		if(_spi->write((const char*)_cmd, 2, (char*)NULL, 0/*, _internalEventCallback, SPI_EVENT_COMPLETE*/) != 2) {
 			// SPI is busy, with another transaction. This means the data to the LCD has been corrupted, so fail here.
 			_state = DONE;
 
 			// Make sure the handler is called again
 			_csTimeout.attach(this, &LS013B7DH03::_cbHandlerTimeout, 0.1f);
+		}else{	//sc...
+			_csTimeout.attach(this, &LS013B7DH03::_cbHandlerTimeout, 0.001f);
 		}
 		return;
 	}
 	else if (_state == WAIT_CLEAR)
 	{
 		_state = TRANSFERS_DONE;
-		if(_spi->transfer((uint8_t*)_cmd, 2, (uint8_t*)NULL, 0, _internalEventCallback, SPI_EVENT_COMPLETE) != 0) {
+		if(_spi->write((const char*)_cmd, 2, (char*)NULL, 0/*, _internalEventCallback, SPI_EVENT_COMPLETE*/) != 2) {
 			// SPI is busy, with another transaction. This means the data to the LCD has been corrupted, so fail here.
 			_state = DONE;
 
 			// Make sure the handler is called again
 			_csTimeout.attach(this, &LS013B7DH03::_cbHandlerTimeout, 0.1f);
+		}else{	//sc...
+			_csTimeout.attach(this, &LS013B7DH03::_cbHandlerTimeout, 0.001f);
 		}
 		return;
 	}