Skip to content

Commit 4c4eaf0

Browse files
committed
0.3.0 Kelvin2RGB
1 parent 792ea0d commit 4c4eaf0

File tree

8 files changed

+64
-29
lines changed

8 files changed

+64
-29
lines changed

libraries/Kelvin2RGB/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9-
## [0.2.0] - 2023-02-19
9+
## [0.3.0] - 2025-02-01
10+
- remove **reset()**
11+
- update readme.md + comments
12+
- minor edits
13+
14+
----
15+
16+
## [0.2.0] - 2024-02-19
1017
- fix in Tanner Helland (very minor).
1118
- remove dead link from readme.md.
1219
- removed experimental from code.

libraries/Kelvin2RGB/Kelvin2RGB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: Kelvin2RGB.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.2.0
4+
// VERSION: 0.3.0
55
// DATE: 2018-01-31
66
// PURPOSE: Arduino library for converting temperature to RGB values
77
// URL: https://github.com/RobTillaart/Kelvin2RGB
@@ -22,7 +22,7 @@ Kelvin2RGB::Kelvin2RGB()
2222
void Kelvin2RGB::begin()
2323
{
2424
_temperature = 0;
25-
_brightness = 0; // default = darkness
25+
_brightness = 0; // default == darkness
2626
_red = 0;
2727
_green = 0;
2828
_blue = 0;

libraries/Kelvin2RGB/Kelvin2RGB.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
//
33
// FILE: Kelvin2RGB.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.2.0
5+
// VERSION: 0.3.0
66
// DATE: 2018-01-31
77
// PURPOSE: Arduino library for converting temperature to RGB values
88
// URL: https://github.com/RobTillaart/Kelvin2RGB
99

1010

11-
#define KELVIN2RGB_LIB_VERSION (F("0.2.0"))
11+
#define KELVIN2RGB_LIB_VERSION (F("0.3.0"))
1212

1313
#include "Arduino.h"
1414

@@ -19,7 +19,7 @@
1919

2020

2121

22-
// Values in table below based on
22+
// Values in table below based on
2323
// https://en.wikipedia.org/wiki/Color_temperature#Categorizing_different_lighting
2424
//
2525
// DAY LIGHT SETTING = TEMPERATURE
@@ -57,12 +57,11 @@ class Kelvin2RGB
5757

5858
// resets all variables to zero.
5959
void begin();
60-
[[deprecated("Use begin() instead")]]
61-
void reset() { begin(); }; // obsolete 0.3.0
60+
6261

6362
// temperature = 0..65500 brightness = 0.0 .. 100.0%
64-
void convert_TH(float temperature, float brightness = 100.0);
65-
void convert_NB(float temperature, float brightness = 100.0);
63+
void convert_TH(float temperature, float brightness = 100.0); // Tanner-Helland algorithm
64+
void convert_NB(float temperature, float brightness = 100.0); // Neil Bartlett algorithm
6665

6766
float temperature();
6867
float brightness();
@@ -77,10 +76,11 @@ class Kelvin2RGB
7776
// returns RGB.
7877
uint32_t setRGB(float red, float green, float blue, float brightness = 100.0);
7978

80-
uint32_t RGB(); // 32 bit colour (only 3 bytes used)
81-
uint16_t RGB565(); // 16 bit colour (2 bytes)
82-
uint32_t BGR();
83-
uint32_t CMYK();
79+
// other color schemes, more space efficient as 3 floats.
80+
uint32_t RGB(); // 32 bit colour (3 bytes used)
81+
uint16_t RGB565(); // 16 bit colour (2 bytes, compact)
82+
uint32_t BGR(); // 32 bit colour (3 bytes used)
83+
uint32_t CMYK(); // 32 bit colour (4 bytes used)
8484

8585

8686
private:

libraries/Kelvin2RGB/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2024 Rob Tillaart
3+
Copyright (c) 2018-2025 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/Kelvin2RGB/README.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Kelvin2RGB
1313

14-
Arduino library for converting temperature and brightness to RGB values.
14+
Arduino library for converting Kelvin temperature and brightness to RGB values.
1515

1616

1717
## Credentials
@@ -62,20 +62,20 @@ Especially with images with more than 8 bits per channel this is preferred.
6262
That said it is also possible to use this on a 565 image or to adjust colour lookup tables.
6363

6464

65-
#### Celsius and Fahrenheit
65+
### Celsius and Fahrenheit
6666

6767
To use Celsius or Fahrenheit with the **Kelvin2RGB** library,
6868
one need to convert that temperature to Kelvin.
6969

7070
```cpp
7171
Kelvin = Celsius + 273.15;
72-
Kelvin = (Fahrenheit - 32) * 5 / 9 - 273.15;
72+
Kelvin = (Fahrenheit - 32) * 5.0 / 9.0 - 273.15;
7373
// or shorter
7474
Kelvin = (Fahrenheit - 523.67) * 0.5555555555;
7575
```
7676

7777

78-
#### Related
78+
### Related
7979

8080
- https://github.com/RobTillaart/Kelvin2RGB
8181
- https://github.com/RobTillaart/map2colour map float onto a colour(gradient).
@@ -90,14 +90,14 @@ Kelvin = (Fahrenheit - 523.67) * 0.5555555555;
9090

9191
The interface is straightforward:
9292

93-
#### Constructor
93+
### Constructor
9494

9595
- **Kelvin2RGB()** constructor.
9696
- **void begin()** resets all internal values to 0.
9797
All colours, brightness and temperature.
9898

9999

100-
#### Convertors
100+
### Convertors
101101

102102
- **void convert_TH(float temperature, float brightness = 100)**
103103
temperature = 0..65500 temperature below 1000 is not well defined.
@@ -114,7 +114,7 @@ The interface is straightforward:
114114
- **float blue()** returns blue channel weight 0.0 .. 1.0
115115

116116

117-
#### Color types
117+
### Color types
118118

119119
- **uint32_t setRGB(float red, float green, float blue, float brightness = 100)** sets RGB values
120120
red, green, blue should be in 0 .. 1.0 range. brightness should be in 0..100%, Default = 100%.
@@ -126,14 +126,41 @@ The interface is straightforward:
126126
- **uint32_t CMYK()** returns a 32 bit = 4 byte CMYK value,
127127

128128

129-
#### Obsolete
129+
### Obsolete
130130

131131
- **void reset()** => replaced by **begin()**
132132

133133

134134
## Predefined colors
135135

136136

137+
```cpp
138+
const uint16_t DLS_dark = 0;
139+
const uint16_t DLS_match = 1700;
140+
const uint16_t DLS_sodiumLamp = 1700;
141+
const uint16_t DLS_candleFlame = 1850;
142+
const uint16_t DLS_sunrise = 1850;
143+
const uint16_t DLS_sunset = 1850;
144+
const uint16_t DLS_bulb = 2400;
145+
const uint16_t DLS_bulbSoftWhite = 2550;
146+
const uint16_t DLS_LEDlamp = 2700;
147+
const uint16_t DLS_warmWhite = 3000;
148+
const uint16_t DLS_studioLight = 3200;
149+
const uint16_t DLS_studioCPlight = 3350;
150+
const uint16_t DLS_daylightHorizon = 5000;
151+
const uint16_t DLS_flashLight = 5700;
152+
const uint16_t DLS_xenonLight = 6200;
153+
const uint16_t DLS_dayLightBright = 6500;
154+
const uint16_t DLS_normal = 6500;
155+
const uint16_t DLS_screenLow = 6500;
156+
const uint16_t DLS_screenMed = 8000;
157+
const uint16_t DLS_screenHigh = 9500;
158+
const uint16_t DLS_polewardSky0 = 15000;
159+
const uint16_t DLS_polewardSky1 = 19000;
160+
const uint16_t DLS_polewardSky2 = 23000;
161+
const uint16_t DLS_polewardSky3 = 27000;
162+
```
163+
137164

138165
## Future
139166

@@ -149,7 +176,6 @@ The interface is straightforward:
149176
- investigate other formulas.
150177
- investigate usability for RGB led strip.
151178
- separate brightness per colour channel to mimic "artificial illumination"
152-
- remove begin() or reset()?
153179
- add examples
154180
- ledstrip
155181
- use a "dirty flag" to minimize math operations.

libraries/Kelvin2RGB/keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Kelvin2RGB KEYWORD1
55

66
# Methods and Functions (KEYWORD2)
7+
begin KEYWORD2
8+
79
convert_TH KEYWORD2
810
convert_NB KEYWORD2
911
temperature KEYWORD2

libraries/Kelvin2RGB/library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Kelvin2RGB",
33
"keywords": "RGB,BGR,RGB565,CMYK,temperature",
4-
"description": "Arduino library for converting temperature to RGB values",
4+
"description": "Arduino library for converting Kelvin temperature to RGB values. Tanner Helland Bartlett",
55
"authors":
66
[
77
{
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/Kelvin2RGB.git"
1717
},
18-
"version": "0.2.0",
18+
"version": "0.3.0",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/Kelvin2RGB/library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Kelvin2RGB
2-
version=0.2.0
2+
version=0.3.0
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
5-
sentence=Arduino library for converting temperature to RGB values
6-
paragraph=
5+
sentence=Arduino library for converting Kelvin temperature to RGB values
6+
paragraph=Tanner Helland Bartlett
77
category=Sensors
88
url=https://github.com/RobTillaart/Kelvin2RGB
99
architectures=*

0 commit comments

Comments
 (0)