mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-27 09:57:49 +00:00
Testing Messagepack for saving/loading stuff from SD card
This commit is contained in:
@@ -138,6 +138,7 @@ CPPSRC = main.cpp \
|
||||
radio.cpp \
|
||||
baseband_cpld.cpp \
|
||||
tuning.cpp \
|
||||
msgpack.cpp \
|
||||
rf_path.cpp \
|
||||
rffc507x.cpp \
|
||||
rffc507x_spi.cpp \
|
||||
|
@@ -21,8 +21,8 @@
|
||||
|
||||
//BUG: No audio in about when shown second time
|
||||
//BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
|
||||
//BUG: Module load and return to systemview
|
||||
//TODO: EPAR transmit
|
||||
//TODO: SD card wiper
|
||||
//TODO: Draw on touchscreen and transmit as spectrum paint
|
||||
//TODO: Use progressbars
|
||||
//TODO: Setting: Prefered input method
|
||||
//TODO: LCR emergency clear all
|
||||
|
@@ -103,10 +103,6 @@ uint32_t TransmitterModel::baseband_oversampling() const {
|
||||
return baseband_configuration.decimation_factor;
|
||||
}
|
||||
|
||||
int32_t TransmitterModel::tuning_offset() {
|
||||
return -(sampling_rate() / 4);
|
||||
}
|
||||
|
||||
void TransmitterModel::update_tuning_frequency() {
|
||||
radio::set_tuning_frequency(tuning_frequency());
|
||||
}
|
||||
|
@@ -70,7 +70,6 @@ private:
|
||||
.sampling_rate = 3072000,
|
||||
.decimation_factor = 1,
|
||||
};
|
||||
int32_t tuning_offset();
|
||||
|
||||
void update_tuning_frequency();
|
||||
void update_rf_amp();
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "ui_closecall.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "msgpack.hpp"
|
||||
|
||||
#include "ch.h"
|
||||
#include "time.hpp"
|
||||
@@ -59,8 +60,6 @@ void CloseCallView::do_detection() {
|
||||
rf::Frequency resolved_frequency;
|
||||
size_t i;
|
||||
|
||||
portapack::display.fill_rectangle({last_pos, 92, 1, 9}, Color::black());
|
||||
|
||||
mean /= (CC_BIN_NB * (slices_max + 1));
|
||||
|
||||
for (i = 0; i < (slices_max + 1); i++) {
|
||||
@@ -87,7 +86,7 @@ void CloseCallView::do_detection() {
|
||||
|
||||
// Lock / release
|
||||
if ((imax >= last_channel - 2) && (imax <= last_channel + 2) && imax) {
|
||||
if (detect_counter == 8) {
|
||||
if (detect_counter >= (5 / (slices_max + 1))) {
|
||||
if (imax != locked_frequency) {
|
||||
//char finalstr[24] = {0};
|
||||
|
||||
@@ -100,6 +99,7 @@ void CloseCallView::do_detection() {
|
||||
//strcat(finalstr, fstr.c_str());
|
||||
text_infos.set("Locked ! ");
|
||||
big_display.set(resolved_frequency);
|
||||
big_display.set_style(&style_locked);
|
||||
|
||||
locked = true;
|
||||
locked_frequency = imax;
|
||||
@@ -114,7 +114,7 @@ void CloseCallView::do_detection() {
|
||||
if (release_counter == 8) {
|
||||
locked = false;
|
||||
text_infos.set("Lost ");
|
||||
//big_display.set(0);
|
||||
big_display.set_style(&style_grey);
|
||||
} else {
|
||||
release_counter++;
|
||||
}
|
||||
@@ -124,8 +124,9 @@ void CloseCallView::do_detection() {
|
||||
last_channel = imax;
|
||||
scan_counter++;
|
||||
|
||||
last_pos = (ui::Coord)(imax + 2);
|
||||
portapack::display.fill_rectangle({last_pos, 92, 1, 9}, Color::red());
|
||||
portapack::display.fill_rectangle({last_pos, 90, 1, 13}, Color::black());
|
||||
last_pos = (ui::Coord)(imax % 240);
|
||||
portapack::display.fill_rectangle({last_pos, 90, 1, 13}, Color::red());
|
||||
}
|
||||
|
||||
void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||
@@ -148,7 +149,7 @@ void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||
}
|
||||
|
||||
display.draw_pixels(
|
||||
{ { 0, 96 + slices_counter * 4 }, { pixel_row.size(), 1 } },
|
||||
{ { 0, 96 + slices_counter * 6 }, { pixel_row.size(), 1 } },
|
||||
pixel_row
|
||||
);
|
||||
|
||||
@@ -247,8 +248,18 @@ void CloseCallView::on_range_changed() {
|
||||
// ex: 100~115 (15): 102.5(97.5~107.5) -> 112.5(107.5~117.5) = 2.5 lost left and right
|
||||
slices_max = (scan_span + CC_SLICE_WIDTH - 1) / CC_SLICE_WIDTH;
|
||||
slices_span = slices_max * CC_SLICE_WIDTH;
|
||||
offset = (slices_span - scan_span) / 2;
|
||||
offset = ((scan_span - slices_span) / 2) + (CC_SLICE_WIDTH / 2);
|
||||
slice_start = std::min(f_min, f_max) + offset;
|
||||
slice_trim = 0;
|
||||
|
||||
/*
|
||||
* ----||||---- 4M -> 2*3M = 6
|
||||
* AAABBB 4-6 = -2 -> -2/2 = -1 -> -1+1.5 = +0.5
|
||||
*
|
||||
* ----1111222233334444----
|
||||
* AAAAaaaaAAAAbbbbBBBBbbbb
|
||||
*
|
||||
*/
|
||||
|
||||
slices_max--; // For slices_counter
|
||||
slicing = true;
|
||||
@@ -267,12 +278,14 @@ void CloseCallView::on_range_changed() {
|
||||
portapack::display.fill_rectangle({0, 97, slice_trim, 4}, Color::orange());
|
||||
portapack::display.fill_rectangle({240 - slice_trim, 97, slice_trim, 4}, Color::orange());
|
||||
|
||||
set_dirty();
|
||||
|
||||
slices_max = 0;
|
||||
slices_counter = 0;
|
||||
slicing = false;
|
||||
}
|
||||
|
||||
text_debug.set(to_string_dec_uint(slice_start));
|
||||
//text_debug.set(to_string_dec_uint(slice_start));
|
||||
|
||||
text_slices.set(to_string_dec_int(slices_max + 1));
|
||||
slices_counter = 0;
|
||||
@@ -312,12 +325,22 @@ CloseCallView::CloseCallView(
|
||||
&button_exit
|
||||
} });
|
||||
|
||||
static constexpr Style style_grey {
|
||||
.font = font::fixed_8x16,
|
||||
.background = Color::black(),
|
||||
.foreground = Color::grey(),
|
||||
};
|
||||
|
||||
uint8_t testbuffer[] = { 0xDE, 0x00, 0x02,
|
||||
0xCD, 0x00, 0x00, // Key 0000 = False
|
||||
0xC2,
|
||||
0xCD, 0x00, 0x01, // Key 0001 = True
|
||||
0xC3
|
||||
};
|
||||
|
||||
// DEBUG
|
||||
bool debug_v;
|
||||
MsgPack msgpack;
|
||||
msgpack.msgpack_get(&testbuffer, sizeof(testbuffer), MsgPack::TestList, &debug_v); // MsgPack::FrequencyList
|
||||
if (debug_v)
|
||||
text_debug.set("OK!");
|
||||
else
|
||||
text_debug.set("NOK");
|
||||
|
||||
text_labels_a.set_style(&style_grey);
|
||||
text_labels_b.set_style(&style_grey);
|
||||
text_labels_c.set_style(&style_grey);
|
||||
|
@@ -20,17 +20,6 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*#include "ui.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_painter.hpp"
|
||||
#include "ui_menu.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "clock_manager.hpp"
|
||||
#include "message.hpp"
|
||||
#include "rf_path.hpp"
|
||||
#include "volume.hpp"
|
||||
#include "receiver_model.hpp"*/
|
||||
|
||||
#include "receiver_model.hpp"
|
||||
|
||||
#include "spectrum_color_lut.hpp"
|
||||
@@ -58,6 +47,17 @@ public:
|
||||
std::string title() const override { return "Close Call"; };
|
||||
|
||||
private:
|
||||
const Style style_grey { // For labels and lost signal
|
||||
.font = font::fixed_8x16,
|
||||
.background = Color::black(),
|
||||
.foreground = Color::grey(),
|
||||
};
|
||||
|
||||
const Style style_locked {
|
||||
.font = font::fixed_8x16,
|
||||
.background = Color::black(),
|
||||
.foreground = Color::green(),
|
||||
};
|
||||
Coord last_pos = 0;
|
||||
ChannelSpectrumFIFO* fifo { nullptr };
|
||||
uint8_t detect_counter = 0, release_counter = 0;
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
* | Min: Max: LNA VGA |
|
||||
* | 0000.0000 0000.0000 00 00 |
|
||||
* | Threshold: 000 |
|
||||
* | Slices: 00 Rate: 000Hz |
|
||||
* | Slices: 00 Rate: 00Hz |
|
||||
* |
|
||||
* */
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
};
|
||||
Text text_labels_c {
|
||||
{ 1 * 8, 3 * 16, 28 * 8, 16 },
|
||||
"Slices: Rate: Hz"
|
||||
"Slices: Rate: Hz"
|
||||
};
|
||||
|
||||
NumberField field_threshold {
|
||||
@@ -133,8 +133,8 @@ private:
|
||||
"--"
|
||||
};
|
||||
Text text_rate {
|
||||
{ 24 * 8, 3 * 16, 3 * 8, 16 },
|
||||
"---"
|
||||
{ 24 * 8, 3 * 16, 2 * 8, 16 },
|
||||
"--2"
|
||||
};
|
||||
|
||||
Text text_infos {
|
||||
|
@@ -96,6 +96,10 @@ void EPARView::journuit() {
|
||||
transmitter_model.enable();
|
||||
}
|
||||
|
||||
void EPARView::on_tuning_frequency_changed(rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
}
|
||||
|
||||
EPARView::EPARView(
|
||||
NavigationView& nav
|
||||
)
|
||||
@@ -125,8 +129,10 @@ EPARView::EPARView(
|
||||
&options_group,
|
||||
&checkbox_ra,
|
||||
&checkbox_rb,
|
||||
&excur,
|
||||
&text_freq,
|
||||
&options_freq,
|
||||
//&options_freq,
|
||||
&field_frequency,
|
||||
&progressbar,
|
||||
&text_debug,
|
||||
&button_transmit,
|
||||
@@ -136,10 +142,31 @@ EPARView::EPARView(
|
||||
|
||||
city_code.set_value(220);
|
||||
options_group.set_selected_index(3); // TP
|
||||
options_freq.set_selected_index(6); // 5 ! DEBUG
|
||||
//options_freq.set_selected_index(6); // 5 ! DEBUG
|
||||
|
||||
checkbox_ra.set_value(true);
|
||||
checkbox_rb.set_value(true);
|
||||
|
||||
excur.set_value(500);
|
||||
shared_memory.excursion = 500;
|
||||
excur.on_change = [this](int32_t v) {
|
||||
(void)v;
|
||||
shared_memory.excursion = excur.value();
|
||||
};
|
||||
|
||||
field_frequency.set_value(31387500); // 31.3805 receiver_model.tuning_frequency()
|
||||
field_frequency.set_step(500);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
this->on_tuning_frequency_changed(f);
|
||||
};
|
||||
field_frequency.on_edit = [this, &nav]() {
|
||||
// TODO: Provide separate modal method/scheme?
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
this->on_tuning_frequency_changed(f);
|
||||
this->field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
city_code.on_change = [this](int32_t v) {
|
||||
(void)v;
|
||||
@@ -189,7 +216,8 @@ EPARView::EPARView(
|
||||
shared_memory.transmit_done = false;
|
||||
memcpy(shared_memory.epardata, epar_bits, 13);
|
||||
|
||||
transmitter_model.set_tuning_frequency(epar_freqs[options_freq.selected_index()]);
|
||||
transmitter_model.set_tuning_frequency(field_frequency.value());
|
||||
//transmitter_model.set_tuning_frequency(epar_freqs[options_freq.selected_index()]);
|
||||
|
||||
txing = true;
|
||||
button_transmit.set_style(&style_cancel);
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "ui_menu.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "clock_manager.hpp"
|
||||
#include "message.hpp"
|
||||
#include "rf_path.hpp"
|
||||
@@ -51,6 +52,7 @@ private:
|
||||
bool txing = false;
|
||||
const rf::Frequency epar_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 };
|
||||
char epar_bits[13];
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
|
||||
/* |012345678901234567890123456789|
|
||||
* | Code ville: 000 |
|
||||
@@ -88,7 +90,10 @@ private:
|
||||
{ 5 * 8, 4 * 16, 10 * 8, 16 },
|
||||
"Frequence:"
|
||||
};
|
||||
OptionsField options_freq {
|
||||
FrequencyField field_frequency {
|
||||
{ 16 * 8, 4 * 16 },
|
||||
};
|
||||
/*OptionsField options_freq {
|
||||
{ 16 * 8, 4 * 16},
|
||||
7,
|
||||
{
|
||||
@@ -100,7 +105,7 @@ private:
|
||||
{ "31.9750", 5 },
|
||||
{ "TEST 88", 6 }
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
||||
Checkbox checkbox_ra {
|
||||
{ 7 * 8, 6 * 16 },
|
||||
@@ -113,6 +118,14 @@ private:
|
||||
"Relais 2"
|
||||
};
|
||||
|
||||
NumberField excur {
|
||||
{ 12 * 8, 10 * 16 },
|
||||
4,
|
||||
{ 0, 5000 },
|
||||
20,
|
||||
' '
|
||||
};
|
||||
|
||||
ProgressBar progressbar {
|
||||
{ 2 * 8, 12 * 16, 26 * 8, 20 },
|
||||
};
|
||||
|
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "ui_handwrite.hpp" // DEBUG
|
||||
#include "ui_soundboard.hpp" // DEBUG
|
||||
#include "ui_closecall.hpp" // DEBUG
|
||||
|
||||
#include "analog_audio_app.hpp"
|
||||
#include "ais_app.hpp"
|
||||
@@ -263,6 +264,7 @@ SystemView::SystemView(
|
||||
navigation_view.push<BMPView>();
|
||||
else
|
||||
//navigation_view.push<SoundBoardView>();
|
||||
//navigation_view.push<CloseCallView>();
|
||||
//navigation_view.push<HandWriteView>(debugtxt, 20);
|
||||
navigation_view.push<SystemMenuView>();
|
||||
}
|
||||
|
Reference in New Issue
Block a user