Started work on ACARS RX

Added ACARS frequencies file
Moved non-implemented apps menu items down
This commit is contained in:
furrtek
2018-06-10 10:15:43 +01:00
parent 5c1ba9b90d
commit dc5d6fef70
17 changed files with 686 additions and 27 deletions

View File

@@ -109,6 +109,7 @@ set(CSRC
# setting.
set(CPPSRC
main.cpp
${COMMON}/acars_packet.cpp
${COMMON}/adsb.cpp
${COMMON}/adsb_frame.cpp
${COMMON}/ais_baseband.cpp
@@ -245,6 +246,7 @@ set(CPPSRC
apps/ui_touchtunes.cpp
apps/ui_view_wav.cpp
apps/ui_whipcalc.cpp
apps/acars_app.cpp
apps/analog_audio_app.cpp
apps/ais_app.cpp
apps/tpms_app.cpp

View File

@@ -0,0 +1,143 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2018 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 "acars_app.hpp"
#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
using namespace acars;
#include "string_format.hpp"
#include "utility.hpp"
void ACARSLogger::log_raw_data(const acars::Packet& packet, const uint32_t frequency) {
std::string entry = "Raw: F:" + to_string_dec_uint(frequency) + "Hz ";
// Raw hex dump of all the bytes
for (size_t c = 0; c < packet.length(); c += 8)
entry += to_string_hex(packet.read(c, 8), 8) + " ";
log_file.write_entry(packet.received_at(), entry);
}
/*void ACARSLogger::log_decoded(
const acars::Packet& packet,
const std::string text) {
log_file.write_entry(packet.timestamp(), text);
}*/
namespace ui {
void ACARSAppView::update_freq(rf::Frequency f) {
set_target_frequency(f);
portapack::persistent_memory::set_tuned_frequency(f); // Maybe not ?
}
ACARSAppView::ACARSAppView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_acars);
add_children({
&rssi,
&channel,
&field_rf_amp,
&field_lna,
&field_vga,
&field_frequency,
&check_log,
&console
});
receiver_model.set_sampling_rate(2457600);
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.enable();
field_frequency.set_value(receiver_model.tuning_frequency());
update_freq(receiver_model.tuning_frequency());
field_frequency.set_step(receiver_model.frequency_step());
field_frequency.on_change = [this](rf::Frequency f) {
update_freq(f);
};
field_frequency.on_edit = [this, &nav]() {
// TODO: Provide separate modal method/scheme?
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
update_freq(f);
field_frequency.set_value(f);
};
};
check_log.set_value(logging);
check_log.on_select = [this](Checkbox&, bool v) {
logging = v;
};
logger = std::make_unique<ACARSLogger>();
if (logger)
logger->append("acars.txt");
}
ACARSAppView::~ACARSAppView() {
receiver_model.disable();
baseband::shutdown();
}
void ACARSAppView::focus() {
field_frequency.focus();
}
// Useless ?
void ACARSAppView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect);
}
void ACARSAppView::on_packet(const acars::Packet& packet) {
std::string alphanum_text = "";
if (!packet.is_valid())
console.writeln("\n\x1B\x0INVALID PACKET");
else {
std::string console_info;
console_info = "\n" + to_string_datetime(packet.received_at(), HM);
console_info += " REG:" + packet.registration_number();
console.write(console_info);
}
// Log raw data whatever it contains
if (logger && logging)
logger->log_raw_data(packet, target_frequency());
}
void ACARSAppView::set_target_frequency(const uint32_t new_value) {
target_frequency_ = new_value;
receiver_model.set_tuning_frequency(new_value);
}
uint32_t ACARSAppView::target_frequency() const {
return target_frequency_;
}
} /* namespace ui */

View File

