Generate PWM Duty Table

Easy Python Math Asked at Microchip
Solve this problem

Produce a lookup table that maps a linear brightness input to PWM duty cycles corrected for the eye's logarithmic response, so a fade looks smooth.

Constraints

  • Table has 256 entries.
  • Output duty values are integers from 0 to the given resolution.
  • Use a gamma of 2.2.
  • Entry 0 must be 0 and entry 255 must be the maximum duty.
  • The table must be non-decreasing.
  • No numpy.
Starter codePython
1def gamma_table(max_duty=255, gamma=2.2):2    # TODO3    return []