According to datasheet, RGB LED has 32 levels of brightness unrelated to RGB value, so i've modified the code:
TinyPICO::TinyPICO()
{
...
brightness = 15;
...
}
void TinyPICO::DotStar_SetBrightness(uint8_t b)
{
if(b>31) b = 31;
brightness = b;
}
void TinyPICO::DotStar_Show(void)
{
if ( !isInit )
{
isInit = true;
swspi_init();
delay(10);
}
// Start-frame marker
for( int i=0; i<4; i++) swspi_out(0x00);
// Pixel start + brightness
swspi_out(0xE0 | brightness);
for( int i=0; i<3; i++) swspi_out(pixel[i]); // R,G,B @Full brightness (no scaling)
// // End frame marker
swspi_out(0xFF);
}
It works fine and RGB values aren't loosing precision. I don't know your original intention for manual brightness, so didn't want to make a pull request.
Another tweak i think is useful is to remove delay(1) from the end of swspi_out. LED works fine without delay but presence of it may be crucial for time sensitive tasks in main loop (like in my case).
According to datasheet, RGB LED has 32 levels of brightness unrelated to RGB value, so i've modified the code:
It works fine and RGB values aren't loosing precision. I don't know your original intention for manual brightness, so didn't want to make a pull request.
Another tweak i think is useful is to remove
delay(1)
from the end ofswspi_out
. LED works fine without delay but presence of it may be crucial for time sensitive tasks in main loop (like in my case).