@@ -0,0 +1,116 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2018 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.
*/
#ifndef __ACARS_APP_H__
#define __ACARS_APP_H__
#include "ui_widget.hpp"
#include "ui_receiver.hpp"
#include "ui_rssi.hpp"
#include "log_file.hpp"
#include "acars_packet.hpp"
class ACARSLogger {
public:
Optional<File::Error> append(const std::string& filename) {
return log_file.append(filename);
}
void log_raw_data(const acars::Packet& packet, const uint32_t frequency);
//void log_decoded(const acars::Packet& packet, const std::string text);
private:
LogFile log_file { };
};
namespace ui {
class ACARSAppView : public View {
public:
ACARSAppView(NavigationView& nav);
~ACARSAppView();
void set_parent_rect(const Rect new_parent_rect) override;
void focus() override;
std::string title() const override { return "ACARS RX"; };
private:
bool logging { false };
RFAmpField field_rf_amp {
{ 13 * 8, 0 * 16 }
};
LNAGainField field_lna {
{ 15 * 8, 0 * 16 }
};
VGAGainField field_vga {
{ 18 * 8, 0 * 16 }
};
RSSI rssi {
{ 21 * 8, 0, 6 * 8, 4 },
};
Channel channel {
{ 21 * 8, 5, 6 * 8, 4 },
};
FrequencyField field_frequency {
{ 0 * 8, 0 * 8 },
};
Checkbox check_log {
{ 22 * 8, 21 },
3,
"LOG",
true
};
Console console {
{ 0, 4 * 16, 240, 240 }
};
std::unique_ptr<ACARSLogger> logger { };
uint32_t target_frequency_ { };
void update_freq(rf::Frequency f);
void on_packet(const acars::Packet& packet);
uint32_t target_frequency() const;
void set_target_frequency(const uint32_t new_value);
MessageHandlerRegistration message_handler_packet {
Message::ID::ACARSPacket,
[this](Message* const p) {
const auto message = static_cast<const ACARSPacketMessage*>(p);
const acars::Packet packet { message->packet };
this->on_packet(packet);
}
};
};
} /* namespace ui */
#endif/*__ACARS_APP_H__*/

View File

@@ -25,8 +25,6 @@
#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
#include "pocsag.hpp"
using namespace portapack;
using namespace pocsag;

View File

