Skip to content

Commit

Permalink
add changelog.md (#5)
Browse files Browse the repository at this point in the history
* add changelog.md
* fix BGR() bug
  • Loading branch information
RobTillaart committed Nov 14, 2022
1 parent 5d7a09e commit 9632d17
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 92 deletions.
17 changes: 17 additions & 0 deletions .arduino-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:

packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
Expand All @@ -9,3 +24,5 @@ compile:
- esp32
# - esp8266
# - mega2560
- rpipico

37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Change Log Kelvin2RGB

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.1.5] - 2022-11-14
- Add RP2040 support to build-CI.
- Add CHANGELOG.md
- extended keywords.txt
- move all code to .cpp
- fix bug in **BGR()**
- fix unit test BGR-bug


## [0.1.4] - 2021-12-20
- update library.json
- update license
- minor edits

## [0.1.3] - 2021-11-06
- update build-CI
- add badges
- add setRGB(), CMYK(), BGR(), reset();

## [0.1.2] - 2021-06-01
- add RGB565() - 16 bit colour - output

## [0.1.1] - 2020-12-30
- ??

## [0.1.0] - 2018-01-31
- initial version


84 changes: 68 additions & 16 deletions Kelvin2RGB.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
//
// FILE: Kelvin2RGB.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.4
// VERSION: 0.1.5
// DATE: 2018-01-31
// PURPOSE: Arduino library for converting temperature to RGB values
// URL: https://github.com/RobTillaart/Kelvin2RGB

// HISTORY
// 0.1.0 2018-01-31 initial version
// 0.1.1 2020-12-30 ??
// 0.1.2 2021-06-01 add RGB565() - 16 bit colour - output
// 0.1.3 2021-11-06 update build-CI, badges
// add setRGB(), CMYK(), BGR(), reset();
// 0.1.4 2021-12-20 update library.json, license, minor edits
//
// HISTORY: see changelog.md


#include "Kelvin2RGB.h"
Expand All @@ -23,22 +17,30 @@

Kelvin2RGB::Kelvin2RGB()
{
begin();
reset();
}


// empty function for now, remove?
void Kelvin2RGB::begin()
{
}


void Kelvin2RGB::reset()
{
_temperature = 0;
_brightness = 0; // default = darkness
_brightness = 0; // default = darkness
_red = 0;
_green = 0;
_blue = 0;
_rgb = 0;
}


// Tanner Helland formulas
////////////////////////////////////////////////////////////////
//
// Tanner Helland formulas
//
void Kelvin2RGB::convert_TH(float temperature, float brightness)
{
_temperature = constrain(temperature, 0, 65500);
Expand Down Expand Up @@ -68,7 +70,10 @@ void Kelvin2RGB::convert_TH(float temperature, float brightness)
}


// Neil Bartlett formulas
////////////////////////////////////////////////////////////////
//
// Neil Bartlett formulas
//
void Kelvin2RGB::convert_NB(float temperature, float brightness)
{
_temperature = constrain(temperature, 0, 65500);
Expand Down Expand Up @@ -102,6 +107,41 @@ void Kelvin2RGB::convert_NB(float temperature, float brightness)
}


////////////////////////////////////////////////////////////////
//
// Other functions
//

float Kelvin2RGB::temperature()
{
return _temperature;
};


float Kelvin2RGB::brightness()
{
return _brightness;
};


float Kelvin2RGB::red()
{
return _red;
};


float Kelvin2RGB::green()
{
return _green;
};


float Kelvin2RGB::blue()
{
return _blue;
};


