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 2:2f10f00fe56c, committed 2015-04-14
- Comitter:
- Steven Cooreman
- Date:
- Tue Apr 14 15:25:58 2015 -0400
- Parent:
- 1:6332f3383fb6
- Child:
- 3:c34c3e4e33fc
- Commit message:
- Move to event_callback_t for xfer callbacks
Changed in this revision
| LS013B7DH03.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LS013B7DH03.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/LS013B7DH03.cpp Wed Mar 18 10:58:34 2015 -0500
+++ b/LS013B7DH03.cpp Tue Apr 14 15:25:58 2015 -0400
@@ -53,7 +53,7 @@
//Save pointer to spi peripheral
_spi = spi;
- _internalCallback.attach(this, &LS013B7DH03::_cbHandler);
+ _internalEventCallback.attach(this, &LS013B7DH03::_cbHandler);
//Initialize
_spi->set_dma_usage((DMAUsage)DMA_USAGE_NEVER);
@@ -64,7 +64,7 @@
_rowCount = 0;
//Start toggling the EXTCOM pin
- _displayToggler.attach(this, &LS013B7DH03::toggle, 0.008f);
+ //_displayToggler.attach(this, &LS013B7DH03::toggle, 0.008f);
}
/**
@@ -168,7 +168,7 @@
_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, &_internalCallback) != 0) {
+ 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) {
// SPI is busy, with another transaction. This means the data to the LCD has been corrupted, so fail here.
_state = DONE;
@@ -189,7 +189,7 @@
// Done sending!
_cmd[1] = 0xFF;
_state = TRANSFERS_DONE;
- if(_spi->transfer((uint8_t*)_cmd, 2, (uint8_t*)NULL, 0, &_internalCallback) != 0) {
+ if(_spi->transfer((uint8_t*)_cmd, 2, (uint8_t*)NULL, 0, _internalEventCallback, SPI_EVENT_COMPLETE) != 0) {
// SPI is busy, with another transaction. This means the data to the LCD has been corrupted, so fail here.
_state = DONE;
@@ -201,7 +201,7 @@
else if (_state == WAIT_CLEAR)
{
_state = TRANSFERS_DONE;
- if(_spi->transfer((uint8_t*)_cmd, 2, (uint8_t*)NULL, 0, &_internalCallback) != 0) {
+ if(_spi->transfer((uint8_t*)_cmd, 2, (uint8_t*)NULL, 0, _internalEventCallback, SPI_EVENT_COMPLETE) != 0) {
// SPI is busy, with another transaction. This means the data to the LCD has been corrupted, so fail here.
_state = DONE;
--- a/LS013B7DH03.h Wed Mar 18 10:58:34 2015 -0500
+++ b/LS013B7DH03.h Tue Apr 14 15:25:58 2015 -0400
@@ -57,91 +57,29 @@
} LS013B7DH03_state_t;
namespace silabs {
-/** A driver for the Sharp LS013B7DH03 Memory LCD, present on some EFM32 Starter Kits.
- *
- * Currently supports LS013B7DH03 only, but should be easily modifiable.
- *
- * @code
- * #include "mbed.h"
- * #include "LS013B7DH03.h"
- * #include "mbed_logo.h"
- *
- * #define SCK PE12
- * #define MOSI PE10
- *
- * DigitalOut CS(PA10);
- * DigitalOut EXTCOM(PF3);
- * DigitalOut DISP(PA8);
- *
- * SPI displaySPI(MOSI, NC, SCK);
- * silabs::LS013B7DH03 display(&displaySPI, &CS, &EXTCOM);
- *
- * volatile bool completed = false;
- *
- * void completionCallback( void ) {
- * completed = true;
- * }
- *
- * int main() {
- * //Enable the LCD
- * DISP = 1;
- *
- * // Reset the LCD to a blank state. (All white)
- * completed = false;
- * display.clearImmediate(completionCallback);
- * while(completed == false) sleep();
- *
- * printf("Initialization done! \n");
- *
- * // Push update to the display
- * uint32_t refreshCount = display.getRefreshTicks();
- * completed = false;
- * display.update(completionCallback);
- *
- * // Sleep while doing the transmit
- * while(refreshed == false) sleep();
- *
- * // Calculate and print refresh duration
- * refreshCount = display.getRefreshTicks() - refreshCount;
- * printf("Refresh duration: %d cycles @ 125Hz \n", (int)refreshCount);
- *
- * // Sleep forever.
- * while(1) sleep();
- * }
- * @endcode
- */
class LS013B7DH03 : public BufferedDisplay {
+
public:
LS013B7DH03(SPI * spi, DigitalOut * CS, DigitalOut * ExtCom, const char *name=NULL);
/**
* Call this function to push all changes to the display
- *
- * @param callback void (void) type callback pointer to call on display update completion.
- * @return Status code
*/
int update( cbptr_t callback = NULL );
/**
* Immediately clear the display: set pixel buffer to zero and clear out the display.
- *
- * @param callback void (void) type callback pointer to call on display clear completion.
- * @return Status code
*/
int clearImmediate( cbptr_t callback = NULL );
/**
* Function to test display buffer
- *
- * @return Status code
*/
int showDemo();
/**
- * Function to get internal 128Hz refresh counter. Can be useful for performance measurement.
- *
- * @return Number of display toggle ticks since init
+ * Function to get internal refresh counter
*/
uint32_t getRefreshTicks();
@@ -153,7 +91,7 @@
mbed::LowPowerTicker _displayToggler;
mbed::LowPowerTimeout _csTimeout;
- mbed::CallbackPointer _internalCallback;
+ event_callback_t _internalEventCallback;
volatile uint32_t _refreshCount;
uint8_t _lcdPolarity;
LS013B7DH03_state_t _state;
@@ -172,7 +110,7 @@
void _cbHandlerTimeout( void );
/**
- * Call this function at 128 Hz to keep the display from losing contrast.
+ * Call this function at 55 ~ 65 Hz to keep the display from losing contrast.
*/
void toggle();
};