@@ -112,7 +112,7 @@ void FreqManBaseView::refresh_list() {
for (size_t n = 0; n < database.size(); n++) {
menu_view.add_item({
freqman_item_string(database[n], 26),
freqman_item_string(database[n], 30),
ui::Color::white(),
nullptr,
[this](){
@@ -212,7 +212,7 @@ FrequencyLoadView::FrequencyLoadView(
});
// Resize menu view to fill screen
menu_view.set_parent_rect({ 0, 3 * 8, 240, 29 * 8 });
menu_view.set_parent_rect({ 0, 3 * 8, 240, 30 * 8 });
// Just to allow exit on left
menu_view.on_left = [&nav, this]() {

View File

@@ -39,8 +39,6 @@ public:
void focus() override;
std::string title() const override { return "Freq. manager"; };
protected:
using option_t = std::pair<std::string, int32_t>;
using options_t = std::vector<option_t>;
@@ -89,6 +87,8 @@ class FrequencySaveView : public FreqManBaseView {
public:
FrequencySaveView(NavigationView& nav, const rf::Frequency value);
std::string title() const override { return "Save frequency"; };
private:
std::string desc_buffer { };
rf::Frequency value_ { };
@@ -126,6 +126,8 @@ public:
FrequencyLoadView(NavigationView& nav);
std::string title() const override { return "Load frequency"; };
private:
void refresh_widgets(const bool v);
};
@@ -135,6 +137,8 @@ public:
FrequencyManagerView(NavigationView& nav);
~FrequencyManagerView();
std::string title() const override { return "Freq. manager"; };
private:
std::string desc_buffer { };

View File

@@ -43,12 +43,14 @@
//GLITCH: Start of tx using ReplayThread plays a small bit of previous transmission (content of 1 buffer ?)
// See fifo.reset_in() ?
//TODO: Increase resolution of audio FFT view ? Currently 48k/(256/2) (375Hz) because of the use of real values (half of FFT output)
//TODO: DCS decoder
//TODO: Make CTCSS display only when squelch is opened
//TODO: Add larger description text field in frequency load, under menuview
//TODO: Allow apps to select a preferred FREQMAN file
//TODO: Make play button larger in Replay
//TODO: Put LNA and VGA controls in Soundboard
//TODO: Add default headphones volume setting in Audio settings
//TODO: Put LNA and VGA controls in Soundboard
//TODO: Make CTCSS display only when squelch is opened
//TODO: DCS decoder
//TODO: Increase resolution of audio FFT view ? Currently 48k/(256/2) (375Hz) because of the use of real values (half of FFT output)
//TODO: Move Touchtunes remote to Custom remote
//TODO: Use escapes \x1B to set colors in text, it works !
//TODO: Open files in File Manager

View File

@@ -42,7 +42,7 @@ void MenuItemView::unhighlight() {
}
void MenuItemView::paint(Painter& painter) {
Coord offset_x;
Coord offset_x { };
if (!item) return;
@@ -71,7 +71,7 @@ void MenuItemView::paint(Painter& painter) {
);
offset_x = 26;
} else
offset_x = 8;
offset_x = 0;
Style text_style {
.font = paint_style.font,

View File

@@ -66,13 +66,14 @@
#include "ui_view_wav.hpp"
#include "ui_whipcalc.hpp"
#include "analog_audio_app.hpp"
#include "acars_app.hpp"
#include "ais_app.hpp"
#include "ert_app.hpp"
#include "tpms_app.hpp"
#include "pocsag_app.hpp"
#include "analog_audio_app.hpp"
#include "capture_app.hpp"
#include "ert_app.hpp"
#include "pocsag_app.hpp"
#include "replay_app.hpp"
#include "tpms_app.hpp"
#include "core_control.hpp"
@@ -330,19 +331,20 @@ void NavigationView::focus() {
ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
add_items({
{ "ADS-B: Planes", ui::Color::green(), &bitmap_icon_adsb, [&nav](){ nav.replace<ADSBRxView>(); }, },
{ "ACARS: Planes", ui::Color::yellow(),&bitmap_icon_adsb, [&nav](){ nav.replace<ACARSAppView>(); }, },
{ "AIS: Boats", ui::Color::green(), &bitmap_icon_ais, [&nav](){ nav.replace<AISAppView>(); } },
{ "AFSK", ui::Color::yellow(),&bitmap_icon_receivers, [&nav](){ nav.replace<AFSKRxView>(); } },
{ "APRS", ui::Color::grey(), &bitmap_icon_aprs, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "Audio", ui::Color::green(), &bitmap_icon_speaker, [&nav](){ nav.replace<AnalogAudioView>(false); } },
{ "DMR framing", ui::Color::grey(), &bitmap_icon_dmr, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "ERT: Utility Meters", ui::Color::green(), &bitmap_icon_ert, [&nav](){ nav.replace<ERTAppView>(); } },
{ "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.replace<POCSAGAppView>(); } },
{ "Radiosondes", ui::Color::yellow(),&bitmap_icon_sonde, [&nav](){ nav.replace<SondeView>(); } },
{ "TPMS: Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.replace<TPMSAppView>(); } },
{ "APRS", ui::Color::grey(), &bitmap_icon_aprs, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "DMR framing", ui::Color::grey(), &bitmap_icon_dmr, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "SIGFOX", ui::Color::grey(), &bitmap_icon_fox, [&nav](){ nav.replace<NotImplementedView>(); } }, // SIGFRXView
{ "LoRa", ui::Color::grey(), &bitmap_icon_lora, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "Radiosondes", ui::Color::yellow(),&bitmap_icon_sonde, [&nav](){ nav.replace<SondeView>(); } },
{ "SSTV", ui::Color::grey(), &bitmap_icon_sstv, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "TETRA framing", ui::Color::grey(), &bitmap_icon_tetra, [&nav](){ nav.replace<NotImplementedView>(); } },
{ "TPMS: Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.replace<TPMSAppView>(); } },
});
on_left = [&nav](){ nav.pop(); };
@@ -356,7 +358,6 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
{ "ADS-B Mode S", ui::Color::yellow(), &bitmap_icon_adsb, [&nav](){ nav.push<ADSBTxView>(); } },
{ "APRS", ui::Color::orange(), &bitmap_icon_aprs, [&nav](){ nav.push<APRSTXView>(); } },
{ "BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav](){ nav.push<BHTView>(); } },
{ "Custom remote", ui::Color::grey(), &bitmap_icon_remote, [&nav](){ nav.push<RemoteView>(); } },
{ "Jammer", ui::Color::yellow(), &bitmap_icon_jammer, [&nav](){ nav.push<JammerView>(); } },
{ "Key fob", ui::Color::orange(), &bitmap_icon_keyfob, [&nav](){ nav.push<KeyfobView>(); } },
{ "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push<MicTXView>(); } },
@@ -369,7 +370,8 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
{ "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } },
{ "SSTV", ui::Color::green(), &bitmap_icon_sstv, [&nav](){ nav.push<SSTVTXView>(); } },
{ "TEDI/LCR AFSK", ui::Color::yellow(), &bitmap_icon_lcr, [&nav](){ nav.push<LCRView>(); } },
{ "TouchTunes remote", ui::Color::yellow(), nullptr, [&nav](){ nav.push<TouchTunesView>(); } },
{ "TouchTunes remote", ui::Color::yellow(), &bitmap_icon_remote [&nav](){ nav.push<TouchTunesView>(); } },
{ "Custom remote", ui::Color::grey(), &bitmap_icon_remote, [&nav](){ nav.push<RemoteView>(); } },
});
on_left = [&nav](){ nav.pop(); };
}