{"id":13893846,"url":"https://github.com/RobTillaart/GAMMA","last_synced_at":"2025-07-17T08:31:07.800Z","repository":{"id":45355839,"uuid":"286303853","full_name":"RobTillaart/GAMMA","owner":"RobTillaart","description":"Arduino Library for the GAMMA function to adjust brightness of LED's etc.","archived":false,"fork":false,"pushed_at":"2024-04-13T09:00:49.000Z","size":39,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-19T06:34:29.460Z","etag":null,"topics":["arduino","correction","gamma"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobTillaart.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"RobTillaart","custom":"https://www.paypal.me/robtillaart"}},"created_at":"2020-08-09T19:31:02.000Z","updated_at":"2024-10-05T01:00:43.000Z","dependencies_parsed_at":"2024-04-19T04:16:04.642Z","dependency_job_id":null,"html_url":"https://github.com/RobTillaart/GAMMA","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FGAMMA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FGAMMA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FGAMMA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FGAMMA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobTillaart","download_url":"https://codeload.github.com/RobTillaart/GAMMA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226243893,"owners_count":17594452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","correction","gamma"],"created_at":"2024-08-06T18:01:18.377Z","updated_at":"2024-11-24T22:30:38.392Z","avatar_url":"https://github.com/RobTillaart.png","language":"C++","funding_links":["https://github.com/sponsors/RobTillaart","https://www.paypal.me/robtillaart"],"categories":["C++"],"sub_categories":[],"readme":"\n[![Arduino CI](https://github.com/RobTillaart/GAMMA/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)\n[![Arduino-lint](https://github.com/RobTillaart/GAMMA/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/GAMMA/actions/workflows/arduino-lint.yml)\n[![JSON check](https://github.com/RobTillaart/GAMMA/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/GAMMA/actions/workflows/jsoncheck.yml)\n[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/GAMMA.svg)](https://github.com/RobTillaart/GAMMA/issues)\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/GAMMA/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/RobTillaart/GAMMA.svg?maxAge=3600)](https://github.com/RobTillaart/GAMMA/releases)\n[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/GAMMA.svg)](https://registry.platformio.org/libraries/robtillaart/GAMMA)\n\n\n# GAMMA\n\nArduino Library for the GAMMA function to adjust brightness of LED's etc.\n\n\n## Description\n\nThis library provides a GAMMA lookup class. It is typical used to\nchange the intensity / brightness of a LED to match the human eye.\nWhen a LED is given 50% PWM it looks far brighter for the eye.\n\nThis lib provides a balance between an expensive math function and the speed\nof a lookup table.\n\nThe accuracy of the library depends on the size of the internal array.\nA size of 256 is the reference. Smaller arrays use interpolation and\nthese interpolated values are good (\u003c 1%) down to internal array size 16.\nThe size can be as small as 2 which is pretty inaccurate.\nIn this latter case the curve is approximated by only two linear interpolations.\nIn short, choose the size that fits your application.\n\nThe library has a **setGamma(float gamma)** function that allows an application\nto change the gamma value runtime.\nThis allows adjustments that are not possible with a fixed table.\n\nThe class provides **dump()** to create a table e.g. to place in PROGMEM.\nSince 0.2.2 the library also has **dumpArray()** to generate a C-style array.\n\nNote: tested on UNO and ESP32 only.\n\n\n#### Related\n\n- https://en.wikipedia.org/wiki/Gamma_correction\n- https://github.com/RobTillaart/map2colour\n\n\n## Interface\n\n```cpp\n#include \"gamma.h\"\n```\n\n### Core functions\n\n- **GAMMA(uint16_t size = 32)** constructor, gets the size of the internal\narray as parameter. The default for size = 32 as this is a good balance between performance\nand size of the internal array.\nThe size parameter must be in {2, 4, 8, 16, 32, 64, 128, 256 }.\n- **~GAMMA()** destructor.\n- **bool begin()** The internal array is allocated and initialized with a gamma == 2.8.\nThis is an often used value to adjust light to human eye responses.\nNote that **begin()** must be called before any other function.\nReturns false if allocation fails.\n- **void setGamma(float gamma)** calculates and fills the array with new values.\nThis can be done runtime so runtime adjustment of gamma mapping is possible.\nThis calculation are relative expensive and takes quite some time (depending on size).\nIf the array already is calculated for gamma, the calculation will be skipped.\nThe parameter **gamma** must be \u003e 0. The value 1 gives an 1:1 mapping.\nReturns false if gamma \u003c= 0 or if no array is allocated.\n- **float getGamma()** returns the set gamma value.\n- **uint8_t operator \\[uint8_t index\\]** allows the GAMMA object to be accessed as an array.\nlike ```x = G[40];``` Makes it easy to switch with a real array.\nThe value returned is in the range 0 .. 255, so the user may need to scale it e.g. to 0.0 - 1.0.\nNote: if internal array not allocated the function returns 0.\nAs this is a legitimate value the user should take care.\n\n\n### Development functions\n\n- **uint16_t size()** returns the size of the internal array.\nThis is always a power of 2.\n- **uint16_t distinct()** returns the number of distinct values in the internal array.\nEspecially with larger internal arrays there will be more duplicate numbers.\n- **bool dump(Stream \\*str = \u0026Serial)** dumps the internal array to a stream, default Serial.\nUseful to create an array in RAM, PROGMEM, EEPROM, in a file or wherever.\nReturns false if no array is allocated.\n- **void dumpArray(Stream \\*str = \u0026Serial)** dumps the internal array to a stream, default Serial, as a C-style array. See example.\nReturns false if no array is allocated.\n\n\n## Operation\n\nSee example.\n\n\n## Future ideas\n\n#### Must\n\n- improve documentation\n\n#### Should\n\n- test other platforms\n\n#### Could\n\n- uint16 version?\n  - GAMMA16,\n  - GAMMA32,\n  - GAMMA_RGB ?\n\n#### Wont\n\n- look for optimizations (done in 0.4.0)\n  - getter \\[\\]\n  - setGamma -\u003e pow() is expensive\n  - setGamma(gamma)  gamma = 1.0 is linear, less math (too specific?)\n\n\n## Support\n\nIf you appreciate my libraries, you can support the development and maintenance.\nImprove the quality of the libraries by providing issues and Pull Requests, or\ndonate through PayPal or GitHub sponsors.\n\nThank you,\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobTillaart%2FGAMMA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRobTillaart%2FGAMMA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobTillaart%2FGAMMA/lists"}