Merge pull request #90 from superkd13/main

Fix spectrum visualisation for edge cases
This commit is contained in:
Armel FAUVEAU authored and GitHub committed 2026-01-14 00:23:21 +01:00
commit 815e5b1a82
1 file changed
+3 -3
+3 -3
View File
@@ -954,16 +954,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
}
}