2016-11-30 01:41:55 -05: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"
|
2017-07-17 20:07:46 -04:00
|
|
|
#include "adsb.hpp"
|
2017-07-25 03:30:12 -04:00
|
|
|
#include "utility.hpp"
|
|
|
|
#include "sine_table.hpp"
|
2016-11-30 01:41:55 -05:00
|
|
|
#include "ui_textentry.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
|
|
|
#include "ui_navigation.hpp"
|
2017-02-11 23:05:21 -05:00
|
|
|
#include "ui_transmitter.hpp"
|
2016-11-30 01:41:55 -05:00
|
|
|
|
|
|
|
#include "message.hpp"
|
|
|
|
#include "transmitter_model.hpp"
|
|
|
|
#include "portapack.hpp"
|
|
|
|
|
2017-07-17 20:07:46 -04:00
|
|
|
using namespace adsb;
|
|
|
|
|
2016-11-30 01:41:55 -05:00
|
|
|
namespace ui {
|
|
|
|
|
2017-07-25 03:30:12 -04:00
|
|
|
class Compass : public Widget {
|
|
|
|
public:
|
|
|
|
Compass(const Point parent_pos);
|
|
|
|
|
|
|
|
void set_value(uint32_t new_value);
|
|
|
|
|
|
|
|
void paint(Painter&) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const range_t<uint32_t> range { 0, 359 };
|
|
|
|
uint32_t value_ { 0 };
|
|
|
|
|
|
|
|
uint32_t clamp_value(uint32_t value);
|
|
|
|
};
|
|
|
|
|
2016-11-30 01:41:55 -05:00
|
|
|
class ADSBTxView : public View {
|
|
|
|
public:
|
|
|
|
ADSBTxView(NavigationView& nav);
|
|
|
|
~ADSBTxView();
|
|
|
|
|
2017-07-23 07:20:32 -04:00
|
|
|
void paint(Painter&) override;
|
2016-11-30 01:41:55 -05:00
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
std::string title() const override { return "ADS-B transmit"; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum tx_modes {
|
|
|
|
IDLE = 0,
|
|
|
|
SINGLE,
|
|
|
|
SEQUENCE
|
|
|
|
};
|
|
|
|
|
2017-07-23 07:20:32 -04:00
|
|
|
const float plane_lats[12] = {
|
|
|
|
0,
|
|
|
|
-1,
|
|
|
|
-2,
|
|
|
|
-3,
|
|
|
|
-4,
|
|
|
|
-5,
|
|
|
|
-4.5,
|
|
|
|
-5,
|
|
|
|
-4,
|
|
|
|
-3,
|
|
|
|
-2,
|
|
|
|
-1
|
|
|
|
};
|
|
|
|
const float plane_lons[12] = {
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
-1,
|
|
|
|
-2,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
2016-11-30 01:41:55 -05:00
|
|
|
tx_modes tx_mode = IDLE;
|
|
|
|
|
2017-07-25 03:30:12 -04:00
|
|
|
std::string callsign = "TEST1234";
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2017-07-23 07:20:32 -04:00
|
|
|
ADSBFrame frames[4] { };
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2017-07-25 03:30:12 -04:00
|
|
|
void start_tx();
|
|
|
|
void generate_frames();
|
|
|
|
//void rotate_frames();
|
2017-05-01 05:42:09 -04:00
|
|
|
void on_txdone(const bool v);
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2017-02-13 00:35:13 -05:00
|
|
|
Labels labels {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ { 2 * 8, 2 * 8 }, "Format: 17 (ADS-B)", Color::light_grey() },
|
2017-02-13 00:35:13 -05:00
|
|
|
{ { 2 * 8, 4 * 8 }, "ICAO24:", Color::light_grey() },
|
2017-07-25 03:30:12 -04:00
|
|
|
{ { 2 * 8, 7 * 8 }, "Callsign:", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 11 * 8 }, "Alt: feet", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 13 * 8 }, "Lat: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font
|
|
|
|
{ { 1 * 8, 15 * 8 }, "Lon: * ' \"", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 18 * 8 }, "Speed: kn Bearing: *", Color::light_grey() },
|
|
|
|
{ { 16 * 8, 22 * 8 }, "Squawk:", Color::light_grey() }
|
2016-11-30 01:41:55 -05:00
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2017-07-25 03:30:12 -04:00
|
|
|
// Only ADS-B is implemented right now
|
|
|
|
/*OptionsField options_format {
|
2016-12-05 06:56:41 -05:00
|
|
|
{ 10 * 8, 1 * 16 },
|
2017-01-31 19:21:13 -05:00
|
|
|
9,
|
2016-11-30 01:41:55 -05:00
|
|
|
{
|
|
|
|
{ "17: ADS-B", 17 },
|
|
|
|
{ "18: TIS-B", 18 },
|
2017-01-31 19:21:13 -05:00
|
|
|
{ "19: MIL ", 19 },
|
2016-11-30 01:41:55 -05:00
|
|
|
}
|
2017-07-25 03:30:12 -04:00
|
|
|
};*/
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
SymField sym_icao {
|
|
|
|
{ 10 * 8, 2 * 16 },
|
|
|
|
6,
|
2017-01-31 19:21:13 -05:00
|
|
|
SymField::SYMFIELD_HEX
|
2016-11-30 01:41:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
Button button_callsign {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 12 * 8, 3 * 16 + 4, 10 * 8, 24 },
|
2016-12-05 06:56:41 -05:00
|
|
|
""
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_altitude {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 6 * 8, 11 * 8 },
|
2016-12-05 06:56:41 -05:00
|
|
|
5,
|
|
|
|
{ -1000, 50000 },
|
|
|
|
250,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_lat_degrees {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 6 * 8, 13 * 8 }, 4, { -90, 90 }, 1, ' '
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
|
|
|
NumberField field_lat_minutes {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 11 * 8, 13 * 8 }, 2, { 0, 59 }, 1, ' '
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
|
|
|
NumberField field_lat_seconds {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 14 * 8, 13 * 8 }, 2, { 0, 59 }, 1, ' '
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
NumberField field_lon_degrees {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 6 * 8, 15 * 8 }, 4, { -180, 180 }, 1, ' '
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
|
|
|
NumberField field_lon_minutes {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 11 * 8, 15 * 8 }, 2, { 0, 59 }, 1, ' '
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
|
|
|
NumberField field_lon_seconds {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 14 * 8, 15 * 8 }, 2, { 0, 59 }, 1, ' '
|
|
|
|
};
|
|
|
|
|
|
|
|
Compass compass {
|
|
|
|
{ 21 * 8, 5 * 16 }
|
|
|
|
};
|
|
|
|
NumberField field_angle {
|
|
|
|
{ 21 * 8 + 20, 9 * 16 }, 3, { 0, 359 }, 1, ' '
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_speed {
|
|
|
|
{ 8 * 8, 18 * 8 }, 3, { 0, 999 }, 5, ' '
|
2016-11-30 01:41:55 -05:00
|
|
|
};
|
|
|
|
|
2017-01-31 19:21:13 -05:00
|
|
|
Checkbox check_emergency {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 2 * 8, 11 * 16 - 4 },
|
2017-01-31 19:21:13 -05:00
|
|
|
9,
|
|
|
|
"Emergency",
|
|
|
|
false
|
|
|
|
};
|
|
|
|
SymField field_squawk {
|
2017-07-25 03:30:12 -04:00
|
|
|
{ 24 * 8, 11 * 16 },
|
2017-01-31 19:21:13 -05:00
|
|
|
4,
|
|
|
|
SymField::SYMFIELD_OCT
|
|
|
|
};
|
|
|
|
|
2017-07-25 03:30:12 -04:00
|
|
|
Text text_frame {
|
|
|
|
{ 1 * 8, 29 * 8, 14 * 8, 16 },
|
2016-12-01 00:58:47 -05:00
|
|
|
"-"
|
|
|
|
};
|
|
|
|
|
2017-02-11 23:05:21 -05:00
|
|
|
TransmitterView tx_view {
|
|
|
|
16 * 16,
|
2017-07-23 07:20:32 -04:00
|
|
|
0,
|
|
|
|
0,
|
2017-02-11 23:05:21 -05:00
|
|
|
true
|
2016-11-30 01:41:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_tx_done {
|
|
|
|
Message::ID::TXDone,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
|
2017-05-01 05:42:09 -04:00
|
|
|
this->on_txdone(message.done);
|
2016-11-30 01:41:55 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|