fix led voltage ring

This commit is contained in:
interfisch 2023-05-23 22:56:39 +02:00
parent a5dcb39295
commit 47b67b8086
1 changed files with 4 additions and 3 deletions

View File

@ -100,10 +100,11 @@ void led_update(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm&
void led_voltage(unsigned long loopmillis,float vbat,float vbat_min,float vbat_max) {
uint32_t colorBG=strip.Color(0, 255, 0, 0);
uint32_t colorEmpty=strip.Color(255, 0, 0, 0);
uint8_t position=map( max(min(vbat,vbat_max),vbat_min) ,vbat_min,vbat_max, 0,strip.numPixels());
uint8_t position=map( max(min(vbat,vbat_max),vbat_min) ,vbat_min,vbat_max, 0,strip.numPixels()+1);
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
uint8_t pp=strip.numPixels()- ((i+10)%strip.numPixels()) ; //Offset and invert
if (i<=position) {
uint8_t pp=(strip.numPixels()-i-1 + 10 )%strip.numPixels(); //Offset and invert
if (i<position) {
strip.setPixelColor(pp, colorBG); // Set pixel's color (in RAM)
}else{
strip.setPixelColor(pp, colorEmpty); // Set pixel's color (in RAM)