fix(cpn): TX battery voltage input collided with left-horizontal stick slot (#7805)
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
44da67ed7a
commit
feb1bee9a5
@@ -51,6 +51,14 @@ uint16_t getRTCBatteryVoltage()
|
||||
|
||||
extern uint16_t simuGetAnalog(uint8_t idx);
|
||||
|
||||
// Negative = no override, fall back to the vBatWarn-derived default below.
|
||||
static int32_t s_simuTxVoltageOverride = -1;
|
||||
|
||||
void simuSetTxVoltage(int32_t decivolts)
|
||||
{
|
||||
s_simuTxVoltageOverride = decivolts;
|
||||
}
|
||||
|
||||
static bool simu_start_conversion()
|
||||
{
|
||||
int max_input = adcGetMaxInputs(ADC_INPUT_ALL);
|
||||
@@ -58,13 +66,18 @@ static bool simu_start_conversion()
|
||||
setAnalogValue(i, simuGetAnalog(i));
|
||||
}
|
||||
|
||||
// set batteries default voltages
|
||||
int i = adcGetInputOffset(ADC_INPUT_VBAT);
|
||||
if (i > 0) {
|
||||
// +0.5V and prec2
|
||||
uint16_t vBatWarn = BATTERY_WARN;
|
||||
if (g_eeGeneral.vBatWarn > 0) vBatWarn = g_eeGeneral.vBatWarn;
|
||||
uint16_t volts = (vBatWarn + 5) * 10;
|
||||
uint16_t vBatDeciVolts;
|
||||
if (s_simuTxVoltageOverride >= 0) {
|
||||
vBatDeciVolts = (uint16_t)s_simuTxVoltageOverride;
|
||||
} else {
|
||||
// set battery default voltage: +0.5V above the warning threshold
|
||||
uint16_t vBatWarn = BATTERY_WARN;
|
||||
if (g_eeGeneral.vBatWarn > 0) vBatWarn = g_eeGeneral.vBatWarn;
|
||||
vBatDeciVolts = vBatWarn + 5;
|
||||
}
|
||||
uint16_t volts = vBatDeciVolts * 10; // prec2
|
||||
setAnalogValue(i, volts * 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,10 @@ void WASM_EXPORT(simuSetKey)(uint8_t key, bool state);
|
||||
void WASM_EXPORT(simuSetTrim)(uint8_t trim, bool state);
|
||||
void WASM_EXPORT(simuSetSwitch)(uint8_t swtch, int8_t state);
|
||||
|
||||
// TX battery voltage override, in decivolts (85 = 8.5V). Pass a negative
|
||||
// value to clear the override and go back to the vBatWarn-derived default.
|
||||
void WASM_EXPORT(simuSetTxVoltage)(int32_t decivolts);
|
||||
|
||||
// Touch: call simuTouchDown(x,y) on press and repeatedly during drag
|
||||
// (continuous position updates), then simuTouchUp() on release.
|
||||
// The firmware detects slides from successive position changes.
|
||||
|
||||
Reference in New Issue
Block a user