import ( "fmt" "math" "strings" ) func printGammaTable(start, end int, gamma float64) { g_s := strings.ReplaceAll(fmt.Sprintf("%1.1f", gamma), ".", "_") fmt.Printf("\nconst uint8_t PROGMEM gamma_%s_%dto%d_table[] = {\n", g_s, start, end) for x := 0; x < 256; x++ { if (x)%16 == 0 { fmt.Print(" ") } fmt.Printf("%3d", int(math.Round(math.Pow(float64(x)/255, gamma)*float64(end-start)))+start) if x < 255 { fmt.Print(",") } if (x+1)%16 == 0 { fmt.Print("\n") } } fmt.Println("};") } func main() { for gamma := 2.2; gamma < 4; gamma += 0.2 { printGammaTable(0, 255, gamma) printGammaTable(1, 255, gamma) } }