2015-07-08 11:39:24 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-07-29 23:27:28 -04:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-07-08 11:39:24 -04: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 "ui_navigation.hpp"
|
2016-04-28 08:59:14 -04:00
|
|
|
|
2017-06-10 21:53:06 -04:00
|
|
|
//#include "modules.h"
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-10-16 22:39:44 -04:00
|
|
|
#include "portapack.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
#include "event_m0.hpp"
|
2016-08-23 02:45:33 -04:00
|
|
|
#include "bmp_splash.hpp"
|
|
|
|
#include "bmp_modal_warning.hpp"
|
2017-06-10 21:53:06 -04:00
|
|
|
#include "portapack_persistent_memory.hpp"
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-01-07 08:17:39 -05:00
|
|
|
#include "ui_about.hpp"
|
2017-07-14 05:02:21 -04:00
|
|
|
#include "ui_adsb_tx.hpp"
|
|
|
|
#include "ui_adsb_rx.hpp"
|
2017-05-25 16:08:33 -04:00
|
|
|
#include "ui_aprstx.hpp"
|
2017-01-16 03:40:17 -05:00
|
|
|
#include "ui_bht_tx.hpp"
|
2017-04-07 01:20:24 -04:00
|
|
|
#include "ui_coasterp.hpp"
|
2017-07-18 14:31:05 -04:00
|
|
|
#include "ui_siggen.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "ui_debug.hpp"
|
|
|
|
#include "ui_encoders.hpp"
|
2016-12-05 06:56:41 -05:00
|
|
|
#include "ui_freqman.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "ui_jammer.hpp"
|
|
|
|
#include "ui_lcr.hpp"
|
2017-03-21 23:21:06 -04:00
|
|
|
#include "ui_mictx.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "ui_morse.hpp"
|
2017-06-23 03:40:22 -04:00
|
|
|
//#include "ui_numbers.hpp"
|
2016-09-23 11:34:50 -04:00
|
|
|
#include "ui_nuoptix.hpp"
|
2017-03-21 23:21:06 -04:00
|
|
|
#include "ui_playdead.hpp"
|
2017-02-07 12:48:17 -05:00
|
|
|
#include "ui_pocsag_tx.hpp"
|
2016-07-26 21:03:40 -04:00
|
|
|
#include "ui_rds.hpp"
|
2017-01-16 03:40:17 -05:00
|
|
|
#include "ui_sd_wipe.hpp"
|
2017-05-18 06:06:11 -04:00
|
|
|
#include "ui_scanner.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "ui_setup.hpp"
|
|
|
|
#include "ui_soundboard.hpp"
|
2017-03-22 14:21:31 -04:00
|
|
|
#include "ui_sstvtx.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "ui_whipcalc.hpp"
|
|
|
|
|
2016-07-26 21:03:40 -04:00
|
|
|
#include "analog_audio_app.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
#include "ais_app.hpp"
|
|
|
|
#include "ert_app.hpp"
|
|
|
|
#include "tpms_app.hpp"
|
2016-08-23 02:45:33 -04:00
|
|
|
#include "pocsag_app.hpp"
|
2016-04-11 13:59:55 -04:00
|
|
|
#include "capture_app.hpp"
|
2017-01-10 14:45:40 -05:00
|
|
|
#include "replay_app.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
|
2016-02-16 14:09:00 -05:00
|
|
|
#include "core_control.hpp"
|
2015-11-20 01:59:09 -05:00
|
|
|
|
2016-04-20 13:22:05 -04:00
|
|
|
#include "file.hpp"
|
2016-02-19 18:34:02 -05:00
|
|
|
#include "png_writer.hpp"
|
2015-07-08 11:39:24 -04:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
/* SystemStatusView ******************************************************/
|
|
|
|
|
|
|
|
SystemStatusView::SystemStatusView() {
|
2017-01-29 20:09:00 -05:00
|
|
|
static constexpr Style style_systemstatus {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::dark_grey(),
|
|
|
|
.foreground = Color::white(),
|
|
|
|
};
|
|
|
|
|
2016-09-05 17:53:04 -04:00
|
|
|
add_children({
|
2017-01-29 20:09:00 -05:00
|
|
|
&backdrop,
|
2016-01-31 03:34:24 -05:00
|
|
|
&button_back,
|
|
|
|
&title,
|
2016-12-09 12:21:47 -05:00
|
|
|
&button_stealth,
|
2016-05-29 06:06:47 -04:00
|
|
|
&button_textentry,
|
2016-02-19 00:35:46 -05:00
|
|
|
&button_camera,
|
2016-01-31 03:34:24 -05:00
|
|
|
&button_sleep,
|
|
|
|
&sd_card_status_view,
|
2016-09-05 17:53:04 -04:00
|
|
|
});
|
2016-05-29 06:06:47 -04:00
|
|
|
|
2017-04-20 19:31:21 -04:00
|
|
|
button_back.id = -1; // Special ID used by FocusManager
|
2017-01-29 20:09:00 -05:00
|
|
|
title.set_style(&style_systemstatus);
|
|
|
|
|
2016-12-25 19:31:38 -05:00
|
|
|
if (!portapack::persistent_memory::ui_config_textentry())
|
2017-02-03 03:21:12 -05:00
|
|
|
button_textentry.set_bitmap(&bitmap_icon_keyboard);
|
2016-05-29 06:06:47 -04:00
|
|
|
else
|
2017-02-03 03:21:12 -05:00
|
|
|
button_textentry.set_bitmap(&bitmap_icon_unistroke);
|
2016-12-09 12:21:47 -05:00
|
|
|
|
|
|
|
if (portapack::persistent_memory::stealth_mode())
|
|
|
|
button_stealth.set_foreground(ui::Color::green());
|
2016-01-31 03:34:24 -05:00
|
|
|
|
2017-01-29 20:09:00 -05:00
|
|
|
button_back.on_select = [this](ImageButton&){
|
2016-12-09 12:21:47 -05:00
|
|
|
if (this->on_back)
|
2016-01-31 03:34:24 -05:00
|
|
|
this->on_back();
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
button_stealth.on_select = [this](ImageButton&) {
|
|
|
|
this->on_stealth();
|
2016-01-31 03:34:24 -05:00
|
|
|
};
|
2016-05-29 06:06:47 -04:00
|
|
|
|
|
|
|
button_textentry.on_select = [this](ImageButton&) {
|
|
|
|
this->on_textentry();
|
|
|
|
};
|
2016-01-31 03:34:24 -05:00
|
|
|
|
2016-02-19 00:35:46 -05:00
|
|
|
button_camera.on_select = [this](ImageButton&) {
|
|
|
|
this->on_camera();
|
|
|
|
};
|
|
|
|
|
2016-02-03 19:04:23 -05:00
|
|
|
button_sleep.on_select = [this](ImageButton&) {
|
2016-01-31 03:34:24 -05:00
|
|
|
DisplaySleepMessage message;
|
2016-06-21 14:00:42 -04:00
|
|
|
EventDispatcher::send_message(message);
|
2016-01-31 03:34:24 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-02-07 13:33:15 -05:00
|
|
|
void SystemStatusView::set_back_enabled(bool new_value) {
|
2017-01-29 20:09:00 -05:00
|
|
|
button_back.set_foreground(new_value ? Color::white() : Color::dark_grey());
|
2016-02-07 13:33:15 -05:00
|
|
|
button_back.set_focusable(new_value);
|
2016-01-31 03:34:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SystemStatusView::set_title(const std::string new_value) {
|
|
|
|
if( new_value.empty() ) {
|
|
|
|
title.set(default_title);
|
|
|
|
} else {
|
|
|
|
title.set(new_value);
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
void SystemStatusView::on_stealth() {
|
|
|
|
bool cfg;
|
|
|
|
|
|
|
|
cfg = portapack::persistent_memory::stealth_mode();
|
|
|
|
portapack::persistent_memory::set_stealth_mode(not cfg);
|
|
|
|
|
|
|
|
if (!cfg)
|
|
|
|
button_stealth.set_foreground(ui::Color::green());
|
|
|
|
else
|
|
|
|
button_stealth.set_foreground(ui::Color::light_grey());
|
|
|
|
|
|
|
|
button_stealth.set_dirty();
|
|
|
|
}
|
|
|
|
|
2016-05-29 06:06:47 -04:00
|
|
|
void SystemStatusView::on_textentry() {
|
|
|
|
uint8_t cfg;
|
|
|
|
|
|
|
|
cfg = portapack::persistent_memory::ui_config_textentry();
|
|
|
|
portapack::persistent_memory::set_config_textentry(cfg ^ 1);
|
|
|
|
|
|
|
|
if (!cfg)
|
2017-02-03 03:21:12 -05:00
|
|
|
button_textentry.set_bitmap(&bitmap_icon_unistroke);
|
2016-05-29 06:06:47 -04:00
|
|
|
else
|
2017-02-03 03:21:12 -05:00
|
|
|
button_textentry.set_bitmap(&bitmap_icon_keyboard);
|
2016-05-29 06:06:47 -04:00
|
|
|
}
|
|
|
|
|
2016-02-19 00:35:46 -05:00
|
|
|
void SystemStatusView::on_camera() {
|
2016-09-08 15:57:34 -04:00
|
|
|
auto path = next_filename_stem_matching_pattern(u"SCR_????");
|
|
|
|
if( path.empty() ) {
|
2016-04-20 13:22:05 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:01:44 -04:00
|
|
|
PNGWriter png;
|
2016-09-08 15:57:34 -04:00
|
|
|
auto create_error = png.create(path.replace_extension(u".PNG"));
|
2016-05-16 17:01:44 -04:00
|
|
|
if( create_error.is_valid() ) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-19 18:34:02 -05:00
|
|
|
|
2017-04-18 16:29:55 -04:00
|
|
|
for(int i = 0; i < 320; i++) {
|
2016-02-19 18:34:02 -05:00
|
|
|
std::array<ColorRGB888, 240> row;
|
|
|
|
portapack::display.read_pixels({ 0, i, 240, 1 }, row);
|
|
|
|
png.write_scanline(row);
|
|
|
|
}
|
2016-02-19 00:35:46 -05:00
|
|
|
}
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
/* Navigation ************************************************************/
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
bool NavigationView::is_top() const {
|
|
|
|
return view_stack.size() == 1;
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
View* NavigationView::push_view(std::unique_ptr<View> new_view) {
|
|
|
|
free_view();
|
|
|
|
|
|
|
|
const auto p = new_view.get();
|
|
|
|
view_stack.emplace_back(std::move(new_view));
|
|
|
|
|
|
|
|
update_view();
|
|
|
|
|
|
|
|
return p;
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationView::pop() {
|
2016-05-17 12:33:16 -04:00
|
|
|
if( view() == modal_view ) {
|
|
|
|
modal_view = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
// Can't pop last item from stack.
|
|
|
|
if( view_stack.size() > 1 ) {
|
2016-01-31 03:34:24 -05:00
|
|
|
free_view();
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
view_stack.pop_back();
|
2016-01-31 03:34:24 -05:00
|
|
|
|
|
|
|
update_view();
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
void NavigationView::pop_modal() {
|
|
|
|
if( view() == modal_view ) {
|
|
|
|
modal_view = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
// Pop modal view + underlying app view
|
2016-12-06 07:31:38 -05:00
|
|
|
if( view_stack.size() > 2 ) {
|
|
|
|
free_view();
|
|
|
|
view_stack.pop_back();
|
|
|
|
free_view();
|
|
|
|
view_stack.pop_back();
|
|
|
|
|
|
|
|
update_view();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-17 13:15:34 -04:00
|
|
|
void NavigationView::display_modal(
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& message
|
2016-12-06 07:31:38 -05:00
|
|
|
) {
|
|
|
|
display_modal(title, message, INFO, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationView::display_modal(
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& message,
|
|
|
|
const modal_t type,
|
|
|
|
const std::function<void(bool)> on_choice
|
2016-05-17 13:15:34 -04:00
|
|
|
) {
|
2016-05-17 12:33:16 -04:00
|
|
|
/* If a modal view is already visible, don't display another */
|
|
|
|
if( !modal_view ) {
|
2016-12-06 07:31:38 -05:00
|
|
|
modal_view = push<ModalMessageView>(title, message, type, on_choice);
|
2016-05-17 12:33:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
void NavigationView::free_view() {
|
|
|
|
remove_child(view());
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
void NavigationView::update_view() {
|
|
|
|
const auto new_view = view_stack.back().get();
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
add_child(new_view);
|
|
|
|
new_view->set_parent_rect({ {0, 0}, size() });
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
focus();
|
|
|
|
set_dirty();
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
if( on_view_changed ) {
|
|
|
|
on_view_changed(*new_view);
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
2016-01-31 03:34:24 -05:00
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
Widget* NavigationView::view() const {
|
|
|
|
return children_.empty() ? nullptr : children_[0];
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationView::focus() {
|
|
|
|
if( view() ) {
|
|
|
|
view()->focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 16:36:30 -04:00
|
|
|
/* ReceiversMenuView *****************************************************/
|
2016-01-31 03:34:24 -05:00
|
|
|
|
2017-05-25 16:36:30 -04:00
|
|
|
ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
|
2017-06-20 22:25:27 -04:00
|
|
|
add_items({
|
2017-07-18 14:31:05 -04:00
|
|
|
{ "ADS-B: Planes", ui::Color::yellow(),&bitmap_icon_adsb, [&nav](){ nav.push<ADSBRxView>(); }, },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "AIS: Boats", ui::Color::green(), &bitmap_icon_ais, [&nav](){ nav.push<AISAppView>(); } },
|
|
|
|
{ "APRS", ui::Color::grey(), &bitmap_icon_aprs, [&nav](){ nav.push<NotImplementedView>(); } },
|
2017-07-18 14:31:05 -04:00
|
|
|
{ "Audio", ui::Color::green(), &bitmap_icon_speaker, [&nav](){ nav.push<AnalogAudioView>(false); } },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "ERT: Utility Meters", ui::Color::green(), &bitmap_icon_ert, [&nav](){ nav.push<ERTAppView>(); } },
|
|
|
|
{ "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push<POCSAGAppView>(); } },
|
|
|
|
{ "SIGFOX", ui::Color::grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
2017-07-18 14:31:05 -04:00
|
|
|
{ "LoRa", ui::Color::grey(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "SSTV", ui::Color::grey(), &bitmap_icon_sstv, [&nav](){ nav.push<NotImplementedView>(); } },
|
|
|
|
{ "TPMS: Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.push<TPMSAppView>(); } },
|
2017-06-20 22:25:27 -04:00
|
|
|
});
|
2016-11-30 01:41:55 -05:00
|
|
|
on_left = [&nav](){ nav.pop(); };
|
2017-07-18 14:31:05 -04:00
|
|
|
//set_highlighted(3); // Default selection is "Audio"
|
2016-11-30 01:41:55 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 16:36:30 -04:00
|
|
|
/* TransmittersMenuView **************************************************/
|
|
|
|
|
|
|
|
TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
2016-09-05 18:20:50 -04:00
|
|
|
add_items({
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "ADS-B Mode S", ui::Color::orange(), &bitmap_icon_adsb, [&nav](){ nav.push<ADSBTxView>(); } },
|
|
|
|
{ "APRS", ui::Color::grey(), &bitmap_icon_aprs, [&nav](){ nav.push<APRSTXView>(); } },
|
|
|
|
{ "BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav](){ nav.push<BHTView>(); } },
|
|
|
|
{ "Jammer", ui::Color::yellow(), &bitmap_icon_jammer, [&nav](){ nav.push<JammerView>(); } },
|
|
|
|
{ "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push<MicTXView>(); } },
|
|
|
|
{ "Morse code", ui::Color::green(), &bitmap_icon_morse, [&nav](){ nav.push<MorseView>(); } },
|
|
|
|
{ "NTTWorks burger pager", ui::Color::yellow(), &bitmap_icon_burger, [&nav](){ nav.push<CoasterPagerView>(); } },
|
2017-06-23 03:40:22 -04:00
|
|
|
{ "Numbers station", ui::Color::grey(), &bitmap_icon_numbers, [&nav](){ nav.push<NotImplementedView>(); } }, // NumbersStationView
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "Nuoptix DTMF timecode", ui::Color::green(), &bitmap_icon_nuoptix, [&nav](){ nav.push<NuoptixView>(); } },
|
|
|
|
{ "OOK remote encoders", ui::Color::yellow(), &bitmap_icon_remote, [&nav](){ nav.push<EncodersView>(); } },
|
|
|
|
{ "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push<POCSAGTXView>(); } },
|
|
|
|
{ "RDS", ui::Color::green(), &bitmap_icon_rds, [&nav](){ nav.push<RDSView>(); } },
|
2017-07-18 14:31:05 -04:00
|
|
|
{ "Signal generator", ui::Color::green(), &bitmap_icon_cwgen, [&nav](){ nav.push<SigGenView>(); } },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } },
|
|
|
|
{ "SSTV", ui::Color::green(), &bitmap_icon_sstv, [&nav](){ nav.push<SSTVTXView>(); } },
|
|
|
|
{ "TEDI/LCR AFSK", ui::Color::yellow(), &bitmap_icon_lcr, [&nav](){ nav.push<LCRView>(); } },
|
2016-09-05 18:20:50 -04:00
|
|
|
});
|
2016-02-04 15:17:10 -05:00
|
|
|
on_left = [&nav](){ nav.pop(); };
|
2016-01-31 03:34:24 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 16:36:30 -04:00
|
|
|
/* UtilitiesMenuView *****************************************************/
|
2016-12-06 07:31:38 -05:00
|
|
|
|
2017-05-25 16:36:30 -04:00
|
|
|
UtilitiesMenuView::UtilitiesMenuView(NavigationView& nav) {
|
2016-09-05 18:20:50 -04:00
|
|
|
add_items({
|
2017-06-22 04:08:37 -04:00
|
|
|
{ "Frequency manager", ui::Color::green(), &bitmap_icon_freqman, [&nav](){ nav.push<FrequencyManagerView>(); } },
|
2017-04-07 01:20:24 -04:00
|
|
|
{ "Whip antenna length", ui::Color::yellow(),nullptr, [&nav](){ nav.push<WhipCalcView>(); } },
|
|
|
|
{ "Notepad", ui::Color::grey(), &bitmap_icon_notepad, [&nav](){ nav.push<NotImplementedView>(); } },
|
|
|
|
{ "Wipe SD card", ui::Color::red(), nullptr, [&nav](){ nav.push<WipeSDView>(); } },
|
2016-09-05 18:20:50 -04:00
|
|
|
});
|
2016-12-06 07:31:38 -05:00
|
|
|
on_left = [&nav](){ nav.pop(); };
|
|
|
|
}
|
2017-05-25 16:36:30 -04:00
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
/* SystemMenuView ********************************************************/
|
|
|
|
|
2016-12-25 19:31:38 -05:00
|
|
|
void SystemMenuView::hackrf_mode(NavigationView& nav) {
|
|
|
|
nav.push<ModalMessageView>("Confirm", "Switch to HackRF mode ?", YESNO,
|
|
|
|
[this](bool choice) {
|
|
|
|
if (choice) {
|
|
|
|
EventDispatcher::request_stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
SystemMenuView::SystemMenuView(NavigationView& nav) {
|
2016-09-05 18:20:50 -04:00
|
|
|
add_items({
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "Play dead", ui::Color::red(), &bitmap_icon_playdead, [&nav](){ nav.push<PlayDeadView>(); } },
|
|
|
|
{ "Receivers", ui::Color::cyan(), &bitmap_icon_receivers, [&nav](){ nav.push<ReceiversMenuView>(); } },
|
2017-08-11 19:27:05 -04:00
|
|
|
{ "Transmitters", ui::Color::green(), &bitmap_icon_transmit, [&nav](){ nav.push<TransmittersMenuView>(); } },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "Capture", ui::Color::blue(), &bitmap_icon_capture, [&nav](){ nav.push<CaptureAppView>(); } },
|
2017-06-23 03:40:22 -04:00
|
|
|
{ "Replay", ui::Color::grey(), &bitmap_icon_replay, [&nav](){ nav.push<ReplayAppView>(); } },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "Scanner/search", ui::Color::orange(), &bitmap_icon_closecall, [&nav](){ nav.push<ScannerView>(); } },
|
|
|
|
{ "Utilities", ui::Color::purple(), &bitmap_icon_utilities, [&nav](){ nav.push<UtilitiesMenuView>(); } },
|
|
|
|
{ "Setup", ui::Color::white(), &bitmap_icon_setup, [&nav](){ nav.push<SetupMenuView>(); } },
|
2017-02-03 01:26:42 -05:00
|
|
|
//{ "Debug", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugMenuView>(); } },
|
2017-05-25 16:36:30 -04:00
|
|
|
{ "HackRF mode", ui::Color::white(), &bitmap_icon_hackrf, [this, &nav](){ hackrf_mode(nav); } },
|
|
|
|
{ "About", ui::Color::white(), nullptr, [&nav](){ nav.push<AboutView>(); } }
|
2016-09-05 18:20:50 -04:00
|
|
|
});
|
2016-12-09 12:21:47 -05:00
|
|
|
|
|
|
|
set_highlighted(1); // Startup selection is "Receivers"
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SystemView ************************************************************/
|
|
|
|
|
|
|
|
static constexpr ui::Style style_default {
|
|
|
|
.font = ui::font::fixed_8x16,
|
|
|
|
.background = ui::Color::black(),
|
2016-05-29 06:06:47 -04:00
|
|
|
.foreground = ui::Color::white()
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
SystemView::SystemView(
|
|
|
|
Context& context,
|
|
|
|
const Rect parent_rect
|
|
|
|
) : View { parent_rect },
|
2015-07-17 15:07:38 -04:00
|
|
|
context_(context)
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
2016-02-07 13:40:06 -05:00
|
|
|
set_style(&style_default);
|
2015-07-08 11:39:24 -04:00
|
|
|
|
|
|
|
constexpr ui::Dim status_view_height = 16;
|
2016-05-09 14:42:20 -04:00
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
add_child(&status_view);
|
|
|
|
status_view.set_parent_rect({
|
|
|
|
{ 0, 0 },
|
|
|
|
{ parent_rect.width(), status_view_height }
|
|
|
|
});
|
2016-01-31 03:34:24 -05:00
|
|
|
status_view.on_back = [this]() {
|
|
|
|
this->navigation_view.pop();
|
|
|
|
};
|
2015-07-08 11:39:24 -04:00
|
|
|
|
|
|
|
add_child(&navigation_view);
|
|
|
|
navigation_view.set_parent_rect({
|
|
|
|
{ 0, status_view_height },
|
|
|
|
{ parent_rect.width(), static_cast<ui::Dim>(parent_rect.height() - status_view_height) }
|
|
|
|
});
|
2016-01-31 03:34:24 -05:00
|
|
|
navigation_view.on_view_changed = [this](const View& new_view) {
|
2016-02-07 13:33:15 -05:00
|
|
|
this->status_view.set_back_enabled(!this->navigation_view.is_top());
|
2016-01-31 03:34:24 -05:00
|
|
|
this->status_view.set_title(new_view.title());
|
|
|
|
};
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-12-26 07:49:23 -05:00
|
|
|
// portapack::persistent_memory::set_playdead_sequence(0x8D1);
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
// Initial view
|
2017-04-01 17:35:14 -04:00
|
|
|
/*if ((portapack::persistent_memory::playing_dead() == 0x5920C1DF) || // Enable code
|
2016-12-09 12:21:47 -05:00
|
|
|
(portapack::persistent_memory::ui_config() & 16)) { // Login option
|
|
|
|
navigation_view.push<PlayDeadView>();
|
2017-04-01 17:35:14 -04:00
|
|
|
} else {*/
|
2016-12-09 12:21:47 -05:00
|
|
|
if (portapack::persistent_memory::ui_config() & 1)
|
|
|
|
navigation_view.push<BMPView>();
|
|
|
|
else
|
|
|
|
navigation_view.push<SystemMenuView>();
|
2017-04-01 17:35:14 -04:00
|
|
|
//}
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Context& SystemView::context() const {
|
|
|
|
return context_;
|
|
|
|
}
|
|
|
|
|
2016-02-05 11:40:14 -05:00
|
|
|
/* ***********************************************************************/
|
|
|
|
|
|
|
|
void BMPView::focus() {
|
|
|
|
button_done.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
BMPView::BMPView(NavigationView& nav) {
|
2017-01-15 22:45:44 -05:00
|
|
|
add_children({
|
2016-02-05 11:40:14 -05:00
|
|
|
&text_info,
|
|
|
|
&button_done
|
2017-01-15 22:45:44 -05:00
|
|
|
});
|
2016-02-05 11:40:14 -05:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
button_done.on_select = [this, &nav](Button&){
|
2016-02-05 11:40:14 -05:00
|
|
|
nav.pop();
|
2016-12-29 17:20:26 -05:00
|
|
|
nav.push<SystemMenuView>();
|
2016-02-05 11:40:14 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
void BMPView::paint(Painter&) {
|
|
|
|
portapack::display.drawBMP({(240 - 185) / 2, 0}, splash_bmp, false);
|
2016-02-05 11:40:14 -05:00
|
|
|
}
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
/* NotImplementedView ****************************************************/
|
|
|
|
|
|
|
|
NotImplementedView::NotImplementedView(NavigationView& nav) {
|
|
|
|
button_done.on_select = [&nav](Button&){
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
2016-09-05 17:53:04 -04:00
|
|
|
add_children({
|
2015-07-08 11:39:24 -04:00
|
|
|
&text_title,
|
|
|
|
&button_done,
|
2016-09-05 17:53:04 -04:00
|
|
|
});
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotImplementedView::focus() {
|
|
|
|
button_done.focus();
|
|
|
|
}
|
|
|
|
|
2016-05-13 00:58:54 -04:00
|
|
|
/* ModalMessageView ******************************************************/
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2016-05-17 13:15:34 -04:00
|
|
|
ModalMessageView::ModalMessageView(
|
|
|
|
NavigationView& nav,
|
|
|
|
const std::string& title,
|
2016-08-23 02:45:33 -04:00
|
|
|
const std::string& message,
|
2016-12-06 07:31:38 -05:00
|
|
|
const modal_t type,
|
|
|
|
const std::function<void(bool)> on_choice
|
2016-08-23 02:45:33 -04:00
|
|
|
) : title_ { title },
|
2017-02-07 14:54:18 -05:00
|
|
|
message_ { message },
|
2016-12-06 07:31:38 -05:00
|
|
|
type_ { type },
|
|
|
|
on_choice_ { on_choice }
|
2016-05-17 13:15:34 -04:00
|
|
|
{
|
2016-12-06 07:31:38 -05:00
|
|
|
if (type == INFO) {
|
|
|
|
add_child(&button_ok);
|
|
|
|
|
|
|
|
button_ok.on_select = [&nav](Button&){
|
2016-08-23 02:45:33 -04:00
|
|
|
nav.pop();
|
|
|
|
};
|
2016-12-06 07:31:38 -05:00
|
|
|
} else if (type == YESNO) {
|
2017-01-15 22:45:44 -05:00
|
|
|
add_children({
|
2016-12-06 07:31:38 -05:00
|
|
|
&button_yes,
|
|
|
|
&button_no
|
2017-01-15 22:45:44 -05:00
|
|
|
});
|
2016-12-06 07:31:38 -05:00
|
|
|
|
|
|
|
button_yes.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(true);
|
2016-08-23 02:45:33 -04:00
|
|
|
nav.pop();
|
|
|
|
};
|
2016-12-06 07:31:38 -05:00
|
|
|
button_no.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(false);
|
2016-08-23 02:45:33 -04:00
|
|
|
nav.pop();
|
|
|
|
};
|
2017-01-10 13:40:33 -05:00
|
|
|
} else if (type == YESCANCEL) {
|
2017-01-15 22:45:44 -05:00
|
|
|
add_children({
|
2017-01-10 13:40:33 -05:00
|
|
|
&button_yes,
|
|
|
|
&button_no
|
2017-01-15 22:45:44 -05:00
|
|
|
});
|
2017-01-10 13:40:33 -05:00
|
|
|
|
|
|
|
button_yes.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(true);
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
button_no.on_select = [this, &nav](Button&){
|
|
|
|
//if (on_choice_) on_choice_(false);
|
|
|
|
nav.pop_modal();
|
|
|
|
};
|
|
|
|
} else { // ABORT
|
2016-12-06 07:31:38 -05:00
|
|
|
add_child(&button_ok);
|
2016-08-23 02:45:33 -04:00
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
button_ok.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(true);
|
|
|
|
nav.pop_modal();
|
|
|
|
};
|
2016-08-23 02:45:33 -04:00
|
|
|
}
|
2016-05-13 00:58:54 -04:00
|
|
|
}
|
|
|
|
|
2017-02-07 14:54:18 -05:00
|
|
|
void ModalMessageView::paint(Painter& painter) {
|
|
|
|
size_t pos, i = 0, start = 0;
|
|
|
|
|
|
|
|
portapack::display.drawBMP({ 100, 48 }, modal_warning_bmp, false);
|
|
|
|
|
|
|
|
// Terrible...
|
|
|
|
while ((pos = message_.find("\n", start)) != std::string::npos) {
|
|
|
|
painter.draw_string(
|
|
|
|
{ 1 * 8, (Coord)(120 + (i * 16)) },
|
|
|
|
style(),
|
2017-02-07 20:19:29 -05:00
|
|
|
message_.substr(start, pos - start)
|
2017-02-07 14:54:18 -05:00
|
|
|
);
|
|
|
|
i++;
|
|
|
|
start = pos + 1;
|
|
|
|
}
|
|
|
|
painter.draw_string(
|
|
|
|
{ 1 * 8, (Coord)(120 + (i * 16)) },
|
|
|
|
style(),
|
|
|
|
message_.substr(start, pos)
|
|
|
|
);
|
2016-08-23 02:45:33 -04:00
|
|
|
}
|
|
|
|
|
2016-05-13 00:58:54 -04:00
|
|
|
void ModalMessageView::focus() {
|
2017-01-10 13:40:33 -05:00
|
|
|
if ((type_ == YESNO) || (type_ == YESCANCEL)) {
|
2016-08-23 02:45:33 -04:00
|
|
|
button_yes.focus();
|
2016-12-06 07:31:38 -05:00
|
|
|
} else {
|
|
|
|
button_ok.focus();
|
2016-08-23 02:45:33 -04:00
|
|
|
}
|
2016-05-13 00:58:54 -04:00
|
|
|
}
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
} /* namespace ui */
|