zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 1 | /** |
| 2 | * \file ST7565R.h |
| 3 | * \brief Constants relating to ST7565R LCD controller. |
| 4 | * \author Andy Gock |
| 5 | * |
| 6 | * Constants and functions specific to ST7565R. |
| 7 | * Tested with Newhaven Display model NHD-C12864WC-FSW-FBW-3V3-M |
| 8 | * |
| 9 | * \todo Need to move functions to be controller independent |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | Copyright (c) 2012, Andy Gock |
| 15 | |
| 16 | All rights reserved. |
| 17 | |
| 18 | Redistribution and use in source and binary forms, with or without |
| 19 | modification, are permitted provided that the following conditions are met: |
| 20 | * Redistributions of source code must retain the above copyright |
| 21 | notice, this list of conditions and the following disclaimer. |
| 22 | * Redistributions in binary form must reproduce the above copyright |
| 23 | notice, this list of conditions and the following disclaimer in the |
| 24 | documentation and/or other materials provided with the distribution. |
| 25 | * Neither the name of Andy Gock nor the |
| 26 | names of its contributors may be used to endorse or promote products |
| 27 | derived from this software without specific prior written permission. |
| 28 | |
| 29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 30 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 31 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 32 | DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY |
| 33 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 34 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 35 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 36 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 38 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 39 | */ |
| 40 | |
| 41 | #ifndef ST7565R_H_ |
| 42 | #define ST7565R_H_ |
| 43 | |
| 44 | #include "stdint.h" |
| 45 | |
| 46 | /* Commands */ |
| 47 | #define ST7565R_DISPLAY_ON 0xAF /* 0b10101111 */ |
| 48 | #define ST7565R_DISPLAY_OFF 0xAE /* 0b10101110 */ |
| 49 | #define ST7565R_PAGE_ADDRESS_SET 0xB0 /* 0b10110000 */ |
| 50 | #define ST7565R_COLUMN_ADDRESS_SET_LOWER 0x00 |
| 51 | #define ST7565R_COLUMN_ADDRESS_SET_UPPER 0x10 |
| 52 | #define ST7565R_DISPLAY_NORMAL 0xA4 /* 0b10100100 */ |
| 53 | #define ST7565R_DISPLAY_ALL_ON 0xA5 /* 0b10100101 */ |
| 54 | #define ST7565R_NORMAL 0xA0 /* 0b10100000 */ |
| 55 | #define ST7565R_REVERSE 0xA1 /* 0b10100001 */ |
| 56 | #define ST7565R_RESET 0xE2 /* 0b11100010 */ |
| 57 | #define ST7565R_SET_START_LINE (1<<6) |
| 58 | |
| 59 | /** |
| 60 | * User specified GLCD width in pixels |
| 61 | * Set to 0 for automatic assignment based on controller. |
| 62 | */ |
| 63 | #define GLCD_LCD_WIDTH1 128 |
| 64 | |
| 65 | /** |
| 66 | * User specified GLCD height in pixels |
| 67 | * Set to 0 for automatic assignment based on controller. |
| 68 | */ |
| 69 | |
| 70 | #define GLCD_LCD_HEIGHT1 64 |
| 71 | |
| 72 | |
| 73 | #define GLCD_NUMBER_OF_BANKS1 (GLCD_LCD_WIDTH1 / 8) |
| 74 | #define GLCD_NUMBER_OF_COLS1 GLCD_LCD_WIDTH1 |
| 75 | |
| 76 | /* These functions only available on ST7565 implementation (for now) */ |
| 77 | |
| 78 | /* Private functions */ |
| 79 | void glcd_set_column_upper(uint8_t addr); |
| 80 | void glcd_set_column_lower(uint8_t addr); |
| 81 | |
| 82 | /** All display points on (native) */ |
| 83 | void glcd_all_on(void); |
| 84 | |
| 85 | /** Set to normal mode */ |
| 86 | void glcd_normal(void); |
| 87 | |
| 88 | /** Set start line/page */ |
| 89 | void glcd_set_start_line(uint8_t addr); |
| 90 | |
| 91 | /** Clear the display immediately, does not buffer */ |
| 92 | void glcd_clear_now(void); |
| 93 | |
| 94 | /** Show a black and white line pattern on the display */ |
| 95 | void glcd_pattern(void); |
| 96 | |
| 97 | /** Init ST7565R controller / display */ |
| 98 | void glcd_ST7565R_init(void); |
| 99 | |
| 100 | void glcd_write(void); |
| 101 | |
| 102 | void glcd_set_y_address(uint8_t y); |
| 103 | |
| 104 | void glcd_set_x_address(uint8_t x); |
| 105 | |
| 106 | void glcd_data(uint8_t c); |
| 107 | |
| 108 | #endif /* ST7565R_H_ */ |