Fixed signalmeter when modulation meter is switched off
This commit is contained in:
+31
-19
@@ -3342,13 +3342,29 @@ void ShowSignalLevel() {
|
||||
if (unit == 1) SStatusprint = ((SStatus * 100) + 10875) / 100;
|
||||
if (unit == 2) SStatusprint = round((float(SStatus) / 10.0 - 10.0 * log10(75) - 90.0) * 10.0);
|
||||
|
||||
static int DisplayedSignalSegments = 0;
|
||||
static unsigned long SignalPreviousMillis = 0;
|
||||
|
||||
if (SStatusprint > (SStatusold + 3) || SStatusprint < (SStatusold - 3)) {
|
||||
if (advancedRDS) {
|
||||
tftReplace(1, String(SStatusold / 10) + "." + String(abs(SStatusold % 10)), String(SStatusprint / 10) + "." + String(abs(SStatusprint % 10)), 273, 51, PrimaryColor, PrimaryColorSmooth, BackgroundColor, 16);
|
||||
tftReplace(1, String(SStatusold / 10) + "." + String(abs(SStatusold % 10)),
|
||||
String(SStatusprint / 10) + "." + String(abs(SStatusprint % 10)),
|
||||
273, 51, PrimaryColor, PrimaryColorSmooth, BackgroundColor, 16);
|
||||
} else {
|
||||
if (SStatusold / 10 != SStatusprint / 10) tftReplace(1, String(SStatusold / 10), String(SStatusprint / 10), 288, 105, FreqColor, FreqColorSmooth, BackgroundColor, 48);
|
||||
tftReplace(1, "." + String(abs(SStatusold % 10)), "." + String(abs(SStatusprint % 10)), 310, 105, FreqColor, FreqColorSmooth, BackgroundColor, 28);
|
||||
if (band < BAND_GAP) segments = map(SStatus / 10, 0, 70, 0, 100); else segments = (SStatus + 200) / 10;
|
||||
if (SStatusold / 10 != SStatusprint / 10) {
|
||||
tftReplace(1, String(SStatusold / 10), String(SStatusprint / 10),
|
||||
288, 105, FreqColor, FreqColorSmooth, BackgroundColor, 48);
|
||||
}
|
||||
tftReplace(1, "." + String(abs(SStatusold % 10)),
|
||||
"." + String(abs(SStatusprint % 10)),
|
||||
310, 105, FreqColor, FreqColorSmooth, BackgroundColor, 28);
|
||||
|
||||
// Calculate segments for signal meter
|
||||
if (band < BAND_GAP) {
|
||||
DisplayedSignalSegments = map(SStatus / 10, 0, 70, 0, 100);
|
||||
} else {
|
||||
DisplayedSignalSegments = (SStatus + 200) / 10;
|
||||
}
|
||||
|
||||
// Extract RGB components from 16-bit colors
|
||||
uint8_t r1 = (BarInsignificantColor >> 11) & 0x1F;
|
||||
@@ -3359,42 +3375,38 @@ void ShowSignalLevel() {
|
||||
uint8_t g2 = (BarSignificantColor >> 5) & 0x3F;
|
||||
uint8_t b2 = BarSignificantColor & 0x1F;
|
||||
|
||||
int gradientStart = (93 * 25) / 100; // Gradient starts at 25% of the bar
|
||||
int gradientEnd = (93 * 60) / 100; // Gradient ends at 60% of the bar
|
||||
int gradientStart = (93 * 25) / 100;
|
||||
int gradientEnd = (93 * 60) / 100;
|
||||
|
||||
// Draw solid color for first 25%
|
||||
for (int i = 0; i < min(DisplayedSegments, gradientStart); i++) {
|
||||
for (int i = 0; i < min(DisplayedSignalSegments, gradientStart); i++) {
|
||||
tft.fillRect(16 + 2 * i, 105, 2, 6, BarInsignificantColor);
|
||||
}
|
||||
|
||||
// Apply gradient only within the 25%-60% range
|
||||
if (DisplayedSegments > gradientStart) {
|
||||
for (int i = gradientStart; i < min(DisplayedSegments, gradientEnd); i++) {
|
||||
// Interpolate color from 25% to 60%
|
||||
// Apply gradient from 25% to 60%
|
||||
if (DisplayedSignalSegments > gradientStart) {
|
||||
for (int i = gradientStart; i < min(DisplayedSignalSegments, gradientEnd); i++) {
|
||||
uint8_t r = map(i, gradientStart, gradientEnd, r1, r2);
|
||||
uint8_t g = map(i, gradientStart, gradientEnd, g1, g2);
|
||||
uint8_t b = map(i, gradientStart, gradientEnd, b1, b2);
|
||||
|
||||
// Convert back to RGB565 format
|
||||
uint16_t gradientColor = (r << 11) | (g << 5) | b;
|
||||
|
||||
// Draw segment with interpolated color
|
||||
tft.fillRect(16 + 2 * i, 105, 2, 6, gradientColor);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw solid end color for segments beyond 60%
|
||||
if (DisplayedSegments > gradientEnd) {
|
||||
for (int i = gradientEnd; i < DisplayedSegments; i++) {
|
||||
if (DisplayedSignalSegments > gradientEnd) {
|
||||
for (int i = gradientEnd; i < DisplayedSignalSegments; i++) {
|
||||
tft.fillRect(16 + 2 * i, 105, 2, 6, BarSignificantColor);
|
||||
}
|
||||
}
|
||||
|
||||
// Grey out unused segments
|
||||
int greyStart = 16 + 2 * DisplayedSegments;
|
||||
int greyWidth = 2 * (94 - DisplayedSegments);
|
||||
int greyStart = 16 + 2 * DisplayedSignalSegments;
|
||||
int greyWidth = 2 * (94 - DisplayedSignalSegments);
|
||||
tft.fillRect(greyStart, 105, greyWidth, 6, GreyoutColor);
|
||||
}
|
||||
|
||||
SStatusold = SStatusprint;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user