mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-03-04 12:55:15 +00:00
Merge pull request #853 from gullradriel/up-down-convert
Up Down Converter (replacement/update of previous HamItUp function)
This commit is contained in:
commit
05429d3d15
@ -146,8 +146,6 @@ SetRadioView::SetRadioView(
|
||||
}
|
||||
|
||||
add_children({
|
||||
&check_hamitup,
|
||||
&button_hamitup_freq,
|
||||
&check_clkout,
|
||||
&field_clkout_freq,
|
||||
&labels_clkout_khz,
|
||||
@ -172,29 +170,7 @@ SetRadioView::SetRadioView(
|
||||
EventDispatcher::send_message(message);
|
||||
};
|
||||
|
||||
check_hamitup.set_value(portapack::persistent_memory::config_hamitup());
|
||||
check_hamitup.on_select = [this](Checkbox&, bool v) {
|
||||
portapack::persistent_memory::set_config_hamitup(v);
|
||||
// Retune to take hamitup change in account
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
//Refresh status bar with/out UP!
|
||||
StatusRefreshMessage message { };
|
||||
EventDispatcher::send_message(message);
|
||||
};
|
||||
|
||||
button_hamitup_freq.set_text( to_string_short_freq( portapack::persistent_memory::config_hamitup_freq() ) + "MHz");
|
||||
|
||||
button_hamitup_freq.on_select = [this, &nav](Button& button) {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_hamitup_freq() );
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
portapack::persistent_memory::set_config_hamitup_freq( f );
|
||||
// Retune to take hamitup change in account
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
button_hamitup_freq.set_text( "<" + to_string_short_freq( f ) + " MHz>" );
|
||||
};
|
||||
};
|
||||
|
||||
field_clkout_freq.set_value(portapack::persistent_memory::clkout_freq());
|
||||
field_clkout_freq.set_value(portapack::persistent_memory::clkout_freq());
|
||||
value_freq_step.set_style(&style_text);
|
||||
|
||||
field_clkout_freq.on_select = [this](NumberField&) {
|
||||
@ -345,6 +321,70 @@ void SetAppSettingsView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Converter Settings
|
||||
// ---------------------------------------------------------
|
||||
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
||||
add_children({
|
||||
&check_show_converter,
|
||||
&check_converter,
|
||||
&converter_mode,
|
||||
&button_converter_freq,
|
||||
&button_save,
|
||||
&button_cancel
|
||||
});
|
||||
|
||||
check_show_converter.set_value(!portapack::persistent_memory::config_hide_converter());
|
||||
check_show_converter.on_select = [this](Checkbox&, bool v) {
|
||||
portapack::persistent_memory::set_config_hide_converter(!v);
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
//Refresh status bar with/out converter
|
||||
StatusRefreshMessage message { };
|
||||
EventDispatcher::send_message(message);
|
||||
};
|
||||
|
||||
check_converter.set_value(portapack::persistent_memory::config_converter());
|
||||
check_converter.on_select = [this](Checkbox&, bool v) {
|
||||
portapack::persistent_memory::set_config_converter(v);
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
//Refresh status bar with/out converter
|
||||
StatusRefreshMessage message { };
|
||||
EventDispatcher::send_message(message);
|
||||
};
|
||||
|
||||
converter_mode.set_by_value( portapack::persistent_memory::config_updown_converter() );
|
||||
converter_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
portapack::persistent_memory::set_config_updown_converter( v );
|
||||
//Refresh status bar with icon up or down
|
||||
StatusRefreshMessage message { };
|
||||
EventDispatcher::send_message(message);
|
||||
};
|
||||
|
||||
button_converter_freq.set_text( to_string_short_freq( portapack::persistent_memory::config_converter_freq() ) + "MHz");
|
||||
button_converter_freq.on_select = [this, &nav](Button& button) {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq() );
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
portapack::persistent_memory::set_config_converter_freq( f );
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
button_converter_freq.set_text( "<" + to_string_short_freq( f ) + " MHz>" );
|
||||
};
|
||||
};
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
button_cancel.on_select = [&nav, this](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
}
|
||||
|
||||
void SetConverterSettingsView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
SetAudioView::SetAudioView(NavigationView& nav) {
|
||||
add_children({
|
||||
&labels,
|
||||
@ -408,6 +448,7 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
||||
{ "Date/Time", ui::Color::dark_cyan(), &bitmap_icon_options_datetime, [&nav](){ nav.push<SetDateTimeView>(); } },
|
||||
{ "Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav](){ nav.push<TouchCalibrationView>(); } },
|
||||
{ "App Settings", ui::Color::dark_cyan(), &bitmap_icon_setup, [&nav](){ nav.push<SetAppSettingsView>(); } },
|
||||
{ "Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav](){ nav.push<SetConverterSettingsView>(); } },
|
||||
{ "QR Code", ui::Color::dark_cyan(), &bitmap_icon_qr_code, [&nav](){ nav.push<SetQRCodeView>(); } }
|
||||
});
|
||||
set_max_rows(2); // allow wider buttons
|
||||
|
@ -198,16 +198,6 @@ private:
|
||||
"Turn on bias voltage"
|
||||
};
|
||||
|
||||
Checkbox check_hamitup {
|
||||
{ 18, 14 * 16},
|
||||
7,
|
||||
"HamItUp"
|
||||
};
|
||||
Button button_hamitup_freq {
|
||||
{ 240 - 15 * 8 , 14 * 16 , 15 * 8 , 24 },
|
||||
"",
|
||||
};
|
||||
|
||||
Button button_save {
|
||||
{ 2 * 8, 16 * 16, 12 * 8, 32 },
|
||||
"Save"
|
||||
@ -336,6 +326,53 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
class SetConverterSettingsView : public View {
|
||||
public:
|
||||
SetConverterSettingsView(NavigationView& nav);
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "Converter"; };
|
||||
|
||||
private:
|
||||
|
||||
Checkbox check_show_converter {
|
||||
{ 18, 4 * 16},
|
||||
19,
|
||||
"show/hide converter"
|
||||
};
|
||||
|
||||
Checkbox check_converter {
|
||||
{ 18, 6 * 16},
|
||||
7,
|
||||
"enable/disable converter"
|
||||
};
|
||||
|
||||
OptionsField converter_mode {
|
||||
{ 18 , 8 * 16 + 4 },
|
||||
0,
|
||||
{
|
||||
{" + ",0}, // up converter
|
||||
{" - ",1} // down converter
|
||||
}
|
||||
};
|
||||
|
||||
Button button_converter_freq {
|
||||
{ 18 + 4 * 8 , 8 * 16 , 16 * 8 , 24 },
|
||||
"",
|
||||
};
|
||||
|
||||
Button button_save {
|
||||
{ 2 * 8, 16 * 16, 12 * 8, 32 },
|
||||
"Save"
|
||||
};
|
||||
|
||||
Button button_cancel {
|
||||
{ 16 * 8, 16 * 16, 12 * 8, 32 },
|
||||
"Cancel",
|
||||
};
|
||||
};
|
||||
|
||||
class SetAudioView : public View {
|
||||
public:
|
||||
SetAudioView(NavigationView& nav);
|
||||
|
@ -197,6 +197,28 @@ static constexpr Bitmap bitmap_icon_debug {
|
||||
{ 16, 16 }, bitmap_icon_debug_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_downconvert_data[] = {
|
||||
0x00, 0x00,
|
||||
0x77, 0x77,
|
||||
0x51, 0x51,
|
||||
0x33, 0x53,
|
||||
0x51, 0x51,
|
||||
0x51, 0x77,
|
||||
0x00, 0x80,
|
||||
0x80, 0x01,
|
||||
0x80, 0x01,
|
||||
0x80, 0x01,
|
||||
0x80, 0x01,
|
||||
0xF8, 0x1F,
|
||||
0xF0, 0x0F,
|
||||
0xE0, 0x07,
|
||||
0xC0, 0x03,
|
||||
0x80, 0x01,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_downconvert {
|
||||
{ 16, 16 }, bitmap_icon_downconvert_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_more_data[] = {
|
||||
0x10,
|
||||
0x10,
|
||||
@ -825,28 +847,6 @@ static constexpr Bitmap bitmap_icon_rename {
|
||||
{ 16, 16 }, bitmap_icon_rename_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_hamitup_data[] = {
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x22, 0x47,
|
||||
0x22, 0x49,
|
||||
0x22, 0x49,
|
||||
0x22, 0x47,
|
||||
0x22, 0x01,
|
||||
0x22, 0x01,
|
||||
0x1C, 0x41,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_hamitup {
|
||||
{ 16, 16 }, bitmap_icon_hamitup_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_lora_data[] = {
|
||||
0xC0, 0x03,
|
||||
0x30, 0x0C,
|
||||
@ -1023,6 +1023,28 @@ static constexpr Bitmap bitmap_icon_dmr {
|
||||
{ 16, 16 }, bitmap_icon_dmr_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_upconvert_data[] = {
|
||||
0x80, 0x01,
|
||||
0xC0, 0x03,
|
||||
0xE0, 0x07,
|
||||
0xF0, 0x0F,
|
||||
0xF8, 0x1F,
|
||||
0x80, 0x01,
|
||||
0x80, 0x01,
|
||||
0x80, 0x01,
|
||||
0x80, 0x01,
|
||||
0x00, 0x00,
|
||||
0x77, 0x77,
|
||||
0x51, 0x51,
|
||||
0x33, 0x53,
|
||||
0x51, 0x51,
|
||||
0x51, 0x77,
|
||||
0x00, 0x80,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_upconvert {
|
||||
{ 16, 16 }, bitmap_icon_upconvert_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_clk_int_data[] = {
|
||||
0x00,
|
||||
0x00,
|
||||
|
@ -170,8 +170,17 @@ void set_direction(const rf::Direction new_direction) {
|
||||
|
||||
bool set_tuning_frequency(const rf::Frequency frequency) {
|
||||
rf::Frequency final_frequency = frequency ;
|
||||
if( portapack::persistent_memory::config_hamitup() ) {
|
||||
final_frequency = frequency + portapack::persistent_memory::config_hamitup_freq();
|
||||
// if feature is enabled
|
||||
if( portapack::persistent_memory::config_converter() ) {
|
||||
//downconvert
|
||||
if( portapack::persistent_memory::config_updown_converter() )
|
||||
{
|
||||
final_frequency = frequency - portapack::persistent_memory::config_converter_freq();
|
||||
}
|
||||
else //upconvert
|
||||
{
|
||||
final_frequency = frequency + portapack::persistent_memory::config_converter_freq();
|
||||
}
|
||||
}
|
||||
const auto tuning_config = tuning::config::create(final_frequency);
|
||||
if( tuning_config.is_valid() ) {
|
||||
|
@ -111,7 +111,7 @@ SystemStatusView::SystemStatusView(
|
||||
&button_back,
|
||||
&title,
|
||||
&button_title,
|
||||
&button_hamitup,
|
||||
&button_converter,
|
||||
&button_speaker,
|
||||
&button_stealth,
|
||||
//&button_textentry,
|
||||
@ -127,6 +127,24 @@ SystemStatusView::SystemStatusView(
|
||||
else
|
||||
button_speaker.hidden(true);
|
||||
|
||||
|
||||
if( portapack::persistent_memory::config_hide_converter() )
|
||||
{
|
||||
button_converter.hidden(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
button_converter.hidden(false);
|
||||
if( portapack::persistent_memory::config_converter() )
|
||||
{
|
||||
button_converter.set_foreground(Color::red());
|
||||
}
|
||||
else
|
||||
{
|
||||
button_converter.set_foreground(Color::light_grey());
|
||||
}
|
||||
}
|
||||
|
||||
button_back.id = -1; // Special ID used by FocusManager
|
||||
title.set_style(&style_systemstatus);
|
||||
|
||||
@ -149,8 +167,8 @@ SystemStatusView::SystemStatusView(
|
||||
this->on_title();
|
||||
};
|
||||
|
||||
button_hamitup.on_select = [this](ImageButton&) {
|
||||
this->on_hamitup();
|
||||
button_converter.on_select = [this](ImageButton&) {
|
||||
this->on_converter();
|
||||
};
|
||||
|
||||
button_speaker.on_select = [this](ImageButton&) {
|
||||
@ -184,16 +202,33 @@ SystemStatusView::SystemStatusView(
|
||||
}
|
||||
|
||||
void SystemStatusView::refresh() {
|
||||
if( portapack::persistent_memory::config_hamitup() )
|
||||
if( portapack::persistent_memory::config_hide_converter() )
|
||||
{
|
||||
button_hamitup.set_foreground(Color::red());
|
||||
button_converter.hidden(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
button_hamitup.set_foreground(Color::light_grey());
|
||||
if( portapack::persistent_memory::config_updown_converter() )
|
||||
{
|
||||
button_converter.set_bitmap(&bitmap_icon_downconvert);
|
||||
}
|
||||
else
|
||||
{
|
||||
button_converter.set_bitmap(&bitmap_icon_upconvert);
|
||||
}
|
||||
button_converter.hidden(false);
|
||||
if( portapack::persistent_memory::config_converter() )
|
||||
{
|
||||
button_converter.set_foreground(Color::red());
|
||||
}
|
||||
else
|
||||
{
|
||||
button_converter.set_foreground(Color::light_grey());
|
||||
}
|
||||
}
|
||||
// Retune to take hamitup change in account
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
transmitter_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() );
|
||||
|
||||
if (!portapack::persistent_memory::config_speaker()) {
|
||||
button_speaker.set_foreground(Color::light_grey());
|
||||
@ -257,16 +292,16 @@ void SystemStatusView::set_title(const std::string new_value) {
|
||||
}
|
||||
}
|
||||
|
||||
void SystemStatusView::on_hamitup() {
|
||||
if(!portapack::persistent_memory::config_hamitup())
|
||||
void SystemStatusView::on_converter() {
|
||||
if(!portapack::persistent_memory::config_converter())
|
||||
{
|
||||
portapack::persistent_memory::set_config_hamitup( true );
|
||||
button_hamitup.set_foreground(Color::red());
|
||||
portapack::persistent_memory::set_config_converter( true );
|
||||
button_converter.set_foreground(Color::red());
|
||||
}
|
||||
else
|
||||
{
|
||||
portapack::persistent_memory::set_config_hamitup( false );
|
||||
button_hamitup.set_foreground(Color::light_grey());
|
||||
portapack::persistent_memory::set_config_converter( false );
|
||||
button_converter.set_foreground(Color::light_grey());
|
||||
}
|
||||
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() ); // Retune
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ namespace ui
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_hamitup{
|
||||
ImageButton button_converter{
|
||||
{17 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_hamitup,
|
||||
&bitmap_icon_upconvert,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
@ -194,7 +194,7 @@ namespace ui
|
||||
SDCardStatusView sd_card_status_view{
|
||||
{28 * 8, 0 * 16, 2 * 8, 1 * 16}};
|
||||
|
||||
void on_hamitup();
|
||||
void on_converter();
|
||||
void on_speaker();
|
||||
void on_stealth();
|
||||
void on_bias_tee();
|
||||
|
@ -288,9 +288,14 @@ struct data_t {
|
||||
// Recon App
|
||||
uint64_t recon_config;
|
||||
|
||||
// HamItUp (+125MHz offset by default, configurable)
|
||||
bool hamitup;
|
||||
int64_t hamitup_freq;
|
||||
// converter: show or hide icon. Hiding cause auto disable to avoid mistakes
|
||||
bool hide_converter ;
|
||||
// enable or disable converter
|
||||
bool converter ;
|
||||
// set up converter (false) or down converter (true) converter
|
||||
bool updown_converter ;
|
||||
// up/down converter offset
|
||||
int64_t converter_frequency_offset ;
|
||||
|
||||
constexpr data_t() :
|
||||
structure_version(data_structure_version_enum::VERSION_CURRENT),
|
||||
@ -320,8 +325,10 @@ struct data_t {
|
||||
|
||||
hardware_config(0),
|
||||
recon_config(0),
|
||||
hamitup(0),
|
||||
hamitup_freq(125000000)
|
||||
hide_converter(0),
|
||||
converter(0),
|
||||
updown_converter(0),
|
||||
converter_frequency_offset(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -739,17 +746,33 @@ void set_recon_load_hamradios(const bool v ){
|
||||
void set_recon_match_mode(const bool v ) {
|
||||
data->recon_config = (data->recon_config & ~0x00800000UL) | (v << 23);
|
||||
}
|
||||
bool config_hamitup() {
|
||||
return data->hamitup;
|
||||
bool config_hide_converter() {
|
||||
return data->hide_converter;
|
||||
}
|
||||
void set_config_hamitup(const bool v ){
|
||||
data-> hamitup = v ;
|
||||
bool config_converter() {
|
||||
return data->converter;
|
||||
}
|
||||
int64_t config_hamitup_freq() {
|
||||
return data->hamitup_freq ;
|
||||
bool config_updown_converter() {
|
||||
return data->updown_converter;
|
||||
}
|
||||
void set_config_hamitup_freq(const int64_t v ){
|
||||
data-> hamitup_freq = v ;
|
||||
int64_t config_converter_freq() {
|
||||
return data->converter_frequency_offset ;
|
||||
}
|
||||
void set_config_hide_converter(const bool v ){
|
||||
data-> hide_converter = v ;
|
||||
if( v )
|
||||
{
|
||||
data -> converter = false ;
|
||||
}
|
||||
}
|
||||
void set_config_converter(const bool v ){
|
||||
data-> converter = v ;
|
||||
}
|
||||
void set_config_updown_converter(const bool v){
|
||||
data-> updown_converter = v ;
|
||||
}
|
||||
void set_config_converter_freq(const int64_t v ){
|
||||
data-> converter_frequency_offset = v ;
|
||||
}
|
||||
} /* namespace persistent_memory */
|
||||
} /* namespace portapack */
|
||||
|
@ -151,8 +151,10 @@ uint8_t config_cpld();
|
||||
void set_config_cpld(uint8_t i);
|
||||
|
||||
bool config_splash();
|
||||
bool config_hamitup();
|
||||
int64_t config_hamitup_freq();
|
||||
bool config_hide_converter();
|
||||
bool config_converter();
|
||||
bool config_updown_converter();
|
||||
int64_t config_converter_freq();
|
||||
bool show_gui_return_icon();
|
||||
bool load_app_settings();
|
||||
bool save_app_settings();
|
||||
@ -169,8 +171,10 @@ void set_load_app_settings(bool v);
|
||||
void set_save_app_settings(bool v);
|
||||
void set_show_bigger_qr_code(bool v);
|
||||
void set_config_splash(bool v);
|
||||
void set_config_hamitup(bool v);
|
||||
void set_config_hamitup_freq(const int64_t v );
|
||||
void set_config_hide_converter(bool v);
|
||||
void set_config_converter(bool v);
|
||||
void set_config_updown_converter(const bool v);
|
||||
void set_config_converter_freq(const int64_t v );
|
||||
void set_clock_hidden(bool v);
|
||||
void set_clock_with_date(bool v);
|
||||
void set_config_login(bool v);
|
||||
|
BIN
firmware/graphics/icon_downconvert.png
Executable file
BIN
firmware/graphics/icon_downconvert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 307 B |
Binary file not shown.
Before Width: | Height: | Size: 189 B |
BIN
firmware/graphics/icon_upconvert.png
Executable file
BIN
firmware/graphics/icon_upconvert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 251 B |
Loading…
x
Reference in New Issue
Block a user