Added tone key mix ratio in Settings -> Audio

Renamed Setup to Settings
Updated binary
This commit is contained in:
furrtek 2018-05-16 09:45:13 +01:00
parent 96828262d7
commit b11c3c94b6
13 changed files with 110 additions and 87 deletions

View file

@ -55,8 +55,7 @@ void MicTXView::configure_baseband() {
sampling_rate / 20, // Update vu-meter at 20Hz
transmitting ? transmitter_model.channel_bandwidth() : 0,
mic_gain,
TONES_F2D(tone_key_frequency(tone_key_index), sampling_rate),
0.2 // 20% mix
TONES_F2D(tone_key_frequency(tone_key_index), sampling_rate)
);
}

View file

@ -20,7 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "ui_setup.hpp"
#include "ui_settings.hpp"
#include "ui_navigation.hpp"
#include "ui_touch_calibration.hpp"
@ -42,7 +42,7 @@ namespace ui {
SetDateTimeView::SetDateTimeView(
NavigationView& nav
) {
button_ok.on_select = [&nav, this](Button&){
button_done.on_select = [&nav, this](Button&){
const auto model = this->form_collect();
const rtc::RTC new_datetime {
model.year, model.month, model.day,
@ -57,18 +57,14 @@ SetDateTimeView::SetDateTimeView(
},
add_children({
&labels,
&field_year,
&text_slash1,
&field_month,
&text_slash2,
&field_day,
&field_hour,
&text_colon1,
&field_minute,
&text_colon2,
&field_second,
&text_format,
&button_ok,
&button_done,
&button_cancel,
});
@ -120,10 +116,6 @@ SetRadioView::SetRadioView(
add_children({
&labels,
&field_ppm,
&text_description_1,
&text_description_2,
&text_description_3,
&text_description_4,
&check_bias,
&button_done,
&button_cancel
@ -252,6 +244,25 @@ void SetUIView::focus() {
checkbox_login.focus();
}
SetAudioView::SetAudioView(NavigationView& nav) {
add_children({
&labels,
&field_tone_mix,
&button_ok
});
field_tone_mix.set_value(persistent_memory::tone_mix());
button_ok.on_select = [&nav, this](Button&) {
persistent_memory::set_tone_mix(field_tone_mix.value());
nav.pop();
};
}
void SetAudioView::focus() {
field_tone_mix.focus();
}
/*void ModInfoView::on_show() {
if (modules_nb) update_infos(0);
}
@ -430,14 +441,13 @@ void ModInfoView::focus() {
button_ok.focus();
}*/
SetupMenuView::SetupMenuView(NavigationView& nav) {
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
add_items({
{ "Audio", ui::Color::white(), &bitmap_icon_speaker, [&nav](){ nav.push<SetAudioView>(); } },
{ "Radio", ui::Color::white(), nullptr, [&nav](){ nav.push<SetRadioView>(); } },
{ "UI", ui::Color::white(), nullptr, [&nav](){ nav.push<SetUIView>(); } },
//{ "SD card modules", ui::Color::white(), [&nav](){ nav.push<ModInfoView>(); } },
{ "Date/Time", ui::Color::white(), nullptr, [&nav](){ nav.push<SetDateTimeView>(); } },
//{ "Frequency correction", ui::Color::white(), nullptr, [&nav](){ nav.push<SetFrequencyCorrectionView>(); } },
//{ "Antenna Bias Voltage", ui::Color::white(), nullptr, [&nav](){ nav.push<AntennaBiasSetupView>(); } },
{ "Touch screen", ui::Color::white(), nullptr, [&nav](){ nav.push<TouchCalibrationView>(); } },
{ "Play dead", ui::Color::white(), &bitmap_icon_playdead, [&nav](){ nav.push<SetPlayDeadView>(); } }
});

View file

@ -20,8 +20,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __UI_SETUP_H__
#define __UI_SETUP_H__
#ifndef __UI_SETTINGS_H__
#define __UI_SETTINGS_H__
#include "ui_widget.hpp"
#include "ui_menu.hpp"
@ -50,6 +50,11 @@ public:
std::string title() const override { return "Set Date/Time"; };
private:
Labels labels {
{ { 8 * 8, 9 * 16 }, "/ / : :", Color::light_grey() },
{ { 4 * 8, 11 * 16 }, "YYYY/MM/DD HH:MM:SS", Color::light_grey() }
};
NumberField field_year {
{ 4 * 8, 9 * 16 },
4,
@ -57,10 +62,6 @@ private:
1,
'0',
};
Text text_slash1 {
{ 8 * 8, 9 * 16, 1 * 8, 16 },
"/",
};
NumberField field_month {
{ 9 * 8, 9 * 16 },
2,
@ -68,10 +69,6 @@ private:
1,
'0',
};
Text text_slash2 {
{ 11 * 8, 9 * 16, 1 * 8, 16 },
"/",
};
NumberField field_day {
{ 12 * 8, 9 * 16 },
2,
@ -87,10 +84,6 @@ private:
1,
'0',
};
Text text_colon1 {
{ 17 * 8, 9 * 16, 1 * 8, 16 },
":"
};
NumberField field_minute {
{ 18 * 8, 9 * 16 },
2,
@ -98,10 +91,6 @@ private:
1,
'0',
};
Text text_colon2 {
{ 20 * 8, 9 * 16, 1 * 8, 16 },
":",
};
NumberField field_second {
{ 21 * 8, 9 * 16 },
2,
@ -110,17 +99,12 @@ private:
'0',
};
Text text_format {
{ 4 * 8, 11 * 16, 19 * 8, 16 },
"YYYY/MM/DD HH:MM:SS",
};
Button button_ok {
{ 4 * 8, 13 * 16, 8 * 8, 24 },
"OK",
Button button_done {
{ 2 * 8, 16 * 16, 12 * 8, 32 },
"Done"
};
Button button_cancel {
{ 18 * 8, 13 * 16, 8 * 8, 24 },
{ 16 * 8, 16 * 16, 12 * 8, 32 },
"Cancel",
};
@ -144,6 +128,10 @@ private:
Labels labels {
{ { 2 * 8, 2 * 16 }, "Frequency correction:", Color::light_grey() },
{ { 6 * 8, 3 * 16 }, "PPM", Color::light_grey() },
{ { 24, 7 * 16 }, "CAUTION: Ensure that all", Color::red() },
{ { 28, 8 * 16 }, "devices attached to the", Color::red() },
{ { 8, 9 * 16 }, "antenna connector can accept", Color::red() },
{ { 68, 10 * 16 }, "a DC voltage!", Color::red() }
};
NumberField field_ppm {
@ -153,26 +141,6 @@ private:
1,
'0',
};
Text text_description_1 {
{ 24, 7 * 16, 24 * 8, 16 },
"\x1B" "\x0C" "CAUTION: Ensure that all"
};
Text text_description_2 {
{ 28, 8 * 16, 23 * 8, 16 },
"\x1B" "\x0C" "devices attached to the"
};
Text text_description_3 {
{ 8, 9 * 16, 28 * 8, 16 },
"\x1B" "\x0C" "antenna connector can accept"
};
Text text_description_4 {
{ 68, 10 * 16, 13 * 8, 16 },
"\x1B" "\x0C" "a DC voltage!"
};
Checkbox check_bias {
{ 28, 12 * 16 },
@ -262,7 +230,34 @@ private:
};
Button button_ok {
{ 72, 260, 96, 32 },
{ 2 * 8, 16 * 16, 12 * 8, 32 },
"OK"
};
};
class SetAudioView : public View {
public:
SetAudioView(NavigationView& nav);
void focus() override;
std::string title() const override { return "Audio settings"; };
private:
Labels labels {
{ { 2 * 8, 3 * 16 }, "Tone key mix: %", Color::light_grey() },
};
NumberField field_tone_mix {
{ 16 * 8, 3 * 16 },
2,
{ 10, 99 },
1,
'0'
};
Button button_ok {
{ 2 * 8, 16 * 16, 12 * 8, 32 },
"OK"
};
};
@ -366,13 +361,13 @@ private:
};
};*/
class SetupMenuView : public MenuView {
class SettingsMenuView : public MenuView {
public:
SetupMenuView(NavigationView& nav);
SettingsMenuView(NavigationView& nav);
std::string title() const override { return "Settings"; };
};
} /* namespace ui */
#endif/*__UI_SETUP_H__*/
#endif/*__UI_SETTINGS_H__*/

View file

@ -98,13 +98,12 @@ void SoundBoardView::file_error() {
void SoundBoardView::play_sound(uint16_t id) {
uint32_t sample_rate = 0;
auto reader = std::make_unique<WAVFileReader>();
uint32_t tone_key_index = options_tone_key.selected_index();
stop(false);
if(!reader->open(sounds[id].path)) {
if (!reader->open(sounds[id].path)) {
file_error();
return;
}
@ -130,11 +129,10 @@ void SoundBoardView::play_sound(uint16_t id) {
}
baseband::set_audiotx_config(
0,
0, // Divider is unused
number_bw.value() * 1000,
10,
TONES_F2D(tone_key_frequency(tone_key_index), sample_rate),
0.2 // 20% mix
0, // Gain is unused
TONES_F2D(tone_key_frequency(tone_key_index), sample_rate)
);
radio::enable({