Skip to content

Instantly share code, notes, and snippets.

View mrcodetastic's full-sized avatar

mrcodetastic

View GitHub Profile
@mrcodetastic
mrcodetastic / cie1931.cpp
Last active March 16, 2025 00:45 — forked from mathiasvr/cie1931.py
Convert LED brightness to PWM value based on CIE 1931 curve.
// Generate lookup table for converting between perceived LED brightness and PWM
// Adapted from: https://jared.geek.nz/2013/feb/linear-led-pwm
// See also: https://ledshield.wordpress.com/2012/11/13/led-brightness-to-your-eye-gamma-correction-no/
#include <iostream>
#include <cmath>
#include <iomanip>
constexpr int TABLE_SIZE = 256; // Number of steps (brightness)