TLC9540 Gamma correction code

I have been messing with a 8x8 rgb matrix for a while. Got round to correcting the gamma this afternoon. This is the basic code you can use it's just a lookup table in PROGMEM.

/// GAMMA 2.5
#include <avr/pgmspace.h>
#include "Tlc5940.h"

prog_uint16_t Gamma [256] PROGMEM = {0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,4,4,5,6,6,7,8,9,11,12,13,14,16,17,19,20,22,24,26,28,30,32,34,37,39,42,44,47,50,53,56,59,62,65,69,72,76,79,83,87,91,95,100,104,108,113,118,123,128,133,138,143,148,154,160,165,171,177,184,190,196,203,209,216,223,230,237,245,252,260,267,275,283,291,300,308,317,325,334,343,352,361,371,380,390,400,410,420,430,441,451,462,473,484,495,507,518,530,542,553,566,578,590,603,616,629,642,655,668,682,696,710,724,738,752,767,781,796,811,827,842,858,873,889,905,922,938,955,972,988,1006,1023,1040,1058,1076,1094,1112,1131,1149,1168,1187,1206,1225,1245,1264,1284,1304,1325,1345,1366,1386,1407,1429,1450,1471,1493,1515,1537,1560,1582,1605,1628,1651,1674,1698,1721,1745,1769,1793,1818,1843,1867,1893,1918,1943,1969,1995,2021,2047,2074,2100,2127,2154,2182,2209,2237,2265,2293,2321,2350,2379,2408,2437,2466,2496,2526,2556,2586,2616,2647,2678,2709,2740,2772,2804,2836,2868,2900,2933,2966,2999,3032,3066,3099,3133,3168,3202,3237,3271,3306,3342,3377,3413,3449,3485,3522,3558,3595,3632,3670,3707,3745,3783,3821,3860,3898,3937,3977,4016,4056,4095};

int ledbrighness=0; // 0 -255
int lednumber=0;

void setup() {  }

void loop() {
Tlc.clear();
Tlc.set(lednumber,pgm_read_word_near(Gamma+ledbrighness));

Tlc.update();
}

I used a JBasic program i found on a forum to figure out the lookup table. Download JBasic for free and run it to get other tables for diffident ranges and gamma levels.

'  Maxim Gamma Correction Algorithm
'
'  JustBASIC (free) interpreter
'
Input "Gamma array size: "; arraysize
Input " Total PWM steps: "; width
Input "Gamma correction: "; gamma       ' maxim uses 2.5

FOR index = 0 to arraysize-1
  dcyval = INT(width*(((width/arraysize*(index+1))/width)^gamma))
  if(index = 0) then
    PRINT
  else
    if(index MOD 10 = 0) then
      PRINT ","
    else
      PRINT ",";
    end if
  end if
  if(dcyval < 100) then print " ";
  if(dcyval < 10) then print " ";
  PRINT dcyval;
NEXT index
PRINT

REM CLOSE

Hope this is helpful.