[NV14] Fix ST7796S LCD controller detection and colors, show LCD controller type on version screen (#1294)
show LCD controller type on NV14 radio version screen fix ST7796S LCD controller detection fix ST7796S driven displays to show correct colors fix NV14 lcd_driver.cpp compiler warning
This commit is contained in:
@@ -207,6 +207,10 @@ RadioVersionPage::RadioVersionPage():
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern uint32_t NV14internalModuleFwVersion;
|
extern uint32_t NV14internalModuleFwVersion;
|
||||||
|
#if defined(PCBNV14)
|
||||||
|
extern const char* boardLcdType;
|
||||||
|
#endif
|
||||||
|
|
||||||
void RadioVersionPage::build(FormWindow * window)
|
void RadioVersionPage::build(FormWindow * window)
|
||||||
{
|
{
|
||||||
FormGridLayout grid;
|
FormGridLayout grid;
|
||||||
@@ -238,6 +242,12 @@ void RadioVersionPage::build(FormWindow * window)
|
|||||||
auto options = new OptionsText(window, grid.getFieldSlot(1,0));
|
auto options = new OptionsText(window, grid.getFieldSlot(1,0));
|
||||||
grid.nextLine(options->height() + 4);
|
grid.nextLine(options->height() + 4);
|
||||||
|
|
||||||
|
#if defined(PCBNV14) && !defined(SIMU)
|
||||||
|
new StaticText(window, grid.getLabelSlot(), "LCD:");
|
||||||
|
new StaticText(window, grid.getFieldSlot(), boardLcdType);
|
||||||
|
grid.nextLine();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(AFHDS2)
|
#if defined(AFHDS2)
|
||||||
new StaticText(window, grid.getLabelSlot(), "RF FW:");
|
new StaticText(window, grid.getLabelSlot(), "RF FW:");
|
||||||
sprintf(reusableBuffer.moduleSetup.msg, "%d.%d.%d", (int)((NV14internalModuleFwVersion >> 16) & 0xFF), (int)((NV14internalModuleFwVersion >> 8) & 0xFF), (int)(NV14internalModuleFwVersion & 0xFF));
|
sprintf(reusableBuffer.moduleSetup.msg, "%d.%d.%d", (int)((NV14internalModuleFwVersion >> 16) & 0xFF), (int)((NV14internalModuleFwVersion >> 8) & 0xFF), (int)(NV14internalModuleFwVersion & 0xFF));
|
||||||
|
|||||||
@@ -623,11 +623,13 @@ void LCD_ILI9481_Off(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int LCD_ILI9481_ReadID(void) {
|
unsigned int LCD_ILI9481_ReadID(void) {
|
||||||
|
#if 1
|
||||||
|
/* Have a issue here */
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
int ID = 0;
|
int ID = 0;
|
||||||
int Data;
|
int Data;
|
||||||
|
|
||||||
/* Have a issue here */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
lcdWriteByte(0, 0xBF);
|
lcdWriteByte(0, 0xBF);
|
||||||
|
|
||||||
@@ -647,6 +649,7 @@ unsigned int LCD_ILI9481_ReadID(void) {
|
|||||||
lcdWriteData(0x82);
|
lcdWriteData(0x82);
|
||||||
//lcdWriteData( 0x9b );
|
//lcdWriteData( 0x9b );
|
||||||
return (ID);
|
return (ID);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCD_ILI9486_On(void) {
|
void LCD_ILI9486_On(void) {
|
||||||
@@ -978,113 +981,106 @@ void LCD_ST7796S_On(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LCD_ST7796S_Init(void) {
|
void LCD_ST7796S_Init(void) {
|
||||||
lcdWriteCommand(0XFB);
|
|
||||||
lcdWriteData(0x00);
|
|
||||||
|
|
||||||
lcdWriteCommand(0x11);
|
|
||||||
delay_ms(120);
|
delay_ms(120);
|
||||||
lcdWriteCommand(0x13);
|
|
||||||
|
|
||||||
lcdWriteCommand(0xf0);
|
lcdWriteCommand( 0x11 );
|
||||||
lcdWriteData(0xc3);
|
delay_ms(120);
|
||||||
lcdWriteCommand(0xf0);
|
lcdWriteCommand( 0xF0 );
|
||||||
lcdWriteData(0x96);
|
lcdWriteData( 0xC3 );
|
||||||
|
|
||||||
lcdWriteCommand(0x36);
|
lcdWriteCommand( 0xF0 );
|
||||||
|
lcdWriteData( 0x96 );
|
||||||
|
|
||||||
#if defined( LCD_DIRECTION ) && ( LCD_DIRECTION == LCD_VERTICAL )
|
lcdWriteCommand( 0x36 );
|
||||||
|
lcdWriteData( 0x88 );
|
||||||
|
|
||||||
lcdWriteData( 0x08 );
|
lcdWriteCommand( 0x3A );
|
||||||
|
lcdWriteData( 0x66 );
|
||||||
|
|
||||||
#else
|
//SET RGB STRAT
|
||||||
#if defined( LCD_DEBUG ) && ( LCD_DEBUG == ON )
|
lcdWriteCommand (0xB0 ); //SET HS VS DE CLK 上升还是下降有效
|
||||||
lcdWriteData( 0xcc );
|
lcdWriteData( 0x80 );
|
||||||
#else
|
|
||||||
lcdWriteData(0xb8);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
lcdWriteCommand( 0xB4 );
|
||||||
|
lcdWriteData( 0x01 );
|
||||||
|
|
||||||
lcdWriteCommand(0x3A);
|
lcdWriteCommand( 0xB6 );
|
||||||
lcdWriteData(0x65);
|
lcdWriteData( 0x20 );
|
||||||
|
lcdWriteData( 0x02 );
|
||||||
|
lcdWriteData( 0x3B );
|
||||||
|
//SET RGB END
|
||||||
|
|
||||||
lcdWriteCommand(0xB4);
|
lcdWriteCommand( 0xB7);
|
||||||
lcdWriteData(0x01);
|
lcdWriteData( 0xC6);
|
||||||
|
|
||||||
lcdWriteCommand(0xb5);
|
lcdWriteCommand( 0xB9 );
|
||||||
lcdWriteData (VERTICAL_FRONT_PORCH);
|
lcdWriteData( 0x02 );
|
||||||
lcdWriteData(VERTICAL_BACK_PORCH + VERTICAL_SYNC_HEIGHT);
|
lcdWriteData( 0xE0 );
|
||||||
lcdWriteData(0x00);
|
|
||||||
lcdWriteData(HORIZONTAL_BACK_PORCH + 4);
|
|
||||||
|
|
||||||
lcdWriteCommand(0xb6);
|
lcdWriteCommand( 0xC0 );
|
||||||
lcdWriteData(0xe0);
|
lcdWriteData( 0x80 );
|
||||||
lcdWriteData(0x42);
|
lcdWriteData( 0x65 );
|
||||||
lcdWriteData(0x3b);
|
|
||||||
|
|
||||||
lcdWriteCommand(0xB7);
|
lcdWriteCommand( 0xC1 );
|
||||||
lcdWriteData(0x66);
|
lcdWriteData( 0x0D );
|
||||||
|
|
||||||
lcdWriteCommand(0xe8);
|
lcdWriteCommand( 0xC2 );
|
||||||
lcdWriteData(0x40);
|
lcdWriteData( 0xA7 );
|
||||||
lcdWriteData(0x8a);
|
|
||||||
lcdWriteData(0x00);
|
|
||||||
lcdWriteData(0x00);
|
|
||||||
lcdWriteData(0x29);
|
|
||||||
lcdWriteData(0x19);
|
|
||||||
lcdWriteData(0xa5);
|
|
||||||
lcdWriteData(0x33);
|
|
||||||
|
|
||||||
lcdWriteCommand(0xc1);
|
lcdWriteCommand( 0xC5 );
|
||||||
lcdWriteData(0x06);
|
lcdWriteData( 0x14 );
|
||||||
|
|
||||||
lcdWriteCommand(0xc2);
|
lcdWriteCommand( 0xE8 );
|
||||||
lcdWriteData(0xa7);
|
lcdWriteData( 0x40 );
|
||||||
|
lcdWriteData( 0x8A );
|
||||||
|
lcdWriteData( 0x00 );
|
||||||
|
lcdWriteData( 0x00 );
|
||||||
|
lcdWriteData( 0x29 );
|
||||||
|
lcdWriteData( 0x19 );
|
||||||
|
lcdWriteData( 0xA5 );
|
||||||
|
lcdWriteData( 0x33 );
|
||||||
|
|
||||||
lcdWriteCommand(0xc5);
|
lcdWriteCommand( 0xE0 );
|
||||||
lcdWriteData(0x18);
|
lcdWriteData( 0xD0 );
|
||||||
|
lcdWriteData( 0x00 );
|
||||||
|
lcdWriteData( 0x04 );
|
||||||
|
lcdWriteData( 0x05 );
|
||||||
|
lcdWriteData( 0x04 );
|
||||||
|
lcdWriteData( 0x21 );
|
||||||
|
lcdWriteData( 0x25 );
|
||||||
|
lcdWriteData( 0x43 );
|
||||||
|
lcdWriteData( 0x3F );
|
||||||
|
lcdWriteData( 0x37 );
|
||||||
|
lcdWriteData( 0x13 );
|
||||||
|
lcdWriteData( 0x13 );
|
||||||
|
lcdWriteData( 0x29 );
|
||||||
|
lcdWriteData( 0x32 );
|
||||||
|
|
||||||
lcdWriteCommand(0xe0); //Positive Voltage Gamma Control
|
lcdWriteCommand( 0xE1 );
|
||||||
lcdWriteData(0xf0);
|
lcdWriteData( 0xD0 );
|
||||||
lcdWriteData(0x09);
|
lcdWriteData( 0x04 );
|
||||||
lcdWriteData(0x0b);
|
lcdWriteData( 0x06 );
|
||||||
lcdWriteData(0x06);
|
lcdWriteData( 0x09 );
|
||||||
lcdWriteData(0x04);
|
lcdWriteData( 0x06 );
|
||||||
lcdWriteData(0x15);
|
lcdWriteData( 0x03 );
|
||||||
lcdWriteData(0x2f);
|
lcdWriteData( 0x25 );
|
||||||
lcdWriteData(0x54);
|
lcdWriteData( 0x32 );
|
||||||
lcdWriteData(0x42);
|
lcdWriteData( 0x3E );
|
||||||
lcdWriteData(0x3c);
|
lcdWriteData( 0x18 );
|
||||||
lcdWriteData(0x17);
|
lcdWriteData( 0x15 );
|
||||||
lcdWriteData(0x14);
|
lcdWriteData( 0x15 );
|
||||||
lcdWriteData(0x18);
|
lcdWriteData( 0x2B );
|
||||||
lcdWriteData(0x1b);
|
lcdWriteData( 0x30 );
|
||||||
|
|
||||||
lcdWriteCommand(0xe1); //Negative Voltage Gamma Control
|
lcdWriteCommand( 0xF0 );
|
||||||
lcdWriteData(0xf0);
|
lcdWriteData( 0x3C );
|
||||||
lcdWriteData(0x09);
|
|
||||||
lcdWriteData(0x0b);
|
|
||||||
lcdWriteData(0x06);
|
|
||||||
lcdWriteData(0x04);
|
|
||||||
lcdWriteData(0x03);
|
|
||||||
lcdWriteData(0x2d);
|
|
||||||
lcdWriteData(0x43);
|
|
||||||
lcdWriteData(0x42);
|
|
||||||
lcdWriteData(0x3b);
|
|
||||||
lcdWriteData(0x16);
|
|
||||||
lcdWriteData(0x14);
|
|
||||||
lcdWriteData(0x17);
|
|
||||||
lcdWriteData(0x1b);
|
|
||||||
|
|
||||||
lcdWriteCommand(0xf0);
|
lcdWriteCommand( 0xF0 );
|
||||||
lcdWriteData(0x3c);
|
lcdWriteData( 0x69 );
|
||||||
lcdWriteCommand(0xf0);
|
|
||||||
lcdWriteData(0x69);
|
|
||||||
|
|
||||||
delay_ms(5);
|
delay_ms(120);
|
||||||
lcdWriteCommand(0x28);
|
|
||||||
//lcdWriteCommand( 0x29 );
|
lcdWriteCommand( 0x21 );
|
||||||
lcdWriteCommand(0x2C);
|
|
||||||
|
|
||||||
LCD_ST7796S_On();
|
LCD_ST7796S_On();
|
||||||
}
|
}
|
||||||
@@ -1094,37 +1090,33 @@ void LCD_ST7796S_Off(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int LCD_ST7796S_ReadID(void) {
|
unsigned int LCD_ST7796S_ReadID(void) {
|
||||||
int ID = 0;
|
unsigned int ID = 0;
|
||||||
|
|
||||||
lcdWriteCommand(0XF7);
|
lcdWriteCommand( 0XF0 );
|
||||||
lcdWriteData(0xA9);
|
lcdWriteData( 0XC3 );
|
||||||
lcdWriteData(0x51);
|
lcdWriteCommand( 0XF0 );
|
||||||
lcdWriteData(0x2C);
|
lcdWriteData( 0X96 );
|
||||||
lcdWriteData(0x82);
|
|
||||||
lcdWriteCommand(0XB0);
|
|
||||||
lcdWriteData(0X80);
|
|
||||||
|
|
||||||
lcdWriteCommand(0XFB);
|
lcdWriteCommand( 0XB0 );
|
||||||
lcdWriteData(0x10 | 0x00);
|
lcdWriteData( 0X80 );
|
||||||
ID = LCD_ReadRegister(0xd3);
|
|
||||||
|
|
||||||
lcdWriteCommand(0XFB);
|
lcdWriteCommand( 0XD3 );
|
||||||
lcdWriteData(0x10 | 0x01);
|
|
||||||
ID = LCD_ReadRegister(0xd3);
|
|
||||||
|
|
||||||
lcdWriteCommand(0XFB);
|
SET_LCD_CLK_OUTPUT();
|
||||||
lcdWriteData(0x10 | 0x02);
|
SET_LCD_DATA_INPUT();
|
||||||
ID = LCD_ReadRegister(0xd3);
|
CLR_LCD_CLK();
|
||||||
ID <<= 8;
|
LCD_DELAY();
|
||||||
lcdWriteCommand(0XFB);
|
LCD_DELAY();
|
||||||
lcdWriteData(0x10 | 0x03);
|
SET_LCD_CLK();
|
||||||
ID |= LCD_ReadRegister(0xd3);
|
LCD_DELAY();
|
||||||
|
LCD_DELAY();
|
||||||
|
|
||||||
lcdWriteCommand(0XFB);
|
LCD_ReadByte();
|
||||||
lcdWriteData(0x00);
|
ID += (uint16_t)(LCD_ReadByte())<<8;
|
||||||
|
ID += LCD_ReadByte();
|
||||||
|
|
||||||
return (ID);
|
return (ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcdReset() {
|
static void lcdReset() {
|
||||||
LCD_NRST_HIGH();
|
LCD_NRST_HIGH();
|
||||||
@@ -1294,6 +1286,7 @@ void LCD_LayerInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern void loadFonts();
|
extern void loadFonts();
|
||||||
|
const char* boardLcdType = "";
|
||||||
|
|
||||||
void LCD_SetLayer(uint32_t layer)
|
void LCD_SetLayer(uint32_t layer)
|
||||||
{
|
{
|
||||||
@@ -1326,30 +1319,37 @@ void lcdInit(void) {
|
|||||||
/* Send LCD initializaiton commands */
|
/* Send LCD initializaiton commands */
|
||||||
if (LCD_ILI9481_ReadID() == LCD_ILI9481_ID) {
|
if (LCD_ILI9481_ReadID() == LCD_ILI9481_ID) {
|
||||||
TRACE("LCD INIT: ILI9481");
|
TRACE("LCD INIT: ILI9481");
|
||||||
|
boardLcdType = "ILI9481";
|
||||||
lcdInitFunction = LCD_ILI9481_Init;
|
lcdInitFunction = LCD_ILI9481_Init;
|
||||||
lcdOffFunction = LCD_ILI9481_Off;
|
lcdOffFunction = LCD_ILI9481_Off;
|
||||||
lcdOnFunction = LCD_ILI9481_On;
|
lcdOnFunction = LCD_ILI9481_On;
|
||||||
} else if (LCD_ILI9486_ReadID() == LCD_ILI9486_ID) {
|
} else if (LCD_ILI9486_ReadID() == LCD_ILI9486_ID) {
|
||||||
TRACE("LCD INIT: ILI9486");
|
TRACE("LCD INIT: ILI9486");
|
||||||
|
boardLcdType = "ILI9486";
|
||||||
lcdInitFunction = LCD_ILI9486_Init;
|
lcdInitFunction = LCD_ILI9486_Init;
|
||||||
lcdOffFunction = LCD_ILI9486_Off;
|
lcdOffFunction = LCD_ILI9486_Off;
|
||||||
lcdOnFunction = LCD_ILI9486_On;
|
lcdOnFunction = LCD_ILI9486_On;
|
||||||
} else if (LCD_ILI9488_ReadID() == LCD_ILI9488_ID) {
|
} else if (LCD_ILI9488_ReadID() == LCD_ILI9488_ID) {
|
||||||
TRACE("LCD INIT: ILI9488");
|
TRACE("LCD INIT: ILI9488");
|
||||||
|
boardLcdType = "ILI9488";
|
||||||
lcdInitFunction = LCD_ILI9488_Init;
|
lcdInitFunction = LCD_ILI9488_Init;
|
||||||
lcdOffFunction = LCD_ILI9488_Off;
|
lcdOffFunction = LCD_ILI9488_Off;
|
||||||
lcdOnFunction = LCD_ILI9488_On;
|
lcdOnFunction = LCD_ILI9488_On;
|
||||||
} else if (LCD_HX8357D_ReadID() == LCD_HX8357D_ID) {
|
} else if (LCD_HX8357D_ReadID() == LCD_HX8357D_ID) {
|
||||||
|
TRACE("LCD INIT: HX8357D");
|
||||||
|
boardLcdType = "HX8357D";
|
||||||
lcdInitFunction = LCD_HX8357D_Init;
|
lcdInitFunction = LCD_HX8357D_Init;
|
||||||
lcdOffFunction = LCD_HX8357D_Off;
|
lcdOffFunction = LCD_HX8357D_Off;
|
||||||
lcdOnFunction = LCD_HX8357D_On;
|
lcdOnFunction = LCD_HX8357D_On;
|
||||||
TRACE("LCD INIT: HX8357D");
|
} else if (LCD_ST7796S_ReadID() == LCD_ST7796S_ID) {
|
||||||
} else { //if (LCD_ST7796S_ReadID() == LCD_ST7796S_ID)
|
|
||||||
/* Default is ST7796S */
|
|
||||||
TRACE("LCD INIT (default): ST7796S");
|
TRACE("LCD INIT (default): ST7796S");
|
||||||
|
boardLcdType = "ST7796S";
|
||||||
lcdInitFunction = LCD_ST7796S_Init;
|
lcdInitFunction = LCD_ST7796S_Init;
|
||||||
lcdOffFunction = LCD_ST7796S_Off;
|
lcdOffFunction = LCD_ST7796S_Off;
|
||||||
lcdOnFunction = LCD_ST7796S_On;
|
lcdOnFunction = LCD_ST7796S_On;
|
||||||
|
} else {
|
||||||
|
TRACE("LCD INIT: unknown LCD controller");
|
||||||
|
boardLcdType = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
lcdInitFunction();
|
lcdInitFunction();
|
||||||
|
|||||||
Reference in New Issue
Block a user