Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ili9163lcd.h@6:7abe5999dc1c, 2021-01-02 (annotated)
- Committer:
- gitakichi
- Date:
- Sat Jan 02 07:29:21 2021 +0000
- Revision:
- 6:7abe5999dc1c
- Parent:
- 3:9caa79f40909
- Child:
- 7:eaaf60683ca4
use burst reduce reload time
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| morita | 0:c0be4e018a09 | 1 | /** |
| morita | 0:c0be4e018a09 | 2 | * @file ili9163lcd.h |
| gitakichi | 2:4d5b94a92f19 | 3 | * @brief ILI9163 128x160 LCD Driver (Header file) |
| morita | 0:c0be4e018a09 | 4 | * |
| morita | 0:c0be4e018a09 | 5 | * This code has been ported from the ili9163lcd library for mbed |
| morita | 0:c0be4e018a09 | 6 | * made by Jun Morita. |
| morita | 0:c0be4e018a09 | 7 | * Source form <http://files.noccylabs.info/lib430/liblcd/ili9163lcd_8c.html> |
| morita | 0:c0be4e018a09 | 8 | * |
| morita | 0:c0be4e018a09 | 9 | * This code has been ported from the ili9163lcd library for avr made |
| morita | 0:c0be4e018a09 | 10 | * by Simon Inns, to run on a msp430. |
| morita | 0:c0be4e018a09 | 11 | * |
| morita | 0:c0be4e018a09 | 12 | * This program is free software: you can redistribute it and/or modify |
| morita | 0:c0be4e018a09 | 13 | * it under the terms of the GNU General Public License as published by |
| morita | 0:c0be4e018a09 | 14 | * the Free Software Foundation, either version 3 of the License, or |
| morita | 0:c0be4e018a09 | 15 | * (at your option) any later version. |
| morita | 0:c0be4e018a09 | 16 | * |
| morita | 0:c0be4e018a09 | 17 | * This program is distributed in the hope that it will be useful, |
| morita | 0:c0be4e018a09 | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| morita | 0:c0be4e018a09 | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| morita | 0:c0be4e018a09 | 20 | * GNU General Public License for more details. |
| morita | 0:c0be4e018a09 | 21 | * |
| morita | 0:c0be4e018a09 | 22 | * You should have received a copy of the GNU General Public License |
| morita | 0:c0be4e018a09 | 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| morita | 0:c0be4e018a09 | 24 | * |
| gitakichi | 2:4d5b94a92f19 | 25 | * @author Gitakichi |
| morita | 0:c0be4e018a09 | 26 | * @author Jun Morita (iccraft) |
| morita | 0:c0be4e018a09 | 27 | * @author Simon Inns <simon.inns@gmail.com> |
| morita | 0:c0be4e018a09 | 28 | * @author Christopher Vagnetoft (NoccyLabs) |
| morita | 0:c0be4e018a09 | 29 | * @copyright (C) 2012 Simon Inns |
| morita | 0:c0be4e018a09 | 30 | * @copyright parts (C) 2012 NoccyLabs |
| morita | 0:c0be4e018a09 | 31 | */ |
| morita | 0:c0be4e018a09 | 32 | |
| morita | 0:c0be4e018a09 | 33 | #ifndef ILI9163LCD_H_ |
| morita | 0:c0be4e018a09 | 34 | #define ILI9163LCD_H_ |
| morita | 0:c0be4e018a09 | 35 | |
| morita | 0:c0be4e018a09 | 36 | #define LCD_WR (1 << 2) |
| morita | 0:c0be4e018a09 | 37 | #define LCD_RS (1 << 4) |
| morita | 0:c0be4e018a09 | 38 | #define LCD_RD (1 << 5) |
| morita | 0:c0be4e018a09 | 39 | #define LCD_CS (1 << 6) |
| morita | 0:c0be4e018a09 | 40 | #define LCD_RESET (1 << 7) |
| morita | 0:c0be4e018a09 | 41 | |
| morita | 0:c0be4e018a09 | 42 | // Screen orientation defines: |
| morita | 0:c0be4e018a09 | 43 | // 0 = Ribbon at top |
| morita | 0:c0be4e018a09 | 44 | // 1 = Ribbon at left |
| morita | 0:c0be4e018a09 | 45 | // 2 = Ribbon at right |
| morita | 0:c0be4e018a09 | 46 | // 3 = Ribbon at bottom |
| gitakichi | 2:4d5b94a92f19 | 47 | #define ROT_TOP 0b00000000 |
| gitakichi | 2:4d5b94a92f19 | 48 | #define ROT_LEFT 0b01100000 |
| gitakichi | 2:4d5b94a92f19 | 49 | #define ROT_RIGHT 0b10100000 |
| gitakichi | 2:4d5b94a92f19 | 50 | #define ROT_BOTTOM 0b11000000 |
| morita | 0:c0be4e018a09 | 51 | |
| morita | 0:c0be4e018a09 | 52 | // ILI9163 LCD Controller Commands |
| morita | 0:c0be4e018a09 | 53 | #define NOP 0x00 |
| morita | 0:c0be4e018a09 | 54 | #define SOFT_RESET 0x01 |
| morita | 0:c0be4e018a09 | 55 | #define GET_RED_CHANNEL 0x06 |
| morita | 0:c0be4e018a09 | 56 | #define GET_GREEN_CHANNEL 0x07 |
| morita | 0:c0be4e018a09 | 57 | #define GET_BLUE_CHANNEL 0x08 |
| morita | 0:c0be4e018a09 | 58 | #define GET_PIXEL_FORMAT 0x0C |
| morita | 0:c0be4e018a09 | 59 | #define GET_POWER_MODE 0x0A |
| morita | 0:c0be4e018a09 | 60 | #define GET_ADDRESS_MODE 0x0B |
| morita | 0:c0be4e018a09 | 61 | #define GET_DISPLAY_MODE 0x0D |
| morita | 0:c0be4e018a09 | 62 | #define GET_SIGNAL_MODE 0x0E |
| morita | 0:c0be4e018a09 | 63 | #define GET_DIAGNOSTIC_RESULT 0x0F |
| morita | 0:c0be4e018a09 | 64 | #define ENTER_SLEEP_MODE 0x10 |
| morita | 0:c0be4e018a09 | 65 | #define EXIT_SLEEP_MODE 0x11 |
| morita | 0:c0be4e018a09 | 66 | #define ENTER_PARTIAL_MODE 0x12 |
| morita | 0:c0be4e018a09 | 67 | #define ENTER_NORMAL_MODE 0x13 |
| morita | 0:c0be4e018a09 | 68 | #define EXIT_INVERT_MODE 0x20 |
| morita | 0:c0be4e018a09 | 69 | #define ENTER_INVERT_MODE 0x21 |
| morita | 0:c0be4e018a09 | 70 | #define SET_GAMMA_CURVE 0x26 |
| morita | 0:c0be4e018a09 | 71 | #define SET_DISPLAY_OFF 0x28 |
| morita | 0:c0be4e018a09 | 72 | #define SET_DISPLAY_ON 0x29 |
| morita | 0:c0be4e018a09 | 73 | #define SET_COLUMN_ADDRESS 0x2A |
| morita | 0:c0be4e018a09 | 74 | #define SET_PAGE_ADDRESS 0x2B |
| morita | 0:c0be4e018a09 | 75 | #define WRITE_MEMORY_START 0x2C |
| morita | 0:c0be4e018a09 | 76 | #define WRITE_LUT 0x2D |
| morita | 0:c0be4e018a09 | 77 | #define READ_MEMORY_START 0x2E |
| morita | 0:c0be4e018a09 | 78 | #define SET_PARTIAL_AREA 0x30 |
| morita | 0:c0be4e018a09 | 79 | #define SET_SCROLL_AREA 0x33 |
| morita | 0:c0be4e018a09 | 80 | #define SET_TEAR_OFF 0x34 |
| morita | 0:c0be4e018a09 | 81 | #define SET_TEAR_ON 0x35 |
| morita | 0:c0be4e018a09 | 82 | #define SET_ADDRESS_MODE 0x36 |
| morita | 0:c0be4e018a09 | 83 | #define SET_SCROLL_START 0X37 |
| morita | 0:c0be4e018a09 | 84 | #define EXIT_IDLE_MODE 0x38 |
| morita | 0:c0be4e018a09 | 85 | #define ENTER_IDLE_MODE 0x39 |
| morita | 0:c0be4e018a09 | 86 | #define SET_PIXEL_FORMAT 0x3A |
| morita | 0:c0be4e018a09 | 87 | #define WRITE_MEMORY_CONTINUE 0x3C |
| morita | 0:c0be4e018a09 | 88 | #define READ_MEMORY_CONTINUE 0x3E |
| morita | 0:c0be4e018a09 | 89 | #define SET_TEAR_SCANLINE 0x44 |
| morita | 0:c0be4e018a09 | 90 | #define GET_SCANLINE 0x45 |
| morita | 0:c0be4e018a09 | 91 | #define READ_ID1 0xDA |
| morita | 0:c0be4e018a09 | 92 | #define READ_ID2 0xDB |
| morita | 0:c0be4e018a09 | 93 | #define READ_ID3 0xDC |
| morita | 0:c0be4e018a09 | 94 | #define FRAME_RATE_CONTROL1 0xB1 |
| morita | 0:c0be4e018a09 | 95 | #define FRAME_RATE_CONTROL2 0xB2 |
| morita | 0:c0be4e018a09 | 96 | #define FRAME_RATE_CONTROL3 0xB3 |
| morita | 0:c0be4e018a09 | 97 | #define DISPLAY_INVERSION 0xB4 |
| morita | 0:c0be4e018a09 | 98 | #define SOURCE_DRIVER_DIRECTION 0xB7 |
| morita | 0:c0be4e018a09 | 99 | #define GATE_DRIVER_DIRECTION 0xB8 |
| morita | 0:c0be4e018a09 | 100 | #define POWER_CONTROL1 0xC0 |
| morita | 0:c0be4e018a09 | 101 | #define POWER_CONTROL2 0xC1 |
| morita | 0:c0be4e018a09 | 102 | #define POWER_CONTROL3 0xC2 |
| morita | 0:c0be4e018a09 | 103 | #define POWER_CONTROL4 0xC3 |
| morita | 0:c0be4e018a09 | 104 | #define POWER_CONTROL5 0xC4 |
| morita | 0:c0be4e018a09 | 105 | #define VCOM_CONTROL1 0xC5 |
| morita | 0:c0be4e018a09 | 106 | #define VCOM_CONTROL2 0xC6 |
| morita | 0:c0be4e018a09 | 107 | #define VCOM_OFFSET_CONTROL 0xC7 |
| morita | 0:c0be4e018a09 | 108 | #define WRITE_ID4_VALUE 0xD3 |
| morita | 0:c0be4e018a09 | 109 | #define NV_MEMORY_FUNCTION1 0xD7 |
| morita | 0:c0be4e018a09 | 110 | #define NV_MEMORY_FUNCTION2 0xDE |
| morita | 0:c0be4e018a09 | 111 | #define POSITIVE_GAMMA_CORRECT 0xE0 |
| morita | 0:c0be4e018a09 | 112 | #define NEGATIVE_GAMMA_CORRECT 0xE1 |
| morita | 0:c0be4e018a09 | 113 | #define GAM_R_SEL 0xF2 |
| gitakichi | 2:4d5b94a92f19 | 114 | //128x160 |
| gitakichi | 2:4d5b94a92f19 | 115 | #define COL_MAX 0x7f |
| gitakichi | 2:4d5b94a92f19 | 116 | #define PAGE_MAX 0x9f |
| morita | 0:c0be4e018a09 | 117 | |
| morita | 0:c0be4e018a09 | 118 | // Macros and in-lines: |
| morita | 0:c0be4e018a09 | 119 | |
| morita | 0:c0be4e018a09 | 120 | // Translates a 3 byte RGB value into a 2 byte value for the LCD (values should be 0-31) |
| morita | 0:c0be4e018a09 | 121 | inline uint16_t decodeRgbValue(uint8_t r, uint8_t g, uint8_t b) |
| morita | 0:c0be4e018a09 | 122 | { |
| gitakichi | 3:9caa79f40909 | 123 | return (r << 11) | (g << 6) | (b); |
| morita | 0:c0be4e018a09 | 124 | } |
| morita | 0:c0be4e018a09 | 125 | |
| morita | 0:c0be4e018a09 | 126 | // This routine takes a row number from 0 to 20 and |
| morita | 0:c0be4e018a09 | 127 | // returns the x coordinate on the screen (0-127) to make |
| morita | 0:c0be4e018a09 | 128 | // it easy to place text |
| morita | 0:c0be4e018a09 | 129 | inline uint8_t lcdTextX(uint8_t x) { return x*6; } |
| morita | 0:c0be4e018a09 | 130 | |
| morita | 0:c0be4e018a09 | 131 | // This routine takes a column number from 0 to 20 and |
| morita | 0:c0be4e018a09 | 132 | // returns the y coordinate on the screen (0-127) to make |
| morita | 0:c0be4e018a09 | 133 | // it easy to place text |
| morita | 0:c0be4e018a09 | 134 | inline uint8_t lcdTextY(uint8_t y) { return y*8; } |
| morita | 0:c0be4e018a09 | 135 | |
| morita | 0:c0be4e018a09 | 136 | // LCD function prototypes |
| morita | 0:c0be4e018a09 | 137 | void lcdReset(void); |
| morita | 0:c0be4e018a09 | 138 | void lcdWriteCommand(uint8_t address); |
| morita | 0:c0be4e018a09 | 139 | void lcdWriteParameter(uint8_t parameter); |
| morita | 0:c0be4e018a09 | 140 | void lcdWriteData(uint8_t dataByte1, uint8_t dataByte2); |
| gitakichi | 6:7abe5999dc1c | 141 | void lcdWriteData_burst(uint16_t *burst_data,uint16_t length); |
| gitakichi | 6:7abe5999dc1c | 142 | void lcdWriteData_sameburst(uint16_t data,uint16_t length); |
| morita | 0:c0be4e018a09 | 143 | void lcdInitialise(uint8_t orientation); |
| morita | 0:c0be4e018a09 | 144 | |
| morita | 0:c0be4e018a09 | 145 | void lcdClearDisplay(uint16_t colour); |
| gitakichi | 3:9caa79f40909 | 146 | void grade(void); |
| gitakichi | 3:9caa79f40909 | 147 | void colorbar(void); |
| morita | 0:c0be4e018a09 | 148 | void lcdPlot(uint8_t x, uint8_t y, uint16_t colour); |
| morita | 0:c0be4e018a09 | 149 | void lcdLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour); |
| morita | 0:c0be4e018a09 | 150 | void lcdRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour); |
| morita | 0:c0be4e018a09 | 151 | void lcdFilledRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour); |
| morita | 0:c0be4e018a09 | 152 | void lcdCircle(int16_t xCentre, int16_t yCentre, int16_t radius, uint16_t colour); |
| morita | 0:c0be4e018a09 | 153 | |
| morita | 0:c0be4e018a09 | 154 | void lcdPutCh(unsigned char character, uint8_t x, uint8_t y, uint16_t fgColour, uint16_t bgColour); |
| morita | 0:c0be4e018a09 | 155 | void lcdPutS(const char *string, uint8_t x, uint8_t y, uint16_t fgColour, uint16_t bgColour); |
| morita | 0:c0be4e018a09 | 156 | |
| morita | 0:c0be4e018a09 | 157 | #endif /* ILI9163LCD_H_ */ |