Interface for Sharp LS012B7DD01 TFT-LCD
Dependents: MAX32630FTHR_iButton_uSD_Logger
Sharp_LS012B7DD01.h@0:a857326491e8, 2016-11-19 (annotated)
- Committer:
- j3
- Date:
- Sat Nov 19 20:34:01 2016 -0800
- Revision:
- 0:a857326491e8
- Child:
- 1:ea88fe2c73ed
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 |
0:a857326491e8 | 1 | /******************************************************************************* |
j3 |
0:a857326491e8 | 2 | * The MIT License (MIT) |
j3 |
0:a857326491e8 | 3 | * |
j3 |
0:a857326491e8 | 4 | * Copyright (c) 2016 j3 |
j3 |
0:a857326491e8 | 5 | * |
j3 |
0:a857326491e8 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
j3 |
0:a857326491e8 | 7 | * of this software and associated documentation files (the "Software"), to deal |
j3 |
0:a857326491e8 | 8 | * in the Software without restriction, including without limitation the rights |
j3 |
0:a857326491e8 | 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
j3 |
0:a857326491e8 | 10 | * copies of the Software, and to permit persons to whom the Software is |
j3 |
0:a857326491e8 | 11 | * furnished to do so, subject to the following conditions: |
j3 |
0:a857326491e8 | 12 | * |
j3 |
0:a857326491e8 | 13 | * The above copyright notice and this permission notice shall be included in |
j3 |
0:a857326491e8 | 14 | * all copies or substantial portions of the Software. |
j3 |
0:a857326491e8 | 15 | * |
j3 |
0:a857326491e8 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
j3 |
0:a857326491e8 | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
j3 |
0:a857326491e8 | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
j3 |
0:a857326491e8 | 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
j3 |
0:a857326491e8 | 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
j3 |
0:a857326491e8 | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
j3 |
0:a857326491e8 | 22 | * SOFTWARE. |
j3 |
0:a857326491e8 | 23 | ******************************************************************************/ |
j3 |
0:a857326491e8 | 24 | |
j3 |
0:a857326491e8 | 25 | #ifndef SHARP_LS012B7DD01_H |
j3 |
0:a857326491e8 | 26 | #define SHARP_LS012B7DD01_H |
j3 |
0:a857326491e8 | 27 | |
j3 |
0:a857326491e8 | 28 | #include "mbed.h" |
j3 |
0:a857326491e8 | 29 | |
j3 |
0:a857326491e8 | 30 | /** |
j3 |
0:a857326491e8 | 31 | * @brief Sharp LS012B&DD01 TFT-LCD |
j3 |
0:a857326491e8 | 32 | */ |
j3 |
0:a857326491e8 | 33 | class SharpLS012B7DD01 |
j3 |
0:a857326491e8 | 34 | { |
j3 |
0:a857326491e8 | 35 | public: |
j3 |
0:a857326491e8 | 36 | |
j3 |
0:a857326491e8 | 37 | static const uint8_t DATA_UPDATE_MODE = 0x80; |
j3 |
0:a857326491e8 | 38 | static const uint8_t DISPLAY_MODE = 0; |
j3 |
0:a857326491e8 | 39 | static const uint8_t ALL_CLEAR_MODE = 0x20; |
j3 |
0:a857326491e8 | 40 | |
j3 |
0:a857326491e8 | 41 | enum SharpCmdResult |
j3 |
0:a857326491e8 | 42 | { |
j3 |
0:a857326491e8 | 43 | Success, |
j3 |
0:a857326491e8 | 44 | Failure, |
j3 |
0:a857326491e8 | 45 | }; |
j3 |
0:a857326491e8 | 46 | |
j3 |
0:a857326491e8 | 47 | /** |
j3 |
0:a857326491e8 | 48 | * @brief SharpLS012B7DD01 Constructor |
j3 |
0:a857326491e8 | 49 | */ |
j3 |
0:a857326491e8 | 50 | SharpLS012B7DD01(PinName disp, PinName extcomin, PinName cs, PinName mosi, PinName sclk); |
j3 |
0:a857326491e8 | 51 | |
j3 |
0:a857326491e8 | 52 | /** |
j3 |
0:a857326491e8 | 53 | * @brief SharpLS012B7DD01 Destructor |
j3 |
0:a857326491e8 | 54 | */ |
j3 |
0:a857326491e8 | 55 | ~SharpLS012B7DD01(); |
j3 |
0:a857326491e8 | 56 | |
j3 |
0:a857326491e8 | 57 | /** |
j3 |
0:a857326491e8 | 58 | * @brief Prints character to given line and position |
j3 |
0:a857326491e8 | 59 | */ |
j3 |
0:a857326491e8 | 60 | SharpCmdResult print_char(uint8_t ln, uint8_t pos, char c); |
j3 |
0:a857326491e8 | 61 | |
j3 |
0:a857326491e8 | 62 | /** |
j3 |
0:a857326491e8 | 63 | * @breif Prints string to given line and position |
j3 |
0:a857326491e8 | 64 | */ |
j3 |
0:a857326491e8 | 65 | SharpCmdResult print_str(uint8_t ln, uint8_t pos, const char *s); |
j3 |
0:a857326491e8 | 66 | |
j3 |
0:a857326491e8 | 67 | void clear_display(); |
j3 |
0:a857326491e8 | 68 | |
j3 |
0:a857326491e8 | 69 | private: |
j3 |
0:a857326491e8 | 70 | |
j3 |
0:a857326491e8 | 71 | /** |
j3 |
0:a857326491e8 | 72 | * @brief Writes memory of Sharp LS012B7DD01 |
j3 |
0:a857326491e8 | 73 | */ |
j3 |
0:a857326491e8 | 74 | SharpCmdResult write_memory(uint8_t data[][23], uint8_t lines, uint8_t offset); |
j3 |
0:a857326491e8 | 75 | |
j3 |
0:a857326491e8 | 76 | /** |
j3 |
0:a857326491e8 | 77 | * @brief Updates display |
j3 |
0:a857326491e8 | 78 | */ |
j3 |
0:a857326491e8 | 79 | void update(const uint8_t mode); |
j3 |
0:a857326491e8 | 80 | |
j3 |
0:a857326491e8 | 81 | /** |
j3 |
0:a857326491e8 | 82 | * @brief Reverses bit order |
j3 |
0:a857326491e8 | 83 | */ |
j3 |
0:a857326491e8 | 84 | uint8_t rev_bit(uint8_t data); |
j3 |
0:a857326491e8 | 85 | |
j3 |
0:a857326491e8 | 86 | /** |
j3 |
0:a857326491e8 | 87 | * @brief Call back for ticker |
j3 |
0:a857326491e8 | 88 | */ |
j3 |
0:a857326491e8 | 89 | void toggle_extcomin(); |
j3 |
0:a857326491e8 | 90 | |
j3 |
0:a857326491e8 | 91 | uint8_t m_data[38][23]; |
j3 |
0:a857326491e8 | 92 | |
j3 |
0:a857326491e8 | 93 | DigitalOut m_disp; |
j3 |
0:a857326491e8 | 94 | DigitalOut m_extcomin; |
j3 |
0:a857326491e8 | 95 | DigitalOut m_cs; |
j3 |
0:a857326491e8 | 96 | SPI m_spi; |
j3 |
0:a857326491e8 | 97 | Ticker m_extcominTicker; |
j3 |
0:a857326491e8 | 98 | }; |
j3 |
0:a857326491e8 | 99 | |
j3 |
0:a857326491e8 | 100 | #endif /*SHARP_LS012B7DD01_H*/ |