2015-07-08 15:39:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-07-30 03:27:28 +00:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-07-08 15:39:24 +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 "ui_navigation.hpp"
|
2016-07-27 01:03:40 +00:00
|
|
|
//#include "ui_loadmodule.hpp"
|
2016-04-28 12:59:14 +00:00
|
|
|
|
|
|
|
#include "modules.h"
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2015-10-17 02:39:44 +00:00
|
|
|
#include "portapack.hpp"
|
2016-01-31 08:34:24 +00:00
|
|
|
#include "event_m0.hpp"
|
2016-04-21 20:12:51 +00:00
|
|
|
#include "portapack_persistent_memory.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
#include "bmp_splash.hpp"
|
|
|
|
#include "bmp_modal_warning.hpp"
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-07 13:17:39 +00:00
|
|
|
#include "ui_about.hpp"
|
2015-07-08 15:39:24 +00:00
|
|
|
#include "ui_setup.hpp"
|
|
|
|
#include "ui_debug.hpp"
|
|
|
|
|
2016-12-05 11:56:41 +00:00
|
|
|
#include "ui_numbers.hpp"
|
2016-12-06 12:31:38 +00:00
|
|
|
#include "ui_whipcalc.hpp"
|
2016-12-07 19:49:42 +00:00
|
|
|
#include "ui_closecall.hpp"
|
2016-12-05 11:56:41 +00:00
|
|
|
#include "ui_freqman.hpp"
|
2016-09-23 15:34:50 +00:00
|
|
|
#include "ui_nuoptix.hpp"
|
2016-08-26 06:11:24 +00:00
|
|
|
#include "ui_soundboard.hpp"
|
2016-08-03 02:53:51 +00:00
|
|
|
#include "ui_encoders.hpp"
|
2016-07-27 01:03:40 +00:00
|
|
|
#include "ui_rds.hpp"
|
|
|
|
#include "ui_xylos.hpp"
|
|
|
|
#include "ui_epar.hpp"
|
|
|
|
#include "ui_lcr.hpp"
|
|
|
|
#include "analog_audio_app.hpp"
|
2016-11-30 06:41:55 +00:00
|
|
|
#include "ui_adsbtx.hpp"
|
|
|
|
#include "ui_jammer.hpp"
|
2016-01-31 08:34:24 +00:00
|
|
|
#include "ais_app.hpp"
|
|
|
|
#include "ert_app.hpp"
|
|
|
|
#include "tpms_app.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
#include "pocsag_app.hpp"
|
2016-04-11 17:59:55 +00:00
|
|
|
#include "capture_app.hpp"
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
#include "ui_debug.hpp"
|
2016-02-16 19:09:00 +00:00
|
|
|
#include "core_control.hpp"
|
2015-11-20 06:59:09 +00:00
|
|
|
|
2016-04-20 17:22:05 +00:00
|
|
|
#include "file.hpp"
|
2016-02-19 23:34:02 +00:00
|
|
|
#include "png_writer.hpp"
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
/* SystemStatusView ******************************************************/
|
|
|
|
|
|
|
|
SystemStatusView::SystemStatusView() {
|
2016-05-29 10:06:47 +00:00
|
|
|
uint8_t cfg;
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
add_children({ {
|
2016-01-31 08:34:24 +00:00
|
|
|
&button_back,
|
|
|
|
&title,
|
2016-05-29 10:06:47 +00:00
|
|
|
&button_textentry,
|
2016-02-19 05:35:46 +00:00
|
|
|
&button_camera,
|
2016-01-31 08:34:24 +00:00
|
|
|
&button_sleep,
|
|
|
|
&sd_card_status_view,
|
2015-07-08 15:39:24 +00:00
|
|
|
} });
|
2016-05-29 10:06:47 +00:00
|
|
|
|
|
|
|
cfg = portapack::persistent_memory::ui_config_textentry();
|
|
|
|
|
|
|
|
if (!cfg)
|
|
|
|
button_textentry.set_bitmap(&bitmap_keyboard);
|
|
|
|
else
|
|
|
|
button_textentry.set_bitmap(&bitmap_unistroke);
|
2016-01-31 08:34:24 +00:00
|
|
|
|
|
|
|
button_back.on_select = [this](Button&){
|
|
|
|
if( this->on_back ) {
|
|
|
|
this->on_back();
|
|
|
|
}
|
|
|
|
};
|
2016-05-29 10:06:47 +00:00
|
|
|
|
|
|
|
button_textentry.on_select = [this](ImageButton&) {
|
|
|
|
this->on_textentry();
|
|
|
|
};
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2016-02-19 05:35:46 +00:00
|
|
|
button_camera.on_select = [this](ImageButton&) {
|
|
|
|
this->on_camera();
|
|
|
|
};
|
|
|
|
|
2016-02-04 00:04:23 +00:00
|
|
|
button_sleep.on_select = [this](ImageButton&) {
|
2016-01-31 08:34:24 +00:00
|
|
|
DisplaySleepMessage message;
|
2016-06-21 18:00:42 +00:00
|
|
|
EventDispatcher::send_message(message);
|
2016-01-31 08:34:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-02-07 18:33:15 +00:00
|
|
|
void SystemStatusView::set_back_enabled(bool new_value) {
|
|
|
|
button_back.set_text(new_value ? back_text_enabled : back_text_disabled);
|
|
|
|
button_back.set_focusable(new_value);
|
2016-01-31 08:34:24 +00: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 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
2016-05-29 10:06:47 +00: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)
|
|
|
|
button_textentry.set_bitmap(&bitmap_unistroke);
|
|
|
|
else
|
|
|
|
button_textentry.set_bitmap(&bitmap_keyboard);
|
|
|
|
}
|
|
|
|
|
2016-02-19 05:35:46 +00:00
|
|
|
void SystemStatusView::on_camera() {
|
2016-05-09 19:05:11 +00:00
|
|
|
const auto filename_stem = next_filename_stem_matching_pattern("SCR_????");
|
|
|
|
if( filename_stem.empty() ) {
|
2016-04-20 17:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-16 21:01:44 +00:00
|
|
|
PNGWriter png;
|
|
|
|
auto create_error = png.create(filename_stem + ".PNG");
|
|
|
|
if( create_error.is_valid() ) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-19 23:34:02 +00:00
|
|
|
|
2016-12-05 11:56:41 +00:00
|
|
|
for (int i=0; i<320; i++) {
|
2016-02-19 23:34:02 +00:00
|
|
|
std::array<ColorRGB888, 240> row;
|
|
|
|
portapack::display.read_pixels({ 0, i, 240, 1 }, row);
|
|
|
|
png.write_scanline(row);
|
|
|
|
}
|
2016-02-19 05:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
/* Navigation ************************************************************/
|
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
bool NavigationView::is_top() const {
|
|
|
|
return view_stack.size() == 1;
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
2016-01-31 08:34:24 +00: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 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationView::pop() {
|
2016-05-17 16:33:16 +00:00
|
|
|
if( view() == modal_view ) {
|
|
|
|
modal_view = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
// Can't pop last item from stack.
|
|
|
|
if( view_stack.size() > 1 ) {
|
2016-01-31 08:34:24 +00:00
|
|
|
free_view();
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
view_stack.pop_back();
|
2016-01-31 08:34:24 +00:00
|
|
|
|
|
|
|
update_view();
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
void NavigationView::pop_modal() {
|
|
|
|
if( view() == modal_view ) {
|
|
|
|
modal_view = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pop modal view and underlying app view
|
|
|
|
if( view_stack.size() > 2 ) {
|
|
|
|
free_view();
|
|
|
|
view_stack.pop_back();
|
|
|
|
free_view();
|
|
|
|
view_stack.pop_back();
|
|
|
|
|
|
|
|
update_view();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-17 17:15:34 +00:00
|
|
|
void NavigationView::display_modal(
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& message
|
2016-12-06 12:31:38 +00: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 17:15:34 +00:00
|
|
|
) {
|
2016-05-17 16:33:16 +00:00
|
|
|
/* If a modal view is already visible, don't display another */
|
|
|
|
if( !modal_view ) {
|
2016-12-06 12:31:38 +00:00
|
|
|
modal_view = push<ModalMessageView>(title, message, type, on_choice);
|
2016-05-17 16:33:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
void NavigationView::free_view() {
|
|
|
|
remove_child(view());
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
void NavigationView::update_view() {
|
|
|
|
const auto new_view = view_stack.back().get();
|
|
|
|
add_child(new_view);
|
|
|
|
new_view->set_parent_rect({ {0, 0}, size() });
|
|
|
|
focus();
|
|
|
|
set_dirty();
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
if( on_view_changed ) {
|
|
|
|
on_view_changed(*new_view);
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
2016-01-31 08:34:24 +00:00
|
|
|
}
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
Widget* NavigationView::view() const {
|
|
|
|
return children_.empty() ? nullptr : children_[0];
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationView::focus() {
|
|
|
|
if( view() ) {
|
|
|
|
view()->focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-09 18:42:20 +00:00
|
|
|
/* TranspondersMenuView **************************************************/
|
2016-01-31 08:34:24 +00:00
|
|
|
|
|
|
|
TranspondersMenuView::TranspondersMenuView(NavigationView& nav) {
|
2016-11-30 06:41:55 +00:00
|
|
|
add_items<4>({ {
|
|
|
|
{ "ADS-B: Planes", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
|
|
|
{ "AIS: Boats", ui::Color::white(), [&nav](){ nav.push<AISAppView>(); } },
|
|
|
|
{ "ERT: Utility Meters", ui::Color::white(), [&nav](){ nav.push<ERTAppView>(); } },
|
|
|
|
{ "TPMS: Cars", ui::Color::white(), [&nav](){ nav.push<TPMSAppView>(); } },
|
2016-01-31 08:34:24 +00:00
|
|
|
} });
|
2016-02-04 20:17:10 +00:00
|
|
|
on_left = [&nav](){ nav.pop(); };
|
2016-01-31 08:34:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ReceiverMenuView ******************************************************/
|
|
|
|
|
|
|
|
ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
|
2016-12-05 11:56:41 +00:00
|
|
|
add_items<6>({ {
|
|
|
|
// { "AFSK", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } }, // AFSKRXView
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Audio", ui::Color::green(), [&nav](){ nav.push<AnalogAudioView>(); } },
|
2016-12-05 11:56:41 +00:00
|
|
|
{ "CCIR", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } }, // XylosRXView
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Nordic/BTLE", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
2016-12-05 11:56:41 +00:00
|
|
|
{ "POCSAG 1200", ui::Color::cyan(), [&nav](){ nav.push<POCSAGAppView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "SIGFOX", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
2016-12-05 11:56:41 +00:00
|
|
|
{ "Transponders", ui::Color::green(), [&nav](){ nav.push<TranspondersMenuView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
} });
|
|
|
|
on_left = [&nav](){ nav.pop(); };
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TransmitterCodedMenuView ******************************************************/
|
|
|
|
|
|
|
|
TransmitterCodedMenuView::TransmitterCodedMenuView(NavigationView& nav) {
|
2016-12-07 19:49:42 +00:00
|
|
|
add_items<8>({ {
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "ADS-B Mode S", ui::Color::yellow(), [&nav](){ nav.push<ADSBTxView>(); } },
|
|
|
|
{ "BHT Epar", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
2016-12-07 19:49:42 +00:00
|
|
|
{ "BHT Xylos", ui::Color::green(), [&nav](){ nav.push<XylosView>(); } },
|
|
|
|
{ "Morse beacon", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Nuoptix DTMF timecode", ui::Color::green(), [&nav](){ nav.push<NuoptixView>(); } },
|
|
|
|
{ "OOK remote encoders", ui::Color::green(), [&nav](){ nav.push<EncodersView>(); } },
|
|
|
|
{ "RDS", ui::Color::orange(), [&nav](){ nav.push<RDSView>(); } },
|
|
|
|
{ "TEDI/LCR AFSK", ui::Color::green(), [&nav](){ nav.push<LCRView>(); } },
|
|
|
|
} });
|
|
|
|
on_left = [&nav](){ nav.pop(); };
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TransmitterAudioMenuView ******************************************************/
|
|
|
|
|
|
|
|
TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) {
|
|
|
|
add_items<4>({ {
|
2016-12-05 11:56:41 +00:00
|
|
|
{ "Soundboard", ui::Color::green(), [&nav](){ nav.push<SoundBoardView>(); } },
|
2016-12-07 19:49:42 +00:00
|
|
|
{ "Numbers station", ui::Color::green(), [&nav](){ nav.push<NumbersStationView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Microphone", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
|
|
|
{ "Whistle", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
2016-01-31 08:34:24 +00:00
|
|
|
} });
|
2016-02-04 20:17:10 +00:00
|
|
|
on_left = [&nav](){ nav.pop(); };
|
2016-01-31 08:34:24 +00:00
|
|
|
}
|
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
/* UtilitiesView *****************************************************************/
|
|
|
|
|
|
|
|
UtilitiesView::UtilitiesView(NavigationView& nav) {
|
2016-12-07 19:49:42 +00:00
|
|
|
add_items<3>({ {
|
2016-12-08 15:13:27 +00:00
|
|
|
{ "Frequency manager", ui::Color::grey(), [&nav](){ nav.push<FreqManView>(); } },
|
2016-12-07 19:49:42 +00:00
|
|
|
{ "Whip antenna length", ui::Color::green(), [&nav](){ nav.push<WhipCalcView>(); } },
|
|
|
|
{ "Notepad", ui::Color::grey(), [&nav](){ nav.push<NotImplementedView>(); } },
|
2016-12-06 12:31:38 +00:00
|
|
|
} });
|
|
|
|
on_left = [&nav](){ nav.pop(); };
|
|
|
|
}
|
2015-07-08 15:39:24 +00:00
|
|
|
/* SystemMenuView ********************************************************/
|
|
|
|
|
|
|
|
SystemMenuView::SystemMenuView(NavigationView& nav) {
|
2016-12-05 11:56:41 +00:00
|
|
|
add_items<11>({ {
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Play dead", ui::Color::red(), [&nav](){ nav.push<PlayDeadView>(false); } },
|
|
|
|
{ "Receivers", ui::Color::cyan(), [&nav](){ nav.push<ReceiverMenuView>(); } },
|
|
|
|
{ "Capture", ui::Color::cyan(), [&nav](){ nav.push<CaptureAppView>(); } },
|
2016-12-05 11:56:41 +00:00
|
|
|
{ "Code transmitters", ui::Color::green(), [&nav](){ nav.push<TransmitterCodedMenuView>(); } },
|
|
|
|
{ "Audio transmitters", ui::Color::green(), [&nav](){ nav.push<TransmitterAudioMenuView>(); } },
|
2016-12-07 19:49:42 +00:00
|
|
|
{ "Close Call", ui::Color::orange(), [&nav](){ nav.push<CloseCallView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Jammer", ui::Color::orange(), [&nav](){ nav.push<JammerView>(); } },
|
2016-12-06 12:31:38 +00:00
|
|
|
{ "Utilities", ui::Color::purple(), [&nav](){ nav.push<UtilitiesView>(); } },
|
2016-05-09 18:42:20 +00:00
|
|
|
//{ "Analyze", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "Setup", ui::Color::white(), [&nav](){ nav.push<SetupMenuView>(); } },
|
2016-12-06 12:31:38 +00:00
|
|
|
//{ "Debug", ui::Color::white(), [&nav](){ nav.push<DebugMenuView>(); } },
|
2016-12-07 19:49:42 +00:00
|
|
|
{ "HackRF mode", ui::Color::white(), [&nav](){ nav.push<HackRFFirmwareView>(); } },
|
2016-11-30 06:41:55 +00:00
|
|
|
{ "About", ui::Color::white(), [&nav](){ nav.push<AboutView>(); } }
|
2015-07-08 15:39:24 +00:00
|
|
|
} });
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SystemView ************************************************************/
|
|
|
|
|
|
|
|
static constexpr ui::Style style_default {
|
|
|
|
.font = ui::font::fixed_8x16,
|
|
|
|
.background = ui::Color::black(),
|
2016-05-29 10:06:47 +00:00
|
|
|
.foreground = ui::Color::white()
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SystemView::SystemView(
|
|
|
|
Context& context,
|
|
|
|
const Rect parent_rect
|
|
|
|
) : View { parent_rect },
|
2015-07-17 19:07:38 +00:00
|
|
|
context_(context)
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
2016-02-07 18:40:06 +00:00
|
|
|
set_style(&style_default);
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
constexpr ui::Dim status_view_height = 16;
|
2016-05-09 18:42:20 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
add_child(&status_view);
|
|
|
|
status_view.set_parent_rect({
|
|
|
|
{ 0, 0 },
|
|
|
|
{ parent_rect.width(), status_view_height }
|
|
|
|
});
|
2016-01-31 08:34:24 +00:00
|
|
|
status_view.on_back = [this]() {
|
|
|
|
this->navigation_view.pop();
|
|
|
|
};
|
2015-07-08 15:39:24 +00: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 08:34:24 +00:00
|
|
|
navigation_view.on_view_changed = [this](const View& new_view) {
|
2016-02-07 18:33:15 +00:00
|
|
|
this->status_view.set_back_enabled(!this->navigation_view.is_top());
|
2016-01-31 08:34:24 +00:00
|
|
|
this->status_view.set_title(new_view.title());
|
|
|
|
};
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
// Initial view.
|
|
|
|
// TODO: Restore from non-volatile memory?
|
2015-09-15 20:34:36 +00:00
|
|
|
|
2015-09-16 13:43:43 +00:00
|
|
|
//if (persistent_memory::playing_dead() == 0x59)
|
|
|
|
// navigation_view.push(new PlayDeadView { navigation_view, true });
|
|
|
|
//else
|
2016-01-03 06:24:30 +00:00
|
|
|
// navigation_view.push(new BMPView { navigation_view });
|
|
|
|
|
2016-01-07 13:17:39 +00:00
|
|
|
if (portapack::persistent_memory::ui_config() & 1)
|
2016-01-31 08:34:24 +00:00
|
|
|
navigation_view.push<BMPView>();
|
2016-01-07 13:17:39 +00:00
|
|
|
else
|
2016-05-09 18:42:20 +00:00
|
|
|
//navigation_view.push<SoundBoardView>();
|
2016-05-15 00:35:08 +00:00
|
|
|
//navigation_view.push<CloseCallView>();
|
2016-05-10 05:20:24 +00:00
|
|
|
//navigation_view.push<HandWriteView>(debugtxt, 20);
|
2016-07-25 14:21:27 +00:00
|
|
|
|
2016-05-10 05:20:24 +00:00
|
|
|
navigation_view.push<SystemMenuView>();
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Context& SystemView::context() const {
|
|
|
|
return context_;
|
|
|
|
}
|
|
|
|
|
2015-08-01 20:46:15 +00:00
|
|
|
/* HackRFFirmwareView ****************************************************/
|
|
|
|
|
|
|
|
HackRFFirmwareView::HackRFFirmwareView(NavigationView& nav) {
|
2016-07-02 23:38:01 +00:00
|
|
|
button_yes.on_select = [](Button&){
|
|
|
|
EventDispatcher::request_stop();
|
2015-08-01 20:46:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
button_no.on_select = [&nav](Button&){
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
add_children({ {
|
|
|
|
&text_title,
|
2015-09-02 03:23:11 +00:00
|
|
|
&text_description_1,
|
|
|
|
&text_description_2,
|
|
|
|
&text_description_3,
|
|
|
|
&text_description_4,
|
2015-08-01 20:46:15 +00:00
|
|
|
&button_yes,
|
|
|
|
&button_no,
|
|
|
|
} });
|
|
|
|
}
|
|
|
|
|
2016-02-05 16:40:14 +00:00
|
|
|
/* ***********************************************************************/
|
|
|
|
|
|
|
|
void BMPView::focus() {
|
|
|
|
button_done.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
BMPView::BMPView(NavigationView& nav) {
|
|
|
|
add_children({ {
|
|
|
|
&text_info,
|
|
|
|
&button_done
|
|
|
|
} });
|
|
|
|
|
|
|
|
button_done.on_select = [this,&nav](Button&){
|
|
|
|
nav.pop();
|
2016-04-21 20:12:51 +00:00
|
|
|
nav.push<SystemMenuView>();
|
2016-02-05 16:40:14 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void BMPView::paint(Painter& painter) {
|
|
|
|
(void)painter;
|
2016-05-27 04:48:04 +00:00
|
|
|
portapack::display.drawBMP({(240-185)/2, 0}, splash_bmp, false);
|
2016-02-05 16:40:14 +00:00
|
|
|
}
|
|
|
|
|
2016-02-04 09:27:53 +00:00
|
|
|
/* PlayDeadView **********************************************************/
|
|
|
|
|
|
|
|
void PlayDeadView::focus() {
|
|
|
|
button_done.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayDeadView::PlayDeadView(NavigationView& nav, bool booting) {
|
|
|
|
_booting = booting;
|
2016-04-21 20:12:51 +00:00
|
|
|
portapack::persistent_memory::set_playing_dead(0x59);
|
2016-02-04 09:27:53 +00:00
|
|
|
|
|
|
|
add_children({ {
|
|
|
|
&text_playdead1,
|
|
|
|
&text_playdead2,
|
|
|
|
&button_done,
|
|
|
|
} });
|
|
|
|
|
|
|
|
button_done.on_dir = [this,&nav](Button&, KeyEvent key){
|
|
|
|
sequence = (sequence<<3) | static_cast<std::underlying_type<KeyEvent>::type>(key);
|
|
|
|
};
|
|
|
|
|
|
|
|
button_done.on_select = [this,&nav](Button&){
|
2016-04-21 20:12:51 +00:00
|
|
|
if (sequence == portapack::persistent_memory::playdead_sequence()) {
|
|
|
|
portapack::persistent_memory::set_playing_dead(0);
|
2016-02-04 09:27:53 +00:00
|
|
|
if (_booting) {
|
|
|
|
nav.pop();
|
|
|
|
nav.push<SystemMenuView>();
|
|
|
|
} else {
|
|
|
|
nav.pop();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sequence = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-08-01 20:46:15 +00:00
|
|
|
void HackRFFirmwareView::focus() {
|
|
|
|
button_no.focus();
|
|
|
|
}
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
/* NotImplementedView ****************************************************/
|
|
|
|
|
|
|
|
NotImplementedView::NotImplementedView(NavigationView& nav) {
|
|
|
|
button_done.on_select = [&nav](Button&){
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
add_children({ {
|
|
|
|
&text_title,
|
|
|
|
&button_done,
|
|
|
|
} });
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotImplementedView::focus() {
|
|
|
|
button_done.focus();
|
|
|
|
}
|
|
|
|
|
2016-05-13 04:58:54 +00:00
|
|
|
/* ModalMessageView ******************************************************/
|
2016-05-17 17:15:34 +00:00
|
|
|
ModalMessageView::ModalMessageView(
|
|
|
|
NavigationView& nav,
|
|
|
|
const std::string& title,
|
2016-08-23 06:45:33 +00:00
|
|
|
const std::string& message,
|
2016-12-06 12:31:38 +00:00
|
|
|
const modal_t type,
|
|
|
|
const std::function<void(bool)> on_choice
|
2016-08-23 06:45:33 +00:00
|
|
|
) : title_ { title },
|
2016-12-06 12:31:38 +00:00
|
|
|
type_ { type },
|
|
|
|
on_choice_ { on_choice }
|
2016-05-17 17:15:34 +00:00
|
|
|
{
|
2016-05-13 04:58:54 +00:00
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
add_child(&text_message);
|
|
|
|
|
|
|
|
if (type == INFO) {
|
|
|
|
add_child(&button_ok);
|
|
|
|
|
|
|
|
button_ok.on_select = [&nav](Button&){
|
2016-08-23 06:45:33 +00:00
|
|
|
nav.pop();
|
|
|
|
};
|
2016-12-06 12:31:38 +00:00
|
|
|
} else if (type == YESNO) {
|
2016-08-23 06:45:33 +00:00
|
|
|
add_children({ {
|
2016-12-06 12:31:38 +00:00
|
|
|
&button_yes,
|
|
|
|
&button_no
|
2016-08-23 06:45:33 +00:00
|
|
|
} });
|
2016-12-06 12:31:38 +00:00
|
|
|
|
|
|
|
button_yes.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(true);
|
2016-08-23 06:45:33 +00:00
|
|
|
nav.pop();
|
|
|
|
};
|
2016-12-06 12:31:38 +00:00
|
|
|
button_no.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(false);
|
2016-08-23 06:45:33 +00:00
|
|
|
nav.pop();
|
|
|
|
};
|
2016-12-06 12:31:38 +00:00
|
|
|
} else {
|
|
|
|
add_child(&button_ok);
|
2016-08-23 06:45:33 +00:00
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
button_ok.on_select = [this, &nav](Button&){
|
|
|
|
if (on_choice_) on_choice_(true);
|
|
|
|
nav.pop_modal();
|
|
|
|
};
|
2016-08-23 06:45:33 +00:00
|
|
|
}
|
2016-05-17 17:29:49 +00:00
|
|
|
|
|
|
|
const int text_message_width = message.size() * 8;
|
|
|
|
text_message.set_parent_rect({
|
2016-12-06 12:31:38 +00:00
|
|
|
(240 - text_message_width) / 2, 8 * 16,
|
2016-05-17 17:29:49 +00:00
|
|
|
text_message_width, 16
|
|
|
|
});
|
2016-12-06 12:31:38 +00:00
|
|
|
text_message.set(message);
|
2016-05-13 04:58:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-23 06:45:33 +00:00
|
|
|
void ModalMessageView::paint(Painter& painter) {
|
|
|
|
(void)painter;
|
2016-12-06 12:31:38 +00:00
|
|
|
portapack::display.drawBMP({96, 64}, modal_warning_bmp, false);
|
2016-08-23 06:45:33 +00:00
|
|
|
}
|
|
|
|
|
2016-05-13 04:58:54 +00:00
|
|
|
void ModalMessageView::focus() {
|
2016-12-06 12:31:38 +00:00
|
|
|
if (type_ == YESNO) {
|
2016-08-23 06:45:33 +00:00
|
|
|
button_yes.focus();
|
2016-12-06 12:31:38 +00:00
|
|
|
} else {
|
|
|
|
button_ok.focus();
|
2016-08-23 06:45:33 +00:00
|
|
|
}
|
2016-05-13 04:58:54 +00:00
|
|
|
}
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
} /* namespace ui */
|