Added back scanning in BHT TX

Added file creation date display in File Manager
This commit is contained in:
furrtek 2018-01-09 21:12:19 +00:00
parent aebd1757da
commit 441a266dc4
17 changed files with 231 additions and 363 deletions

View File

@ -37,119 +37,111 @@ void BHTView::focus() {
void BHTView::start_tx() { void BHTView::start_tx() {
baseband::shutdown(); baseband::shutdown();
if (tx_type == XYLOS) { transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
if (target_system == XYLOS) {
baseband::run_image(portapack::spi_flash::image_tag_tones); baseband::run_image(portapack::spi_flash::image_tag_tones);
view_xylos.generate_message(); view_xylos.generate_message();
//if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE) //if (tx_mode == SINGLE) {
progressbar.set_max(20); progressbar.set_max(XY_TONE_COUNT);
//else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) /*} else if (tx_mode == SCAN) {
// progressbar.set_max(20 * XY_SEQ_COUNT); progressbar.set_max(XY_TONE_COUNT * view_xylos.get_scan_remaining());
}*/
transmitter_model.set_sampling_rate(TONES_SAMPLERATE); transmitter_model.set_sampling_rate(TONES_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();
// Setup tones // Setup tones
for (size_t c = 0; c < ccir_deltas.size(); c++) for (size_t c = 0; c < ccir_deltas.size(); c++)
baseband::set_tone(c, ccir_deltas[c], XY_TONE_LENGTH); baseband::set_tone(c, ccir_deltas[c], XY_TONE_DURATION);
baseband::set_tones_config(transmitter_model.channel_bandwidth(), XY_SILENCE, XY_TONE_COUNT, false, false); baseband::set_tones_config(transmitter_model.channel_bandwidth(), XY_SILENCE, XY_TONE_COUNT, false, false);
} else if (tx_type == EPAR) { } else if (target_system == EPAR) {
baseband::run_image(portapack::spi_flash::image_tag_ook); baseband::run_image(portapack::spi_flash::image_tag_ook);
size_t bitstream_length = view_EPAR.generate_message(); auto bitstream_length = view_EPAR.generate_message();
progressbar.set_max(2 * 26); //if (tx_mode == SINGLE) {
progressbar.set_max(2 * EPAR_REPEAT_COUNT);
/*} else if (tx_mode == SCAN) {
progressbar.set_max(2 * EPAR_REPEAT_COUNT * view_EPAR.get_scan_remaining());
}*/
transmitter_model.set_sampling_rate(OOK_SAMPLERATE); transmitter_model.set_sampling_rate(OOK_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();
baseband::set_ook_data( baseband::set_ook_data(
bitstream_length, bitstream_length,
OOK_SAMPLERATE / 580, EPAR_BIT_DURATION,
26, EPAR_REPEAT_COUNT,
encoder_defs[ENCODER_UM3750].pause_symbols encoder_defs[ENCODER_UM3750].pause_symbols
); );
} }
} }
void BHTView::stop_tx() {
transmitter_model.disable();
baseband::shutdown();
tx_mode = IDLE;
tx_view.set_transmitting(false);
progressbar.set_value(0);
}
void BHTView::on_tx_progress(const uint32_t progress, const bool done) { void BHTView::on_tx_progress(const uint32_t progress, const bool done) {
//if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE) { if (target_system == XYLOS) {
if (done) {
transmitter_model.disable();
view_xylos.tx_mode = XylosView::tx_modes::IDLE;
tx_view.set_transmitting(false);
}
if (tx_type == XYLOS) {
if (done) { if (done) {
if (!checkbox_cligno.value()) { if (tx_mode == SINGLE) {
view_xylos.tx_mode = XylosView::tx_modes::IDLE; if (checkbox_cligno.value()) {
tx_view.set_transmitting(false); // TODO: Thread !
progressbar.set_value(0); chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :(
} else { view_xylos.flip_relays();
chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :( start_tx();
} else
view_xylos.flip_relays(); stop_tx();
} else if (tx_mode == SCAN) {
start_tx(); if (view_xylos.increment_address())
start_tx();
else
stop_tx(); // Reached end of scan range
} }
} else } else
progressbar.set_value(progress); progressbar.set_value(progress);
} else if (tx_type == EPAR) { } else if (target_system == EPAR) {
if (done) { if (done) {
if (!view_EPAR.half) { if (!view_EPAR.half) {
view_EPAR.half = 1; view_EPAR.half = true;
start_tx(); // Start second half of transmission start_tx(); // Start second half of transmission
} else { } else {
view_EPAR.half = 0; view_EPAR.half = false;
progressbar.set_value(0); if (tx_mode == SINGLE) {
if (checkbox_cligno.value()) { if (checkbox_cligno.value()) {
chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :( // TODO: Thread !
chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :(
view_EPAR.flip_relays(); view_EPAR.flip_relays();
start_tx();
start_tx(); } else
stop_tx();
} else if (tx_mode == SCAN) {
if (view_EPAR.increment_address())
start_tx();
else
stop_tx(); // Reached end of scan range
} }
} }
} else } else
progressbar.set_value((26 * view_EPAR.half) + progress); progressbar.set_value(progress);
} }
/*} else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) {
if (done) {
transmitter_model.disable();
if (view_xylos.seq_index < (XY_SEQ_COUNT - 1)) {
for (c = 0; c < view_xylos.sequence_matin[view_xylos.seq_index].delay; c++)
chThdSleepMilliseconds(1000);
view_xylos.seq_index++;
start_tx();
} else {
progressbar.set_value(0);
view_xylos.tx_mode = XylosView::tx_modes::IDLE;
tx_view.set_transmitting(false);
}
} else {
progressbar.set_value((view_xylos.seq_index * 20) + progress);
}
}*/
} }
BHTView::~BHTView() { BHTView::~BHTView() {
transmitter_model.disable(); transmitter_model.disable();
baseband::shutdown();
} }
BHTView::BHTView(NavigationView& nav) { BHTView::BHTView(NavigationView& nav) {
@ -158,10 +150,10 @@ BHTView::BHTView(NavigationView& nav) {
&labels, &labels,
&view_xylos, &view_xylos,
&view_EPAR, &view_EPAR,
&checkbox_scan,
&checkbox_cligno, &checkbox_cligno,
&field_tempo, &field_tempo,
&progressbar, &progressbar,
&text_message,
&tx_view &tx_view
}); });
@ -174,31 +166,42 @@ BHTView::BHTView(NavigationView& nav) {
}; };
}; };
/*button_seq.on_select = [this, &nav](Button&) {
if (tx_mode == IDLE) {
seq_index = 0;
tx_mode = SEQUENCE;
tx_view.set_transmitting(true);
start_tx();
}
};*/
tx_view.on_start = [this]() { tx_view.on_start = [this]() {
if (view_xylos.tx_mode == XylosView::tx_modes::IDLE) { if (tx_mode == IDLE) {
view_xylos.tx_mode = XylosView::tx_modes::SINGLE; if (checkbox_scan.value()) {
tx_mode = SCAN;
} else {
tx_mode = SINGLE;
}
progressbar.set_value(0);
tx_view.set_transmitting(true); tx_view.set_transmitting(true);
tx_type = (tx_type_t)tab_view.selected(); target_system = (target_system_t)tab_view.selected();
view_EPAR.half = false;
start_tx(); start_tx();
} }
}; };
tx_view.on_stop = [this]() { tx_view.on_stop = [this]() {
transmitter_model.disable(); stop_tx();
tx_view.set_transmitting(false);
view_xylos.tx_mode = XylosView::tx_modes::IDLE;
}; };
} }
bool EPARView::increment_address() {
auto city_code = field_city.value();
if (city_code < EPAR_MAX_CITY) {
field_city.set_value(city_code + 1);
return true;
} else
return false;
}
uint32_t EPARView::get_scan_remaining() {
return EPAR_MAX_CITY - field_city.value();
}
void EPARView::flip_relays() { void EPARView::flip_relays() {
// Invert first relay's state // Invert first relay's state
relay_states[0].set_selected_index(relay_states[0].selected_index() ^ 1); relay_states[0].set_selected_index(relay_states[0].selected_index() ^ 1);
@ -207,7 +210,7 @@ void EPARView::flip_relays() {
size_t EPARView::generate_message() { size_t EPARView::generate_message() {
// R2, then R1 // R2, then R1
return gen_message_ep(field_city.value(), field_group.selected_index_value(), return gen_message_ep(field_city.value(), field_group.selected_index_value(),
1 - half, relay_states[half].selected_index()); half ? 0 : 1, relay_states[half].selected_index());
} }
EPARView::EPARView( EPARView::EPARView(
@ -219,18 +222,17 @@ EPARView::EPARView(
add_children({ add_children({
&labels, &labels,
&field_city, &field_city,
&field_group, &field_group
//&button_scan
}); });
field_city.set_value(220); field_city.set_value(0);
field_group.set_selected_index(2); field_group.set_selected_index(2);
field_city.on_change = [this](int32_t) { generate_message(); }; field_city.on_change = [this](int32_t) { generate_message(); };
field_group.on_change = [this](size_t, int32_t) { generate_message(); }; field_group.on_change = [this](size_t, int32_t) { generate_message(); };
const auto relay_state_fn = [this](size_t, OptionsField::value_t) { const auto relay_state_fn = [this](size_t, OptionsField::value_t) {
this->generate_message(); generate_message();
}; };
size_t n = 0; size_t n = 0;
@ -259,19 +261,25 @@ void XylosView::flip_relays() {
relay_states[0].set_selected_index(rs ^ 3); relay_states[0].set_selected_index(rs ^ 3);
} }
bool XylosView::increment_address() {
auto city_code = field_city.value();
if (city_code < XY_MAX_CITY) {
field_city.set_value(city_code + 1);
return true;
} else
return false;
}
uint32_t XylosView::get_scan_remaining() {
return XY_MAX_CITY - field_city.value();
}
void XylosView::generate_message() { void XylosView::generate_message() {
//if (tx_mode == SINGLE) { gen_message_xy(field_header_a.value(), field_header_b.value(), field_city.value(), field_family.value(),
//text_message.set( checkbox_wcsubfamily.value(), field_subfamily.value(), checkbox_wcid.value(), field_receiver.value(),
gen_message_xy(field_header_a.value(), field_header_b.value(), field_city.value(), field_family.value(), relay_states[0].selected_index(), relay_states[1].selected_index(),
checkbox_wcsubfamily.value(), field_subfamily.value(), checkbox_wcid.value(), field_receiver.value(), relay_states[2].selected_index(), relay_states[3].selected_index());
relay_states[0].selected_index(), relay_states[1].selected_index(),
relay_states[2].selected_index(), relay_states[3].selected_index());
//);
/*} else if (tx_mode == SEQUENCE) {
//text_message.set(
gen_message_xy(sequence_matin[seq_index].code);
//);
}*/
} }
XylosView::XylosView( XylosView::XylosView(
@ -300,7 +308,11 @@ XylosView::XylosView(
field_subfamily.set_value(1); field_subfamily.set_value(1);
field_receiver.set_value(1); field_receiver.set_value(1);
field_header_a.on_change = [this](int32_t) { generate_message(); }; const auto field_fn = [this](int32_t) {
generate_message();
};
field_header_a.on_change = field_fn;
field_header_b.on_change = [this](int32_t) { generate_message(); }; field_header_b.on_change = [this](int32_t) { generate_message(); };
field_city.on_change = [this](int32_t) { generate_message(); }; field_city.on_change = [this](int32_t) { generate_message(); };
field_family.on_change = [this](int32_t) { generate_message(); }; field_family.on_change = [this](int32_t) { generate_message(); };
@ -321,7 +333,7 @@ XylosView::XylosView(
checkbox_wcid.set_value(true); checkbox_wcid.set_value(true);
const auto relay_state_fn = [this](size_t, OptionsField::value_t) { const auto relay_state_fn = [this](size_t, OptionsField::value_t) {
this->generate_message(); generate_message();
}; };
size_t n = 0; size_t n = 0;

View File

@ -34,8 +34,6 @@
#include "encoders.hpp" #include "encoders.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#define XY_SEQ_COUNT 14
namespace ui { namespace ui {
class XylosView : public View { class XylosView : public View {
@ -46,39 +44,9 @@ public:
void flip_relays(); void flip_relays();
void generate_message(); void generate_message();
bool increment_address();
uint32_t get_scan_remaining();
enum tx_modes {
IDLE = 0,
SINGLE,
SEQUENCE
};
tx_modes tx_mode = IDLE;
uint32_t seq_index { 0 };
struct sequence_t {
const std::string code;
const uint32_t delay;
};
const sequence_t sequence_matin[XY_SEQ_COUNT] = {
{ "0000189000B1002B0000", 19 }, // 18:9:0:00 R1=OFF (1)
{ "0000189200B2110B0000", 16 }, // 18:9:2:00 R1=ON (4)
{ "0000189200B1110B0000", 52 }, // 18:9:2:00 R1=OFF (4)
{ "0000189200B2110B0000", 17 }, // 18:9:2:00 R1=ON (4)
{ "0000189200B1110B0000", 16 }, // 18:9:2:00 R1=OFF (4)
{ "0000189000B0012B0000", 22 }, // 18:9:0:00 R3=OFF (2)
{ "0000189200B1120B0000", 17 }, // 18:9:2:00 R3=ON (6)
{ "0000189200B1110B0000", 17 }, // 18:9:2:00 R3=OFF (6)
{ "0000181AAAB1000B0000", 17 }, // 18:1:A:AA R1=OFF (10)
{ "0000189400B1000B0000", 17 }, // 18:9:4:00 R1=OFF (7)
{ "0000189200B1120B0000", 14 }, // 18:9:2:00 R3=ON (6)
{ "0000189200B1110B0000", 17 }, // 18:9:2:00 R3=OFF (6)
{ "0000181AAAB1000B0000", 17 }, // 18:1:A:AA
{ "0000189400B0100B0000", 17 } // 18:9:4:00 R2=OFF (8)
};
private: private:
Labels labels { Labels labels {
{ { 8 * 8, 1 * 8 }, "Header:", Color::light_grey() }, { { 8 * 8, 1 * 8 }, "Header:", Color::light_grey() },
@ -107,7 +75,7 @@ private:
NumberField field_city { NumberField field_city {
{ 16 * 8, 3 * 8 }, { 16 * 8, 3 * 8 },
2, 2,
{ 0, 99 }, { 0, XY_MAX_CITY },
1, 1,
' ' ' '
}; };
@ -154,11 +122,6 @@ private:
{ &bitmap_bulb_off, 1 }, { &bitmap_bulb_off, 1 },
{ &bitmap_bulb_on, 2 } { &bitmap_bulb_on, 2 }
}; };
Button button_seq {
{ 24 * 8, 1 * 8, 40, 32 },
"Seq"
};
}; };
class EPARView : public View { class EPARView : public View {
@ -169,8 +132,10 @@ public:
void flip_relays(); void flip_relays();
size_t generate_message(); size_t generate_message();
bool increment_address();
uint32_t get_scan_remaining();
size_t half { 0 }; bool half { false };
private: private:
Labels labels { Labels labels {
@ -182,9 +147,9 @@ private:
NumberField field_city { NumberField field_city {
{ 16 * 8, 1 * 8 }, { 16 * 8, 1 * 8 },
3, 3,
{ 0, 255 }, { 0, EPAR_MAX_CITY },
1, 1,
' ' '0'
}; };
OptionsField field_group { OptionsField field_group {
@ -204,11 +169,6 @@ private:
{ &bitmap_bulb_off, 0 }, { &bitmap_bulb_off, 0 },
{ &bitmap_bulb_on, 1 } { &bitmap_bulb_on, 1 }
}; };
Button button_scan {
{ 22 * 8, 1 * 8, 56, 32 },
"Scan"
};
}; };
class BHTView : public View { class BHTView : public View {
@ -223,15 +183,24 @@ public:
private: private:
void on_tx_progress(const uint32_t progress, const bool done); void on_tx_progress(const uint32_t progress, const bool done);
void start_tx(); void start_tx();
void stop_tx();
enum tx_type_t { enum target_system_t {
XYLOS = 0, XYLOS = 0,
EPAR = 1 EPAR = 1
}; };
tx_type_t tx_type = { }; target_system_t target_system = { };
Rect view_rect = { 0, 3 * 8, 240, 192 }; enum tx_modes {
IDLE = 0,
SINGLE,
SCAN
};
tx_modes tx_mode = IDLE;
Rect view_rect = { 0, 3 * 8, 240, 176 };
XylosView view_xylos { view_rect }; XylosView view_xylos { view_rect };
EPARView view_EPAR { view_rect }; EPARView view_EPAR { view_rect };
@ -245,27 +214,29 @@ private:
{ { 29 * 8, 14 * 16 + 4 }, "s", Color::light_grey() } { { 29 * 8, 14 * 16 + 4 }, "s", Color::light_grey() }
}; };
ProgressBar progressbar { Checkbox checkbox_scan {
{ 1 * 8, 14 * 16, 20 * 8, 16 }, { 1 * 8, 25 * 8 },
}; 4,
Text text_message { "Scan"
{ 1 * 8, 15 * 16, 20 * 8, 16 },
""
}; };
Checkbox checkbox_cligno { Checkbox checkbox_cligno {
{ 22 * 8, 14 * 16 }, { 16 * 8, 25 * 8 },
1, 6,
"~" "Cligno"
}; };
NumberField field_tempo { NumberField field_tempo {
{ 27 * 8, 14 * 16 + 4 }, { 26 * 8, 25 * 8 + 4 },
2, 2,
{ 1, 99 }, { 1, 99 },
1, 1,
' ' ' '
}; };
ProgressBar progressbar {
{ 0 * 8, 29 * 8, 30 * 8, 16 },
};
TransmitterView tx_view { TransmitterView tx_view {
16 * 16, 16 * 16,
10000, 10000,

View File

@ -274,11 +274,17 @@ FileManagerView::FileManagerView(
add_children({ add_children({
&menu_view, &menu_view,
&text_empty, &text_empty,
&labels,
&text_date,
&button_rename, &button_rename,
&button_new_dir, &button_new_dir,
&button_delete &button_delete
}); });
menu_view.on_highlight = [this]() {
text_date.set(to_string_FAT_timestamp(file_created_date(get_selected_path())));
};
refresh_list(); refresh_list();
on_select_entry = [this]() { on_select_entry = [this]() {

View File

@ -149,21 +149,30 @@ private:
void refresh_widgets(const bool v); void refresh_widgets(const bool v);
void on_rename(NavigationView& nav); void on_rename(NavigationView& nav);
void on_delete(); void on_delete();
Labels labels {
{ { 0, 26 * 8 }, "Created ", Color::light_grey() }
};
Text text_date {
{ 8 * 8, 26 * 8 , 19 * 8, 16 },
""
};
Button button_rename { Button button_rename {
{ 0 * 8, 28 * 8, 14 * 8, 32 }, { 0 * 8, 29 * 8, 12 * 8, 32 },
"Rename" "Rename"
}; };
Button button_delete {
{ 18 * 8, 29 * 8, 12 * 8, 32 },
"Delete"
};
Button button_new_dir { Button button_new_dir {
{ 0 * 8, 33 * 8, 14 * 8, 32 }, { 0 * 8, 34 * 8, 14 * 8, 32 },
"New dir" "New dir"
}; };
Button button_delete {
{ 18 * 8, 28 * 8, 12 * 8, 32 },
"Delete"
};
}; };
} /* namespace ui */ } /* namespace ui */

View File

@ -72,7 +72,7 @@ void FreqManBaseView::populate_categories() {
categories.clear(); categories.clear();
for (size_t n = 0; n < file_list.size(); n++) for (size_t n = 0; n < file_list.size(); n++)
categories.emplace_back(std::make_pair(file_list[n], n)); categories.emplace_back(std::make_pair(file_list[n].substr(0, 14), n));
// Alphabetical sort // Alphabetical sort
std::sort(categories.begin(), categories.end(), [](auto &left, auto &right) { std::sort(categories.begin(), categories.end(), [](auto &left, auto &right) {

View File

@ -149,8 +149,8 @@ private:
}; };
Button button_new_category { Button button_new_category {
{ 18 * 8, 2, 12 * 8, 20 }, { 23 * 8, 2, 7 * 8, 20 },
"Create new" "New"
}; };
Button button_edit_freq { Button button_edit_freq {

View File

@ -260,6 +260,7 @@ RDSView::RDSView(
}; };
tx_view.on_stop = [this]() { tx_view.on_stop = [this]() {
// Kill tx_thread here ?
tx_view.set_transmitting(false); tx_view.set_transmitting(false);
transmitter_model.disable(); transmitter_model.disable();
txing = false; txing = false;

View File

@ -205,6 +205,14 @@ void rename_file(const std::filesystem::path& file_path, const std::filesystem::
f_rename(reinterpret_cast<const TCHAR*>(file_path.c_str()), reinterpret_cast<const TCHAR*>(new_name.c_str())); f_rename(reinterpret_cast<const TCHAR*>(file_path.c_str()), reinterpret_cast<const TCHAR*>(new_name.c_str()));
} }
FATTimestamp file_created_date(const std::filesystem::path& file_path) {
FILINFO filinfo;
f_stat(reinterpret_cast<const TCHAR*>(file_path.c_str()), &filinfo);
return { filinfo.fdate, filinfo.ftime };
}
uint32_t make_new_directory(const std::filesystem::path& dir_path) { uint32_t make_new_directory(const std::filesystem::path& dir_path) {
return f_mkdir(reinterpret_cast<const TCHAR*>(dir_path.c_str())); return f_mkdir(reinterpret_cast<const TCHAR*>(dir_path.c_str()));
} }

View File

@ -233,8 +233,14 @@ space_info space(const path& p);
} /* namespace filesystem */ } /* namespace filesystem */
} /* namespace std */ } /* namespace std */
struct FATTimestamp {
uint16_t FAT_date;
uint16_t FAT_time;
};
void delete_file(const std::filesystem::path& file_path); void delete_file(const std::filesystem::path& file_path);
void rename_file(const std::filesystem::path& file_path, const std::filesystem::path& new_name); void rename_file(const std::filesystem::path& file_path, const std::filesystem::path& new_name);
FATTimestamp file_created_date(const std::filesystem::path& file_path);
uint32_t make_new_directory(const std::filesystem::path& dir_path); uint32_t make_new_directory(const std::filesystem::path& dir_path);
std::vector<std::filesystem::path> scan_root_files(const std::filesystem::path& directory, const std::filesystem::path& extension); std::vector<std::filesystem::path> scan_root_files(const std::filesystem::path& directory, const std::filesystem::path& extension);
@ -255,6 +261,7 @@ class File {
public: public:
using Size = uint64_t; using Size = uint64_t;
using Offset = uint64_t; using Offset = uint64_t;
using Timestamp = uint32_t;
using Error = std::filesystem::filesystem_error; using Error = std::filesystem::filesystem_error;
template<typename T> template<typename T>
@ -321,8 +328,9 @@ public:
Result<Size> read(void* const data, const Size bytes_to_read); Result<Size> read(void* const data, const Size bytes_to_read);
Result<Size> write(const void* const data, const Size bytes_to_write); Result<Size> write(const void* const data, const Size bytes_to_write);
Result<Offset> seek(const uint64_t Offset); Result<Offset> seek(const uint64_t Offset);
Timestamp created_date();
Size size(); Size size();
template<size_t N> template<size_t N>

View File

@ -27,15 +27,14 @@
//TEST: Check AFSK transmit end, skips last bits ? //TEST: Check AFSK transmit end, skips last bits ?
//TEST: Imperial in whipcalc //TEST: Imperial in whipcalc
//BUG: Auto backlight off doesn't work anymore
//BUG: (Workaround ok) CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay //BUG: (Workaround ok) CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
//BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one //BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
//BUG: SCANNER Multiple slices //BUG: SCANNER Multiple slices
//TODO: Open files in File Manager
//TODO: Ask for filename after record
//TODO: Make entries disappear from RecentEntries list in ADS-B RX (after 2 minutes with no update ?) //TODO: Make entries disappear from RecentEntries list in ADS-B RX (after 2 minutes with no update ?)
//TODO: Display file creation/modification date in FileLoadView
//TODO: Super simple text file viewer //TODO: Super simple text file viewer
//TODO: Display recording frequency in Replay (from associated .txt file, if present)
//TODO: Clean up ReplayThread //TODO: Clean up ReplayThread
//TODO: Cap Wav viewer position //TODO: Cap Wav viewer position
//TODO: Adapt wav viewer position step //TODO: Adapt wav viewer position step

View File

@ -1,168 +0,0 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
// Color bitmaps generated with:
// Gimp image > indexed colors (16), then "xxd -i *.bmp"
//TEST: Menuview refresh, seems to blink a lot
//TEST: Check AFSK transmit end, skips last bits ?
//TEST: Imperial in whipcalc
//BUG: Auto backlight off doesn't work anymore
//BUG: CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
//BUG: REPLAY See what's wrong with quality (format, or need for interpolation filter ?)
//BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
//BUG: SCANNER Multiple slices
//TODO: Cap Wav viewer position
//TODO: Adapt wav viewer position step
//TODO: Use unit_auto_scale
//TODO: Remove make_bistream from encoders.cpp, too complex, stinks. bitstream_append should be enough.
//TODO: Continue work on proc_afskrx_corr, see python script (it works !)
//TODO: Super simple text file viewer
//TODO: De bruijn sequence scanner for encoders
//TODO: FILEMAN Rename folders
//TODO: FILEMAN Move files
//TODO: Frequency and bw settings were removed from modemsetup, put those back in LCR TX
//TODO: Use separate thread for scanning in EPAR TX
//TODO: Use separate thread for scanning in LCR TX
//TODO: REPLAY Convert C16 to C8 on M0 core
//TODO: Make freqman refresh simpler (use previous black rectangle method)
//TODO: Merge AFSK and TONES procs ?
//TODO: NFM RX mode: nav.pop on squelch
//TODO: MORSE use prosigns
//TODO: MORSE live keying mode
//TODO: Use to_string_short_freq wherever possible
//TODO: SCANNER Waveform widget as FFT view ?
//TODO: Optimize (and group ?) CTCSS tone gen code
/*
Continuous (Fox-oring)
12s transmit, 48s space (Sprint 1/5th)
60s transmit, 240s space (Classic 1/5 min)
60s transmit, 360s space (Classic 1/7 min)
*/
<<<<<<< Updated upstream
=======
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
>>>>>>> Stashed changes
//TODO: FreqMan: Remove and rename categories
//TODO: Mousejack ?
//TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere)
//TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback
//TODO: RDS multiple groups (sequence)
//TODO: Use ModalMessageView confirmation for TX ?
//TODO: Use msgpack for settings, lists... on sd card
// Multimon-style stuff:
//TODO: CTCSS detector
//TODO: DMR detector
//TODO: GSM channel detector
//TODO: SIGFOX RX/TX
//TODO: Playdead amnesia and login
//TODO: Setup: Play dead by default ? Enable/disable ?
// Old or low-priority stuff:
//TODO: Bodet :)
//TODO: Analog TV tx with camcorder font character generator
//TODO: Show address/data bit fields in OOK TX
//TODO: Scan for OOK TX
//TODO: Script engine ?
//TODO: AFSK receiver
//TODO: Check more OOK encoders
//BUG (fixed ?): No audio in about when shown second time
//TODO: Show MD5 mismatches for modules not found, etc...
//TODO: Module name/filename in modules.hpp to indicate requirement in case it's not found ui_loadmodule
//BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
//TODO: Two players tic-tac-toe
//TODO: Analog TV pong game
#include "ch.h"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
#include "message_queue.hpp"
#include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "ui_navigation.hpp"
#include "irq_lcd_frame.hpp"
#include "irq_controls.hpp"
#include "irq_rtc.hpp"
#include "event_m0.hpp"
#include "core_control.hpp"
#include "spi_image.hpp"
#include "debug.hpp"
#include "led.hpp"
#include "gcc.hpp"
#include "sd_card.hpp"
#include <string.h>
static void event_loop() {
ui::Context context;
ui::SystemView system_view {
context,
portapack::display.screen_rect()
};
EventDispatcher event_dispatcher { &system_view, context };
MessageHandlerRegistration message_handler_display_sleep {
Message::ID::DisplaySleep,
[&event_dispatcher](const Message* const) {
event_dispatcher.set_display_sleep(true);
}
};
event_dispatcher.run();
}
int main(void) {
if( portapack::init() ) {
portapack::display.init();
sdcStart(&SDCD1, nullptr);
controls_init();
lcd_frame_sync_configure();
rtc_interrupt_enable();
event_loop();
sdcDisconnect(&SDCD1);
sdcStop(&SDCD1);
portapack::shutdown();
}
m4_init(portapack::spi_flash::image_tag_hackrf, portapack::memory::map::m4_code_hackrf);
m0_halt();
return 0;
}

View File

@ -28,9 +28,14 @@
using namespace encoders; using namespace encoders;
#define XY_TONE_LENGTH ((TONES_SAMPLERATE * 0.1) - 1) // 100ms #define XY_TONE_DURATION ((TONES_SAMPLERATE * 0.1) - 1) // 100ms
#define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms #define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms
#define XY_TONE_COUNT 20 #define XY_TONE_COUNT 20
#define XY_MAX_CITY 99
#define EPAR_BIT_DURATION (OOK_SAMPLERATE / 580)
#define EPAR_REPEAT_COUNT 26
#define EPAR_MAX_CITY 255
struct bht_city { struct bht_city {
std::string name; std::string name;

View File

@ -165,27 +165,35 @@ std::string to_string_datetime(const rtc::RTC& value, const TimeFormat format) {
std::string string { "" }; std::string string { "" };
if (format == YMDHMS) { if (format == YMDHMS) {
string += to_string_dec_uint(value.year(), 4, '0') + "/" + string += to_string_dec_uint(value.year(), 4) + "/" +
to_string_dec_uint(value.month(), 2, '0') + "/" + to_string_dec_uint(value.month(), 2) + "/" +
to_string_dec_uint(value.day(), 2, '0') + " "; to_string_dec_uint(value.day(), 2) + " ";
} }
string += to_string_dec_uint(value.hour(), 2, '0') + ":" + string += to_string_dec_uint(value.hour(), 2) + ":" +
string += to_string_dec_uint(value.minute(), 2, '0'); string += to_string_dec_uint(value.minute(), 2);
if ((format == YMDHMS) || (format == HMS)) if ((format == YMDHMS) || (format == HMS))
string += ":" + to_string_dec_uint(value.second(), 2, '0'); string += ":" + to_string_dec_uint(value.second(), 2);
return string; return string;
} }
std::string to_string_timestamp(const rtc::RTC& value) { std::string to_string_timestamp(const rtc::RTC& value) {
return to_string_dec_uint(value.year(), 4, '0') + return to_string_dec_uint(value.year(), 4) +
to_string_dec_uint(value.month(), 2, '0') + to_string_dec_uint(value.month(), 2) +
to_string_dec_uint(value.day(), 2, '0') + to_string_dec_uint(value.day(), 2) +
to_string_dec_uint(value.hour(), 2, '0') + to_string_dec_uint(value.hour(), 2) +
to_string_dec_uint(value.minute(), 2, '0') + to_string_dec_uint(value.minute(), 2) +
to_string_dec_uint(value.second(), 2, '0'); to_string_dec_uint(value.second(), 2);
}
std::string to_string_FAT_timestamp(const FATTimestamp& timestamp) {
return to_string_dec_uint((timestamp.FAT_date >> 9) + 1980) + "/" +
to_string_dec_uint((timestamp.FAT_date >> 5) & 0xF, 2) + "/" +
to_string_dec_uint((timestamp.FAT_date & 0x1F), 2) + " " +
to_string_dec_uint((timestamp.FAT_time >> 11), 2) + ":" +
to_string_dec_uint((timestamp.FAT_time >> 5) & 0x3F, 2);
} }
std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision) { std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision) {
@ -208,7 +216,7 @@ std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precisi
string = to_string_dec_int(integer_part); string = to_string_dec_int(integer_part);
if (precision) if (precision)
string += '.' + to_string_dec_uint(fractional_part, precision, '0'); string += '.' + to_string_dec_uint(fractional_part, precision);
if (prefix_index != 3) if (prefix_index != 3)
string += unit_prefix[prefix_index]; string += unit_prefix[prefix_index];

View File

@ -25,6 +25,8 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include "file.hpp"
// BARF! rtc::RTC is leaking everywhere. // BARF! rtc::RTC is leaking everywhere.
#include "lpc43xx_cpp.hpp" #include "lpc43xx_cpp.hpp"
using namespace lpc43xx; using namespace lpc43xx;
@ -39,7 +41,7 @@ const char unit_prefix[7] { 'n', 'u', 'm', 0, 'k', 'M', 'G' };
// TODO: Allow l=0 to not fill/justify? Already using this way in ui_spectrum.hpp... // TODO: Allow l=0 to not fill/justify? Already using this way in ui_spectrum.hpp...
std::string to_string_bin(const uint32_t n, const uint8_t l = 0); std::string to_string_bin(const uint32_t n, const uint8_t l = 0);
std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char fill = 0); std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char fill = '0');
std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0); std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0);
std::string to_string_hex(const uint64_t n, const int32_t l = 0); std::string to_string_hex(const uint64_t n, const int32_t l = 0);
std::string to_string_hex_array(uint8_t * const array, const int32_t l = 0); std::string to_string_hex_array(uint8_t * const array, const int32_t l = 0);
@ -49,6 +51,7 @@ std::string to_string_time_ms(const uint32_t ms);
std::string to_string_datetime(const rtc::RTC& value, const TimeFormat format = YMDHMS); std::string to_string_datetime(const rtc::RTC& value, const TimeFormat format = YMDHMS);
std::string to_string_timestamp(const rtc::RTC& value); std::string to_string_timestamp(const rtc::RTC& value);
std::string to_string_FAT_timestamp(const FATTimestamp& timestamp);
std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision); std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision);

View File

@ -231,7 +231,10 @@ bool MenuView::set_highlighted(int32_t new_value) {
highlighted_item = new_value; highlighted_item = new_value;
item_view(highlighted_item - offset)->highlight(); item_view(highlighted_item - offset)->highlight();
} }
if (on_highlight)
on_highlight();
return true; return true;
} }

View File

@ -74,6 +74,7 @@ private:
class MenuView : public View { class MenuView : public View {
public: public:
std::function<void(void)> on_left { }; std::function<void(void)> on_left { };
std::function<void(void)> on_highlight { nullptr };
MenuView(Rect new_parent_rect = { 0, 0, 240, 304 }, bool keep_highlight = false); MenuView(Rect new_parent_rect = { 0, 0, 240, 304 }, bool keep_highlight = false);

View File

@ -531,7 +531,9 @@ ProgressBar::ProgressBar(
void ProgressBar::set_max(const uint32_t max) { void ProgressBar::set_max(const uint32_t max) {
if (max == _max) return; if (max == _max) return;
_value = 0; if (_value > _max)
_value = _max;
_max = max; _max = max;
set_dirty(); set_dirty();
} }