ssd1963

Committer:
sPymbed
Date:
Fri Oct 16 17:39:40 2020 +0000
Revision:
4:84a51911fb31
Parent:
3:31ca3cd96572
fixed: backlight

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sPymbed 0:94df05e3330d 1 /*****************************************************************************
sPymbed 0:94df05e3330d 2 * Project : 7" TFT LCD 800x480 [AT070TN92]
sPymbed 0:94df05e3330d 3 * Compiler : mbed Online
sPymbed 0:94df05e3330d 4 * Type : Libraries
sPymbed 0:94df05e3330d 5 * Comment : Support mbed ST Nucleo Board.
sPymbed 0:94df05e3330d 6 * : Support Chip = SSD1963
sPymbed 0:94df05e3330d 7 * File : SSD1963.h
sPymbed 0:94df05e3330d 8 *
sPymbed 0:94df05e3330d 9 * Author : Mr.Thongchai Artsamart [Bird Techstep]
sPymbed 0:94df05e3330d 10 * E-Mail : t.artsamart@gmail.com
sPymbed 0:94df05e3330d 11 * : tbird_th@hotmail.com
sPymbed 0:94df05e3330d 12 * Start Date : 20/03/2014 [dd/mm/yyyy]
sPymbed 0:94df05e3330d 13 * Version Date : 20/03/2014 [dd/mm/yyyy]
sPymbed 0:94df05e3330d 14 * Licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
sPymbed 0:94df05e3330d 15 *****************************************************************************
sPymbed 0:94df05e3330d 16 * Remark : Thank you -. no1wudi [CooCox]
sPymbed 0:94df05e3330d 17 * -.
sPymbed 0:94df05e3330d 18 *****************************************************************************/
sPymbed 0:94df05e3330d 19 #ifndef __SSD1963_H_
sPymbed 0:94df05e3330d 20 #define __SSD1963_H_
sPymbed 2:d8a9ebd28f0a 21 #include "lcd_base.h"
sPymbed 0:94df05e3330d 22
sPymbed 0:94df05e3330d 23 /*********************************************************************
sPymbed 0:94df05e3330d 24 * Overview: Image orientation (can be 0, 90, 180, 270 degrees).
sPymbed 0:94df05e3330d 25 *********************************************************************/
sPymbed 0:94df05e3330d 26 #define DISP_ORIENTATION 0
sPymbed 0:94df05e3330d 27 /*********************************************************************
sPymbed 0:94df05e3330d 28 * Overview: Panel Data Width (R,G,B) in (6,6,6)
sPymbed 0:94df05e3330d 29 *********************************************************************/
sPymbed 2:d8a9ebd28f0a 30 #define DISP_DATA_WIDTH 18
sPymbed 0:94df05e3330d 31 /*********************************************************************
sPymbed 0:94df05e3330d 32 * Overview: Horizontal and vertical display resolution
sPymbed 0:94df05e3330d 33 * (from the glass datasheet).
sPymbed 0:94df05e3330d 34 *********************************************************************/
sPymbed 2:d8a9ebd28f0a 35 #define DISP_HOR_RESOLUTION 480
sPymbed 2:d8a9ebd28f0a 36 #define DISP_VER_RESOLUTION 272
sPymbed 0:94df05e3330d 37 /*********************************************************************
sPymbed 0:94df05e3330d 38 * Overview: Horizontal synchronization timing in pixels
sPymbed 0:94df05e3330d 39 * (from the glass datasheet).
sPymbed 0:94df05e3330d 40 *********************************************************************/
sPymbed 0:94df05e3330d 41 #define DISP_HOR_PULSE_WIDTH 1
sPymbed 0:94df05e3330d 42 #define DISP_HOR_BACK_PORCH 210
sPymbed 0:94df05e3330d 43 #define DISP_HOR_FRONT_PORCH 45
sPymbed 0:94df05e3330d 44 /*********************************************************************
sPymbed 0:94df05e3330d 45 * Overview: Vertical synchronization timing in lines
sPymbed 0:94df05e3330d 46 * (from the glass datasheet).
sPymbed 0:94df05e3330d 47 *********************************************************************/
sPymbed 0:94df05e3330d 48 #define DISP_VER_PULSE_WIDTH 1
sPymbed 0:94df05e3330d 49 #define DISP_VER_BACK_PORCH 34
sPymbed 0:94df05e3330d 50 #define DISP_VER_FRONT_PORCH 10
sPymbed 0:94df05e3330d 51
sPymbed 0:94df05e3330d 52 /*********************************************************************
sPymbed 0:94df05e3330d 53 * Overview: Some basic colors definitions.
sPymbed 0:94df05e3330d 54 *********************************************************************/
sPymbed 0:94df05e3330d 55 #define BLACK RGB565CONVERT(0, 0, 0)
sPymbed 0:94df05e3330d 56 #define BRIGHTBLUE RGB565CONVERT(0, 0, 255)
sPymbed 0:94df05e3330d 57 #define BRIGHTGREEN RGB565CONVERT(0, 255, 0)
sPymbed 0:94df05e3330d 58 #define BRIGHTCYAN RGB565CONVERT(0, 255, 255)
sPymbed 0:94df05e3330d 59 #define BRIGHTRED RGB565CONVERT(255, 0, 0)
sPymbed 0:94df05e3330d 60 #define BRIGHTMAGENTA RGB565CONVERT(255, 0, 255)
sPymbed 0:94df05e3330d 61 #define BRIGHTYELLOW RGB565CONVERT(255, 255, 0)
sPymbed 0:94df05e3330d 62 #define BLUE RGB565CONVERT(0, 0, 128)
sPymbed 0:94df05e3330d 63 #define GREEN RGB565CONVERT(0, 128, 0)
sPymbed 0:94df05e3330d 64 #define CYAN RGB565CONVERT(0, 128, 128)
sPymbed 0:94df05e3330d 65 #define RED RGB565CONVERT(128, 0, 0)
sPymbed 0:94df05e3330d 66 #define MAGENTA RGB565CONVERT(128, 0, 128)
sPymbed 0:94df05e3330d 67 #define BROWN RGB565CONVERT(255, 128, 0)
sPymbed 0:94df05e3330d 68 #define LIGHTGRAY RGB565CONVERT(128, 128, 128)
sPymbed 0:94df05e3330d 69 #define DARKGRAY RGB565CONVERT(64, 64, 64)
sPymbed 0:94df05e3330d 70 #define LIGHTBLUE RGB565CONVERT(128, 128, 255)
sPymbed 0:94df05e3330d 71 #define LIGHTGREEN RGB565CONVERT(128, 255, 128)
sPymbed 0:94df05e3330d 72 #define LIGHTCYAN RGB565CONVERT(128, 255, 255)
sPymbed 0:94df05e3330d 73 #define LIGHTRED RGB565CONVERT(255, 128, 128)
sPymbed 0:94df05e3330d 74 #define LIGHTMAGENTA RGB565CONVERT(255, 128, 255)
sPymbed 0:94df05e3330d 75 #define YELLOW RGB565CONVERT(255, 255, 128)
sPymbed 0:94df05e3330d 76 #define WHITE RGB565CONVERT(255, 255, 255)
sPymbed 0:94df05e3330d 77
sPymbed 0:94df05e3330d 78 #define GRAY0 RGB565CONVERT(224, 224, 224)
sPymbed 0:94df05e3330d 79 #define GRAY1 RGB565CONVERT(192, 192, 192)
sPymbed 0:94df05e3330d 80 #define GRAY2 RGB565CONVERT(160, 160, 160)
sPymbed 0:94df05e3330d 81 #define GRAY3 RGB565CONVERT(128, 128, 128)
sPymbed 0:94df05e3330d 82 #define GRAY4 RGB565CONVERT(96, 96, 96)
sPymbed 0:94df05e3330d 83 #define GRAY5 RGB565CONVERT(64, 64, 64)
sPymbed 0:94df05e3330d 84 #define GRAY6 RGB565CONVERT(32, 32, 32)
sPymbed 0:94df05e3330d 85
sPymbed 0:94df05e3330d 86 /*
sPymbed 0:94df05e3330d 87 // Section : SSD1963 Command --------------------------------------------------
sPymbed 0:94df05e3330d 88 // - HX83XX Register Names ----------------------------------------------------
sPymbed 0:94df05e3330d 89 #define COL_ADD_START_HI 0x02 // W/R - SC[15:8] (8'b0000_0000)
sPymbed 0:94df05e3330d 90 #define COL_ADD_START_LO 0x03 // W/R - SC[7:0] (8'b0000_0000)
sPymbed 0:94df05e3330d 91
sPymbed 0:94df05e3330d 92 #define COL_ADD_END_HI 0x04 // W/R - EC[15:8] (8'b0000_0000)
sPymbed 0:94df05e3330d 93 #define COL_ADD_END_LO 0x05 // W/R - EC[7:0] (8'b1110_1111)
sPymbed 0:94df05e3330d 94
sPymbed 0:94df05e3330d 95 #define ROW_ADD_START_HI 0x06 // W/R - SP[15:8] (8'b0000_0000)
sPymbed 0:94df05e3330d 96 #define ROW_ADD_START_LO 0x07 // W/R - SP[7:0] (8'b0000_00000)
sPymbed 0:94df05e3330d 97
sPymbed 0:94df05e3330d 98 #define ROW_ADD_END_HI 0x08 // W/R - EP[15:8] (8'b0000_0001)
sPymbed 0:94df05e3330d 99 #define ROW_ADD_END_LO 0x09 // W/R - EP[7:0] (8'b0011_1111)
sPymbed 0:94df05e3330d 100
sPymbed 0:94df05e3330d 101 //#define MEM_ACCESS 0x16 // W/R - MY(0) MX(0) MV(0) ML(0) BGR(0) - - -
sPymbed 0:94df05e3330d 102 #define MEM_ACCESS 0x36
sPymbed 0:94df05e3330d 103 //#define SRAM_WRITE 0x22 // W/R SRAM Write
sPymbed 0:94df05e3330d 104 #define SRAM_WRITE 0x2C
sPymbed 0:94df05e3330d 105 */
sPymbed 2:d8a9ebd28f0a 106
sPymbed 0:94df05e3330d 107 #define Com_NOP 0x00 // brief No opeation
sPymbed 0:94df05e3330d 108 #define Com_Reset 0x01 // brief Software reset
sPymbed 0:94df05e3330d 109 #define Com_GetPowerMode 0x0A // brief Get power mode
sPymbed 0:94df05e3330d 110 #define Com_GetAddressMode 0x0B // brief Get the frame memory t the display panel read order
sPymbed 0:94df05e3330d 111 #define Com_GetPixelFormat 0x0C // brief Get the current pixel format
sPymbed 0:94df05e3330d 112 #define Com_GetDisplayModule 0x0D // brief Get the current display format
sPymbed 0:94df05e3330d 113 #define Com_GetSignalMode 0x0E // brief Get the display mode from peripharel
sPymbed 0:94df05e3330d 114 #define Com_EnterSleepMode 0x10 // brief Enter the sleep mode
sPymbed 0:94df05e3330d 115 #define Com_ExitSleepMode 0x11 // brief Turn on the panel
sPymbed 0:94df05e3330d 116 #define Com_EnterPartialMode 0x12 // brief Enter partial mode
sPymbed 0:94df05e3330d 117 #define Com_EnterNormalMode 0x13 // brief Enter normal mode
sPymbed 0:94df05e3330d 118 #define Com_ExitInvertMode 0x20 // brief Exit the invert mode
sPymbed 0:94df05e3330d 119 #define Com_EnterInvertMode 0x21
sPymbed 0:94df05e3330d 120
sPymbed 0:94df05e3330d 121 #define Com_SetGammaCurve 0x26
sPymbed 0:94df05e3330d 122
sPymbed 0:94df05e3330d 123 #define Com_SetDisplayOff 0x28
sPymbed 0:94df05e3330d 124 #define Com_SetDisplayOn 0x29
sPymbed 0:94df05e3330d 125
sPymbed 0:94df05e3330d 126 #define Com_SetColumnAddress 0x2A
sPymbed 0:94df05e3330d 127
sPymbed 0:94df05e3330d 128 #define Com_SetPageAddress 0x2B
sPymbed 0:94df05e3330d 129
sPymbed 0:94df05e3330d 130 #define Com_WriteMemory 0x2C
sPymbed 0:94df05e3330d 131
sPymbed 0:94df05e3330d 132 #define Com_ReadMomery 0x2E
sPymbed 0:94df05e3330d 133
sPymbed 0:94df05e3330d 134 #define Com_SetPartialArea 0x30
sPymbed 0:94df05e3330d 135
sPymbed 0:94df05e3330d 136 #define Com_SetScrollArea 0x33
sPymbed 0:94df05e3330d 137
sPymbed 0:94df05e3330d 138 #define Com_SetTearOff 0x34
sPymbed 0:94df05e3330d 139 #define Com_SetTearOn 0x35
sPymbed 0:94df05e3330d 140
sPymbed 0:94df05e3330d 141 #define Com_SetAddressMode 0x36
sPymbed 0:94df05e3330d 142
sPymbed 0:94df05e3330d 143 #define Com_SetScrollStart 0x37
sPymbed 0:94df05e3330d 144
sPymbed 0:94df05e3330d 145 #define Com_ExtiIdleMode 0x38
sPymbed 0:94df05e3330d 146 #define Com_EnterIdleMode 0x39
sPymbed 0:94df05e3330d 147
sPymbed 0:94df05e3330d 148 #define Com_SetPixelFormat 0x3A
sPymbed 0:94df05e3330d 149
sPymbed 0:94df05e3330d 150 #define Com_WriteMemoryContinue 0x3C
sPymbed 0:94df05e3330d 151
sPymbed 0:94df05e3330d 152 #define Com_ReadMemoryContinue 0x3E
sPymbed 0:94df05e3330d 153
sPymbed 0:94df05e3330d 154 #define Com_SetTearScanLine 0x44
sPymbed 0:94df05e3330d 155 #define Com_GetTearScanLine 0x45
sPymbed 0:94df05e3330d 156
sPymbed 0:94df05e3330d 157 #define Com_GetDDB 0xA1
sPymbed 0:94df05e3330d 158
sPymbed 0:94df05e3330d 159 #define Com_SetLCDMode 0xB0
sPymbed 0:94df05e3330d 160 #define Com_GetLCDMode 0xB1
sPymbed 0:94df05e3330d 161
sPymbed 0:94df05e3330d 162 #define Com_SetHoriPeriod 0xB4
sPymbed 0:94df05e3330d 163 #define Com_GetHoriPeriod 0xB5
sPymbed 0:94df05e3330d 164
sPymbed 0:94df05e3330d 165 #define Com_SetVertPeriod 0xB6
sPymbed 0:94df05e3330d 166 #define Com_GetVertPeriod 0xB7
sPymbed 0:94df05e3330d 167
sPymbed 0:94df05e3330d 168 #define Com_SetGPIOConf 0xB8
sPymbed 0:94df05e3330d 169 #define Com_GetGPIOConf 0xB9
sPymbed 0:94df05e3330d 170
sPymbed 0:94df05e3330d 171 #define Com_SetGPIOValue 0xBA
sPymbed 0:94df05e3330d 172
sPymbed 0:94df05e3330d 173 #define Com_GetGPIOStatus 0xBB
sPymbed 0:94df05e3330d 174
sPymbed 0:94df05e3330d 175 #define Com_SetPostProcessor 0xBC
sPymbed 0:94df05e3330d 176 #define Com_GetPostProcessor 0xBD
sPymbed 0:94df05e3330d 177
sPymbed 0:94df05e3330d 178 #define Com_SetPWMConf 0xBE
sPymbed 0:94df05e3330d 179 #define Com_GetPWMConf 0xBF
sPymbed 0:94df05e3330d 180
sPymbed 0:94df05e3330d 181 #define Com_SetLCDGenerator0 0xC0
sPymbed 0:94df05e3330d 182 #define Com_GetLCDGenerator0 0xC1
sPymbed 0:94df05e3330d 183
sPymbed 0:94df05e3330d 184 #define Com_SetLCDGenerator1 0xC2
sPymbed 0:94df05e3330d 185 #define Com_GetLCDGenerator1 0xC3
sPymbed 0:94df05e3330d 186
sPymbed 0:94df05e3330d 187 #define Com_SetLCDGenerator2 0xC4
sPymbed 0:94df05e3330d 188 #define Com_GetLCDGenerator2 0xC5
sPymbed 0:94df05e3330d 189
sPymbed 0:94df05e3330d 190 #define Com_SetLCDGenerator3 0xC6
sPymbed 0:94df05e3330d 191 #define Com_GetLCDGenerator3 0xC7
sPymbed 0:94df05e3330d 192
sPymbed 0:94df05e3330d 193 #define Com_SetDynamicBackLightConf 0xD0
sPymbed 0:94df05e3330d 194 #define Com_GetDynamicBackLightConf 0xD1
sPymbed 0:94df05e3330d 195
sPymbed 0:94df05e3330d 196 #define Com_SetDynamicBackLightThreshold 0xD4
sPymbed 0:94df05e3330d 197 #define Com_GetDynamicBackLightThreshold 0xD5
sPymbed 0:94df05e3330d 198
sPymbed 0:94df05e3330d 199 #define Com_SetPLLStart 0xE0
sPymbed 0:94df05e3330d 200
sPymbed 0:94df05e3330d 201 #define Com_SetPLLConfig 0xE2
sPymbed 0:94df05e3330d 202 #define Com_GetPLLConfig 0xE3
sPymbed 0:94df05e3330d 203
sPymbed 0:94df05e3330d 204 #define Com_GetPLLStatus 0xE4
sPymbed 0:94df05e3330d 205
sPymbed 0:94df05e3330d 206 #define Com_SetDeepSleepMode 0xE5
sPymbed 0:94df05e3330d 207
sPymbed 0:94df05e3330d 208 #define Com_GetPixelClock 0xE7
sPymbed 0:94df05e3330d 209 #define Com_SetPixelClock 0xE6
sPymbed 0:94df05e3330d 210
sPymbed 0:94df05e3330d 211 #define Com_SetPixelInterface 0xF0
sPymbed 0:94df05e3330d 212 #define Com_GetPixelInterface 0xF1
sPymbed 2:d8a9ebd28f0a 213
sPymbed 0:94df05e3330d 214 // End : SSD1963 Command ------------------------------------------------------
sPymbed 0:94df05e3330d 215
sPymbed 0:94df05e3330d 216 #define swap(a, b) { int16_t t = a; a = b; b = t; }
sPymbed 1:74bac5f988d8 217 #define LOW 0
sPymbed 1:74bac5f988d8 218 #define HIGH 1
sPymbed 0:94df05e3330d 219
sPymbed 2:d8a9ebd28f0a 220 class SSD1963 : public LCD {
sPymbed 0:94df05e3330d 221 public:
sPymbed 3:31ca3cd96572 222 SSD1963(PinName CS, PinName RESET, PinName RS, PinName WR, BusInOut* DATA_PORT, PinName RD, PinName BL = NC, backlight_t blType = Constant);
sPymbed 0:94df05e3330d 223 void begin(void);
sPymbed 0:94df05e3330d 224 void reset(void);
sPymbed 2:d8a9ebd28f0a 225
sPymbed 2:d8a9ebd28f0a 226 uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
sPymbed 2:d8a9ebd28f0a 227
sPymbed 2:d8a9ebd28f0a 228 protected:
sPymbed 2:d8a9ebd28f0a 229 /** Assigns a chunk of the display memory to receive data.
sPymbed 2:d8a9ebd28f0a 230 *
sPymbed 2:d8a9ebd28f0a 231 * When data is sent to the display after this function completes, the opertion will
sPymbed 2:d8a9ebd28f0a 232 * start from the begining of the assigned address (pixel position) and the pointer
sPymbed 2:d8a9ebd28f0a 233 * will be automatically incremented so that the next data write operation will continue
sPymbed 2:d8a9ebd28f0a 234 * with the next pixel from the memory block. If more data is written than available
sPymbed 2:d8a9ebd28f0a 235 * pixels, at the end of the block the pointer will jump back to its beginning and
sPymbed 2:d8a9ebd28f0a 236 * commence again, until the next address change command is sent to the display.
sPymbed 2:d8a9ebd28f0a 237 *
sPymbed 2:d8a9ebd28f0a 238 * \param x1 The X coordinate of the pixel at the beginning of the block.
sPymbed 2:d8a9ebd28f0a 239 * \param y1 The Y coordinate of the pixel at the beginning of the block.
sPymbed 2:d8a9ebd28f0a 240 * \param x2 The X coordinate of the pixel at the end of the block.
sPymbed 2:d8a9ebd28f0a 241 * \param y2 The Y coordinate of the pixel at the end of the block.
sPymbed 2:d8a9ebd28f0a 242 * \remarks Addressing commands are controller-specific and this function needs to be
sPymbed 2:d8a9ebd28f0a 243 * implemented separately for each available controller.
sPymbed 2:d8a9ebd28f0a 244 */
sPymbed 2:d8a9ebd28f0a 245 virtual void SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 );
sPymbed 2:d8a9ebd28f0a 246
sPymbed 2:d8a9ebd28f0a 247 /** Sets the color of the pixel at the address pointer of the controller.
sPymbed 2:d8a9ebd28f0a 248 *
sPymbed 2:d8a9ebd28f0a 249 * This function is to be provided by each implementation separately in
sPymbed 2:d8a9ebd28f0a 250 * order to account for different color depth used by the controller.
sPymbed 2:d8a9ebd28f0a 251 * \param color The color of the pixel.
sPymbed 2:d8a9ebd28f0a 252 * \param mode The depth (palette) of the color.
sPymbed 2:d8a9ebd28f0a 253 */
sPymbed 2:d8a9ebd28f0a 254 virtual void SetPixelColor( unsigned int color, colordepth_t mode = RGB24 );
sPymbed 0:94df05e3330d 255
sPymbed 2:d8a9ebd28f0a 256 virtual void WriteData(unsigned short data);
sPymbed 2:d8a9ebd28f0a 257 virtual void WriteCmd(unsigned short cmd);
sPymbed 0:94df05e3330d 258 uint16_t readData(void);
sPymbed 0:94df05e3330d 259 void writeRegister(uint16_t addr, uint16_t data);
sPymbed 2:d8a9ebd28f0a 260
sPymbed 0:94df05e3330d 261 private:
sPymbed 1:74bac5f988d8 262 DigitalOut _lcd_pin_wr;
sPymbed 2:d8a9ebd28f0a 263 BusInOut* _lcd_port;
sPymbed 1:74bac5f988d8 264 DigitalOut _lcd_pin_rd;
sPymbed 0:94df05e3330d 265 };
sPymbed 0:94df05e3330d 266
sPymbed 0:94df05e3330d 267 #endif