mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Merge pull request #90 from superkd13/main
Fix spectrum visualisation for edge cases
This commit is contained in:
1 file changed
+3
-3
+3
-3
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user