2015-09-04 18:37:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-08-02 10:44:31 +00:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-09-04 18:37:27 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2017-04-24 17:15:57 +00:00
|
|
|
#include "ui_modemsetup.hpp"
|
2015-09-04 18:37:27 +00:00
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
|
|
|
|
#include "portapack.hpp"
|
2016-02-05 16:40:14 +00:00
|
|
|
#include "string_format.hpp"
|
2015-09-04 18:37:27 +00:00
|
|
|
|
|
|
|
#include "portapack_shared_memory.hpp"
|
|
|
|
#include "portapack_persistent_memory.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2016-02-05 16:40:14 +00:00
|
|
|
using namespace portapack;
|
2017-04-21 05:22:31 +00:00
|
|
|
using namespace modems;
|
2015-09-04 18:37:27 +00:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2017-04-24 17:15:57 +00:00
|
|
|
void ModemSetupView::focus() {
|
2015-09-04 18:37:27 +00:00
|
|
|
button_setfreq.focus();
|
|
|
|
}
|
|
|
|
|
2017-04-24 17:15:57 +00:00
|
|
|
void ModemSetupView::update_freq(rf::Frequency f) {
|
2017-04-21 05:22:31 +00:00
|
|
|
persistent_memory::set_tuned_frequency(f);
|
2015-09-04 18:37:27 +00:00
|
|
|
|
2017-05-18 20:56:55 +00:00
|
|
|
button_setfreq.set_text(to_string_short_freq(f));
|
2015-09-04 18:37:27 +00:00
|
|
|
}
|
|
|
|
|
2017-04-24 17:15:57 +00:00
|
|
|
ModemSetupView::ModemSetupView(
|
2016-02-04 09:27:53 +00:00
|
|
|
NavigationView& nav
|
|
|
|
)
|
2015-09-04 18:37:27 +00:00
|
|
|
{
|
2016-08-02 10:44:31 +00:00
|
|
|
using name_t = std::string;
|
|
|
|
using value_t = int32_t;
|
|
|
|
using option_t = std::pair<name_t, value_t>;
|
|
|
|
using options_t = std::vector<option_t>;
|
2017-04-21 05:22:31 +00:00
|
|
|
options_t modem_options;
|
2016-08-02 10:44:31 +00:00
|
|
|
size_t i;
|
2015-09-04 18:37:27 +00:00
|
|
|
|
2017-01-16 03:45:44 +00:00
|
|
|
add_children({
|
2017-02-12 07:23:31 +00:00
|
|
|
&labels,
|
2015-09-04 18:37:27 +00:00
|
|
|
&button_setfreq,
|
2017-04-21 05:22:31 +00:00
|
|
|
&field_baudrate,
|
2015-09-04 18:37:27 +00:00
|
|
|
&field_mark,
|
|
|
|
&field_space,
|
2015-09-16 13:43:43 +00:00
|
|
|
&field_bw,
|
2016-07-27 22:08:05 +00:00
|
|
|
&field_repeat,
|
2017-04-21 05:22:31 +00:00
|
|
|
&options_modem,
|
|
|
|
&button_set_modem,
|
|
|
|
&sym_format,
|
2016-08-02 10:44:31 +00:00
|
|
|
&button_save
|
2017-01-16 03:45:44 +00:00
|
|
|
});
|
2015-09-04 18:37:27 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
for (i = 0; i < MODEM_DEF_COUNT; i++) {
|
|
|
|
if (modem_defs[i].modulation == AFSK)
|
|
|
|
modem_options.emplace_back(std::make_pair(modem_defs[i].name, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
options_modem.set_options(modem_options);
|
|
|
|
options_modem.set_selected_index(0);
|
2016-08-02 10:44:31 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
sym_format.set_symbol_list(0, "6789"); // Data bits
|
|
|
|
sym_format.set_symbol_list(1, "NEo"); // Parity
|
|
|
|
sym_format.set_symbol_list(2, "012"); // Stop bits
|
|
|
|
sym_format.set_symbol_list(3, "ML"); // MSB/LSB first
|
2015-09-05 18:17:43 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
sym_format.set_sym(0, persistent_memory::serial_format().data_bits - 6);
|
|
|
|
sym_format.set_sym(1, persistent_memory::serial_format().parity);
|
|
|
|
sym_format.set_sym(2, persistent_memory::serial_format().stop_bits);
|
|
|
|
sym_format.set_sym(3, persistent_memory::serial_format().bit_order);
|
2015-09-04 18:37:27 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
update_freq(persistent_memory::tuned_frequency());
|
2015-09-16 13:43:43 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
field_mark.set_value(persistent_memory::afsk_mark_freq());
|
|
|
|
field_space.set_value(persistent_memory::afsk_space_freq());
|
|
|
|
field_bw.set_value(persistent_memory::modem_bw() / 1000);
|
|
|
|
field_repeat.set_value(persistent_memory::modem_repeat());
|
|
|
|
|
|
|
|
button_setfreq.on_select = [this, &nav](Button&) {
|
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(persistent_memory::tuned_frequency());
|
2015-09-04 18:37:27 +00:00
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
2016-08-02 10:44:31 +00:00
|
|
|
update_freq(f);
|
2015-09-04 18:37:27 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
field_baudrate.set_value(persistent_memory::modem_baudrate());
|
|
|
|
|
|
|
|
button_set_modem.on_select = [this, &nav](Button&) {
|
|
|
|
size_t modem_def_index = options_modem.selected_index();
|
|
|
|
|
|
|
|
field_mark.set_value(modem_defs[modem_def_index].mark_freq);
|
|
|
|
field_space.set_value(modem_defs[modem_def_index].space_freq);
|
|
|
|
field_baudrate.set_value(modem_defs[modem_def_index].baudrate);
|
|
|
|
};
|
2015-09-04 18:37:27 +00:00
|
|
|
|
2016-08-02 10:44:31 +00:00
|
|
|
button_save.on_select = [this,&nav](Button&) {
|
2017-04-21 05:22:31 +00:00
|
|
|
serial_format_t serial_format;
|
|
|
|
|
|
|
|
persistent_memory::set_afsk_mark(field_mark.value());
|
|
|
|
persistent_memory::set_afsk_space(field_space.value());
|
|
|
|
|
|
|
|
persistent_memory::set_modem_baudrate(field_baudrate.value());
|
|
|
|
persistent_memory::set_modem_bw(field_bw.value() * 1000);
|
|
|
|
persistent_memory::set_modem_repeat(field_repeat.value());
|
2015-09-05 18:17:43 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
serial_format.data_bits = sym_format.get_sym(0) + 6;
|
|
|
|
serial_format.parity = (parity_enum)sym_format.get_sym(1);
|
|
|
|
serial_format.stop_bits = sym_format.get_sym(2);
|
|
|
|
serial_format.bit_order = (order_enum)sym_format.get_sym(3);
|
2015-09-05 18:17:43 +00:00
|
|
|
|
2017-04-21 05:22:31 +00:00
|
|
|
persistent_memory::set_serial_format(serial_format);
|
2015-09-05 18:17:43 +00:00
|
|
|
|
2015-09-04 18:37:27 +00:00
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|