Skip to content

Commit

Permalink
update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Oct 26, 2023
1 parent 86b2001 commit 2258e39
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.4.1] - 2023-10-26
- update readme.md


## [0.4.0] - 2023-01-26
- optimize **setGamma()** especially for ESP32
- optimize **get[]** especially for ESP32
Expand Down
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/GAMMA/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/GAMMA/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/GAMMA/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/GAMMA/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/GAMMA/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/GAMMA.svg)](https://github.com/RobTillaart/GAMMA/issues)

[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/GAMMA/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/GAMMA.svg?maxAge=3600)](https://github.com/RobTillaart/GAMMA/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/GAMMA.svg)](https://registry.platformio.org/libraries/robtillaart/GAMMA)


# GAMMA
Expand All @@ -13,7 +16,7 @@ Arduino Library for the GAMMA function to adjust brightness of LED's etc.

## Description

This library is provides a gamma lookup class. It is typical used to
This library provides a GAMMA lookup class. It is typical used to
change the intensity / brightness of a LED to match the human eye.
When a LED is given 50% PWM it looks far brighter for the eye.

Expand All @@ -37,6 +40,12 @@ Since 0.2.2 the library also has **dumpArray()** to generate a C-style array.
Note: tested on UNO and ESP32 only.


#### Related

- https://en.wikipedia.org/wiki/Gamma_correction
- https://github.com/RobTillaart/map2colour


## Interface

```cpp
Expand All @@ -59,26 +68,26 @@ This can be done runtime so runtime adjustment of gamma mapping is possible.
This calculation are relative expensive and takes quite some time (depending on size).
If the array already is calculated for gamma, the calculation will be skipped.
The parameter **gamma** must be > 0. The value 1 gives an 1:1 mapping.
Returns false if gamma <= 0 or if no table is allocated.
Returns false if gamma <= 0 or if no array is allocated.
- **float getGamma()** returns the set gamma value.
- **uint8_t operator \[uint8_t index\]** allows the GAMMA object to be accessed as an array.
like ```x = G[40];``` Makes it easy to switch with a real array.
The value returned is in the range 0 .. 255, so the user may need to scale it e.g. to 0.0 - 1.0.
Note: if internal table not allocated the function returns 0.
Note: if internal array not allocated the function returns 0.
As this is a legitimate value the user should take care.


### Development functions

- **uint16_t size()** returns the size of the internal array.
This is always a power of 2.
- **uint16_t distinct()** returns the number of distinct values in the table.
Especially with larger internal tables there will be duplicate numbers in the table.
- **bool dump(Stream \*str = &Serial)** dumps the internal table to a stream, default Serial.
- **uint16_t distinct()** returns the number of distinct values in the internal array.
Especially with larger internal arrays there will be more duplicate numbers.
- **bool dump(Stream \*str = &Serial)** dumps the internal array to a stream, default Serial.
Useful to create an array in RAM, PROGMEM, EEPROM, in a file or wherever.
Returns false if no table is allocated.
- **void dumpArray(Stream \*str = &Serial)** dumps the internal table to a stream, default Serial, as a C-style array. See example.
Returns false if no table is allocated.
Returns false if no array is allocated.
- **void dumpArray(Stream \*str = &Serial)** dumps the internal array to a stream, default Serial, as a C-style array. See example.
Returns false if no array is allocated.


## Operation
Expand Down Expand Up @@ -110,3 +119,12 @@ See example.
- setGamma -> pow() is expensive
- setGamma(gamma) gamma = 1.0 is linear, less math (too specific?)


## Support

If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.

Thank you,

2 changes: 1 addition & 1 deletion gamma.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: gamma.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.4.1
// DATE: 2020-08-08
// PURPOSE: Arduino Library to efficiently hold a gamma lookup table

Expand Down
4 changes: 2 additions & 2 deletions gamma.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
//
// FILE: gamma.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.4.1
// DATE: 2020-08-08
// PURPOSE: Arduino Library to efficiently hold a gamma lookup table


#include "Arduino.h"

#define GAMMA_LIB_VERSION (F("0.4.0"))
#define GAMMA_LIB_VERSION (F("0.4.1"))

#define GAMMA_DEFAULT_SIZE 32
#define GAMMA_MAX_SIZE 256
Expand Down
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ GAMMA KEYWORD1
begin KEYWORD2
setGamma KEYWORD2
getGamma KEYWORD2

size KEYWORD2
distinct KEYWORD2

dump KEYWORD2
dumpArray KEYWORD2

Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/GAMMA.git"
},
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "gamma.h"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GAMMA
version=0.4.0
version=0.4.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino Library for the GAMMA function
Expand Down

0 comments on commit 2258e39

Please sign in to comment.