mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-12-05 17:22:09 +00:00
Added "test app" as a draft zone for... stuff
Added second signature for M2K2 radiosonde
This commit is contained in:
@@ -209,6 +209,7 @@ set(CPPSRC
|
||||
ui_spectrum.cpp
|
||||
ui_sstvtx.cpp
|
||||
ui_tabview.cpp
|
||||
ui_test.cpp
|
||||
ui_textentry.cpp
|
||||
ui_touch_calibration.cpp
|
||||
ui_touchtunes.cpp
|
||||
@@ -229,6 +230,7 @@ set(CPPSRC
|
||||
${COMMON}/adsb_frame.cpp
|
||||
${COMMON}/adsb.cpp
|
||||
${COMMON}/sonde_packet.cpp
|
||||
${COMMON}/test_packet.cpp
|
||||
ais_app.cpp
|
||||
tpms_app.cpp
|
||||
pocsag_app.cpp
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "ui_sonde.hpp"
|
||||
#include "ui_soundboard.hpp"
|
||||
#include "ui_sstvtx.hpp"
|
||||
#include "ui_test.hpp"
|
||||
#include "ui_touchtunes.hpp"
|
||||
#include "ui_view_wav.hpp"
|
||||
#include "ui_whipcalc.hpp"
|
||||
@@ -335,6 +336,7 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
|
||||
UtilitiesMenuView::UtilitiesMenuView(NavigationView& nav) {
|
||||
add_items({
|
||||
{ "Test app", ui::Color::grey(), nullptr, [&nav](){ nav.push<TestView>(); } },
|
||||
{ "Frequency manager", ui::Color::green(), &bitmap_icon_freqman, [&nav](){ nav.push<FrequencyManagerView>(); } },
|
||||
{ "File manager", ui::Color::yellow(), &bitmap_icon_file, [&nav](){ nav.push<FileManagerView>(); } },
|
||||
{ "Whip antenna length", ui::Color::yellow(), nullptr, [&nav](){ nav.push<WhipCalcView>(); } },
|
||||
|
||||
123
firmware/application/ui_test.cpp
Normal file
123
firmware/application/ui_test.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 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_test.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
TestView::TestView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_test);
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&field_frequency,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&rssi,
|
||||
&text_debug_a,
|
||||
&text_debug_b
|
||||
});
|
||||
|
||||
field_frequency.set_value(target_frequency_);
|
||||
field_frequency.set_step(10000);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
set_target_frequency(f);
|
||||
field_frequency.set_value(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) {
|
||||
set_target_frequency(f);
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
radio::enable({
|
||||
tuning_frequency(),
|
||||
sampling_rate,
|
||||
baseband_bandwidth,
|
||||
rf::Direction::Receive,
|
||||
receiver_model.rf_amp(),
|
||||
static_cast<int8_t>(receiver_model.lna()),
|
||||
static_cast<int8_t>(receiver_model.vga()),
|
||||
});
|
||||
}
|
||||
|
||||
TestView::~TestView() {
|
||||
radio::disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
void TestView::focus() {
|
||||
field_vga.focus();
|
||||
}
|
||||
|
||||
void TestView::on_packet(const testapp::Packet& packet) {
|
||||
const auto hex_formatted = packet.symbols_formatted();
|
||||
auto v = packet.value();
|
||||
|
||||
packet_count++;
|
||||
uint32_t diff = ((v - 1) - prev_v);
|
||||
if (diff < 20)
|
||||
packets_lost += diff;
|
||||
prev_v = v;
|
||||
|
||||
text_debug_a.set(hex_formatted.data.substr(0, 30));
|
||||
|
||||
text_debug_b.set(to_string_dec_uint((packets_lost * 1000) / packet_count) + " per 1000");
|
||||
|
||||
display.draw_pixel(Point(cur_x, 4 * 16 + (256 - packet.alt())), Color::white());
|
||||
|
||||
cur_x++;
|
||||
if (cur_x >= 240) {
|
||||
display.fill_rectangle(Rect(0, 4 * 16, 240, 256), Color::black());
|
||||
cur_x = 0;
|
||||
}
|
||||
|
||||
//radio::disable();
|
||||
|
||||
/*text_serial.set(packet.serial_number());
|
||||
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V");
|
||||
|
||||
altitude = packet.GPS_altitude();
|
||||
latitude = packet.GPS_latitude();
|
||||
longitude = packet.GPS_longitude();*/
|
||||
}
|
||||
|
||||
void TestView::set_target_frequency(const uint32_t new_value) {
|
||||
target_frequency_ = new_value;
|
||||
radio::set_tuning_frequency(tuning_frequency());
|
||||
}
|
||||
|
||||
uint32_t TestView::tuning_frequency() const {
|
||||
return target_frequency_ - (sampling_rate / 4);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
106
firmware/application/ui_test.hpp
Normal file
106
firmware/application/ui_test.hpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 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 __UI_TEST_H__
|
||||
#define __UI_TEST_H__
|
||||
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_rssi.hpp"
|
||||
|
||||
#include "event_m0.hpp"
|
||||
|
||||
#include "test_packet.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
namespace ui {
|
||||
|
||||
class TestView : public View {
|
||||
public:
|
||||
static constexpr uint32_t sampling_rate = 2457600;
|
||||
static constexpr uint32_t baseband_bandwidth = 1750000;
|
||||
|
||||
TestView(NavigationView& nav);
|
||||
~TestView();
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "Test app"; };
|
||||
|
||||
private:
|
||||
uint32_t target_frequency_ { 439255000 };
|
||||
Coord cur_x { 0 };
|
||||
uint32_t packet_count { 0 };
|
||||
uint32_t packets_lost { 0 };
|
||||
uint32_t prev_v { 0 };
|
||||
|
||||
Labels labels {
|
||||
{ { 0 * 8, 1 * 16 }, "Data:", Color::light_grey() }
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
};
|
||||
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 },
|
||||
};
|
||||
|
||||
Text text_debug_a {
|
||||
{ 0 * 8, 2 * 16, 30 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
Text text_debug_b {
|
||||
{ 0 * 8, 3 * 16, 30 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_packet {
|
||||
Message::ID::TestAppPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const TestAppPacketMessage*>(p);
|
||||
const testapp::Packet packet { message->packet };
|
||||
this->on_packet(packet);
|
||||
}
|
||||
};
|
||||
|
||||
void on_packet(const testapp::Packet& packet);
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
uint32_t tuning_frequency() const;
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif/*__UI_TEST_H__*/
|
||||
Reference in New Issue
Block a user