#ifndef _LED_H_ #define _LED_H_ #include #define LED_PIN 3 #define LED_COUNT 16 // NeoPixel brightness, 0 (min) to 255 (max) #define BRIGHTNESS 50 // Set BRIGHTNESS to about 1/5 (max = 255) // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); unsigned long last_ledupdate=0; #define LEDUPDATEINTERVAL 100 uint8_t led_errorcount=0; //count led progress errors. used for delay at end if any errors occured void led_dotcircle(unsigned long loopmillis); void led_voltage(unsigned long loopmillis,float vbat,float vbat_min,float vbat_max); void init_led() { strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(BRIGHTNESS); } void led_testLEDSBlocking(){ strip.clear(); strip.show(); delay(10); uint32_t color=strip.Color(0, 0, 0, 0); for(int i=0; i0) { delay(5000); }else{ delay(100); } } void led_update(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm& escRear) { if (loopmillis>last_ledupdate+LEDUPDATEINTERVAL) { last_ledupdate=loopmillis; float vbat=min(escRear.getFeedback_batVoltage(),escFront.getFeedback_batVoltage()); //led_dotcircle(loopmillis); led_voltage(loopmillis,vbat,3*12,4.2*12); strip.show(); // Update strip to match } } 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()); for(int i=0; i