Added microphone TX (very basic for now)

This commit is contained in:
furrtek 2017-03-12 07:09:22 +00:00
parent 6ac911feb7
commit 44b2fc469c
11 changed files with 140 additions and 39 deletions

View File

@ -155,6 +155,7 @@ set(CPPSRC
ui_afsksetup.cpp ui_afsksetup.cpp
ui_alphanum.cpp ui_alphanum.cpp
ui_audio.cpp ui_audio.cpp
ui_audiotx.cpp
ui_baseband_stats_view.cpp ui_baseband_stats_view.cpp
ui_bht_tx.cpp ui_bht_tx.cpp
ui_channel.cpp ui_channel.cpp

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -41,7 +42,7 @@ constexpr i2s::ConfigTX i2s0_config_tx {
.mono = 0, .mono = 0,
.stop = 1, .stop = 1,
.reset = 0, .reset = 0,
.ws_sel = 0, .ws_sel = 0, // Master
.ws_halfperiod = 0x0f, .ws_halfperiod = 0x0f,
.mute = 1, .mute = 1,
}, },
@ -65,7 +66,7 @@ constexpr i2s::ConfigRX i2s0_config_rx {
.mono = 0, .mono = 0,
.stop = 1, .stop = 1,
.reset = 0, .reset = 0,
.ws_sel = 1, .ws_sel = 0, // Master
.ws_halfperiod = 0x0f, .ws_halfperiod = 0x0f,
}, },
.rxrate = i2s::MCLKRate { .rxrate = i2s::MCLKRate {
@ -103,6 +104,18 @@ WM8731 audio_codec { i2c0, wm8731_i2c_address };
} /* namespace */ } /* namespace */
namespace input {
void start() {
i2s::i2s0::rx_start();
}
void stop() {
i2s::i2s0::rx_stop();
}
} /* namespace input */
namespace output { namespace output {
void start() { void start() {

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -38,6 +39,13 @@ void unmute();
} /* namespace output */ } /* namespace output */
namespace input {
void start();
void stop();
} /* namespace input */
namespace headphone { namespace headphone {
volume_range_t volume_range(); volume_range_t volume_range();

View File

@ -25,7 +25,7 @@
const ctcss_tone ctcss_tones[CTCSS_TONES_NB] = { const ctcss_tone ctcss_tones[CTCSS_TONES_NB] = {
{ "XZ", 0, 67.000 }, { "XZ", 0, 67.000 },
{ "WZ", 1, 69.400 }, { "WZ", 1, 69.400 },
{ "XA", 39, 71.900 }, { "XA", 2, 71.900 },
{ "WA", 3, 74.400 }, { "WA", 3, 74.400 },
{ "XB", 4, 77.000 }, { "XB", 4, 77.000 },
{ "WB", 5, 79.700 }, { "WB", 5, 79.700 },

View File

@ -21,15 +21,12 @@
#include "ui_audiotx.hpp" #include "ui_audiotx.hpp"
#include "ch.h" #include "baseband_api.hpp"
#include "ui_alphanum.hpp" #include "ui_alphanum.hpp"
#include "ff.h" #include "audio.hpp"
#include "hackrf_gpio.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "radio.hpp" #include "pins.hpp"
#include "string_format.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
#include <cstring> #include <cstring>
@ -42,6 +39,38 @@ void AudioTXView::focus() {
button_transmit.focus(); button_transmit.focus();
} }
void AudioTXView::paint(Painter& painter) {
_painter = &painter;
}
void AudioTXView::draw_vumeter() {
uint32_t bar;
Color color;
bool lit = true;
uint32_t bar_level = audio_level / 15;
if (bar_level > 16) bar_level = 16;
for (bar = 0; bar < 16; bar++) {
if (bar >= bar_level)
lit = false;
if (bar < 11)
color = lit ? Color::green() : Color::dark_green();
else if ((bar >= 11) && (bar < 13))
color = lit ? Color::yellow() : Color::dark_yellow();
else if ((bar >= 13) && (bar < 15))
color = lit ? Color::orange() : Color::dark_orange();
else
color = lit ? Color::red() : Color::dark_red();
_painter->fill_rectangle({ 100, (Coord)(210 - (bar * 12)), 40, 10 }, color);
}
//text_power.set(to_string_hex(LPC_I2S0->STATE, 8) + " " + to_string_dec_uint(audio_level) + " ");
text_power.set(to_string_dec_uint(audio_level) + " ");
}
void AudioTXView::on_tuning_frequency_changed(rf::Frequency f) { void AudioTXView::on_tuning_frequency_changed(rf::Frequency f) {
transmitter_model.set_tuning_frequency(f); transmitter_model.set_tuning_frequency(f);
} }
@ -50,10 +79,14 @@ AudioTXView::AudioTXView(
NavigationView& nav NavigationView& nav
) )
{ {
pins[P6_2].mode(3); // I2S0_RX_SDA !
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
transmitter_model.set_tuning_frequency(92200000); transmitter_model.set_tuning_frequency(92200000);
add_children({ add_children({
&text_title, &text_power,
&field_frequency, &field_frequency,
&button_transmit, &button_transmit,
&button_exit &button_exit
@ -74,22 +107,32 @@ AudioTXView::AudioTXView(
}; };
button_transmit.on_select = [](Button&){ button_transmit.on_select = [](Button&){
transmitter_model.set_baseband_configuration({ transmitter_model.set_sampling_rate(1536000U);
.mode = 1,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
transmitter_model.set_rf_amp(true); transmitter_model.set_rf_amp(true);
transmitter_model.set_lna(40);
transmitter_model.set_vga(40);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();
baseband::set_audiotx_data(
76800, // 20Hz level update
10000, // 10kHz bw
false,
0
);
}; };
button_exit.on_select = [&nav](Button&){ button_exit.on_select = [&nav](Button&){
nav.pop(); nav.pop();
}; };
audio::set_rate(audio::Rate::Hz_24000);
audio::input::start();
} }
AudioTXView::~AudioTXView() { AudioTXView::~AudioTXView() {
transmitter_model.disable(); transmitter_model.disable();
baseband::shutdown();
} }
} }

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -19,16 +20,15 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __UI_AUDIOTX_H__
#define __UI_AUDIOTX_H__
#include "ui.hpp" #include "ui.hpp"
#include "hal.h"
#include "ui_widget.hpp" #include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "ui_menu.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
#include "ui_font_fixed_8x16.hpp" #include "ui_font_fixed_8x16.hpp"
#include "clock_manager.hpp"
#include "message.hpp" #include "message.hpp"
#include "rf_path.hpp"
#include "max2837.hpp"
#include "volume.hpp" #include "volume.hpp"
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "transmitter_model.hpp" #include "transmitter_model.hpp"
@ -40,29 +40,58 @@ public:
AudioTXView(NavigationView& nav); AudioTXView(NavigationView& nav);
~AudioTXView(); ~AudioTXView();
AudioTXView(const AudioTXView&) = delete;
AudioTXView(AudioTXView&&) = delete;
AudioTXView& operator=(const AudioTXView&) = delete;
AudioTXView& operator=(AudioTXView&&) = delete;
void focus() override; void focus() override;
void paint(Painter& painter) override;
std::string title() const override { return "Microphone TX"; };
private: private:
void draw_vumeter();
void on_tuning_frequency_changed(rf::Frequency f); void on_tuning_frequency_changed(rf::Frequency f);
FrequencyField field_frequency { uint32_t audio_level { 0 };
{ 5 * 8, 3 * 16 }, Painter * _painter { };
Text text_power {
{ 6 * 8, 28 * 8, 16 * 8, 16 },
"-"
}; };
Text text_title { FrequencyField field_frequency {
{ 76, 64, 88, 16 }, { 6 * 8, 30 * 8 },
"Audio TX"
}; };
Button button_transmit { Button button_transmit {
{ 72, 130, 96, 32 }, { 1 * 8, 33 * 8, 12 * 8, 32 },
"Transmit" "Transmit"
}; };
Button button_exit { Button button_exit {
{ 72, 270, 96, 32 }, { 16 * 8, 33 * 8, 12 * 8, 32 },
"Exit" "Exit"
}; };
MessageHandlerRegistration message_handler_lcd_sync {
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->draw_vumeter();
}
};
MessageHandlerRegistration message_handler_audio_level {
Message::ID::AudioLevel,
[this](const Message* const p) {
const auto message = static_cast<const AudioLevelMessage*>(p);
this->audio_level = message->value;
}
};
}; };
} /* namespace ui */ } /* namespace ui */
#endif/*__UI_AUDIOTX_H__*/

View File

@ -31,7 +31,7 @@
using namespace portapack; using namespace portapack;
namespace ui { namespace ui {
void HandWriteView::paint(Painter& painter) { void HandWriteView::paint(Painter& painter) {
_painter = &painter; _painter = &painter;
} }

View File

@ -33,6 +33,7 @@
#include "ui_about.hpp" #include "ui_about.hpp"
#include "ui_adsbtx.hpp" #include "ui_adsbtx.hpp"
#include "ui_audiotx.hpp"
#include "ui_bht_tx.hpp" #include "ui_bht_tx.hpp"
#include "ui_closecall.hpp" #include "ui_closecall.hpp"
#include "ui_cw.hpp" #include "ui_cw.hpp"
@ -321,9 +322,9 @@ TransmitterCodedMenuView::TransmitterCodedMenuView(NavigationView& nav) {
TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) { TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) {
add_items<4>({ { add_items<4>({ {
{ "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } }, { "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } },
{ "Numbers station", ui::Color::green(), &bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } }, { "Numbers station", ui::Color::orange(),&bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } },
{ "Microphone", ui::Color::grey(), &bitmap_icon_microphone, [&nav](){ nav.push<NotImplementedView>(); } }, { "Microphone", ui::Color::orange(),&bitmap_icon_microphone, [&nav](){ nav.push<AudioTXView>(); } },
{ "Whistle", ui::Color::yellow(),&bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } }, { "Whistle", ui::Color::yellow(),&bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } },
} }); } });
on_left = [&nav](){ nav.pop(); }; on_left = [&nav](){ nav.pop(); };
} }

