mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-14 20:03:44 +00:00
bae3854d27
* Add SAME TX external app Adds a Specific Area Message Encoding (SAME/EAS) transmitter as an external app (.ppma) for HackRF PortaPack. SAME is the digital protocol used by NOAA Weather Radio and the Emergency Alert System in the US and Canada for broadcasting emergency alerts (tornado warnings, flash floods, EAN, etc.) on 162.400-162.550 MHz and AM/FM broadcast stations. Features: - Originator code selector (WXR, EAS, CIV, PEP) - Event code selector: 26 standard SAME event codes (RWT, TOR, SVR, FFW, EAN, etc.) with live name display - FIPS location code entry (state 00-99 + county 000-999) - Purge time entry (hours + minutes) - Live message preview showing the encoded header - AFSK encoding: mark=2083Hz, space=1563Hz, 520.833 baud - FM deviation: 5 kHz, repeated 3x per SAME spec - Default frequency: 162.550 MHz (WX channel 7) Protocol details: - 16-byte 0xAB preamble (bit-reversed for LSB-first AFSK) - Header: ZCZC-ORG-EVT-SSPCCC+HHMM-JJJHHMM-STATION- - Uses existing PAFT (proc_afsk) baseband image * Apply clang-format via format-code.sh * Add GPL license headers, guard re-entry, call set_transmitting(true) - Add standard PortaPack GPL-2.0 license header to ui_same_tx.cpp and .hpp - Guard start_tx() with tx_active_ to prevent re-entrant calls - Call tx_view.set_transmitting(true) after starting TX so the TransmitterView button switches to stop mode
85 lines
3.1 KiB
C++
85 lines
3.1 KiB
C++
#ifndef __UI_SAME_TX_H__
|
|
#define __UI_SAME_TX_H__
|
|
|
|
/*
|
|
* Copyright (C) 2024 HTotoo
|
|
*
|
|
* 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 "ui_widget.hpp"
|
|
#include "ui_navigation.hpp"
|
|
#include "ui_transmitter.hpp"
|
|
#include "app_settings.hpp"
|
|
#include "radio_state.hpp"
|
|
#include "message.hpp"
|
|
#include "modems.hpp"
|
|
|
|
namespace ui::external_app::same_tx {
|
|
|
|
class SameTxView : public View {
|
|
public:
|
|
SameTxView(NavigationView& nav);
|
|
~SameTxView();
|
|
SameTxView(const SameTxView&) = delete;
|
|
SameTxView& operator=(const SameTxView&) = delete;
|
|
void focus() override;
|
|
std::string title() const override { return "SAME TX"; }
|
|
|
|
private:
|
|
NavigationView& nav_;
|
|
bool tx_active_{false};
|
|
void start_tx();
|
|
void stop_tx();
|
|
void on_tx_progress(const uint32_t progress, const bool done);
|
|
void update_msg_preview();
|
|
|
|
TxRadioState radio_state_{162550000, 1750000, AFSK_TX_SAMPLERATE};
|
|
app_settings::SettingsManager settings_{"tx_same", app_settings::Mode::TX};
|
|
|
|
Labels labels{{
|
|
{{0 * 8, 0 * 16}, "Org:", ui::Theme::getInstance()->fg_light->foreground},
|
|
{{8 * 8, 0 * 16}, "Evt:", ui::Theme::getInstance()->fg_light->foreground},
|
|
{{0 * 8, 1 * 16}, "FIPS:", ui::Theme::getInstance()->fg_light->foreground},
|
|
{{16 * 8, 1 * 16}, "Dur:", ui::Theme::getInstance()->fg_light->foreground},
|
|
}};
|
|
OptionsField field_org{
|
|
{4 * 8, 0 * 16},
|
|
3,
|
|
{{"WXR", 0}, {"EAS", 1}, {"CIV", 2}, {"PEP", 3}}};
|
|
NumberField field_event_idx{{12 * 8, 0 * 16}, 2, {0, 25}, 1, '0', true};
|
|
Text text_evt{{15 * 8, 0 * 16, 3 * 8, 16}, "RWT"};
|
|
NumberField field_fips_state{{5 * 8, 1 * 16}, 2, {0, 99}, 1, '0'};
|
|
NumberField field_fips_county{{7 * 8 + 4, 1 * 16}, 3, {0, 999}, 1, '0'};
|
|
NumberField field_dur_h{{20 * 8, 1 * 16}, 2, {0, 99}, 1, '0'};
|
|
NumberField field_dur_m{{22 * 8, 1 * 16}, 2, {0, 59}, 1, '0'};
|
|
Text text_msg{{0, 2 * 16, 240, 16}, ""};
|
|
Text text_status{{0, 3 * 16, 240, 16}, "Ready"};
|
|
TransmitterView tx_view{(int16_t)UI_POS_Y_BOTTOM(4), 1000, 0};
|
|
MessageHandlerRegistration message_handler_tx_progress{
|
|
Message::ID::TXProgress,
|
|
[this](const Message* const p) {
|
|
const auto msg = *reinterpret_cast<const TXProgressMessage*>(p);
|
|
this->on_tx_progress(msg.progress, msg.done);
|
|
}};
|
|
};
|
|
|
|
} // namespace ui::external_app::same_tx
|
|
#endif
|