2017-05-18 10:06:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2018-04-19 19:50:32 +00:00
|
|
|
* Copyright (C) 2018 Furrtek
|
2017-05-18 10:06:11 +00:00
|
|
|
*
|
|
|
|
* 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 "ui_receiver.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2018-04-19 19:50:32 +00:00
|
|
|
class ScannerThread {
|
|
|
|
public:
|
|
|
|
ScannerThread(std::vector<rf::Frequency> frequency_list);
|
|
|
|
~ScannerThread();
|
|
|
|
|
|
|
|
void set_scanning(const bool v);
|
|
|
|
|
|
|
|
ScannerThread(const ScannerThread&) = delete;
|
|
|
|
ScannerThread(ScannerThread&&) = delete;
|
|
|
|
ScannerThread& operator=(const ScannerThread&) = delete;
|
|
|
|
ScannerThread& operator=(ScannerThread&&) = delete;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<rf::Frequency> frequency_list_ { };
|
|
|
|
Thread* thread { nullptr };
|
|
|
|
|
|
|
|
bool _scanning { true };
|
|
|
|
|
|
|
|
static msg_t static_fn(void* arg);
|
|
|
|
|
|
|
|
void run();
|
|
|
|
};
|
|
|
|
|
2017-05-18 10:06:11 +00:00
|
|
|
class ScannerView : public View {
|
|
|
|
public:
|
2018-04-19 19:50:32 +00:00
|
|
|
ScannerView(NavigationView&);
|
2017-05-18 10:06:11 +00:00
|
|
|
~ScannerView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
2018-03-27 11:52:07 +00:00
|
|
|
std::string title() const override { return "Scanner"; };
|
2017-05-18 10:06:11 +00:00
|
|
|
|
|
|
|
private:
|
2018-04-19 19:50:32 +00:00
|
|
|
void on_statistics_update(const ChannelStatistics& statistics);
|
|
|
|
void on_headphone_volume_changed(int32_t v);
|
|
|
|
void handle_retune(uint32_t i);
|
|
|
|
|
|
|
|
std::vector<rf::Frequency> frequency_list { };
|
|
|
|
int32_t squelch { 0 };
|
|
|
|
uint32_t timer { 0 };
|
|
|
|
|
2017-05-18 10:06:11 +00:00
|
|
|
Labels labels {
|
2018-04-19 19:50:32 +00:00
|
|
|
{ { 0 * 8, 0 * 16 }, "LNA: VGA: AMP: VOL:", Color::light_grey() },
|
|
|
|
{ { 0 * 8, 1 * 16 }, "SQUELCH: /99", Color::light_grey() },
|
|
|
|
{ { 0 * 8, 3 * 16 }, "Work in progress...", Color::light_grey() }
|
|
|
|
};
|
|
|
|
|
|
|
|
LNAGainField field_lna {
|
|
|
|
{ 4 * 8, 0 * 16 }
|
|
|
|
};
|
|
|
|
|
|
|
|
VGAGainField field_vga {
|
|
|
|
{ 11 * 8, 0 * 16 }
|
|
|
|
};
|
|
|
|
|
|
|
|
RFAmpField field_rf_amp {
|
|
|
|
{ 18 * 8, 0 * 16 }
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_volume {
|
|
|
|
{ 24 * 8, 0 * 16 },
|
|
|
|
2,
|
|
|
|
{ 0, 99 },
|
|
|
|
1,
|
|
|
|
' ',
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_squelch {
|
|
|
|
{ 8 * 8, 1 * 16 },
|
|
|
|
2,
|
|
|
|
{ 0, 99 },
|
|
|
|
1,
|
|
|
|
' ',
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_cycle {
|
|
|
|
{ 0, 5 * 16, 240, 16 },
|
|
|
|
"--/--"
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<ScannerThread> scan_thread { };
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_retune {
|
|
|
|
Message::ID::Retune,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const RetuneMessage*>(p);
|
|
|
|
this->handle_retune(message.range);
|
|
|
|
}
|
2017-05-18 10:06:11 +00:00
|
|
|
};
|
|
|
|
|
2018-04-19 19:50:32 +00:00
|
|
|
MessageHandlerRegistration message_handler_stats {
|
|
|
|
Message::ID::ChannelStatistics,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
|
|
|
}
|
2017-05-18 10:06:11 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|