View File

@ -172,7 +172,7 @@ public:
private: private:
Text text_info { Text text_info {
{ 5 * 8, 284, 20 * 8, 16 }, { 5 * 8, 284, 20 * 8, 16 },
"shrbrnd-sig-ftk 2016" "shrbrnd-sig-ftk 2017"
}; };
Button button_done { Button button_done {

View File

@ -181,8 +181,7 @@ void SoundBoardView::change_page(Button& button, const KeyEvent key) {
page--; page--;
refresh_buttons(button.id); refresh_buttons(button.id);
} }
} } else if (button.screen_pos().x() > 120) {
if (button.screen_pos().x() > 120) {
if ((key == KeyEvent::Right) && (page < max_page - 1)) { if ((key == KeyEvent::Right) && (page < max_page - 1)) {
page++; page++;
refresh_buttons(button.id); refresh_buttons(button.id);
@ -194,9 +193,7 @@ SoundBoardView::SoundBoardView(
NavigationView& nav NavigationView& nav
) : nav_ (nav) ) : nav_ (nav)
{ {
using name_t = std::string; using option_t = std::pair<std::string, int32_t>;
using value_t = int32_t;
using option_t = std::pair<name_t, value_t>;
using options_t = std::vector<option_t>; using options_t = std::vector<option_t>;
options_t ctcss_options; options_t ctcss_options;
std::vector<std::filesystem::path> file_list; std::vector<std::filesystem::path> file_list;
@ -278,6 +275,7 @@ SoundBoardView::SoundBoardView(
return false; return false;
}; };
// Generate buttons
size_t n = 0; size_t n = 0;
for(auto& button : buttons) { for(auto& button : buttons) {
add_child(&button); add_child(&button);
@ -294,7 +292,7 @@ SoundBoardView::SoundBoardView(
refresh_buttons(0); refresh_buttons(0);
check_loop.set_value(false); check_loop.set_value(false);
number_bw.set_value(15); number_bw.set_value(12);
field_frequency.set_value(transmitter_model.tuning_frequency()); field_frequency.set_value(transmitter_model.tuning_frequency());
field_frequency.set_step(10000); field_frequency.set_step(10000);

View File

@ -129,6 +129,7 @@ set(CPPSRC
rssi_thread.cpp rssi_thread.cpp
audio_compressor.cpp audio_compressor.cpp
audio_output.cpp audio_output.cpp
audio_input.cpp
audio_dma.cpp audio_dma.cpp
audio_stats_collector.cpp audio_stats_collector.cpp
${COMMON}/utility.cpp ${COMMON}/utility.cpp
@ -365,6 +366,13 @@ set(MODE_CPPSRC
) )
DeclareTargets(PATX audio_tx) DeclareTargets(PATX audio_tx)
### Microphone transmit
set(MODE_CPPSRC
proc_mictx.cpp
)
DeclareTargets(PMTX mic_tx)
### AFSK ### AFSK
set(MODE_CPPSRC set(MODE_CPPSRC