feat: use (only) dedicated charge led on compatible Jumper handsets (#5512)

This commit is contained in:
3djc
2024-09-11 18:50:16 +10:00
committed by GitHub
parent b78da3436e
commit f680d86034
4 changed files with 31 additions and 35 deletions
+5
View File
@@ -75,6 +75,7 @@ if (PCB STREQUAL X10)
endif()
# Aux2 is reserved for serial gimbal on this radio
set(AUX2_SERIAL OFF)
set(USB_CHARGE_LED YES)
add_definitions(-DMANUFACTURER_JUMPER)
set(LCD_DRIVER lcd_st7796s_driver.cpp)
elseif (PCBREV STREQUAL T16)
@@ -341,6 +342,10 @@ if(SWSERIALPOWER)
add_definitions(-DSWSERIALPOWER)
endif()
if(USB_CHARGE_LED)
add_definitions(-DUSB_CHARGE_LED)
endif()
if(USB_CHARGER)
add_definitions(-DUSB_CHARGER)
target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp)
+3 -33
View File
@@ -127,46 +127,14 @@ void boardInit()
board_set_bor_level();
#endif
pwrInit();
#if defined(FUNCTION_SWITCHES) && !defined(DEBUG_SEGGER_RTT)
#if defined(RADIO_T15)
#define LEDCHARGEON(x) fsLedOff(x)
#define LEDCHARGEOFF(x) fsLedOn(x)
#else
#define LEDCHARGEON(x) fsLedOn(x)
#define LEDCHARGEOFF(x) fsLedOff(x)
#endif
#if defined(FUNCTION_SWITCHES) && !defined(DEBUG_DISABLE_USB)
// This is needed to prevent radio from starting when usb is plugged to charge
usbInit();
ledInit();
// prime debounce state...
usbPlugged();
if (usbPlugged()) {
delaysInit();
adcInit(&_adc_driver);
getADC();
pwrOn(); // required to get bat adc reads
INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF();
for (uint8_t i=0; i < NUM_FUNCTIONS_SWITCHES; i++)
LEDCHARGEOFF(i);
while (usbPlugged()) {
// Let it charge ...
getADC(); // Warning: the value read does not include VBAT calibration
// Also, MCU is running which create a drop vs off
if (getBatteryVoltage() >= 660)
LEDCHARGEON(0);
if (getBatteryVoltage() >= 700)
LEDCHARGEON(1);
if (getBatteryVoltage() >= 740)
LEDCHARGEON(2);
if (getBatteryVoltage() >= 780)
LEDCHARGEON(3);
if (getBatteryVoltage() >= 810)
LEDCHARGEON(4);
if (getBatteryVoltage() >= 820)
LEDCHARGEON(5);
delay_ms(1000);
}
while(1) // Wait power to drain
@@ -174,6 +142,8 @@ void boardInit()
}
#endif
pwrInit();
boardInitModulePorts();
#if defined(INTMODULE_HEARTBEAT) && \
+7
View File
@@ -145,6 +145,7 @@ elseif(PCB STREQUAL X7)
set(NAVIGATION_TYPE x7)
set(CPU_TYPE_FULL STM32F407xG)
set(ROTARY_ENCODER YES)
set(USB_CHARGE_LED YES)
add_definitions(-DRADIO_TPROS)
add_definitions(-DMANUFACTURER_JUMPER)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
@@ -156,6 +157,7 @@ elseif(PCB STREQUAL X7)
set(ROTARY_ENCODER YES)
set(CPU_TYPE_FULL STM32F407xG)
set(PXX2 ON)
set(USB_CHARGE_LED YES)
add_definitions(-DRADIO_T14)
add_definitions(-DMANUFACTURER_JUMPER)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
@@ -166,6 +168,7 @@ elseif(PCB STREQUAL X7)
set(FLAVOUR t12max)
set(NAVIGATION_TYPE x7)
set(ROTARY_ENCODER YES)
set(USB_CHARGE_LED YES)
set(CPU_TYPE_FULL STM32F407xG)
add_definitions(-DRADIO_T12MAX)
add_definitions(-DMANUFACTURER_JUMPER)
@@ -609,6 +612,10 @@ if(BIND_KEY)
target_sources(board PRIVATE ${TARGET_SRC_DIR}/bind_button_driver.cpp)
endif()
if(USB_CHARGE_LED)
add_definitions(-DUSB_CHARGE_LED)
endif()
if(USB_CHARGER)
add_definitions(-DUSB_CHARGER)
target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp)
+16 -2
View File
@@ -114,6 +114,20 @@ void boardInit()
LL_APB1_GRP1_EnableClock(AUDIO_RCC_APB1Periph);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
#if defined(USB_CHARGE_LED) && !defined(DEBUG_DISABLE_USB)
usbInit();
// prime debounce state...
usbPlugged();
if (usbPlugged()) {
delaysInit();
while (usbPlugged()) {
delay_ms(1000);
}
pwrOff();
}
#endif
#if defined(BLUETOOTH) && !defined(PCBX9E)
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, true);
#endif
@@ -158,7 +172,7 @@ void boardInit()
// TODO: needs refactoring if any other manufacturer implements either of the following:
// - function switches and the radio supports charging
// - single USB for data + charge which powers on radio
#if defined(MANUFACTURER_JUMPER)
#if defined(MANUFACTURER_JUMPER) && !defined(USB_CHARGE_LED)
// This is needed to prevent radio from starting when usb is plugged to charge
usbInit();
// prime debounce state...
@@ -166,13 +180,13 @@ void boardInit()
if (usbPlugged()) {
delaysInit();
__enable_irq();
adcInit(&_adc_driver);
getADC();
pwrOn(); // required to get bat adc reads
INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF();
delay_ms(2000); // let this stabilize
while (usbPlugged()) {
// // Let it charge ...
getADC(); // Warning: the value read does not include VBAT calibration