Add brightness control to UTFT library

I'm deep into a large project using a 7" TFT displey with an SSD1963 controller. I'm using the UTFT library made by Henning Karlsen (UTFT - Rinky-Dink Electronics) and I'm naturally very grateful for his tremendous effort. The library has its limitations though, like there's no support for some functions for SSD1963.
I looked up the data sheet for SSD1963, found the command codes for turning on and off the LCD and added them to the library. It works great. Like so:

void UTFT::lcdOff()
{
	cbi(P_CS, B_CS);
	switch (display_model)
	{
	case PCF8833:
		LCD_Write_COM(0x28);
		break;
	case CPLD:
		LCD_Write_COM_DATA(0x01,0x0000);
		LCD_Write_COM(0x0F);   
		break;
	case CTE70: //added by me
		LCD_Write_COM(0x10);
		break;
	}
	sbi(P_CS, B_CS);
}

void UTFT::lcdOn()
{
	cbi(P_CS, B_CS);
	switch (display_model)
	{
	case PCF8833:
		LCD_Write_COM(0x29);
		break;
	case CPLD:
		LCD_Write_COM_DATA(0x01,0x0010);
		LCD_Write_COM(0x0F);   
		break;
	case CTE70:  // I added this part
		LCD_Write_COM(0x11);
		break;
	}
	sbi(P_CS, B_CS);
}

So that's pretty basic, just copy/pasting a command from the data sheet to the library since the LCD_Write_COM seems to work just fine.

But now I want to control the brightness of the backlight. It is, according to the data sheet, done by adjusting the PWM signal from one of the pins of the SSD1963:

Pin name: PWM Type: O Ref:VDDLCD Pin Nr:B5 or 51 Descr:PWM output for backlight driver
(datasheet page 14: https://pdf1.alldatasheet.com/datasheet-pdf/view/1179028/ETC2/SSD1963.html)

And so we reach the end of my understanding of how to speak to microcontrollers, pampered as I am by the Arduino environment. How do I send code to the SSD1963 that tells it to adjust the PWM output from that pin?

These are apparently the communication functions from the UTFT library:

void UTFT::LCD_Write_COM(char VL)  
{   
	if (display_transfer_mode!=1)
	{
		cbi(P_RS, B_RS);
		LCD_Writ_Bus(0x00,VL,display_transfer_mode);
	}
	else
		LCD_Writ_Bus(0x00,VL,display_transfer_mode);
}

void UTFT::LCD_Write_DATA(char VH,char VL)
{
	if (display_transfer_mode!=1)
	{
		sbi(P_RS, B_RS);
		LCD_Writ_Bus(VH,VL,display_transfer_mode);
	}
	else
	{
		LCD_Writ_Bus(0x01,VH,display_transfer_mode);
		LCD_Writ_Bus(0x01,VL,display_transfer_mode);
	}
}

void UTFT::LCD_Write_DATA(char VL)
{
	if (display_transfer_mode!=1)
	{
		sbi(P_RS, B_RS);
		LCD_Writ_Bus(0x00,VL,display_transfer_mode);
	}
	else
		LCD_Writ_Bus(0x01,VL,display_transfer_mode);
}

void UTFT::LCD_Write_COM_DATA(char com1,int dat1)
{
     LCD_Write_COM(com1);
     LCD_Write_DATA(dat1>>8,dat1);
}

void UTFT::LCD_Write_DATA_8(char VL)
{	
    sbi(P_RS, B_RS);
    LCD_Write_Bus_8(VL);
}

Hello

Did you try the pseudocode shown on page 71 of the datasheet ?

No, I didn't. I understood that code to be a way to set the mode for the operation of the PWM signal. Not a way to manipulate the PWM output itself? But I might be mistaken. Would that be the two first lines of code? With the PWM value being the second?

The hardware pin, PWM is the output signal from SSD1963 to the system backlight driver.  
So it should configure PWM module before enable DBC. 

WRITE COMMAND “0xBE” 
WRITE DATA “0x0E” (set PWM frequency) 
WRITE DATA “0xFF” (dummy value if DBC is used)
 WRITE DATA “0x09” (enable PWM controlled by DBC) 
WRITE DATA “0xFF” 
WRITE DATA “0x00” 
WRITE DATA “0x00” 
WRITE COMMAND “0xD4” (Define the threshold value) 
WRITE DATA ..... 
WRITE COMMAND “0xD0” 
WRITE DATA “0x0D”     (Enable DBC with Aggressive mode) 

Also, I don't fully understand what the "Dynamic Background Control" is. Do you?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.