2016-12-09 17:21:47 +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 "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
2017-08-11 23:27:05 +00:00
|
|
|
#include "ui_tabview.hpp"
|
2016-12-09 17:21:47 +00:00
|
|
|
#include "ui_navigation.hpp"
|
2017-01-30 13:10:30 +00:00
|
|
|
#include "ui_transmitter.hpp"
|
2016-12-09 17:21:47 +00:00
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
|
|
|
|
2016-12-26 15:15:54 +00:00
|
|
|
#include "bht.hpp"
|
2017-07-18 18:31:05 +00:00
|
|
|
#include "bitmap.hpp"
|
2016-12-09 17:21:47 +00:00
|
|
|
#include "message.hpp"
|
|
|
|
#include "transmitter_model.hpp"
|
|
|
|
#include "encoders.hpp"
|
2022-05-13 12:38:04 +00:00
|
|
|
#include "app_settings.hpp"
|
2016-12-09 17:21:47 +00:00
|
|
|
#include "portapack.hpp"
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
class XylosView : public View {
|
2016-12-09 17:21:47 +00:00
|
|
|
public:
|
2017-09-21 08:18:17 +00:00
|
|
|
XylosView(Rect parent_rect);
|
2017-08-11 23:27:05 +00:00
|
|
|
|
2016-12-09 17:21:47 +00:00
|
|
|
void focus() override;
|
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
void flip_relays();
|
|
|
|
void generate_message();
|
2018-01-09 21:12:19 +00:00
|
|
|
bool increment_address();
|
|
|
|
uint32_t get_scan_remaining();
|
2017-08-11 23:27:05 +00:00
|
|
|
|
|
|
|
private:
|
2017-02-13 05:35:13 +00:00
|
|
|
Labels labels {
|
2017-08-11 23:27:05 +00:00
|
|
|
{ { 8 * 8, 1 * 8 }, "Header:", Color::light_grey() },
|
2022-05-13 12:38:04 +00:00
|
|
|
{ { 4 * 8, 3 * 8 }, "City code:", Color::light_grey() },
|
|
|
|
{ { 7 * 8, 5 * 8 }, "Family:", Color::light_grey() },
|
|
|
|
{ { 2 * 8, 7 * 8 + 2 }, "Subfamily:", Color::light_grey() },
|
|
|
|
{ { 2 * 8, 11 * 8 }, "Receiver ID:", Color::light_grey() },
|
|
|
|
{ { 2 * 8, 14 * 8 }, "Relay:", Color::light_grey() }
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
NumberField field_header_a {
|
|
|
|
{ 16 * 8, 1 * 8 },
|
2016-12-09 17:21:47 +00:00
|
|
|
2,
|
|
|
|
{ 0, 99 },
|
|
|
|
1,
|
|
|
|
'0'
|
|
|
|
};
|
2017-08-11 23:27:05 +00:00
|
|
|
NumberField field_header_b {
|
|
|
|
{ 18 * 8, 1 * 8 },
|
2016-12-09 17:21:47 +00:00
|
|
|
2,
|
|
|
|
{ 0, 99 },
|
|
|
|
1,
|
|
|
|
'0'
|
|
|
|
};
|
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
NumberField field_city {
|
|
|
|
{ 16 * 8, 3 * 8 },
|
2016-12-09 17:21:47 +00:00
|
|
|
2,
|
2018-01-09 21:12:19 +00:00
|
|
|
{ 0, XY_MAX_CITY },
|
2016-12-09 17:21:47 +00:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
NumberField field_family {
|
|
|
|
{ 16 * 8, 5 * 8 },
|
2016-12-09 17:21:47 +00:00
|
|
|
1,
|
|
|
|
{ 0, 9 },
|
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
2017-08-11 23:27:05 +00:00
|
|
|
|
|
|
|
NumberField field_subfamily {
|
|
|
|
{ 16 * 8, 7 * 8 + 2 },
|
2016-12-09 17:21:47 +00:00
|
|
|
1,
|
|
|
|
{ 0, 9 },
|
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
2017-08-11 23:27:05 +00:00
|
|
|
|
2016-12-09 17:21:47 +00:00
|
|
|
Checkbox checkbox_wcsubfamily {
|
2017-08-11 23:27:05 +00:00
|
|
|
{ 20 * 8, 6 * 8 + 6 },
|
2022-05-13 12:38:04 +00:00
|
|
|
3,
|
|
|
|
"All"
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
NumberField field_receiver {
|
|
|
|
{ 16 * 8, 11 * 8 },
|
2016-12-09 17:21:47 +00:00
|
|
|
2,
|
|
|
|
{ 0, 99 },
|
|
|
|
1,
|
|
|
|
'0'
|
|
|
|
};
|
|
|
|
Checkbox checkbox_wcid {
|
2017-08-11 23:27:05 +00:00
|
|
|
{ 20 * 8, 10 * 8 + 4 },
|
2022-05-13 12:38:04 +00:00
|
|
|
3,
|
|
|
|
"All"
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
|
|
|
|
2017-01-30 13:10:30 +00:00
|
|
|
std::array<ImageOptionsField, 4> relay_states { };
|
2016-12-09 17:21:47 +00:00
|
|
|
|
|
|
|
ImageOptionsField::options_t relay_options = {
|
2017-07-18 18:31:05 +00:00
|
|
|
{ &bitmap_bulb_ignore, 0 },
|
|
|
|
{ &bitmap_bulb_off, 1 },
|
|
|
|
{ &bitmap_bulb_on, 2 }
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
2017-08-11 23:27:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class EPARView : public View {
|
|
|
|
public:
|
2017-09-21 08:18:17 +00:00
|
|
|
EPARView(Rect parent_rect);
|
2017-08-11 23:27:05 +00:00
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
void flip_relays();
|
2017-09-21 08:18:17 +00:00
|
|
|
size_t generate_message();
|
2018-01-09 21:12:19 +00:00
|
|
|
bool increment_address();
|
|
|
|
uint32_t get_scan_remaining();
|
2017-08-11 23:27:05 +00:00
|
|
|
|
2018-01-09 21:12:19 +00:00
|
|
|
bool half { false };
|
2017-09-21 08:18:17 +00:00
|
|
|
|
2017-08-11 23:27:05 +00:00
|
|
|
private:
|
|
|
|
Labels labels {
|
2022-05-13 12:38:04 +00:00
|
|
|
{ { 4 * 8, 1 * 8 }, "City code:", Color::light_grey() },
|
|
|
|
{ { 8 * 8, 3 * 8 }, "Group:", Color::light_grey() },
|
|
|
|
{ { 8 * 8, 7 * 8 }, "Relay:", Color::light_grey() }
|
2017-08-11 23:27:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_city {
|
|
|
|
{ 16 * 8, 1 * 8 },
|
|
|
|
3,
|
2018-01-09 21:12:19 +00:00
|
|
|
{ 0, EPAR_MAX_CITY },
|
2017-08-11 23:27:05 +00:00
|
|
|
1,
|
2018-01-09 21:12:19 +00:00
|
|
|
'0'
|
2017-08-11 23:27:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
OptionsField field_group {
|
|
|
|
{ 16 * 8, 3 * 8 },
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
{ "A ", 2 }, // See receiver PCB
|
|
|
|
{ "B ", 1 },
|
|
|
|
{ "C ", 0 },
|
|
|
|
{ "TP", 3 }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::array<ImageOptionsField, 2> relay_states { };
|
|
|
|
|
|
|
|
ImageOptionsField::options_t relay_options = {
|
|
|
|
{ &bitmap_bulb_off, 0 },
|
|
|
|
{ &bitmap_bulb_on, 1 }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class BHTView : public View {
|
|
|
|
public:
|
|
|
|
BHTView(NavigationView& nav);
|
|
|
|
~BHTView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
2023-03-22 07:46:58 +00:00
|
|
|
std::string title() const override { return "BHT TX"; };
|
2017-08-11 23:27:05 +00:00
|
|
|
|
|
|
|
private:
|
2022-05-13 12:38:04 +00:00
|
|
|
// app save settings
|
|
|
|
std::app_settings settings { };
|
|
|
|
std::app_settings::AppSettings app_settings { };
|
|
|
|
|
2017-09-24 19:05:42 +00:00
|
|
|
void on_tx_progress(const uint32_t progress, const bool done);
|
2017-08-11 23:27:05 +00:00
|
|
|
void start_tx();
|
2018-01-09 21:12:19 +00:00
|
|
|
void stop_tx();
|
2017-08-11 23:27:05 +00:00
|
|
|
|
2018-01-09 21:12:19 +00:00
|
|
|
enum target_system_t {
|
2017-09-21 08:18:17 +00:00
|
|
|
XYLOS = 0,
|
|
|
|
EPAR = 1
|
|
|
|
};
|
|
|
|
|
2018-01-09 21:12:19 +00:00
|
|
|
target_system_t target_system = { };
|
|
|
|
|
|
|
|
enum tx_modes {
|
|
|
|
IDLE = 0,
|
|
|
|
SINGLE,
|
|
|
|
SCAN
|
|
|
|
};
|
|
|
|
|
|
|
|
tx_modes tx_mode = IDLE;
|
2017-09-21 08:18:17 +00:00
|
|
|
|
2018-01-09 21:12:19 +00:00
|
|
|
Rect view_rect = { 0, 3 * 8, 240, 176 };
|
2017-09-21 08:18:17 +00:00
|
|
|
|
|
|
|
XylosView view_xylos { view_rect };
|
|
|
|
EPARView view_EPAR { view_rect };
|
2017-08-11 23:27:05 +00:00
|
|
|
|
|
|
|
TabView tab_view {
|
|
|
|
{ "Xylos", Color::cyan(), &view_xylos },
|
|
|
|
{ "EPAR", Color::green(), &view_EPAR }
|
|
|
|
};
|
|
|
|
|
|
|
|
Labels labels {
|
|
|
|
{ { 29 * 8, 14 * 16 + 4 }, "s", Color::light_grey() }
|
|
|
|
};
|
|
|
|
|
2018-01-09 21:12:19 +00:00
|
|
|
Checkbox checkbox_scan {
|
|
|
|
{ 1 * 8, 25 * 8 },
|
|
|
|
4,
|
|
|
|
"Scan"
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
|
|
|
|
2022-05-13 13:31:58 +00:00
|
|
|
Checkbox checkbox_flashing {
|
2018-01-09 21:12:19 +00:00
|
|
|
{ 16 * 8, 25 * 8 },
|
2022-05-13 12:38:04 +00:00
|
|
|
8,
|
|
|
|
"Flashing"
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
2022-05-13 13:31:58 +00:00
|
|
|
NumberField field_speed {
|
2018-01-09 21:12:19 +00:00
|
|
|
{ 26 * 8, 25 * 8 + 4 },
|
2016-12-09 17:21:47 +00:00
|
|
|
2,
|
|
|
|
{ 1, 99 },
|
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
2018-01-09 21:12:19 +00:00
|
|
|
ProgressBar progressbar {
|
|
|
|
{ 0 * 8, 29 * 8, 30 * 8, 16 },
|
|
|
|
};
|
|
|
|
|
2017-01-30 13:10:30 +00:00
|
|
|
TransmitterView tx_view {
|
|
|
|
16 * 16,
|
|
|
|
10000,
|
|
|
|
12
|
|
|
|
};
|
|
|
|
|
2017-09-24 19:05:42 +00:00
|
|
|
MessageHandlerRegistration message_handler_tx_progress {
|
|
|
|
Message::ID::TXProgress,
|
2016-12-09 17:21:47 +00:00
|
|
|
[this](const Message* const p) {
|
2017-09-24 19:05:42 +00:00
|
|
|
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
2016-12-09 17:21:47 +00:00
|
|
|
this->on_tx_progress(message.progress, message.done);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|