2015-07-08 15:39:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-11-30 06:41:55 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UI_NAVIGATION_H__
|
|
|
|
#define __UI_NAVIGATION_H__
|
|
|
|
|
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
|
|
|
#include "ui_focus.hpp"
|
|
|
|
#include "ui_menu.hpp"
|
|
|
|
|
|
|
|
#include "ui_rssi.hpp"
|
|
|
|
#include "ui_channel.hpp"
|
|
|
|
#include "ui_audio.hpp"
|
2016-01-31 08:34:24 +00:00
|
|
|
#include "ui_sd_card_status_view.hpp"
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-05-09 19:05:11 +00:00
|
|
|
#include "bitmap.hpp"
|
2017-01-10 18:40:33 +00:00
|
|
|
#include "ff.h"
|
|
|
|
#include "diskio.h"
|
|
|
|
#include "lfsr_random.hpp"
|
|
|
|
#include "sd_card.hpp"
|
2016-05-09 19:05:11 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
#include <vector>
|
2016-01-31 08:34:24 +00:00
|
|
|
#include <utility>
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2017-01-10 18:40:33 +00:00
|
|
|
using namespace sd_card;
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
namespace ui {
|
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
enum modal_t {
|
|
|
|
INFO = 0,
|
|
|
|
YESNO,
|
2017-01-10 18:40:33 +00:00
|
|
|
YESCANCEL,
|
2016-12-06 12:31:38 +00:00
|
|
|
ABORT
|
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
class SystemStatusView : public View {
|
|
|
|
public:
|
2016-11-27 00:50:44 +00:00
|
|
|
std::function<void(void)> on_back { };
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
SystemStatusView();
|
|
|
|
|
2016-02-07 18:33:15 +00:00
|
|
|
void set_back_enabled(bool new_value);
|
2016-01-31 08:34:24 +00:00
|
|
|
void set_title(const std::string new_value);
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
private:
|
2016-04-28 12:59:14 +00:00
|
|
|
static constexpr auto default_title = "PortaPack|Havoc";
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2017-01-30 01:09:00 +00:00
|
|
|
Rectangle backdrop {
|
|
|
|
{ 0 * 8, 0 * 16, 240, 16 },
|
|
|
|
Color::dark_grey()
|
|
|
|
};
|
|
|
|
|
|
|
|
ImageButton button_back {
|
2017-01-30 13:10:30 +00:00
|
|
|
{ 2, 0 * 16, 16, 16 },
|
2017-02-03 08:21:12 +00:00
|
|
|
&bitmap_icon_previous,
|
2017-01-30 01:09:00 +00:00
|
|
|
Color::white(),
|
|
|
|
Color::dark_grey()
|
2016-01-31 08:34:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Text title {
|
2018-01-07 23:13:08 +00:00
|
|
|
{ 20, 0, 17 * 8, 1 * 16 },
|
2016-01-31 08:34:24 +00:00
|
|
|
default_title,
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
2016-05-29 10:06:47 +00:00
|
|
|
|
2016-12-09 17:21:47 +00:00
|
|
|
ImageButton button_stealth {
|
2018-01-07 23:13:08 +00:00
|
|
|
{ 20 * 8, 0, 2 * 8, 1 * 16 },
|
2017-02-03 08:21:12 +00:00
|
|
|
&bitmap_icon_stealth,
|
2016-12-09 17:21:47 +00:00
|
|
|
Color::light_grey(),
|
2017-01-30 01:09:00 +00:00
|
|
|
Color::dark_grey()
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
|
|
|
|
2017-09-20 06:50:59 +00:00
|
|
|
/*ImageButton button_textentry {
|
2016-12-09 17:21:47 +00:00
|
|
|
{ 170, 0, 2 * 8, 1 * 16 },
|
2017-02-03 08:21:12 +00:00
|
|
|
&bitmap_icon_unistroke,
|
2016-05-29 10:06:47 +00:00
|
|
|
Color::white(),
|
2017-01-30 01:09:00 +00:00
|
|
|
Color::dark_grey()
|
2017-09-20 06:50:59 +00:00
|
|
|
};*/
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2016-02-19 05:35:46 +00:00
|
|
|
ImageButton button_camera {
|
2018-01-07 23:13:08 +00:00
|
|
|
{ 22 * 8, 0, 2 * 8, 1 * 16 },
|
2017-02-03 08:21:12 +00:00
|
|
|
&bitmap_icon_camera,
|
2016-02-19 05:35:46 +00:00
|
|
|
Color::white(),
|
2017-01-30 01:09:00 +00:00
|
|
|
Color::dark_grey()
|
2016-02-19 05:35:46 +00:00
|
|
|
};
|
|
|
|
|
2016-02-04 00:04:23 +00:00
|
|
|
ImageButton button_sleep {
|
2018-01-07 23:13:08 +00:00
|
|
|
{ 24 * 8, 0, 2 * 8, 1 * 16 },
|
2017-02-03 08:21:12 +00:00
|
|
|
&bitmap_icon_sleep,
|
2016-02-04 00:04:23 +00:00
|
|
|
Color::white(),
|
2017-01-30 01:09:00 +00:00
|
|
|
Color::dark_grey()
|
2016-01-31 08:34:24 +00:00
|
|
|
};
|
2018-01-07 23:13:08 +00:00
|
|
|
|
|
|
|
Image image_bias_tee {
|
|
|
|
{ 26 * 8, 0, 2 * 8, 1 * 16 },
|
|
|
|
&bitmap_icon_biast_off,
|
|
|
|
Color::light_grey(),
|
|
|
|
Color::dark_grey()
|
|
|
|
};
|
|
|
|
|
2016-02-03 23:50:14 +00:00
|
|
|
SDCardStatusView sd_card_status_view {
|
|
|
|
{ 28 * 8, 0 * 16, 2 * 8, 1 * 16 }
|
|
|
|
};
|
2016-02-19 05:35:46 +00:00
|
|
|
|
2016-12-09 17:21:47 +00:00
|
|
|
void on_stealth();
|
2017-09-20 06:50:59 +00:00
|
|
|
//void on_textentry();
|
2016-12-09 17:21:47 +00:00
|
|
|
void on_camera();
|
2018-01-07 23:13:08 +00:00
|
|
|
void refresh();
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_refresh {
|
|
|
|
Message::ID::StatusRefresh,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
(void)p;
|
|
|
|
this->refresh();
|
|
|
|
}
|
|
|
|
};
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class NavigationView : public View {
|
|
|
|
public:
|
2016-11-27 00:50:44 +00:00
|
|
|
std::function<void(const View&)> on_view_changed { };
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2016-11-27 00:50:44 +00:00
|
|
|
NavigationView() = default;
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
NavigationView(const NavigationView&) = delete;
|
|
|
|
NavigationView(NavigationView&&) = delete;
|
2016-11-27 00:52:57 +00:00
|
|
|
NavigationView& operator=(const NavigationView&) = delete;
|
|
|
|
NavigationView& operator=(NavigationView&&) = delete;
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
bool is_top() const;
|
|
|
|
|
|
|
|
template<class T, class... Args>
|
|
|
|
T* push(Args&&... args) {
|
|
|
|
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
|
|
|
}
|
2016-02-04 09:27:53 +00:00
|
|
|
|
|
|
|
void push(View* v);
|
2016-01-31 08:34:24 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
void pop();
|
2016-12-06 12:31:38 +00:00
|
|
|
void pop_modal();
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-05-17 17:15:34 +00:00
|
|
|
void display_modal(const std::string& title, const std::string& message);
|
2017-09-20 06:50:59 +00:00
|
|
|
void display_modal(const std::string& title, const std::string& message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
|
2016-05-17 16:33:16 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
2016-11-27 00:50:44 +00:00
|
|
|
std::vector<std::unique_ptr<View>> view_stack { };
|
2016-05-17 16:33:16 +00:00
|
|
|
Widget* modal_view { nullptr };
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
Widget* view() const;
|
2016-01-31 08:34:24 +00:00
|
|
|
|
|
|
|
void free_view();
|
|
|
|
void update_view();
|
|
|
|
View* push_view(std::unique_ptr<View> new_view);
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
2015-09-04 18:37:27 +00:00
|
|
|
class BMPView : public View {
|
|
|
|
public:
|
|
|
|
BMPView(NavigationView& nav);
|
2016-12-09 17:21:47 +00:00
|
|
|
void paint(Painter&) override;
|
2015-09-04 18:37:27 +00:00
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Text text_info {
|
2018-01-07 23:13:08 +00:00
|
|
|
{ 76, 284, 20 * 8, 16 },
|
|
|
|
"GIT " GIT_REVISION
|
2015-09-04 18:37:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Button button_done {
|
|
|
|
{ 240, 0, 1, 1 },
|
|
|
|
""
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-05-25 20:36:30 +00:00
|
|
|
class ReceiversMenuView : public MenuView {
|
2016-01-31 08:34:24 +00:00
|
|
|
public:
|
2017-05-25 20:36:30 +00:00
|
|
|
ReceiversMenuView(NavigationView& nav);
|
2016-11-30 06:41:55 +00:00
|
|
|
std::string title() const override { return "Receivers"; };
|
|
|
|
};
|
|
|
|
|
2017-05-25 20:36:30 +00:00
|
|
|
class TransmittersMenuView : public MenuView {
|
2016-11-30 06:41:55 +00:00
|
|
|
public:
|
2017-05-25 20:36:30 +00:00
|
|
|
TransmittersMenuView(NavigationView& nav);
|
|
|
|
std::string title() const override { return "Transmitters"; };
|
2016-01-31 08:34:24 +00:00
|
|
|
};
|
|
|
|
|
2017-05-25 20:36:30 +00:00
|
|
|
class UtilitiesMenuView : public MenuView {
|
2016-12-06 12:31:38 +00:00
|
|
|
public:
|
2017-05-25 20:36:30 +00:00
|
|
|
UtilitiesMenuView(NavigationView& nav);
|
2016-12-06 12:31:38 +00:00
|
|
|
std::string title() const override { return "Utilities"; };
|
|
|
|
};
|
|
|
|
|
2016-01-31 08:34:24 +00:00
|
|
|
class SystemMenuView : public MenuView {
|
|
|
|
public:
|
|
|
|
SystemMenuView(NavigationView& nav);
|
2016-12-26 00:31:38 +00:00
|
|
|
private:
|
|
|
|
void hackrf_mode(NavigationView& nav);
|
2016-01-31 08:34:24 +00:00
|
|
|
};
|
2015-09-04 18:37:27 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
class SystemView : public View {
|
|
|
|
public:
|
|
|
|
SystemView(
|
|
|
|
Context& context,
|
|
|
|
const Rect parent_rect
|
|
|
|
);
|
|
|
|
|
|
|
|
Context& context() const override;
|
|
|
|
|
|
|
|
private:
|
2016-11-27 00:50:44 +00:00
|
|
|
SystemStatusView status_view { };
|
|
|
|
NavigationView navigation_view { };
|
2015-07-08 15:39:24 +00:00
|
|
|
Context& context_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class NotImplementedView : public View {
|
|
|
|
public:
|
|
|
|
NotImplementedView(NavigationView& nav);
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Text text_title {
|
|
|
|
{ 5 * 8, 7 * 16, 19 * 8, 16 },
|
|
|
|
"Not Yet Implemented"
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_done {
|
|
|
|
{ 10 * 8, 13 * 16, 10 * 8, 24 },
|
|
|
|
"Bummer",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-05-13 04:58:54 +00:00
|
|
|
class ModalMessageView : public View {
|
|
|
|
public:
|
2016-05-17 17:15:34 +00:00
|
|
|
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-05-17 17:15:34 +00:00
|
|
|
);
|
2016-12-09 17:21:47 +00:00
|
|
|
|
2016-08-23 06:45:33 +00:00
|
|
|
void paint(Painter& painter) override;
|
2016-05-13 04:58:54 +00:00
|
|
|
void focus() override;
|
|
|
|
|
2016-12-09 17:21:47 +00:00
|
|
|
std::string title() const override { return title_; };
|
2016-05-17 17:15:34 +00:00
|
|
|
|
2016-05-13 04:58:54 +00:00
|
|
|
private:
|
2016-05-17 17:15:34 +00:00
|
|
|
const std::string title_;
|
2017-02-07 19:54:18 +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-05-13 04:58:54 +00:00
|
|
|
|
2016-12-06 12:31:38 +00:00
|
|
|
Button button_ok {
|
2017-02-08 01:19:29 +00:00
|
|
|
{ 10 * 8, 14 * 16, 10 * 8, 48 },
|
2016-05-13 04:58:54 +00:00
|
|
|
"OK",
|
|
|
|
};
|
2016-08-23 06:45:33 +00:00
|
|
|
|
|
|
|
Button button_yes {
|
2017-02-08 01:19:29 +00:00
|
|
|
{ 5 * 8, 14 * 16, 8 * 8, 48 },
|
2016-08-23 06:45:33 +00:00
|
|
|
"YES",
|
|
|
|
};
|
2016-12-26 00:31:38 +00:00
|
|
|
|
2016-08-23 06:45:33 +00:00
|
|
|
Button button_no {
|
2017-02-08 01:19:29 +00:00
|
|
|
{ 17 * 8, 14 * 16, 8 * 8, 48 },
|
2016-08-23 06:45:33 +00:00
|
|
|
"NO",
|
|
|
|
};
|
2016-05-13 04:58:54 +00:00
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
} /* namespace ui */
|
|
|
|
|
|
|
|
#endif/*__UI_NAVIGATION_H__*/
|