0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 14:21:25 +03:00

Restored battery bar thresholds back to the stored calibration values.

This commit is contained in:
OneOfEleven 2023-10-02 10:40:27 +01:00
parent ec33203403
commit af342cf904
7 changed files with 20 additions and 53 deletions

View File

@ -12,9 +12,11 @@ Anyway, have fun.
Please note that the Quansheng uv-k radios are not professional quality transceivers, their
performance is strictly limited, somewhat below that of a decent transceiver. The RX front
end has no track-tuned band pass filtering at all, and so are wide band/wide open to any
and all signals over a wide frequency range. Using the radio in high intensity RF environments
will nearly always destroy your reception, the receiver simply doesn't have a great dynamic
range, though are quite sensitive (weak signal wise).
and all signals over a wide frequency range.
Using the radio in high intensity RF environments will nearly always destroy your reception,
the receiver simply doesn't have a great dynamic range, which means distorted AM audio with
strong received signals, there is nothing more anyone can do in firmware/software to stop that
happening once the RX gain adjustment I do (AM fix) reaches the hardwares limit.
Saying that, they are nice toys for the price, fun to play with.

Binary file not shown.

Binary file not shown.

View File

@ -86,37 +86,22 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
gBatteryDisplayLevel = 0;
if (Voltage >= gBatteryCalibration[5])
gBatteryDisplayLevel = 11;
else
if (Voltage >= ((gBatteryCalibration[4] + gBatteryCalibration[5]) / 2))
gBatteryDisplayLevel = 10;
else
if (Voltage >= gBatteryCalibration[4])
gBatteryDisplayLevel = 9;
else
if (Voltage >= ((gBatteryCalibration[3] + gBatteryCalibration[4]) / 2))
gBatteryDisplayLevel = 8;
else
if (Voltage >= gBatteryCalibration[3])
gBatteryDisplayLevel = 7;
else
if (Voltage >= ((gBatteryCalibration[2] + gBatteryCalibration[3]) / 2))
if (gBatteryCalibration[5] < Voltage)
gBatteryDisplayLevel = 6;
else
if (Voltage >= gBatteryCalibration[2])
if (gBatteryCalibration[4] < Voltage)
gBatteryDisplayLevel = 5;
else
if (Voltage >= ((gBatteryCalibration[1] + gBatteryCalibration[2]) / 2))
if (gBatteryCalibration[3] < Voltage)
gBatteryDisplayLevel = 4;
else
if (Voltage >= gBatteryCalibration[1])
if (gBatteryCalibration[2] < Voltage)
gBatteryDisplayLevel = 3;
else
if (Voltage >= ((gBatteryCalibration[0] + gBatteryCalibration[1]) / 2))
if (gBatteryCalibration[1] < Voltage)
gBatteryDisplayLevel = 2;
else
if (Voltage >= gBatteryCalibration[0])
if (gBatteryCalibration[0] < Voltage)
gBatteryDisplayLevel = 1;
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];

2
main.c
View File

@ -132,7 +132,7 @@ void Main(void)
gDebounceCounter = 0;
}
if (!gChargingWithTypeC && !gBatteryDisplayLevel)
if (!gChargingWithTypeC && gBatteryDisplayLevel == 0)
{
FUNCTION_Select(FUNCTION_POWER_SAVE);

View File

@ -962,8 +962,7 @@ void RADIO_PrepareTX(void)
if (gBatteryDisplayLevel == 0)
State = VFO_STATE_BAT_LOW; // charge your battery !
else
//if (gBatteryDisplayLevel >= 6)
if (gBatteryDisplayLevel >= 11) // I've increased the battery level bar resolution
if (gBatteryDisplayLevel >= 6)
State = VFO_STATE_VOLTAGE_HIGH; // over voltage .. this is being a pain
}
else

View File

@ -187,54 +187,35 @@ void UI_DisplayStatus(const bool test_display)
x += sizeof(BITMAP_USB_C);
// BATTERY LEVEL indicator
#if 1
if (gBatteryDisplayLevel >= 2 && !gLowBattery)
{
line += x;
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
#ifndef ENABLE_REVERSE_BAT_SYMBOL
line += sizeof(BITMAP_BatteryLevel1);
if (gBatteryDisplayLevel >= 2)
memmove(line - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
if (gBatteryDisplayLevel >= 5)
if (gBatteryDisplayLevel >= 3)
memmove(line - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
if (gBatteryDisplayLevel >= 7)
if (gBatteryDisplayLevel >= 4)
memmove(line - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
if (gBatteryDisplayLevel >= 9)
if (gBatteryDisplayLevel >= 5)
memmove(line - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
#else
if (gBatteryDisplayLevel >= 2)
memmove(line + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
if (gBatteryDisplayLevel >= 5)
if (gBatteryDisplayLevel >= 3)
memmove(line + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
if (gBatteryDisplayLevel >= 7)
if (gBatteryDisplayLevel >= 4)
memmove(line + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
if (gBatteryDisplayLevel >= 9)
if (gBatteryDisplayLevel >= 5)
memmove(line + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
#endif
}
else
if (gLowBatteryBlink == 1)
memmove(line + x, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
#else
// UI_DisplayBattery(gBatteryDisplayLevel);
line += x;
if (gBatteryDisplayLevel > 0)
{
const uint8_t level = (gBatteryDisplayLevel <= 11) ? gBatteryDisplayLevel : 11;
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
#ifdef ENABLE_REVERSE_BAT_SYMBOL
for (uint8_t i = 0; i < level; i++)
line[3 + i] = (i & 1u) ? 0b01011101 : 0b01011101;
#else
for (uint8_t i = 0; i < level; i++)
line[sizeof(BITMAP_BatteryLevel1) - 3 - i] = (i & 1u) ? 0b01011101 : 0b01011101;
#endif
}
else
memset(line, 0, sizeof(BITMAP_BatteryLevel1));
#endif
// **************