mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-21 23:19:02 +00:00
c7a0846645
* EPIRB RX: add receiver-overload indicator on channel bar Tint the channel-power bar red when the front-end overloads (ADC near full scale). EPIRB demodulation relies on the constant-envelope carrier and the +/-1.1 rad biphase phase jumps; ADC clipping distorts both, so a visible cue to reduce RF-amp/LNA/VGA gain is useful. Implemented in the shared ui::Channel widget via an opt-in set_overload_threshold(): when the last ChannelStatistics max_db reaches the threshold the bar is drawn red instead of blue. Default threshold is above the 0 dBFS ceiling, so all existing users are unaffected. The EPIRB view enables it at -3 dBFS. Done in the widget (main firmware) rather than the EPIRB app because the epirb_rx external app is already at the 32 KB flash limit; the app only pays for a single setter call.
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
/*
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
*
|
|
* This file is part of PortaPack.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __UI_CHANNEL_H__
|
|
#define __UI_CHANNEL_H__
|
|
|
|
#include "ui.hpp"
|
|
#include "ui_widget.hpp"
|
|
#include "ui_painter.hpp"
|
|
|
|
#include "event_m0.hpp"
|
|
|
|
#include "message.hpp"
|
|
|
|
#include <cstdint>
|
|
|
|
namespace ui {
|
|
|
|
class Channel : public Widget {
|
|
public:
|
|
Channel(
|
|
const Rect parent_rect)
|
|
: Widget{parent_rect},
|
|
max_db_{-120} {
|
|
}
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
// Opt-in receiver-overload tint: when the channel power (peak IQ magnitude
|
|
// in dBFS, 0 = full scale) reaches this threshold the bar is drawn red
|
|
// instead of blue, flagging that the analog gain is too high and the ADC is
|
|
// clipping. Default is disabled (threshold above the 0 dBFS ceiling) so
|
|
// existing users are unaffected.
|
|
void set_overload_threshold(int32_t db) {
|
|
overload_threshold_ = db;
|
|
set_dirty();
|
|
}
|
|
|
|
private:
|
|
int32_t max_db_;
|
|
int32_t overload_threshold_{INT32_MAX};
|
|
|
|
MessageHandlerRegistration message_handler_stats{
|
|
Message::ID::ChannelStatistics,
|
|
[this](const Message* const p) {
|
|
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
|
}};
|
|
|
|
void on_statistics_update(const ChannelStatistics& statistics);
|
|
};
|
|
|
|
} // namespace ui
|
|
|
|
#endif /*__UI_CHANNEL_H__*/
|