TPMS to ext app (#2128)

* initial

* fix
This commit is contained in:
Totoo 2024-04-29 13:30:21 +02:00 committed by GitHub
parent 819f35ac93
commit d74fd527e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 177 additions and 86 deletions

View File

@ -277,8 +277,7 @@ set(CPPSRC
apps/pocsag_app.cpp
# apps/replay_app.cpp
apps/soundboard_app.cpp
apps/tpms_app.cpp
apps/tpms_app.cpp
# apps/tpms_app.cpp
apps/ui_about_simple.cpp
apps/ui_adsb_rx.cpp
apps/ui_adsb_tx.cpp

View File

@ -80,6 +80,10 @@ set(EXTCPPSRC
#wardrivemap
external/wardrivemap/main.cpp
external/wardrivemap/ui_wardrivemap.cpp
#tpmsrx
external/tpmsrx/main.cpp
external/tpmsrx/tpms_app.cpp
)
set(EXTAPPLIST
@ -102,4 +106,5 @@ set(EXTAPPLIST
foxhunt_rx
audio_test
wardrivemap
tpmsrx
)

View File

@ -42,6 +42,7 @@ MEMORY
ram_external_app_foxhunt_rx(rwx) : org = 0xADC00000, len = 32k
ram_external_app_audio_test(rwx) : org = 0xADC10000, len = 32k
ram_external_app_wardrivemap(rwx) : org = 0xADC20000, len = 32k
ram_external_app_tpmsrx(rwx) : org = 0xADC30000, len = 32k
}
SECTIONS
@ -160,4 +161,10 @@ SECTIONS
*(*ui*external_app*wardrivemap*);
} > ram_external_app_wardrivemap
.external_app_tpmsrx : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_tpmsrx.application_information));
*(*ui*external_app*tpmsrx*);
} > ram_external_app_tpmsrx
}

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2024 Mark Thompson
*
* 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 "tpms_app.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::tpmsrx {
void initialize_app(ui::NavigationView& nav) {
nav.push<TPMSAppView>();
}
} // namespace ui::external_app::tpmsrx
extern "C" {
__attribute__((section(".external_app.app_tpmsrx.application_information"), used)) application_information_t _application_information_tpmsrx = {
/*.memory_location = */ (uint8_t*)0x00000000, // will be filled at compile time
/*.externalAppEntry = */ ui::external_app::tpmsrx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "TPMS RX",
/*.bitmap_data = */ {
0xC0,
0x03,
0xF0,
0x0F,
0x18,
0x18,
0xEC,
0x37,
0x36,
0x6D,
0x3A,
0x59,
0x4B,
0xD5,
0x8B,
0xD3,
0xCB,
0xD1,
0xAB,
0xD2,
0x9A,
0x5C,
0xB6,
0x6C,
0xEC,
0x37,
0x18,
0x18,
0xF0,
0x0F,
0xC0,
0x03,
},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::RX,
/*.m4_app_tag = portapack::spi_flash::image_tag_tpms */ {'P', 'T', 'P', 'M'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}

View File

@ -34,15 +34,15 @@ using namespace portapack;
namespace pmem = portapack::persistent_memory;
namespace tpms {
namespace ui::external_app::tpmsrx {
namespace format {
std::string type(Reading::Type type) {
std::string type(tpms::Reading::Type type) {
return to_string_dec_uint(toUType(type), 2);
}
std::string id(TransponderID id) {
std::string id(tpms::TransponderID id) {
return to_string_hex(id.value(), 8);
}
@ -54,17 +54,17 @@ std::string temperature(Temperature temperature) {
return to_string_dec_int(units_fahr ? temperature.fahrenheit() : temperature.celsius(), 3);
}
std::string flags(Flags flags) {
std::string flags(tpms::Flags flags) {
return to_string_hex(flags, 2);
}
static std::string signal_type(SignalType signal_type) {
static std::string signal_type(tpms::SignalType signal_type) {
switch (signal_type) {
case SignalType::FSK_19k2_Schrader:
case tpms::SignalType::FSK_19k2_Schrader:
return "FSK 38400 19200 Schrader";
case SignalType::OOK_8k192_Schrader:
case tpms::SignalType::OOK_8k192_Schrader:
return "OOK - 8192 Schrader";
case SignalType::OOK_8k4_Schrader:
case tpms::SignalType::OOK_8k4_Schrader:
return "OOK - 8400 Schrader";
default:
return "- - - -";
@ -73,15 +73,13 @@ static std::string signal_type(SignalType signal_type) {
} /* namespace format */
} /* namespace tpms */
void TPMSLogger::on_packet(const tpms::Packet& packet, const uint32_t target_frequency) {
const auto hex_formatted = packet.symbols_formatted();
// TODO: function doesn't take uint64_t, so when >= 1<<32, weirdness will ensue!
const auto target_frequency_str = to_string_dec_uint(target_frequency, 10);
std::string entry = target_frequency_str + " " + tpms::format::signal_type(packet.signal_type()) + " " + hex_formatted.data + "/" + hex_formatted.errors;
std::string entry = target_frequency_str + " " + ui::external_app::tpmsrx::format::signal_type(packet.signal_type()) + " " + hex_formatted.data + "/" + hex_formatted.errors;
log_file.write_entry(packet.received_at(), entry);
}
@ -101,52 +99,9 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) {
}
}
namespace ui {
template <>
void RecentEntriesTable<TPMSRecentEntries>::draw(
const Entry& entry,
const Rect& target_rect,
Painter& painter,
const Style& style) {
std::string line = tpms::format::type(entry.type) + " " + tpms::format::id(entry.id);
if (entry.last_pressure.is_valid()) {
line += " " + tpms::format::pressure(entry.last_pressure.value());
} else {
line +=
" "
" ";
}
if (entry.last_temperature.is_valid()) {
line += " " + tpms::format::temperature(entry.last_temperature.value());
} else {
line +=
" "
" ";
}
if (entry.received_count > 999) {
line += " +++";
} else {
line += " " + to_string_dec_uint(entry.received_count, 3);
}
if (entry.last_flags.is_valid()) {
line += " " + tpms::format::flags(entry.last_flags.value());
} else {
line +=
" "
" ";
}
line.resize(target_rect.width() / 8, ' ');
painter.draw_string(target_rect.location(), style, line);
}
TPMSAppView::TPMSAppView(NavigationView&) {
baseband::run_image(portapack::spi_flash::image_tag_tpms);
// baseband::run_image(portapack::spi_flash::image_tag_tpms);
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({&rssi,
&field_volume,
@ -167,16 +122,16 @@ TPMSAppView::TPMSAppView(NavigationView&) {
options_band.set_by_value(receiver_model.target_frequency());
options_pressure.on_change = [this](size_t, int32_t i) {
tpms::format::units_psi = (bool)i;
format::units_psi = (bool)i;
update_view();
};
options_pressure.set_selected_index(tpms::format::units_psi, true);
options_pressure.set_selected_index(format::units_psi, true);
options_temperature.on_change = [this](size_t, int32_t i) {
tpms::format::units_fahr = (bool)i;
format::units_fahr = (bool)i;
update_view();
};
options_temperature.set_selected_index(tpms::format::units_fahr, true);
options_temperature.set_selected_index(format::units_fahr, true);
logger = std::make_unique<TPMSLogger>();
if (logger) {
@ -234,4 +189,50 @@ void TPMSAppView::on_show_list() {
recent_entries_view.focus();
}
} /* namespace ui */
} // namespace ui::external_app::tpmsrx
namespace ui {
template <>
void RecentEntriesTable<ui::external_app::tpmsrx::TPMSRecentEntries>::draw(
const Entry& entry,
const Rect& target_rect,
Painter& painter,
const Style& style) {
std::string line = ui::external_app::tpmsrx::format::type(entry.type) + " " + ui::external_app::tpmsrx::format::id(entry.id);
if (entry.last_pressure.is_valid()) {
line += " " + ui::external_app::tpmsrx::format::pressure(entry.last_pressure.value());
} else {
line +=
" "
" ";
}
if (entry.last_temperature.is_valid()) {
line += " " + ui::external_app::tpmsrx::format::temperature(entry.last_temperature.value());
} else {
line +=
" "
" ";
}
if (entry.received_count > 999) {
line += " +++";
} else {
line += " " + to_string_dec_uint(entry.received_count, 3);
}
if (entry.last_flags.is_valid()) {
line += " " + ui::external_app::tpmsrx::format::flags(entry.last_flags.value());
} else {
line +=
" "
" ";
}
line.resize(target_rect.width() / 8, ' ');
painter.draw_string(target_rect.location(), style, line);
}
} // namespace ui

View File

@ -38,7 +38,7 @@
#include "tpms_packet.hpp"
namespace tpms {
namespace ui::external_app::tpmsrx {
namespace format {
@ -47,12 +47,6 @@ static bool units_fahr{false};
} /* namespace format */
} /* namespace tpms */
namespace std {
} /* namespace std */
struct TPMSRecentEntry {
using Key = std::pair<tpms::Reading::Type, tpms::TransponderID>;
@ -94,8 +88,6 @@ class TPMSLogger {
LogFile log_file{};
};
namespace ui {
using TPMSRecentEntriesView = RecentEntriesView<TPMSRecentEntries>;
class TPMSAppView : public View {
@ -115,16 +107,18 @@ class TPMSAppView : public View {
private:
RxRadioState radio_state_{
314950000 /* frequency*/,
314950000 /* frequency*/
,
1750000 /* bandwidth */,
2457600 /* sampling rate */};
2457600 /* sampling rate */
};
app_settings::SettingsManager settings_{
"rx_tpms",
app_settings::Mode::RX,
{
{"units_psi"sv, &tpms::format::units_psi},
{"units_fahr"sv, &tpms::format::units_fahr},
{"units_psi"sv, &format::units_psi},
{"units_fahr"sv, &format::units_fahr},
}};
MessageHandlerRegistration message_handler_packet{
@ -198,6 +192,6 @@ class TPMSAppView : public View {
void update_view();
};
} /* namespace ui */
} // namespace ui::external_app::tpmsrx
#endif /*__TPMS_APP_H__*/

View File

@ -100,7 +100,7 @@
#include "pocsag_app.hpp"
#include "replay_app.hpp"
#include "soundboard_app.hpp"
#include "tpms_app.hpp"
// #include "tpms_app.hpp" //moved to ext
#include "core_control.hpp"
#include "file.hpp"
@ -171,9 +171,9 @@ const NavigationView::AppList NavigationView::appList = {
{"radiosonde", "Radiosnde", RX, Color::green(), &bitmap_icon_sonde, new ViewFactory<SondeView>()},
{"recon", "Recon", RX, Color::green(), &bitmap_icon_scanner, new ViewFactory<ReconView>()},
{"search", "Search", RX, Color::yellow(), &bitmap_icon_search, new ViewFactory<SearchView>()},
{"tmps", "TPMS Cars", RX, Color::green(), &bitmap_icon_tpms, new ViewFactory<TPMSAppView>()},
{"weather", "Weather", RX, Color::green(), &bitmap_icon_thermometer, new ViewFactory<WeatherView>()},
//{"tmps", "TPMS Cars", RX, Color::green(), &bitmap_icon_tpms, new ViewFactory<TPMSAppView>()},
{"subghzd", "SubGhzD", RX, Color::yellow(), &bitmap_icon_remote, new ViewFactory<SubGhzDView>()},
{"weather", "Weather", RX, Color::green(), &bitmap_icon_thermometer, new ViewFactory<WeatherView>()},
//{"fskrx", "FSK RX", RX, Color::yellow(), &bitmap_icon_remote, new ViewFactory<FskxRxMainView>()},
//{"dmr", "DMR", RX, Color::dark_grey(), &bitmap_icon_dmr, new ViewFactory<NotImplementedView>()},
//{"sigfox", "SIGFOX", RX, Color::dark_grey(), &bitmap_icon_fox, new ViewFactory<NotImplementedView>()},

View File

@ -498,12 +498,6 @@ set(MODE_CPPSRC
)
DeclareTargets(PTON tones)
### TPMS
set(MODE_CPPSRC
proc_tpms.cpp
)
DeclareTargets(PTPM tpms)
### Wideband Spectrum
@ -651,6 +645,15 @@ set(MODE_CPPSRC
)
DeclareTargets(PABP audio_beep)
### TPMS
set(MODE_CPPSRC
proc_tpms.cpp
)
DeclareTargets(PTPM tpms)
### HackRF "factory" firmware
add_custom_command(