2016-05-11 10:45:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "receiver_model.hpp"
|
|
|
|
|
|
|
|
#include "spectrum_color_lut.hpp"
|
|
|
|
|
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2017-02-01 08:53:26 +00:00
|
|
|
#define CC_SLICE_WIDTH 2500000 // Radio bandwidth
|
|
|
|
#define CC_BIN_NB 256 // Total power bins (skip 4 at center, 2*6 on sides)
|
|
|
|
#define CC_BIN_NB_NO_DC (CC_BIN_NB - 16)
|
|
|
|
#define CC_BIN_WIDTH (CC_SLICE_WIDTH / CC_BIN_NB)
|
2016-05-11 10:45:03 +00:00
|
|
|
|
|
|
|
class CloseCallView : public View {
|
|
|
|
public:
|
|
|
|
CloseCallView(NavigationView& nav);
|
|
|
|
~CloseCallView();
|
|
|
|
|
2017-01-16 08:40:17 +00:00
|
|
|
CloseCallView(const CloseCallView&) = delete;
|
|
|
|
CloseCallView(CloseCallView&&) = delete;
|
|
|
|
CloseCallView& operator=(const CloseCallView&) = delete;
|
|
|
|
CloseCallView& operator=(CloseCallView&&) = delete;
|
|
|
|
|
2016-05-11 10:45:03 +00:00
|
|
|
void on_show() override;
|
|
|
|
void on_hide() override;
|
|
|
|
void focus() override;
|
2016-05-11 21:57:22 +00:00
|
|
|
std::string title() const override { return "Close Call"; };
|
2016-05-11 10:45:03 +00:00
|
|
|
|
|
|
|
private:
|
2016-05-15 00:35:08 +00:00
|
|
|
const Style style_grey { // For labels and lost signal
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::grey(),
|
|
|
|
};
|
|
|
|
|
|
|
|
const Style style_locked {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::green(),
|
|
|
|
};
|
2016-12-08 15:13:27 +00:00
|
|
|
|
2017-02-13 05:35:13 +00:00
|
|
|
rf::Frequency f_min { 0 }, f_max { 0 };
|
2017-02-01 08:53:26 +00:00
|
|
|
Coord last_pos { 0 };
|
2016-05-11 10:45:03 +00:00
|
|
|
ChannelSpectrumFIFO* fifo { nullptr };
|
2017-02-01 08:53:26 +00:00
|
|
|
uint8_t detect_counter { 0 }, release_counter { 0 };
|
2017-02-13 05:35:13 +00:00
|
|
|
uint8_t slice_trim { 0 };
|
2017-02-01 08:53:26 +00:00
|
|
|
uint32_t mean { 0 };
|
|
|
|
uint32_t min_threshold { 80 }; // Todo: Put this in persistent / settings
|
2017-02-13 05:35:13 +00:00
|
|
|
rf::Frequency slice_start { 0 };
|
|
|
|
rf::Frequency slice_frequency { 0 };
|
|
|
|
uint8_t slices_max { 0 };
|
|
|
|
uint8_t slices_counter { 0 };
|
|
|
|
int16_t last_channel { 0 };
|
2017-02-01 08:53:26 +00:00
|
|
|
uint32_t weight { 0 };
|
|
|
|
uint64_t frequency_acc { 0 };
|
2017-02-13 05:35:13 +00:00
|
|
|
rf::Frequency scan_span { 0 }, resolved_frequency { 0 };
|
|
|
|
uint16_t locked_imax { 0 };
|
2017-02-01 08:53:26 +00:00
|
|
|
uint8_t slicemax_pow[32]; // Todo: Cap max slices !
|
|
|
|
int16_t slicemax_idx[32];
|
2017-02-13 05:35:13 +00:00
|
|
|
uint8_t scan_counter { 0 };
|
2017-02-01 08:53:26 +00:00
|
|
|
SignalToken signal_token_tick_second { };
|
|
|
|
bool ignore { true };
|
|
|
|
bool slicing { false };
|
|
|
|
bool locked { false };
|
2016-12-08 15:13:27 +00:00
|
|
|
|
2016-05-11 10:45:03 +00:00
|
|
|
void on_channel_spectrum(const ChannelSpectrum& spectrum);
|
|
|
|
void on_range_changed();
|
|
|
|
void do_detection();
|
2016-05-11 21:57:22 +00:00
|
|
|
void on_lna_changed(int32_t v_db);
|
|
|
|
void on_vga_changed(int32_t v_db);
|
2016-05-12 23:18:04 +00:00
|
|
|
void on_tick_second();
|
2016-05-11 10:45:03 +00:00
|
|
|
|
2016-05-11 21:57:22 +00:00
|
|
|
/* |012345678901234567890123456789|
|
|
|
|
* | Min: Max: LNA VGA |
|
|
|
|
* | 0000.0000 0000.0000 00 00 |
|
|
|
|
* | Threshold: 000 |
|
2016-05-15 00:35:08 +00:00
|
|
|
* | Slices: 00 Rate: 00Hz |
|
2016-05-11 21:57:22 +00:00
|
|
|
* |
|
|
|
|
* */
|
|
|
|
|
2017-02-13 05:35:13 +00:00
|
|
|
Labels labels {
|
|
|
|
{ { 1 * 8, 0 }, "Min: Max: LNA VGA", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 4 * 8 }, "Threshold:", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 6 * 8 }, "Slices: Rate: Hz", Color::light_grey() }
|
2016-05-11 21:57:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_threshold {
|
|
|
|
{ 12 * 8, 2 * 16 },
|
|
|
|
3,
|
|
|
|
{ 5, 250 },
|
|
|
|
5,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
2016-05-11 10:45:03 +00:00
|
|
|
FrequencyField field_frequency_min {
|
2016-05-11 21:57:22 +00:00
|
|
|
{ 1 * 8, 1 * 16 },
|
2016-05-11 10:45:03 +00:00
|
|
|
};
|
|
|
|
FrequencyField field_frequency_max {
|
2016-05-11 21:57:22 +00:00
|
|
|
{ 11 * 8, 1 * 16 },
|
2016-05-11 10:45:03 +00:00
|
|
|
};
|
|
|
|
|
2016-05-11 21:57:22 +00:00
|
|
|
LNAGainField field_lna {
|
|
|
|
{ 22 * 8, 1 * 16 }
|
|
|
|
};
|
|
|
|
VGAGainField field_vga {
|
|
|
|
{ 26 * 8, 1 * 16 }
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_slices {
|
|
|
|
{ 9 * 8, 3 * 16, 2 * 8, 16 },
|
2016-05-11 10:45:03 +00:00
|
|
|
"--"
|
|
|
|
};
|
2016-05-11 21:57:22 +00:00
|
|
|
Text text_rate {
|
2016-05-15 00:35:08 +00:00
|
|
|
{ 24 * 8, 3 * 16, 2 * 8, 16 },
|
2016-12-08 15:13:27 +00:00
|
|
|
"--"
|
2016-05-11 21:57:22 +00:00
|
|
|
};
|
2016-05-11 10:45:03 +00:00
|
|
|
|
|
|
|
Text text_infos {
|
2016-12-08 15:13:27 +00:00
|
|
|
{ 1 * 8, 6 * 16, 28 * 8, 16 },
|
2016-05-11 21:57:22 +00:00
|
|
|
"..."
|
|
|
|
};
|
|
|
|
|
|
|
|
BigFrequency big_display {
|
|
|
|
{ 4, 8 * 16, 28 * 8, 32 },
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2016-05-16 10:02:45 +00:00
|
|
|
Text text_mhz {
|
2016-12-08 15:13:27 +00:00
|
|
|
{ 26 * 8, 12 * 16 - 4, 3 * 8, 16 },
|
2016-05-16 10:02:45 +00:00
|
|
|
"MHz"
|
|
|
|
};
|
|
|
|
|
2016-05-17 18:27:51 +00:00
|
|
|
Text text_precision {
|
2016-05-11 21:57:22 +00:00
|
|
|
{ 1 * 8, 13 * 16, 28 * 8, 16 },
|
2016-12-08 15:13:27 +00:00
|
|
|
"..."
|
2016-05-17 18:27:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Text text_debug {
|
|
|
|
{ 1 * 8, 14 * 16, 28 * 8, 16 },
|
2016-12-08 15:13:27 +00:00
|
|
|
"DEBUG: -"
|
2016-05-11 10:45:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Button button_exit {
|
|
|
|
{ 92, 264, 56, 32 },
|
|
|
|
"Exit"
|
|
|
|
};
|
2016-07-27 01:03:40 +00:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_spectrum_config {
|
|
|
|
Message::ID::ChannelSpectrumConfig,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p);
|
|
|
|
this->fifo = message.fifo;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MessageHandlerRegistration message_handler_frame_sync {
|
|
|
|
Message::ID::DisplayFrameSync,
|
|
|
|
[this](const Message* const) {
|
|
|
|
if( this->fifo ) {
|
|
|
|
ChannelSpectrum channel_spectrum;
|
|
|
|
while( fifo->out(channel_spectrum) ) {
|
|
|
|
this->on_channel_spectrum(channel_spectrum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-05-11 10:45:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|