Fix spectrum visualisation for edge cases

This commit is contained in:
KD Diallo committed 2026-01-13 11:54:49 +01:00
1 parent c2ee08d486
commit 2f01dd0118
1 file changed
+3 -3
+3 -3
View File
@@ -950,16 +950,16 @@ uint8_t Rssi2Y(uint16_t rssi)
// Total width units = (bars - 1) full bars + 2 half bars = bars
// First bar: half width, middle bars: full width, last bar: half width
// Scale: 128 pixels / (bars - 1) = pixels per full bar
uint16_t fullWidth = 128 * 2 / (bars - 1); // x2 for precision
uint16_t fullWidth = (128 << 8) / (bars - 1); // x256 for precision
if (i == 0)
{
x = fullWidth / 4; // half of half (because fullWidth is x2)
x = fullWidth / (2 << 8); // half of /256 (because fullWidth is x256)
}
else
{
// Position = half + (i-1) full bars + current bar
x = fullWidth / 4 + (uint16_t)i * fullWidth / 2;
x = fullWidth / (2 << 8) + (uint16_t)i * fullWidth / (1 << 8);
if (i == bars - 1) x = 128; // Last bar ends at screen edge
}
}