feat: use (only) dedicated charge led on compatible Jumper handsets (#5512)
This commit is contained in:
@@ -75,6 +75,7 @@ if (PCB STREQUAL X10)
|
|||||||
endif()
|
endif()
|
||||||
# Aux2 is reserved for serial gimbal on this radio
|
# Aux2 is reserved for serial gimbal on this radio
|
||||||
set(AUX2_SERIAL OFF)
|
set(AUX2_SERIAL OFF)
|
||||||
|
set(USB_CHARGE_LED YES)
|
||||||
add_definitions(-DMANUFACTURER_JUMPER)
|
add_definitions(-DMANUFACTURER_JUMPER)
|
||||||
set(LCD_DRIVER lcd_st7796s_driver.cpp)
|
set(LCD_DRIVER lcd_st7796s_driver.cpp)
|
||||||
elseif (PCBREV STREQUAL T16)
|
elseif (PCBREV STREQUAL T16)
|
||||||
@@ -341,6 +342,10 @@ if(SWSERIALPOWER)
|
|||||||
add_definitions(-DSWSERIALPOWER)
|
add_definitions(-DSWSERIALPOWER)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USB_CHARGE_LED)
|
||||||
|
add_definitions(-DUSB_CHARGE_LED)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(USB_CHARGER)
|
if(USB_CHARGER)
|
||||||
add_definitions(-DUSB_CHARGER)
|
add_definitions(-DUSB_CHARGER)
|
||||||
target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp)
|
target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp)
|
||||||
|
|||||||
@@ -127,46 +127,14 @@ void boardInit()
|
|||||||
board_set_bor_level();
|
board_set_bor_level();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pwrInit();
|
#if defined(FUNCTION_SWITCHES) && !defined(DEBUG_DISABLE_USB)
|
||||||
|
|
||||||
#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
|
|
||||||
// This is needed to prevent radio from starting when usb is plugged to charge
|
// This is needed to prevent radio from starting when usb is plugged to charge
|
||||||
usbInit();
|
usbInit();
|
||||||
ledInit();
|
|
||||||
// prime debounce state...
|
// prime debounce state...
|
||||||
usbPlugged();
|
usbPlugged();
|
||||||
if (usbPlugged()) {
|
if (usbPlugged()) {
|
||||||
delaysInit();
|
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()) {
|
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);
|
delay_ms(1000);
|
||||||
}
|
}
|
||||||
while(1) // Wait power to drain
|
while(1) // Wait power to drain
|
||||||
@@ -174,6 +142,8 @@ void boardInit()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pwrInit();
|
||||||
|
|
||||||
boardInitModulePorts();
|
boardInitModulePorts();
|
||||||
|
|
||||||
#if defined(INTMODULE_HEARTBEAT) && \
|
#if defined(INTMODULE_HEARTBEAT) && \
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ elseif(PCB STREQUAL X7)
|
|||||||
set(NAVIGATION_TYPE x7)
|
set(NAVIGATION_TYPE x7)
|
||||||
set(CPU_TYPE_FULL STM32F407xG)
|
set(CPU_TYPE_FULL STM32F407xG)
|
||||||
set(ROTARY_ENCODER YES)
|
set(ROTARY_ENCODER YES)
|
||||||
|
set(USB_CHARGE_LED YES)
|
||||||
add_definitions(-DRADIO_TPROS)
|
add_definitions(-DRADIO_TPROS)
|
||||||
add_definitions(-DMANUFACTURER_JUMPER)
|
add_definitions(-DMANUFACTURER_JUMPER)
|
||||||
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
|
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
|
||||||
@@ -156,6 +157,7 @@ elseif(PCB STREQUAL X7)
|
|||||||
set(ROTARY_ENCODER YES)
|
set(ROTARY_ENCODER YES)
|
||||||
set(CPU_TYPE_FULL STM32F407xG)
|
set(CPU_TYPE_FULL STM32F407xG)
|
||||||
set(PXX2 ON)
|
set(PXX2 ON)
|
||||||
|
set(USB_CHARGE_LED YES)
|
||||||
add_definitions(-DRADIO_T14)
|
add_definitions(-DRADIO_T14)
|
||||||
add_definitions(-DMANUFACTURER_JUMPER)
|
add_definitions(-DMANUFACTURER_JUMPER)
|
||||||
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
|
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
|
||||||
@@ -166,6 +168,7 @@ elseif(PCB STREQUAL X7)
|
|||||||
set(FLAVOUR t12max)
|
set(FLAVOUR t12max)
|
||||||
set(NAVIGATION_TYPE x7)
|
set(NAVIGATION_TYPE x7)
|
||||||
set(ROTARY_ENCODER YES)
|
set(ROTARY_ENCODER YES)
|
||||||
|
set(USB_CHARGE_LED YES)
|
||||||
set(CPU_TYPE_FULL STM32F407xG)
|
set(CPU_TYPE_FULL STM32F407xG)
|
||||||
add_definitions(-DRADIO_T12MAX)
|
add_definitions(-DRADIO_T12MAX)
|
||||||
add_definitions(-DMANUFACTURER_JUMPER)
|
add_definitions(-DMANUFACTURER_JUMPER)
|
||||||
@@ -609,6 +612,10 @@ if(BIND_KEY)
|
|||||||
target_sources(board PRIVATE ${TARGET_SRC_DIR}/bind_button_driver.cpp)
|
target_sources(board PRIVATE ${TARGET_SRC_DIR}/bind_button_driver.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USB_CHARGE_LED)
|
||||||
|
add_definitions(-DUSB_CHARGE_LED)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(USB_CHARGER)
|
if(USB_CHARGER)
|
||||||
add_definitions(-DUSB_CHARGER)
|
add_definitions(-DUSB_CHARGER)
|
||||||
target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp)
|
target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp)
|
||||||
|
|||||||
@@ -114,6 +114,20 @@ void boardInit()
|
|||||||
LL_APB1_GRP1_EnableClock(AUDIO_RCC_APB1Periph);
|
LL_APB1_GRP1_EnableClock(AUDIO_RCC_APB1Periph);
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
|
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)
|
#if defined(BLUETOOTH) && !defined(PCBX9E)
|
||||||
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, true);
|
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, true);
|
||||||
#endif
|
#endif
|
||||||
@@ -158,7 +172,7 @@ void boardInit()
|
|||||||
// TODO: needs refactoring if any other manufacturer implements either of the following:
|
// TODO: needs refactoring if any other manufacturer implements either of the following:
|
||||||
// - function switches and the radio supports charging
|
// - function switches and the radio supports charging
|
||||||
// - single USB for data + charge which powers on radio
|
// - 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
|
// This is needed to prevent radio from starting when usb is plugged to charge
|
||||||
usbInit();
|
usbInit();
|
||||||
// prime debounce state...
|
// prime debounce state...
|
||||||
@@ -166,13 +180,13 @@ void boardInit()
|
|||||||
|
|
||||||
if (usbPlugged()) {
|
if (usbPlugged()) {
|
||||||
delaysInit();
|
delaysInit();
|
||||||
|
__enable_irq();
|
||||||
adcInit(&_adc_driver);
|
adcInit(&_adc_driver);
|
||||||
getADC();
|
getADC();
|
||||||
pwrOn(); // required to get bat adc reads
|
pwrOn(); // required to get bat adc reads
|
||||||
INTERNAL_MODULE_OFF();
|
INTERNAL_MODULE_OFF();
|
||||||
EXTERNAL_MODULE_OFF();
|
EXTERNAL_MODULE_OFF();
|
||||||
delay_ms(2000); // let this stabilize
|
delay_ms(2000); // let this stabilize
|
||||||
|
|
||||||
while (usbPlugged()) {
|
while (usbPlugged()) {
|
||||||
// // Let it charge ...
|
// // Let it charge ...
|
||||||
getADC(); // Warning: the value read does not include VBAT calibration
|
getADC(); // Warning: the value read does not include VBAT calibration
|
||||||
|
|||||||
Reference in New Issue
Block a user