Skip to content

Instantly share code, notes, and snippets.

@mathiasvr
mathiasvr / cie1931.py
Last active August 22, 2025 12:45
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/
from sys import stdout
TABLE_SIZE = 256 # Number of steps (brightness)
RESOLUTION = 2**10 # PWM resolution (10-bit = 1024)
@jirihnidek
jirihnidek / CMakeLists.txt
Last active December 15, 2024 22:01
Example of IPv6 TCP client-server application(s) using blocking sockets
# Main CMakeFile.txt
# Minimal version of CMake
cmake_minimum_required (VERSION 2.6)
# Build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui