Fork of Silabs MemoryLCD library

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LS013B7DH03.h Source File

LS013B7DH03.h

Go to the documentation of this file.
00001 /***************************************************************************//**
00002  * @file LS013B7DH03.h
00003  * @brief Driver class for the Sharp LS013B7DH03 memory LCD on some kits.
00004  *******************************************************************************
00005  * @section License
00006  * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
00007  *******************************************************************************
00008  *
00009  * Permission is granted to anyone to use this software for any purpose,
00010  * including commercial applications, and to alter it and redistribute it
00011  * freely, subject to the following restrictions:
00012  *
00013  * 1. The origin of this software must not be misrepresented; you must not
00014  *    claim that you wrote the original software.
00015  * 2. Altered source versions must be plainly marked as such, and must not be
00016  *    misrepresented as being the original software.
00017  * 3. This notice may not be removed or altered from any source distribution.
00018  *
00019  * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
00020  * obligation to support this Software. Silicon Labs is providing the
00021  * Software "AS IS", with no express or implied warranties of any kind,
00022  * including, but not limited to, any implied warranties of merchantability
00023  * or fitness for any particular purpose or warranties against infringement
00024  * of any proprietary rights of a third party.
00025  *
00026  * Silicon Labs will not be liable for any consequential, incidental, or
00027  * special damages, or any other relief, or for any claim by any third party,
00028  * arising from your use of this Software.
00029  *
00030  ******************************************************************************/
00031 
00032 #ifndef SILABS_LS013B7DH03_H
00033 #define SILABS_LS013B7DH03_H
00034 
00035 #include "platform.h"
00036 #include <mbed.h>
00037 #include "../screen/BufferedDisplay.h"
00038 #include "../screen/LCDSettings.h"
00039 //#include "Peripherals.h"
00040 
00041 typedef void (*cbptr_t)(void);
00042 
00043 #define LS013B7DH03_ERROR_BUSY      -1
00044 #define LS013B7DH03_ERROR_SPI_BUSY  -2
00045 #define LS013B7DH03_NO_ACTION       -3
00046 #define LS013B7DH03_ERROR_ARGUMENT  -4
00047 #define LS013B7DH03_OK              0
00048 
00049 typedef enum {
00050     IDLE,           // No operation currently ongoing
00051     CLEARING,       // In the process of clearing the display
00052     WRITING,        // In the process of sending a display update
00053     WAIT_CLEAR,     // Going to clear after CS pin timeout
00054     WAIT_WRITE,     // Going to write after CS pin timeout
00055     TRANSFERS_DONE, // Last transfer in progress
00056     DONE            // Done with transmission, waiting for CS pin to become high
00057 } LS013B7DH03_state_t;
00058 
00059 namespace silabs {
00060 class LS013B7DH03 : public BufferedDisplay {
00061 
00062 public:
00063 
00064     LS013B7DH03(SPI * spi, DigitalOut * CS,  const char *name=NULL);
00065 
00066     /**
00067      * Call this function to push all changes to the display
00068      */
00069     int update( cbptr_t callback = NULL );
00070 
00071     /**
00072      * Immediately clear the display: set pixel buffer to zero and clear out the display.
00073      */
00074     int clearImmediate( cbptr_t callback = NULL );
00075 
00076     /**
00077      * Function to test display buffer
00078      */
00079     int showDemo();
00080 
00081 
00082 
00083     /**
00084      * Function to get internal refresh counter
00085      */
00086     uint32_t getRefreshTicks();
00087 
00088 
00089 protected:
00090     mbed::SPI *_spi;
00091     //mbed::DigitalOut *_EXTCOM;
00092     mbed::DigitalOut *_CS;
00093 
00094     mbed::Ticker _displayToggler;
00095     mbed::Timeout _csTimeout;
00096 
00097     event_callback_t _internalEventCallback;
00098     volatile uint32_t _refreshCount;
00099     uint8_t _lcdPolarity;
00100     LS013B7DH03_state_t _state;
00101     cbptr_t _completionCallbackPtr;
00102     volatile uint32_t _rowCount;
00103     uint8_t _cmd[2 + (DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE))];
00104 
00105     /**
00106      * Callback handler for internal SPI transfers.
00107      */
00108     void _cbHandler( int event );
00109 
00110     /**
00111      * Callback handler for internal SPI transfers triggered by timeout.
00112      */
00113     void _cbHandlerTimeout( void );
00114 
00115     /**
00116      * Call this function at 55 ~ 65 Hz to keep the display from losing contrast.
00117      */
00118     void toggle();
00119 };
00120 
00121 } // namespace silabs
00122 
00123 #endif //SILABS_LS013B7DH03_H