Skip to content

DimitriGilbert/RGBProgress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RGBProgress

C++ library for arduino to calculate an RGB color according to a progression

Usage

Basic

'''
#include "RGBProgress.h"

// get a progress calculator 
RGBProgress rgbp(0, 100);
...
int myRGB[3] {
    // Red
    0,
    // Green
    0,
    // Blue
    0
}

rgbp.Rgb(27, myRGB);
// myRGB now contains the value coding for the color corresponding to 27%
'''

Set value range

'''
#include "RGBProgress.h"

// get a progress calculator 
RGBProgress rgbp(
    [any float value inferior to the next param],
    [any float value superior to the previous param]
);
...
'''

Set color order

'''
#include "RGBProgress.h"

// get a progress calculator 
RGBProgress rgbp(0, 100);

void setup()
{
    rgbp.setColorProgression(RGBProgress::R, RGBProgress::G, RGBProgress::B);
    // or 
    // rgbp.setColorProgression(RGBProgress::G, RGBProgress::R, RGBProgress::B);
}
'''

Set progression steps

all progression steps are describe using values between 0 and 1

'''
#include "RGBProgress.h"

// get a progress calculator 
RGBProgress rgbp(0, 100);

void setup()
{
    // first color cut off
    // here for values above 50
    rgbp.setProgression_StartDecrementUntil_(0.5);
    // second color start
    // value above 20
    rgbp.setProgression_MediumStart_(0.2);
    //second color stop
    // value above 80
    rgbp.setProgression_MediumStop_(0.8);
    //second color peak
    // peak at 50
    rgbp.setProgression_MediumMax_(0.5);
    // last color start
    // start at 50
    rgbp.setProgression_FinishIncrementFrom_(0.5);
}
'''

About

C++ library for arduino to calculate an RGB color according to a progression

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages