TS-8390-47XX Backlight: Difference between revisions

From embeddedTS Manuals
(Created page with "The backlight brightness can be adjusted by controlling the duty cycle of PWM on the processor DIO. This example takes an integer percentage as the only argument which will s...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The backlight brightness can be adjusted by controlling the duty cycle of PWM on the processor DIO.  This example takes an integer percentage as the only argument which will set the brightness.
The backlight brightness on our off the shelf LCD products use the LCD_PWM output.  This example takes an integer percentage as the only argument which will set the brightness.


<source lang=c>
<source lang=c>
/* Compile with:
* gcc name.c -o output -mcpu=arm9
*/
#include <stdio.h>
#include <stdio.h>
#include <stdint.h>
#include <stdint.h>

Latest revision as of 11:07, 25 March 2014

The backlight brightness on our off the shelf LCD products use the LCD_PWM output. This example takes an integer percentage as the only argument which will set the brightness.

/* Compile with:
 * gcc name.c -o output -mcpu=arm9
 */
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>

volatile uint32_t *mvpwmregs = 0;
void set_brightness(int pct) 
{
	if(mvpwmregs == 0) {
		int mem = open("/dev/mem", O_RDWR|O_SYNC);
		assert(mem != -1);
		mvpwmregs = (unsigned int *) mmap(0, 4096,
	  	  PROT_READ | PROT_WRITE, MAP_SHARED, mem, 0xd401a000);
	}

	// duty cycle floor is 57, max is 128
	mvpwmregs[0x004/4] = 57 + ((pct * 71)/100);
}

int main(int argc, char **argv)
{
	set_brightness(atoi(argv[1]));
	return 0;
}