added periodic resending, free memory readout, rgb callibration.

This commit is contained in:
2019-01-07 18:59:05 +01:00
parent 775ff9313b
commit d2bb858317
8 changed files with 129 additions and 29 deletions

View File

@ -5,9 +5,9 @@ RgbLed::RgbLed( Pwm8b* pwmA, Pwm8b* pwmB ): _pwmA(pwmA), _pwmB(pwmB) {}
void RgbLed::setSolidColor( const uint8_t r, const uint8_t g, const uint8_t b)
{
_pattern=0;
_targetR = r;
_targetG = g;
_targetB = b;
_targetR = applyCal(r, calRed);
_targetG = applyCal(g, calGreen);
_targetB = applyCal(b, calBlue);
}
void RgbLed::setPreset( const uint8_t preset)
@ -106,6 +106,25 @@ void RgbLed::setFade(bool fade)
_fade=fade;
}
uint8_t RgbLed::applyCal(uint16_t value, const uint16_t* cal)
{
uint16_t calValue;
if(value < 128) calValue = cal[0] + ((cal[1] - cal[0])*(value/8))/16;
else calValue = cal[1] + ((cal[2] - cal[1])*((value-128)/8))/16;
return (value*calValue)/1000;
}
void RgbLed::adjustHeadroom(uint8_t& r, uint8_t& g, uint8_t& b, const uint8_t lumina)
{
uint8_t postCalLumina = ((uint16_t)r+g+b)/3;
while(postCalLumina < lumina && r < 255 && g < 255 && b < 255)
{
if(r > 255);
}
}
void RgbLed::patternStep()
{
if(_pattern == 1)