uint32_t Kelvin2RGB::setRGB(float red, float green, float blue, float brightness)
{
_brightness = brightness;
Expand All @@ -113,7 +153,19 @@ uint32_t Kelvin2RGB::setRGB(float red, float green, float blue, float brightness
}


// 16 bit colour - of last conversion.
//
// 32 bit colour (only 3 bytes used)
//
uint32_t Kelvin2RGB::RGB()
{
return _rgb;
};



//
// 16 bit colour - of last conversion.
//
uint16_t Kelvin2RGB::RGB565()
{
uint16_t val = 0;
Expand Down Expand Up @@ -142,7 +194,7 @@ uint32_t Kelvin2RGB::CMYK()

uint32_t Kelvin2RGB::BGR()
{
return round(_blue) * 65536UL + round(_green) * 256UL + round(_red);
return round(255 * _blue) * 65536UL + round(255 * _green) * 256UL + round(255 * _red);
}


Expand Down
92 changes: 47 additions & 45 deletions Kelvin2RGB.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,53 @@
//
// FILE: Kelvin2RGB.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.4
// VERSION: 0.1.5
// DATE: 2018-01-31
// PURPOSE: Arduino library for converting temperature to RGB values
// URL: https://github.com/RobTillaart/Kelvin2RGB
//


#define KELVIN2RGB_LIB_VERSION (F("0.1.4"))
#define KELVIN2RGB_LIB_VERSION (F("0.1.5"))

#include "Arduino.h"


//
// Based upon article Tanner Helland and Neil Bartlett
// http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
// http://www.zombieprototypes.com/?p=210
// https://en.wikipedia.org/wiki/Color_temperature#Categorizing_different_lighting
// Based upon article Tanner Helland and Neil Bartlett
// http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
// http://www.zombieprototypes.com/?p=210
// https://en.wikipedia.org/wiki/Color_temperature#Categorizing_different_lighting
//
//
// based on https://en.wikipedia.org/wiki/Color_temperature#Categorizing_different_lighting
// based on https://en.wikipedia.org/wiki/Color_temperature#Categorizing_different_lighting
//
// DAY LIGHT SETTING TEMPERATURE
//
#define DLS_dark 0
#define DLS_match 1700
#define DLS_sodiumLamp 1700
#define DLS_candleFlame 1850
#define DLS_sunrise 1850
#define DLS_sunset 1850
#define DLS_bulb 2400
#define DLS_bulbSoftWhite 2550
#define DLS_LEDlamp 2700
#define DLS_warmWhite 3000
#define DLS_studioLight 3200
#define DLS_studioCPlight 3350
#define DLS_daylightHorizon 5000
#define DLS_flashLight 5700
#define DLS_xenonLight 6200
#define DLS_dayLightBright 6500
#define DLS_normal 6500
#define DLS_screenlow 6500
#define DLS_screenMed 8000
#define DLS_screenHigh 9500
#define DLS_polewardSky0 15000
#define DLS_polewardSky1 19000
#define DLS_polewardSky2 23000
#define DLS_polewardSky3 27000
#define DLS_dark 0
#define DLS_match 1700
#define DLS_sodiumLamp 1700
#define DLS_candleFlame 1850
#define DLS_sunrise 1850
#define DLS_sunset 1850
#define DLS_bulb 2400
#define DLS_bulbSoftWhite 2550
#define DLS_LEDlamp 2700
#define DLS_warmWhite 3000
#define DLS_studioLight 3200
#define DLS_studioCPlight 3350
#define DLS_daylightHorizon 5000
#define DLS_flashLight 5700
#define DLS_xenonLight 6200
#define DLS_dayLightBright 6500
#define DLS_normal 6500
#define DLS_screenlow 6500
#define DLS_screenMed 8000
#define DLS_screenHigh 9500
#define DLS_polewardSky0 15000
#define DLS_polewardSky1 19000
#define DLS_polewardSky2 23000
#define DLS_polewardSky3 27000



Expand All @@ -57,36 +57,36 @@ class Kelvin2RGB
public:
Kelvin2RGB();

void begin(); // empty function - obsolete?
void begin(); // empty function for now, remove?
void reset();

// temp = 0..65500 brightness = 0.0 .. 100.0%
void convert_TH(float temperature, float brightness = 100);
void convert_NB(float temperature, float brightness = 100);
// temperature = 0..65500 brightness = 0.0 .. 100.0%
void convert_TH(float temperature, float brightness = 100.0);
void convert_NB(float temperature, float brightness = 100.0);

float temperature() { return _temperature; };
float brightness() { return _brightness; };
float temperature();
float brightness();;

// returns 0.0 .. 1.0
float red() { return _red; };
float green() { return _green; };
float blue() { return _blue; };
float red();
float green();
float blue();

// red, green, blue should be in 0 .. 1.0 range
// brightness should be in 0..100%, Default = 100%,
// returns RGB.
uint32_t setRGB(float red, float green, float blue, float brightness = 100);
uint32_t setRGB(float red, float green, float blue, float brightness = 100.0);

uint32_t RGB() { return _rgb; }; // 32 bit colour
uint16_t RGB565(); // 16 bit colour
uint32_t RGB(); // 32 bit colour (only 3 bytes used)
uint16_t RGB565(); // 16 bit colour

// experimental 0.1.3
// Experimental 0.1.3
uint32_t CMYK();
uint32_t BGR();


private:
void _normalize();
void _normalize();

float _temperature = 0;
float _brightness = 0;
Expand All @@ -96,4 +96,6 @@ class Kelvin2RGB
uint32_t _rgb = 0;
};


// -- END OF FILE --

Loading

0 comments on commit 9632d17

Please sign in to comment.