feat: TPro - Use function switch leds as charge level indicator when charging

Co-authored-by: Batam <batam@macbook-pro.home>
Port of https://github.com/opentx/opentx/pull/8871
This commit is contained in:
Batambatam
2022-03-13 22:04:15 +10:00
committed by GitHub
parent 7bf679908b
commit 9e6ab84599
+37
View File
@@ -158,6 +158,43 @@ void boardInit()
ledGreen();
#endif
// Support for FS Led to indicate battery charge level
#if defined(RADIO_TPRO)
// This is needed to prevent radio from starting when usb is plugged to charge
usbInit();
// prime debounce state...
usbPlugged();
if (usbPlugged()) {
delaysInit();
adcInit(&stm32_hal_adc_driver);
getADC();
pwrOn(); // required to get bat adc reads
storageReadRadioSettings(false); // Needed for bat calibration
INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF();
while (usbPlugged()) {
// Let it charge ...
getADC();
delay_ms(20);
if (getBatteryVoltage() >= 660)
fsLedOn(0);
if (getBatteryVoltage() >= 700)
fsLedOn(1);
if (getBatteryVoltage() >= 740)
fsLedOn(2);
if (getBatteryVoltage() >= 780)
fsLedOn(3);
if (getBatteryVoltage() >= 820)
fsLedOn(4);
if (getBatteryVoltage() >= 842)
fsLedOn(5);
}
pwrOff();
}
#endif
keysInit();
#if defined(ROTARY_ENCODER_NAVIGATION)