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"
|
2016-11-30 01:41:55 -05:00
|
|
|
#include "ui_textentry.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
2017-08-03 14:06:59 -04:00
|
|
|
#include "ui_geomap.hpp"
|
2017-07-30 04:39:01 -04:00
|
|
|
#include "ui_tabview.hpp"
|
2016-11-30 01:41:55 -05:00
|
|
|
#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 };
|
2017-07-30 09:46:42 -04:00
|
|
|
};
|
2017-07-25 03:30:12 -04:00
|
|
|
|
2017-07-30 09:46:42 -04:00
|
|
|
class ADSBView : public View {
|
|
|
|
public:
|
|
|
|
ADSBView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
void set_type(std::string type);
|
|
|
|
void collect_frames(const uint32_t ICAO_address, std::vector<ADSBFrame>& frame_list);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool enabled { false };
|
|
|
|
|
|
|
|
void set_enabled(bool value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Checkbox check_enable {
|
|
|
|
{ 2 * 8, 0 * 16 },
|
|
|
|
20,
|
|
|
|
"",
|
|
|
|
false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class ADSBPositionView : public ADSBView {
|
|
|
|
public:
|
|
|
|
ADSBPositionView(NavigationView& nav);
|
|
|
|
|
|
|
|
void collect_frames(const uint32_t ICAO_address, std::vector<ADSBFrame>& frame_list);
|
|
|
|
|
|
|
|
private:
|
2017-08-03 14:06:59 -04:00
|
|
|
GeoPos geopos {
|
|
|
|
{ 0, 2 * 16 }
|
2017-07-30 09:46:42 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
Button button_set_map {
|
|
|
|
{ 7 * 8, 7 * 16, 14 * 8, 2 * 16 },
|
|
|
|
"Set from map"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class ADSBCallsignView : public ADSBView {
|
|
|
|
public:
|
|
|
|
ADSBCallsignView(NavigationView& nav);
|
|
|
|
|
|
|
|
void collect_frames(const uint32_t ICAO_address, std::vector<ADSBFrame>& frame_list);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string callsign = "TEST1234";
|
|
|
|
|
|
|
|
Labels labels_callsign {
|
|
|
|
{ { 2 * 8, 5 * 8 }, "Callsign:", Color::light_grey() }
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_callsign {
|
|
|
|
{ 12 * 8, 2 * 16, 10 * 8, 2 * 16 },
|
|
|
|
""
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class ADSBSpeedView : public ADSBView {
|
|
|
|
public:
|
|
|
|
ADSBSpeedView();
|
|
|
|
|
|
|
|
void collect_frames(const uint32_t ICAO_address, std::vector<ADSBFrame>& frame_list);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Labels labels_speed {
|
|
|
|
{ { 1 * 8, 6 * 16 }, "Speed: kn Bearing: *", Color::light_grey() }
|
|
|
|
};
|
|
|
|
|
|
|
|
Compass compass {
|
|
|
|
{ 21 * 8, 2 * 16 }
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_angle {
|
|
|
|
{ 21 * 8 + 20, 6 * 16 }, 3, { 0, 359 }, 1, ' ', true
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_speed {
|
|
|
|
{ 8 * 8, 6 * 16 }, 3, { 0, 999 }, 5, ' '
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class ADSBSquawkView : public ADSBView {
|
|
|
|
public:
|
|
|
|
ADSBSquawkView();
|
|
|
|
|
|
|
|
void collect_frames(const uint32_t ICAO_address, std::vector<ADSBFrame>& frame_list);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Labels labels_squawk {
|
|
|
|
{ { 2 * 8, 2 * 16 }, "Squawk:", Color::light_grey() }
|
|
|
|
};
|
|
|
|
|
|
|
|
SymField field_squawk {
|
|
|
|
{ 10 * 8, 2 * 16 },
|
|
|
|
4,
|
|
|
|
SymField::SYMFIELD_OCT
|
|
|
|
};
|
2017-07-25 03:30:12 -04:00
|
|
|
};
|
|
|
|
|
2016-11-30 01:41:55 -05:00
|
|
|
class ADSBTxView : public View {
|
|
|
|
public:
|
|
|
|
ADSBTxView(NavigationView& nav);
|
|
|
|
~ADSBTxView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
std::string title() const override { return "ADS-B transmit"; };
|
|
|
|
|
|
|
|
private:
|
2017-08-03 14:06:59 -04:00
|
|
|
/*enum tx_modes {
|
2016-11-30 01:41:55 -05:00
|
|
|
IDLE = 0,
|
|
|
|
SINGLE,
|
|
|
|
SEQUENCE
|
2017-08-03 14:06:59 -04:00
|
|
|
};*/
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2017-08-03 14:06:59 -04:00
|
|
|
/*const float plane_lats[12] = {
|
2017-07-23 07:20:32 -04:00
|
|
|
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
|
2017-08-03 14:06:59 -04:00
|
|
|
};*/
|
2017-07-23 07:20:32 -04:00
|
|
|
|
2017-08-03 14:06:59 -04:00
|
|
|
//tx_modes tx_mode = IDLE;
|
2017-07-30 09:46:42 -04:00
|
|
|
NavigationView& nav_;
|
|
|
|
std::vector<ADSBFrame> frames { };
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2017-07-25 03:30:12 -04:00
|
|
|
void start_tx();
|
|
|
|
void generate_frames();
|
2017-07-30 09:46:42 -04:00
|
|
|
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-07-30 09:46:42 -04:00
|
|
|
ADSBPositionView view_position { nav_ };
|
|
|
|
ADSBCallsignView view_callsign { nav_ };
|
|
|
|
ADSBSpeedView view_speed { };
|
|
|
|
ADSBSquawkView view_squawk { };
|
2016-11-30 01:41:55 -05:00
|
|
|
|
2017-07-30 04:39:01 -04:00
|
|
|
TabView tab_view {
|
2017-07-30 09:46:42 -04:00
|
|
|
{ "Position", Color::cyan(), &view_position },
|
|
|
|
{ "Callsign", Color::green(), &view_callsign },
|
|
|
|
{ "Speed", Color::yellow(), &view_speed },
|
|
|
|
{ "Squawk", Color::orange(), &view_squawk }
|
|
|
|
};
|
|
|
|
|
|
|
|
Labels labels {
|
|
|
|
{ { 2 * 8, 4 * 8 }, "ICAO24:", Color::light_grey() }
|
2017-07-30 04:39:01 -04:00
|
|
|
};
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
SymField sym_icao {
|
2017-07-30 09:46:42 -04:00
|
|
|
{ 10 * 8, 4 * 8 },
|
2016-12-05 06:56:41 -05:00
|
|
|
6,
|
2017-01-31 19:21:13 -05:00
|
|
|
SymField::SYMFIELD_HEX
|
2016-11-30 01:41:55 -05:00
|
|
|
};
|
2017-01-31 19:21:13 -05:00
|
|
|
|
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-30 04:39:01 -04:00
|
|
|
1000000,
|
|
|
|
0
|
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 */
|