-
Notifications
You must be signed in to change notification settings - Fork 2
Gamma
Most LCD Controllers has a way to adjust the brightness of the colours. This is to match LCD panels with different characteristics.
Some controllers have one table/curve and other have one positive and one negative.
Some FBTFT drivers has support for configurable gamma correction. The table/curve can be set with the gamma argument of fbtft_device or through /sys/class/graphics/fb1/gamma.
Format: Values are hexadecimal. Each value is separated by space or comma. Each row/curve is separated by semicolon or newline.
Usage
sudo modprobe fbtft_device name=ssd1351fb gamma=5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5
/bin/echo "5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5" > /sys/class/graphics/fb1/gamma
This controller has positive and negative Gamma correction values. Ref. 11. Gamma Correction
Gamma string format:
VRP0 VRP1 RP0 RP1 KP0 KP1 KP2 KP3 KP4 KP5 KP6
VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5 KN6
Default gamma
0F,00,7,2,0,0,6,5,4,1;04,16,2,7,6,3,2,1,7,7
Some Gamma curves collected by Richard Hull
-
http://spritesmods.com/rpi_arcade/ili9325_gpio_driver_rpi.diff
0C,03,5,2,0,0,3,2,1,0;08,10,2,5,7,6,5,4,7,7
-
http://pastebin.com/HDsQ2G35
08,04,6,2,7,1,6,3,7,2;03,05,4,5,6,1,2,1,7,2
-
http://andybrown.me.uk/wk/2012/01/01/stm32plus-ili9325-tft-driver/
02,0B,6,1,6,0,1,1,3,0;0B,02,0,6,2,3,7,7,7,0
-
http://mbed.org/forum/mbed/topic/3655/?page=1
08,08,6,2,0,0,0,0,0,0;00,00,0,0,7,0,1,2,0,0
This Python script was used to convert from register values to FBTFT gamma values:
a = [0x0000,0x0506,0x0104,0x0207,0x000F,0x0306,0x0102,0x0707,0x0702,0x1604] # Default
b = [0x0000,0x0203,0x0001,0x0205,0x030C,0x0607,0x0405,0x0707,0x0502,0x1008] # http://spritesmods.com/rpi_arcade/ili9325_gpio_driver_rpi.diff
c = [0x0107,0x0306,0x0207,0x0206,0x0408,0x0106,0x0102,0x0207,0x0504,0x0503] # http://pastebin.com/HDsQ2G35
d = [0x0006,0x0101,0x0003,0x0106,0x0b02,0x0302,0x0707,0x0007,0x0600,0x020b] # http://andybrown.me.uk/wk/2012/01/01/stm32plus-ili9325-tft-driver/
e = [0x0000,0x0000,0x0000,0x0206,0x0808,0x0007,0x0201,0x0000,0x0000,0x0000] # http://mbed.org/forum/mbed/topic/3655/?page=1
def convert(reg):
print("%02X,%02X,%X,%X,%X,%X,%X,%X,%X,%X;%02X,%02X,%X,%X,%X,%X,%X,%X,%X,%X" %( reg[4]&0xFF, reg[4]>>8, reg[3]&0xFF, reg[3]>>8, reg[0]&0xFF, reg[0]>>8, reg[1]&0xFF, reg[1]>>8, reg[2]&0xFF, reg[2]>>8 , reg[9]&0xFF, reg[9]>>8, reg[8]&0xFF, reg[8]>>8, reg[5]&0xFF, reg[5]>>8, reg[6]&0xFF, reg[6]>>8, reg[7]&0xFF, reg[7]>>8 ))
convert(a)
convert(b)
convert(c)
convert(d)
convert(e)
This controller has one Grayscale Lookup Table with 63 values. Ref. 10.1.16 Look Up Table for Gray Scale Pulse width (B8h)
To make the table easier to manipulate, the values is relative to the previous value. The values are accumulated when written to the register. Max value is 180 decimal.
Default gamma
5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5