mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-11 00:59:28 +00:00
Fixed mic tx not working the first time it was entered
Fixed SD card FAT wipe (buffer size too big) Cleared some warnings from ADSB rx Updated binary
This commit is contained in:
@@ -23,20 +23,16 @@
|
||||
#include "ui_mictx.hpp"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
#include "hackrf_gpio.hpp"
|
||||
#include "audio.hpp"
|
||||
#include "tonesets.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "pins.hpp"
|
||||
#include "portapack_hal.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "irq_controls.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace tonekey;
|
||||
using namespace portapack;
|
||||
using namespace hackrf::one;
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -58,7 +54,7 @@ void MicTXView::configure_baseband() {
|
||||
baseband::set_audiotx_data(
|
||||
sampling_rate / 20, // Update vu-meter at 20Hz
|
||||
transmitting ? transmitter_model.channel_bandwidth() : 0,
|
||||
mic_gain_x10,
|
||||
mic_gain,
|
||||
TONES_F2D(tone_key_frequency(tone_key_index)),
|
||||
0.2 // 20% mix
|
||||
);
|
||||
@@ -68,8 +64,11 @@ void MicTXView::set_tx(bool enable) {
|
||||
if (enable) {
|
||||
transmitting = true;
|
||||
configure_baseband();
|
||||
gpio_tx.write(1);
|
||||
led_tx.on();
|
||||
transmitter_model.set_rf_amp(true);
|
||||
transmitter_model.enable();
|
||||
portapack::pin_i2s0_rx_sda.mode(3); // This is already done in audio::init but gets changed by the CPLD overlay reprogramming
|
||||
//gpio_tx.write(1);
|
||||
//led_tx.on();
|
||||
} else {
|
||||
if (transmitting && rogerbeep_enabled) {
|
||||
baseband::request_beep();
|
||||
@@ -77,8 +76,10 @@ void MicTXView::set_tx(bool enable) {
|
||||
} else {
|
||||
transmitting = false;
|
||||
configure_baseband();
|
||||
gpio_tx.write(0);
|
||||
led_tx.off();
|
||||
transmitter_model.set_rf_amp(false);
|
||||
transmitter_model.disable();
|
||||
//gpio_tx.write(0);
|
||||
//led_tx.off();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,8 +129,8 @@ MicTXView::MicTXView(
|
||||
NavigationView& nav
|
||||
)
|
||||
{
|
||||
pins[P6_2].mode(3); // Set P6_2 pin function to I2S0_RX_SDA
|
||||
|
||||
portapack::pin_i2s0_rx_sda.mode(3); // This is already done in audio::init but gets changed by the CPLD overlay reprogramming
|
||||
|
||||
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
|
||||
|
||||
add_children({
|
||||
@@ -154,7 +155,7 @@ MicTXView::MicTXView(
|
||||
options_tone_key.set_selected_index(0);
|
||||
|
||||
options_gain.on_change = [this](size_t, int32_t v) {
|
||||
mic_gain_x10 = v;
|
||||
mic_gain = v / 10.0;
|
||||
configure_baseband();
|
||||
};
|
||||
options_gain.set_selected_index(1); // x1.0
|
||||
@@ -206,11 +207,9 @@ MicTXView::MicTXView(
|
||||
};
|
||||
field_va_decay.set_value(1000);
|
||||
|
||||
// Run baseband as soon as the app starts to get audio levels without transmitting (rf amp off)
|
||||
transmitter_model.set_sampling_rate(sampling_rate);
|
||||
transmitter_model.set_rf_amp(true);
|
||||
transmitter_model.set_rf_amp(false);
|
||||
transmitter_model.set_baseband_bandwidth(1750000);
|
||||
transmitter_model.enable();
|
||||
|
||||
set_tx(false);
|
||||
|
||||
@@ -219,6 +218,7 @@ MicTXView::MicTXView(
|
||||
}
|
||||
|
||||
MicTXView::~MicTXView() {
|
||||
audio::input::stop();
|
||||
transmitter_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@
|
||||
#define __UI_MICTX_H__
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "hal.h"
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "transmitter_model.hpp"
|
||||
#include "tone_key.hpp"
|
||||
@@ -73,7 +71,7 @@ private:
|
||||
bool va_enabled { };
|
||||
bool rogerbeep_enabled { };
|
||||
uint32_t tone_key_index { };
|
||||
uint32_t mic_gain_x10 { 10 };
|
||||
float mic_gain { 1.0 };
|
||||
uint32_t audio_level { 0 };
|
||||
uint32_t va_level { };
|
||||
uint32_t attack_ms { };
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
Thread* WipeSDView::thread { nullptr };
|
||||
|
||||
WipeSDView::WipeSDView(NavigationView& nav) : nav_ (nav) {
|
||||
add_children({
|
||||
&text_info,
|
||||
@@ -33,28 +35,24 @@ WipeSDView::WipeSDView(NavigationView& nav) : nav_ (nav) {
|
||||
}
|
||||
|
||||
WipeSDView::~WipeSDView() {
|
||||
if (thread) chThdTerminate(thread);
|
||||
if (thread)
|
||||
chThdTerminate(thread);
|
||||
}
|
||||
|
||||
Thread* WipeSDView::thread { nullptr };
|
||||
|
||||
void WipeSDView::focus() {
|
||||
BlockDeviceInfo block_device_info;
|
||||
|
||||
dummy.focus();
|
||||
|
||||
if (!confirmed) {
|
||||
nav_.push<ModalMessageView>("Warning !", "Wipe first 32MB of SD card\n(filesystem included) ?", YESCANCEL, [this](bool choice) {
|
||||
nav_.push<ModalMessageView>("Warning !", "Wipe FAT of SD card ?", YESCANCEL, [this](bool choice) {
|
||||
if (choice)
|
||||
confirmed = true;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if (sdcGetInfo(&SDCD1, &block_device_info) == CH_SUCCESS) {
|
||||
blocks = 32; // Only erase first 32MB (block_device_info.blk_size * uint64_t(block_device_info.blk_num)) / (1024 * 1024);
|
||||
progress.set_max(blocks);
|
||||
|
||||
thread = chThdCreateFromHeap(NULL, 2048, NORMALPRIO + 10, WipeSDView::static_fn, this);
|
||||
thread = chThdCreateFromHeap(NULL, 2048, NORMALPRIO, WipeSDView::static_fn, this);
|
||||
} else {
|
||||
nav_.pop(); // Just silently abort for now
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "ff.h"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -37,13 +38,12 @@ public:
|
||||
~WipeSDView();
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "SD card wipe"; };
|
||||
std::string title() const override { return "Wipe FAT"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
bool confirmed = false;
|
||||
uint32_t blocks { 0 };
|
||||
static Thread* thread;
|
||||
|
||||
static msg_t static_fn(void* arg) {
|
||||
@@ -53,21 +53,24 @@ private:
|
||||
}
|
||||
|
||||
void run() {
|
||||
uint32_t n, b;
|
||||
lfsr_word_t v = 1;
|
||||
const auto buffer = std::make_unique<std::array<uint8_t, 16384>>();
|
||||
//DIR d;
|
||||
const auto buffer = std::make_unique<std::array<uint8_t, 512>>();
|
||||
|
||||
for (b = 0; b < blocks; b++) {
|
||||
progress.set_value(b);
|
||||
//f_opendir(&d, (TCHAR*)u"");
|
||||
|
||||
uint32_t count = 512; //sd_card::fs.n_fats * sd_card::fs.fsize;
|
||||
progress.set_max(count);
|
||||
|
||||
for (uint32_t c = 0; c < count; c++) {
|
||||
progress.set_value(c);
|
||||
|
||||
lfsr_fill(v,
|
||||
reinterpret_cast<lfsr_word_t*>(buffer->data()),
|
||||
sizeof(*buffer.get()) / sizeof(lfsr_word_t));
|
||||
|
||||
// 1MB
|
||||
for (n = 0; n < 64; n++) {
|
||||
if (disk_write(sd_card::fs.drv, buffer->data(), n + (b * 64), 16384 / 512) != RES_OK) nav_.pop();
|
||||
}
|
||||
|
||||
if (disk_write(sd_card::fs.drv, buffer->data(), sd_card::fs.fatbase + c, 1) != RES_OK)
|
||||
break;
|
||||
}
|
||||
nav_.pop();
|
||||
}
|
||||
|
||||
@@ -220,6 +220,7 @@ void init(audio::Codec* const codec) {
|
||||
|
||||
void shutdown() {
|
||||
audio_codec->reset();
|
||||
input::stop();
|
||||
output::stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -152,12 +152,12 @@ void kill_afsk() {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
|
||||
void set_audiotx_data(const uint32_t divider, const float deviation_hz, const float audio_gain,
|
||||
const uint32_t tone_key_delta, const float tone_key_mix_weight) {
|
||||
const AudioTXConfigMessage message {
|
||||
divider,
|
||||
bw,
|
||||
gain_x10,
|
||||
deviation_hz,
|
||||
audio_gain,
|
||||
tone_key_delta,
|
||||
tone_key_mix_weight
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint1
|
||||
const bool dual_tone, const bool audio_out);
|
||||
void kill_tone();
|
||||
void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration);
|
||||
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
|
||||
void set_audiotx_data(const uint32_t divider, const float deviation_hz, const float audio_gain,
|
||||
const uint32_t tone_key_delta, const float tone_key_mix_weight);
|
||||
void set_fifo_data(const int8_t * data);
|
||||
void set_pitch_rssi(int32_t avg, bool enabled);
|
||||
|
||||
Reference in New Issue
Block a user