fix(color): spectrum analyzer on non 480x272 screens (#7324)

This commit is contained in:
3djc
2026-04-28 11:50:22 +10:00
committed by GitHub
parent ef3008bb37
commit c51728154b
2 changed files with 22 additions and 42 deletions
+8 -33
View File
@@ -160,28 +160,14 @@ static void processMultiScannerPacket(const uint8_t *data, const uint8_t moduleI
for (uint8_t channel = 0; channel <5; channel++) {
uint8_t power = max<int>(0,(data[channel+1] - 34) >> 1); // remove everything below -120dB
#if LCD_W == 480
coord_t x = cur_channel*2;
if (x < LCD_W) {
reusableBuffer.spectrumAnalyser.bars[x] = power;
if (x + 1 < LCD_W) {
reusableBuffer.spectrumAnalyser.bars[x + 1] = power;
}
if (power > reusableBuffer.spectrumAnalyser.max[x]) {
reusableBuffer.spectrumAnalyser.max[x] = power;
if (x + 1 < LCD_W) {
reusableBuffer.spectrumAnalyser.max[x + 1] = power;
}
}
if (power > reusableBuffer.spectrumAnalyser.peak[x]) {
reusableBuffer.spectrumAnalyser.peak[x] = power;
if (x + 1 < LCD_W) {
reusableBuffer.spectrumAnalyser.peak[x + 1] = power;
}
}
#elif LCD_W == 212
coord_t x = cur_channel;
if (x < LCD_W) {
// Spread the (MULTI_SCANNER_MAX_CHANNEL + 1) channels across the full
// chart width so the spectrum fills the screen on any LCD size.
coord_t x_start =
((coord_t)cur_channel * LCD_W) / (MULTI_SCANNER_MAX_CHANNEL + 1);
coord_t x_end = ((coord_t)(cur_channel + 1) * LCD_W) /
(MULTI_SCANNER_MAX_CHANNEL + 1);
if (x_end <= x_start) x_end = x_start + 1;
for (coord_t x = x_start; x < x_end && x < LCD_W; x++) {
reusableBuffer.spectrumAnalyser.bars[x] = power;
if (power > reusableBuffer.spectrumAnalyser.max[x]) {
reusableBuffer.spectrumAnalyser.max[x] = power;
@@ -189,17 +175,6 @@ static void processMultiScannerPacket(const uint8_t *data, const uint8_t moduleI
if (power > reusableBuffer.spectrumAnalyser.peak[x]) {
reusableBuffer.spectrumAnalyser.peak[x] = power;
}
#else
coord_t x = cur_channel / 2 + 1;
if (x < LCD_W) {
reusableBuffer.spectrumAnalyser.bars[x] = power;
if (power > reusableBuffer.spectrumAnalyser.max[x]) {
reusableBuffer.spectrumAnalyser.max[x] = power;
}
if (power > reusableBuffer.spectrumAnalyser.peak[x]) {
reusableBuffer.spectrumAnalyser.peak[x] = power;
}
#endif
}
if (++cur_channel > MULTI_SCANNER_MAX_CHANNEL)
cur_channel = 0;