124 lines
3.0 KiB
C++
Raw Normal View History

2024-11-11 17:05:19 +01:00
/*
* Copyright (C) 2024 HTotoo
2025-03-12 04:17:47 +08:00
* copyleft Whiterose of the Dark Army
2024-11-11 17:05:19 +01:00
*
* This file is part of PortaPack.
*
*/
#ifndef __UI_OOKBRUTE_H__
#define __UI_OOKBRUTE_H__
#include "ui.hpp"
#include "ui_language.hpp"
#include "ui_navigation.hpp"
#include "ui_transmitter.hpp"
#include "ui_freq_field.hpp"
#include "ui_record_view.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "utility.hpp"
using namespace ui;
namespace ui::external_app::ookbrute {
#define OOK_SAMPLERATE 2280000U
2024-11-21 21:24:40 +01:00
class OOKBruteView : public View {
2024-11-11 17:05:19 +01:00
public:
2024-11-21 21:24:40 +01:00
OOKBruteView(NavigationView& nav);
~OOKBruteView();
2024-11-11 17:05:19 +01:00
void focus() override;
std::string title() const override {
2024-11-21 21:24:40 +01:00
return "OOKBrute";
2024-11-11 17:05:19 +01:00
};
private:
NavigationView& nav_;
TxRadioState radio_state_{
433920000 /* frequency */,
1750000 /* bandwidth */,
OOK_SAMPLERATE /* sampling rate */
};
TxFrequencyField field_frequency{
{0 * 8, 0 * 16},
nav_};
TransmitterView2 tx_view{
{11 * 8, 0 * 16},
/*short_ui*/ true};
app_settings::SettingsManager settings_{
"tx_ookbrute", app_settings::Mode::TX};
2025-03-12 04:17:47 +08:00
Labels labels{
{{0 * 8, 2 * 16}, "Start Position:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 7 * 16}, "Stop Position:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 13 * 16}, "Encoder Type:", Theme::getInstance()->fg_light->foreground}};
2024-11-11 17:05:19 +01:00
Button button_startstop{
2025-03-12 04:17:47 +08:00
{8, screen_height - 48 - 16, screen_width - 2 * 8, 48},
2024-11-11 17:05:19 +01:00
LanguageHelper::currentMessages[LANG_START]};
2025-03-12 04:17:47 +08:00
Button button_input_start_position{
{8, 4 * 16, screen_width - 2 * 8, 24},
"Input Start Pos"};
Button button_input_stop_position{
{8, 9 * 16, screen_width - 2 * 8, 24},
"Input Stop Pos"};
2024-11-11 17:05:19 +01:00
NumberField field_start{
2025-03-12 04:17:47 +08:00
{0 * 8, 3 * 16},
2024-11-11 17:05:19 +01:00
8,
{0, 2500},
1,
' ',
true};
NumberField field_stop{
2025-03-12 04:17:47 +08:00
{0, 8 * 16},
2024-11-11 17:05:19 +01:00
9,
{0, 2500},
1,
' ',
true};
2025-03-12 04:17:47 +08:00
// NB: when add new encoder here you should also change the char count limit for input range buttons by it's digits in DEC
2024-11-11 17:05:19 +01:00
OptionsField options_atkmode{
2025-03-12 04:17:47 +08:00
{0, 14 * 16},
2024-11-11 17:05:19 +01:00
12,
{{"Came12", 0},
{"Came24", 1},
{"Nice12", 2},
{"Nice24", 3},
{"Holtek12", 4},
{"Princeton24", 5}}};
bool is_running{false};
uint32_t counter = 0; // for packet change
2025-03-12 04:17:47 +08:00
std::string text_input_buffer{}; // this is needed by the text_prompt func
2024-11-11 17:05:19 +01:00
void start();
void stop();
void on_tx_progress(const bool done);
void validate_start_stop();
void update_start_stop(uint32_t proto);
void generate_packet();
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
this->on_tx_progress(message.done);
}};
};
}; // namespace ui::external_app::ookbrute
#endif /*__UI_OOKBRUTE_H__*/