mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-02-28 19:27:44 +00:00
Added microphone TX (very basic for now)
This commit is contained in:
parent
6ac911feb7
commit
44b2fc469c
@ -155,6 +155,7 @@ set(CPPSRC
|
||||
ui_afsksetup.cpp
|
||||
ui_alphanum.cpp
|
||||
ui_audio.cpp
|
||||
ui_audiotx.cpp
|
||||
ui_baseband_stats_view.cpp
|
||||
ui_bht_tx.cpp
|
||||
ui_channel.cpp
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@ -41,7 +42,7 @@ constexpr i2s::ConfigTX i2s0_config_tx {
|
||||
.mono = 0,
|
||||
.stop = 1,
|
||||
.reset = 0,
|
||||
.ws_sel = 0,
|
||||
.ws_sel = 0, // Master
|
||||
.ws_halfperiod = 0x0f,
|
||||
.mute = 1,
|
||||
},
|
||||
@ -65,7 +66,7 @@ constexpr i2s::ConfigRX i2s0_config_rx {
|
||||
.mono = 0,
|
||||
.stop = 1,
|
||||
.reset = 0,
|
||||
.ws_sel = 1,
|
||||
.ws_sel = 0, // Master
|
||||
.ws_halfperiod = 0x0f,
|
||||
},
|
||||
.rxrate = i2s::MCLKRate {
|
||||
@ -103,6 +104,18 @@ WM8731 audio_codec { i2c0, wm8731_i2c_address };
|
||||
|
||||
} /* namespace */
|
||||
|
||||
namespace input {
|
||||
|
||||
void start() {
|
||||
i2s::i2s0::rx_start();
|
||||
}
|
||||
|
||||
void stop() {
|
||||
i2s::i2s0::rx_stop();
|
||||
}
|
||||
|
||||
} /* namespace input */
|
||||
|
||||
namespace output {
|
||||
|
||||
void start() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@ -38,6 +39,13 @@ void unmute();
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
namespace input {
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
} /* namespace input */
|
||||
|
||||
namespace headphone {
|
||||
|
||||
volume_range_t volume_range();
|
||||
|
@ -25,7 +25,7 @@
|
||||
const ctcss_tone ctcss_tones[CTCSS_TONES_NB] = {
|
||||
{ "XZ", 0, 67.000 },
|
||||
{ "WZ", 1, 69.400 },
|
||||
{ "XA", 39, 71.900 },
|
||||
{ "XA", 2, 71.900 },
|
||||
{ "WA", 3, 74.400 },
|
||||
{ "XB", 4, 77.000 },
|
||||
{ "WB", 5, 79.700 },
|
||||
|
@ -21,15 +21,12 @@
|
||||
|
||||
#include "ui_audiotx.hpp"
|
||||
|
||||
#include "ch.h"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
#include "ui_alphanum.hpp"
|
||||
#include "ff.h"
|
||||
#include "hackrf_gpio.hpp"
|
||||
#include "audio.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "radio.hpp"
|
||||
|
||||
#include "hackrf_hal.hpp"
|
||||
#include "pins.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include <cstring>
|
||||
@ -42,6 +39,38 @@ void AudioTXView::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) {
|
||||
transmitter_model.set_tuning_frequency(f);
|
||||
}
|
||||
@ -50,10 +79,14 @@ AudioTXView::AudioTXView(
|
||||
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);
|
||||
|
||||
add_children({
|
||||
&text_title,
|
||||
&text_power,
|
||||
&field_frequency,
|
||||
&button_transmit,
|
||||
&button_exit
|
||||
@ -74,22 +107,32 @@ AudioTXView::AudioTXView(
|
||||
};
|
||||
|
||||
button_transmit.on_select = [](Button&){
|
||||
transmitter_model.set_baseband_configuration({
|
||||
.mode = 1,
|
||||
.sampling_rate = 1536000,
|
||||
.decimation_factor = 1,
|
||||
});
|
||||
transmitter_model.set_sampling_rate(1536000U);
|
||||
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();
|
||||
|
||||
baseband::set_audiotx_data(
|
||||
76800, // 20Hz level update
|
||||
10000, // 10kHz bw
|
||||
false,
|
||||
0
|
||||
);
|
||||
};
|
||||
|
||||
button_exit.on_select = [&nav](Button&){
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::input::start();
|
||||
}
|
||||
|
||||
AudioTXView::~AudioTXView() {
|
||||
transmitter_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@ -19,16 +20,15 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UI_AUDIOTX_H__
|
||||
#define __UI_AUDIOTX_H__
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "hal.h"
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_painter.hpp"
|
||||
#include "ui_menu.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
#include "clock_manager.hpp"
|
||||
#include "message.hpp"
|
||||
#include "rf_path.hpp"
|
||||
#include "max2837.hpp"
|
||||
#include "volume.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "transmitter_model.hpp"
|
||||
@ -40,29 +40,58 @@ public:
|
||||
AudioTXView(NavigationView& nav);
|
||||
~AudioTXView();
|
||||
|
||||
AudioTXView(const AudioTXView&) = delete;
|
||||
AudioTXView(AudioTXView&&) = delete;
|
||||
AudioTXView& operator=(const AudioTXView&) = delete;
|
||||
AudioTXView& operator=(AudioTXView&&) = delete;
|
||||
|
||||
void focus() override;
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
std::string title() const override { return "Microphone TX"; };
|
||||
|
||||
private:
|
||||
void draw_vumeter();
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 5 * 8, 3 * 16 },
|
||||
uint32_t audio_level { 0 };
|
||||
Painter * _painter { };
|
||||
|
||||
Text text_power {
|
||||
{ 6 * 8, 28 * 8, 16 * 8, 16 },
|
||||
"-"
|
||||
};
|
||||
|
||||
Text text_title {
|
||||
{ 76, 64, 88, 16 },
|
||||
"Audio TX"
|
||||
FrequencyField field_frequency {
|
||||
{ 6 * 8, 30 * 8 },
|
||||
};
|
||||
|
||||
Button button_transmit {
|
||||
{ 72, 130, 96, 32 },
|
||||
{ 1 * 8, 33 * 8, 12 * 8, 32 },
|
||||
"Transmit"
|
||||
};
|
||||
|
||||
Button button_exit {
|
||||
{ 72, 270, 96, 32 },
|
||||
{ 16 * 8, 33 * 8, 12 * 8, 32 },
|
||||
"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 */
|
||||
|
||||
#endif/*__UI_AUDIOTX_H__*/
|
||||
|
@ -31,7 +31,7 @@
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
|
||||
void HandWriteView::paint(Painter& painter) {
|
||||
_painter = &painter;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "ui_about.hpp"
|
||||
#include "ui_adsbtx.hpp"
|
||||
#include "ui_audiotx.hpp"
|
||||
#include "ui_bht_tx.hpp"
|
||||
#include "ui_closecall.hpp"
|
||||
#include "ui_cw.hpp"
|
||||
@ -321,9 +322,9 @@ TransmitterCodedMenuView::TransmitterCodedMenuView(NavigationView& nav) {
|
||||
TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) {
|
||||
add_items<4>({ {
|
||||
{ "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } },
|
||||
{ "Numbers station", ui::Color::green(), &bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } },
|
||||
{ "Microphone", ui::Color::grey(), &bitmap_icon_microphone, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "Whistle", ui::Color::yellow(),&bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } },
|
||||
{ "Numbers station", ui::Color::orange(),&bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } },
|
||||
{ "Microphone", ui::Color::orange(),&bitmap_icon_microphone, [&nav](){ nav.push<AudioTXView>(); } },
|
||||
{ "Whistle", ui::Color::yellow(),&bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } },
|
||||
} });
|
||||
on_left = [&nav](){ nav.pop(); };
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public:
|
||||
private:
|
||||
Text text_info {
|
||||
{ 5 * 8, 284, 20 * 8, 16 },
|
||||
"shrbrnd-sig-ftk 2016"
|
||||
"shrbrnd-sig-ftk 2017"
|
||||
};
|
||||
|
||||
Button button_done {
|
||||
|
@ -181,8 +181,7 @@ void SoundBoardView::change_page(Button& button, const KeyEvent key) {
|
||||
page--;
|
||||
refresh_buttons(button.id);
|
||||
}
|
||||
}
|
||||
if (button.screen_pos().x() > 120) {
|
||||
} else if (button.screen_pos().x() > 120) {
|
||||
if ((key == KeyEvent::Right) && (page < max_page - 1)) {
|
||||
page++;
|
||||
refresh_buttons(button.id);
|
||||
@ -194,9 +193,7 @@ SoundBoardView::SoundBoardView(
|
||||
NavigationView& nav
|
||||
) : nav_ (nav)
|
||||
{
|
||||
using name_t = std::string;
|
||||
using value_t = int32_t;
|
||||
using option_t = std::pair<name_t, value_t>;
|
||||
using option_t = std::pair<std::string, int32_t>;
|
||||
using options_t = std::vector<option_t>;
|
||||
options_t ctcss_options;
|
||||
std::vector<std::filesystem::path> file_list;
|
||||
@ -278,6 +275,7 @@ SoundBoardView::SoundBoardView(
|
||||
return false;
|
||||
};
|
||||
|
||||
// Generate buttons
|
||||
size_t n = 0;
|
||||
for(auto& button : buttons) {
|
||||
add_child(&button);
|
||||
@ -294,7 +292,7 @@ SoundBoardView::SoundBoardView(
|
||||
refresh_buttons(0);
|
||||
|
||||
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_step(10000);
|
||||
|
@ -129,6 +129,7 @@ set(CPPSRC
|
||||
rssi_thread.cpp
|
||||
audio_compressor.cpp
|
||||
audio_output.cpp
|
||||
audio_input.cpp
|
||||
audio_dma.cpp
|
||||
audio_stats_collector.cpp
|
||||
${COMMON}/utility.cpp
|
||||
@ -365,6 +366,13 @@ set(MODE_CPPSRC
|
||||
)
|
||||
DeclareTargets(PATX audio_tx)
|
||||
|
||||
### Microphone transmit
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_mictx.cpp
|
||||
)
|
||||
DeclareTargets(PMTX mic_tx)
|
||||
|
||||
### AFSK
|
||||
|
||||
set(MODE_CPPSRC
|
||||
|
Loading…
x
Reference in New Issue
Block a user