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.
LS013B7DH03.h@12:ca0bcb4777e9, 2019-01-02 (annotated)
- Committer:
- gmehmet
- Date:
- Wed Jan 02 13:20:35 2019 +0300
- Revision:
- 12:ca0bcb4777e9
- Parent:
- 3:c34c3e4e33fc
adapt memorylcd code to use it with maxim boards
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Steven Cooreman |
0:a0faa86660d4 | 1 | /***************************************************************************//** |
Steven Cooreman |
0:a0faa86660d4 | 2 | * @file LS013B7DH03.h |
Steven Cooreman |
0:a0faa86660d4 | 3 | * @brief Driver class for the Sharp LS013B7DH03 memory LCD on some kits. |
Steven Cooreman |
0:a0faa86660d4 | 4 | ******************************************************************************* |
Steven Cooreman |
0:a0faa86660d4 | 5 | * @section License |
Steven Cooreman |
0:a0faa86660d4 | 6 | * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> |
Steven Cooreman |
0:a0faa86660d4 | 7 | ******************************************************************************* |
Steven Cooreman |
0:a0faa86660d4 | 8 | * |
Steven Cooreman |
0:a0faa86660d4 | 9 | * Permission is granted to anyone to use this software for any purpose, |
Steven Cooreman |
0:a0faa86660d4 | 10 | * including commercial applications, and to alter it and redistribute it |
Steven Cooreman |
0:a0faa86660d4 | 11 | * freely, subject to the following restrictions: |
Steven Cooreman |
0:a0faa86660d4 | 12 | * |
Steven Cooreman |
0:a0faa86660d4 | 13 | * 1. The origin of this software must not be misrepresented; you must not |
Steven Cooreman |
0:a0faa86660d4 | 14 | * claim that you wrote the original software. |
Steven Cooreman |
0:a0faa86660d4 | 15 | * 2. Altered source versions must be plainly marked as such, and must not be |
Steven Cooreman |
0:a0faa86660d4 | 16 | * misrepresented as being the original software. |
Steven Cooreman |
0:a0faa86660d4 | 17 | * 3. This notice may not be removed or altered from any source distribution. |
Steven Cooreman |
0:a0faa86660d4 | 18 | * |
Steven Cooreman |
0:a0faa86660d4 | 19 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
Steven Cooreman |
0:a0faa86660d4 | 20 | * obligation to support this Software. Silicon Labs is providing the |
Steven Cooreman |
0:a0faa86660d4 | 21 | * Software "AS IS", with no express or implied warranties of any kind, |
Steven Cooreman |
0:a0faa86660d4 | 22 | * including, but not limited to, any implied warranties of merchantability |
Steven Cooreman |
0:a0faa86660d4 | 23 | * or fitness for any particular purpose or warranties against infringement |
Steven Cooreman |
0:a0faa86660d4 | 24 | * of any proprietary rights of a third party. |
Steven Cooreman |
0:a0faa86660d4 | 25 | * |
Steven Cooreman |
0:a0faa86660d4 | 26 | * Silicon Labs will not be liable for any consequential, incidental, or |
Steven Cooreman |
0:a0faa86660d4 | 27 | * special damages, or any other relief, or for any claim by any third party, |
Steven Cooreman |
0:a0faa86660d4 | 28 | * arising from your use of this Software. |
Steven Cooreman |
0:a0faa86660d4 | 29 | * |
Steven Cooreman |
0:a0faa86660d4 | 30 | ******************************************************************************/ |
Steven Cooreman |
0:a0faa86660d4 | 31 | |
Steven Cooreman |
0:a0faa86660d4 | 32 | #ifndef SILABS_LS013B7DH03_H |
Steven Cooreman |
0:a0faa86660d4 | 33 | #define SILABS_LS013B7DH03_H |
Steven Cooreman |
0:a0faa86660d4 | 34 | |
Steven Cooreman |
0:a0faa86660d4 | 35 | #include "platform.h" |
Steven Cooreman |
0:a0faa86660d4 | 36 | #include <mbed.h> |
gmehmet | 12:ca0bcb4777e9 | 37 | #include "../screen/BufferedDisplay.h" |
gmehmet | 12:ca0bcb4777e9 | 38 | #include "../screen/LCDSettings.h" |
gmehmet | 12:ca0bcb4777e9 | 39 | //#include "Peripherals.h" |
Steven Cooreman |
0:a0faa86660d4 | 40 | |
Steven Cooreman |
0:a0faa86660d4 | 41 | typedef void (*cbptr_t)(void); |
Steven Cooreman |
0:a0faa86660d4 | 42 | |
Steven Cooreman |
0:a0faa86660d4 | 43 | #define LS013B7DH03_ERROR_BUSY -1 |
Steven Cooreman |
0:a0faa86660d4 | 44 | #define LS013B7DH03_ERROR_SPI_BUSY -2 |
Steven Cooreman |
0:a0faa86660d4 | 45 | #define LS013B7DH03_NO_ACTION -3 |
Steven Cooreman |
0:a0faa86660d4 | 46 | #define LS013B7DH03_ERROR_ARGUMENT -4 |
Steven Cooreman |
0:a0faa86660d4 | 47 | #define LS013B7DH03_OK 0 |
Steven Cooreman |
0:a0faa86660d4 | 48 | |
Steven Cooreman |
0:a0faa86660d4 | 49 | typedef enum { |
Steven Cooreman |
0:a0faa86660d4 | 50 | IDLE, // No operation currently ongoing |
Steven Cooreman |
0:a0faa86660d4 | 51 | CLEARING, // In the process of clearing the display |
Steven Cooreman |
0:a0faa86660d4 | 52 | WRITING, // In the process of sending a display update |
Steven Cooreman |
0:a0faa86660d4 | 53 | WAIT_CLEAR, // Going to clear after CS pin timeout |
Steven Cooreman |
0:a0faa86660d4 | 54 | WAIT_WRITE, // Going to write after CS pin timeout |
Steven Cooreman |
0:a0faa86660d4 | 55 | TRANSFERS_DONE, // Last transfer in progress |
Steven Cooreman |
0:a0faa86660d4 | 56 | DONE // Done with transmission, waiting for CS pin to become high |
Steven Cooreman |
0:a0faa86660d4 | 57 | } LS013B7DH03_state_t; |
Steven Cooreman |
0:a0faa86660d4 | 58 | |
Steven Cooreman |
0:a0faa86660d4 | 59 | namespace silabs { |
Steven Cooreman |
1:6332f3383fb6 | 60 | class LS013B7DH03 : public BufferedDisplay { |
Steven Cooreman |
2:2f10f00fe56c | 61 | |
Steven Cooreman |
0:a0faa86660d4 | 62 | public: |
Steven Cooreman |
0:a0faa86660d4 | 63 | |
gmehmet | 12:ca0bcb4777e9 | 64 | LS013B7DH03(SPI * spi, DigitalOut * CS, const char *name=NULL); |
Steven Cooreman |
0:a0faa86660d4 | 65 | |
Steven Cooreman |
0:a0faa86660d4 | 66 | /** |
Steven Cooreman |
0:a0faa86660d4 | 67 | * Call this function to push all changes to the display |
Steven Cooreman |
0:a0faa86660d4 | 68 | */ |
Steven Cooreman |
0:a0faa86660d4 | 69 | int update( cbptr_t callback = NULL ); |
Steven Cooreman |
0:a0faa86660d4 | 70 | |
Steven Cooreman |
0:a0faa86660d4 | 71 | /** |
Steven Cooreman |
0:a0faa86660d4 | 72 | * Immediately clear the display: set pixel buffer to zero and clear out the display. |
Steven Cooreman |
0:a0faa86660d4 | 73 | */ |
Steven Cooreman |
0:a0faa86660d4 | 74 | int clearImmediate( cbptr_t callback = NULL ); |
Steven Cooreman |
0:a0faa86660d4 | 75 | |
Steven Cooreman |
0:a0faa86660d4 | 76 | /** |
Steven Cooreman |
0:a0faa86660d4 | 77 | * Function to test display buffer |
Steven Cooreman |
0:a0faa86660d4 | 78 | */ |
Steven Cooreman |
0:a0faa86660d4 | 79 | int showDemo(); |
Steven Cooreman |
0:a0faa86660d4 | 80 | |
gmehmet | 12:ca0bcb4777e9 | 81 | |
gmehmet | 12:ca0bcb4777e9 | 82 | |
Steven Cooreman |
0:a0faa86660d4 | 83 | /** |
Steven Cooreman |
2:2f10f00fe56c | 84 | * Function to get internal refresh counter |
Steven Cooreman |
0:a0faa86660d4 | 85 | */ |
Steven Cooreman |
0:a0faa86660d4 | 86 | uint32_t getRefreshTicks(); |
Steven Cooreman |
0:a0faa86660d4 | 87 | |
gmehmet | 12:ca0bcb4777e9 | 88 | |
Steven Cooreman |
0:a0faa86660d4 | 89 | protected: |
Steven Cooreman |
0:a0faa86660d4 | 90 | mbed::SPI *_spi; |
gmehmet | 12:ca0bcb4777e9 | 91 | //mbed::DigitalOut *_EXTCOM; |
Steven Cooreman |
0:a0faa86660d4 | 92 | mbed::DigitalOut *_CS; |
Steven Cooreman |
0:a0faa86660d4 | 93 | |
gmehmet | 12:ca0bcb4777e9 | 94 | mbed::Ticker _displayToggler; |
gmehmet | 12:ca0bcb4777e9 | 95 | mbed::Timeout _csTimeout; |
Steven Cooreman |
0:a0faa86660d4 | 96 | |
Steven Cooreman |
2:2f10f00fe56c | 97 | event_callback_t _internalEventCallback; |
Steven Cooreman |
0:a0faa86660d4 | 98 | volatile uint32_t _refreshCount; |
Steven Cooreman |
0:a0faa86660d4 | 99 | uint8_t _lcdPolarity; |
Steven Cooreman |
0:a0faa86660d4 | 100 | LS013B7DH03_state_t _state; |
Steven Cooreman |
0:a0faa86660d4 | 101 | cbptr_t _completionCallbackPtr; |
Steven Cooreman |
0:a0faa86660d4 | 102 | volatile uint32_t _rowCount; |
Steven Cooreman |
0:a0faa86660d4 | 103 | uint8_t _cmd[2 + (DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE))]; |
Steven Cooreman |
0:a0faa86660d4 | 104 | |
Steven Cooreman |
0:a0faa86660d4 | 105 | /** |
Steven Cooreman |
0:a0faa86660d4 | 106 | * Callback handler for internal SPI transfers. |
Steven Cooreman |
0:a0faa86660d4 | 107 | */ |
Steven Cooreman |
0:a0faa86660d4 | 108 | void _cbHandler( int event ); |
Steven Cooreman |
0:a0faa86660d4 | 109 | |
Steven Cooreman |
0:a0faa86660d4 | 110 | /** |
Steven Cooreman |
0:a0faa86660d4 | 111 | * Callback handler for internal SPI transfers triggered by timeout. |
Steven Cooreman |
0:a0faa86660d4 | 112 | */ |
Steven Cooreman |
0:a0faa86660d4 | 113 | void _cbHandlerTimeout( void ); |
Steven Cooreman |
0:a0faa86660d4 | 114 | |
Steven Cooreman |
0:a0faa86660d4 | 115 | /** |
Steven Cooreman |
2:2f10f00fe56c | 116 | * Call this function at 55 ~ 65 Hz to keep the display from losing contrast. |
Steven Cooreman |
0:a0faa86660d4 | 117 | */ |
Steven Cooreman |
0:a0faa86660d4 | 118 | void toggle(); |
Steven Cooreman |
0:a0faa86660d4 | 119 | }; |
Steven Cooreman |
0:a0faa86660d4 | 120 | |
Steven Cooreman |
0:a0faa86660d4 | 121 | } // namespace silabs |
Steven Cooreman |
0:a0faa86660d4 | 122 | |
Steven Cooreman |
0:a0faa86660d4 | 123 | #endif //SILABS_LS013B7DH03_H |