2015-09-04 14:37:27 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
*
|
|
|
|
* 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_rds.hpp"
|
|
|
|
#include "ui_afsksetup.hpp"
|
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
|
|
|
|
#include "ff.h"
|
|
|
|
#include "hackrf_gpio.hpp"
|
|
|
|
#include "portapack.hpp"
|
|
|
|
#include "radio.hpp"
|
2016-02-05 11:40:14 -05:00
|
|
|
#include "string_format.hpp"
|
2015-09-04 14:37:27 -04:00
|
|
|
|
|
|
|
#include "hackrf_hal.hpp"
|
|
|
|
#include "portapack_shared_memory.hpp"
|
|
|
|
#include "portapack_persistent_memory.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2016-02-05 11:40:14 -05:00
|
|
|
using namespace portapack;
|
2015-09-04 14:37:27 -04:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
void AFSKSetupView::focus() {
|
|
|
|
button_setfreq.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AFSKSetupView::paint(Painter& painter) {
|
2016-01-05 05:47:46 -05:00
|
|
|
(void)painter;
|
2015-09-04 14:37:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AFSKSetupView::updfreq(rf::Frequency f) {
|
|
|
|
char finalstr[9] = {0};
|
|
|
|
|
2015-11-18 16:01:48 -05:00
|
|
|
portapack::persistent_memory::set_tuned_frequency(f);
|
2015-09-04 14:37:27 -04:00
|
|
|
|
|
|
|
auto mhz = to_string_dec_int(f / 1000000, 3);
|
|
|
|
auto hz100 = to_string_dec_int((f / 100) % 10000, 4, '0');
|
|
|
|
|
|
|
|
strcat(finalstr, mhz.c_str());
|
|
|
|
strcat(finalstr, ".");
|
|
|
|
strcat(finalstr, hz100.c_str());
|
|
|
|
|
|
|
|
this->button_setfreq.set_text(finalstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
AFSKSetupView::AFSKSetupView(
|
2016-02-04 04:27:53 -05:00
|
|
|
NavigationView& nav
|
|
|
|
)
|
2015-09-04 14:37:27 -04:00
|
|
|
{
|
2015-09-16 09:43:43 -04:00
|
|
|
uint8_t rpt;
|
2015-09-04 14:37:27 -04:00
|
|
|
|
|
|
|
add_children({ {
|
|
|
|
&text_title,
|
|
|
|
&button_setfreq,
|
|
|
|
&button_setbps,
|
|
|
|
&text_mark,
|
|
|
|
&field_mark,
|
|
|
|
&text_space,
|
|
|
|
&field_space,
|
2015-09-16 09:43:43 -04:00
|
|
|
&text_bw,
|
|
|
|
&field_bw,
|
2016-07-27 18:08:05 -04:00
|
|
|
&text_repeat,
|
|
|
|
&field_repeat,
|
2016-07-25 10:21:27 -04:00
|
|
|
//&checkbox_lsb,
|
|
|
|
//&checkbox_parity,
|
|
|
|
//&checkbox_datasize,
|
|
|
|
&checkbox_altformat,
|
2015-09-04 14:37:27 -04:00
|
|
|
&button_done
|
|
|
|
} });
|
|
|
|
|
2016-07-25 10:21:27 -04:00
|
|
|
//if (portapack::persistent_memory::afsk_config() & 1) checkbox_lsb.set_value(true);
|
|
|
|
//if (portapack::persistent_memory::afsk_config() & 2) checkbox_parity.set_value(true);
|
|
|
|
//if (portapack::persistent_memory::afsk_config() & 4) checkbox_datasize.set_value(true);
|
|
|
|
if (portapack::persistent_memory::afsk_config() & 8) checkbox_altformat.set_value(true);
|
2015-09-05 14:17:43 -04:00
|
|
|
|
2015-11-18 16:01:48 -05:00
|
|
|
updfreq(portapack::persistent_memory::tuned_frequency());
|
2015-09-04 14:37:27 -04:00
|
|
|
|
2015-11-18 16:01:48 -05:00
|
|
|
field_mark.set_value(portapack::persistent_memory::afsk_mark_freq()*100);
|
|
|
|
field_space.set_value(portapack::persistent_memory::afsk_space_freq()*100);
|
|
|
|
field_bw.set_value(portapack::persistent_memory::afsk_bw());
|
|
|
|
rpt = (portapack::persistent_memory::afsk_config() >> 8) & 0xFF;
|
2015-09-16 09:43:43 -04:00
|
|
|
if (rpt > 99) rpt = 5;
|
|
|
|
field_repeat.set_value(rpt);
|
|
|
|
|
2015-09-04 14:37:27 -04:00
|
|
|
button_setfreq.on_select = [this,&nav](Button&){
|
2016-07-26 21:03:40 -04:00
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::tuned_frequency());
|
2015-09-04 14:37:27 -04:00
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
|
|
|
updfreq(f);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-11-18 16:01:48 -05:00
|
|
|
if (portapack::persistent_memory::afsk_bitrate() == 1200) {
|
2015-09-04 14:37:27 -04:00
|
|
|
button_setbps.set_text("1200 bps");
|
|
|
|
} else {
|
|
|
|
button_setbps.set_text("2400 bps");
|
|
|
|
}
|
|
|
|
|
|
|
|
button_setbps.on_select = [this](Button&){
|
2015-11-18 16:01:48 -05:00
|
|
|
if (portapack::persistent_memory::afsk_bitrate() == 1200) {
|
|
|
|
portapack::persistent_memory::set_afsk_bitrate(2400);
|
2015-09-04 14:37:27 -04:00
|
|
|
button_setbps.set_text("2400 bps");
|
|
|
|
} else {
|
2015-11-18 16:01:48 -05:00
|
|
|
portapack::persistent_memory::set_afsk_bitrate(1200);
|
2015-09-04 14:37:27 -04:00
|
|
|
button_setbps.set_text("1200 bps");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
button_done.on_select = [this,&nav](Button&){
|
2015-09-16 09:43:43 -04:00
|
|
|
uint32_t afsk_config = 0;
|
2015-09-05 14:17:43 -04:00
|
|
|
|
2015-11-18 16:01:48 -05:00
|
|
|
portapack::persistent_memory::set_afsk_mark(field_mark.value()/100);
|
|
|
|
portapack::persistent_memory::set_afsk_space(field_space.value()/100);
|
|
|
|
portapack::persistent_memory::set_afsk_bw(field_bw.value());
|
2015-09-05 14:17:43 -04:00
|
|
|
|
2016-07-25 10:21:27 -04:00
|
|
|
//if (checkbox_lsb.value() == true) afsk_config |= 1;
|
|
|
|
//if (checkbox_parity.value() == true) afsk_config |= 2;
|
|
|
|
//if (checkbox_datasize.value() == true) afsk_config |= 4;
|
|
|
|
if (checkbox_altformat.value() == true) afsk_config |= 8;
|
2015-09-16 09:43:43 -04:00
|
|
|
afsk_config |= (field_repeat.value() << 8);
|
2015-11-18 16:01:48 -05:00
|
|
|
portapack::persistent_memory::set_afsk_config(afsk_config);
|
2015-09-05 14:17:43 -04:00
|
|
|
|
2015-09-04 14:37:27 -04:00
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|