Skip to content

Commit

Permalink
freqman: limiting description size to 30, and minor fix (#1977)
Browse files Browse the repository at this point in the history
* Limiting description size to 30 as it was documented before

* cosmetic adjustement

---------

Co-authored-by: GullCode <gullradriel@hotmail.com>
  • Loading branch information
gullradriel and GullCode committed Mar 11, 2024
1 parent 866e12f commit 910fd82
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion firmware/application/apps/ui_freqman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void FrequencyManagerView::on_edit_freq() {

void FrequencyManagerView::on_edit_desc() {
temp_buffer_ = current_entry().description;
text_prompt(nav_, temp_buffer_, desc_edit_max, [this](std::string& new_desc) {
text_prompt(nav_, temp_buffer_, freqman_max_desc_size, [this](std::string& new_desc) {
auto entry = current_entry();
entry.description = std::move(new_desc);
db_.replace_entry(current_index(), entry);
Expand Down
8 changes: 3 additions & 5 deletions firmware/application/apps/ui_freqman.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class FreqManBaseView : public View {

void focus() override;

static constexpr size_t desc_edit_max = 0x80;

protected:
using options_t = OptionsField::options_t;

Expand All @@ -63,11 +61,11 @@ class FreqManBaseView : public View {

/* The top section (category) is 20px tall. */
Labels label_category{
{{0, 2}, "Category:", Color::light_grey()}};
{{0, 2}, "F:", Color::light_grey()}};

OptionsField options_category{
{9 * 8, 2},
14 /* length */,
{3 * 8, 2},
20 /* length */,
{}};

FreqManUIList freqlist_view{
Expand Down
4 changes: 2 additions & 2 deletions firmware/application/freqman_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ bool parse_freqman_entry(std::string_view str, freqman_entry& entry) {
} else if (key == "c") {
entry.tone = parse_tone_key(value);
} else if (key == "d") {
entry.description = trim(value);
entry.description = trim(value).substr(0, freqman_max_desc_size);
} else if (key == "f") {
entry.type = freqman_type::Single;
parse_int(value, entry.frequency_a);
Expand Down Expand Up @@ -492,7 +492,7 @@ freqman_entry FreqmanDB::operator[](Index index) const {
return entry;
else if (read_raw_) {
entry.type = freqman_type::Raw;
entry.description = trim(*line_text);
entry.description = trim(*line_text).substr(0, freqman_max_desc_size);
return entry;
}
}
Expand Down
3 changes: 3 additions & 0 deletions firmware/application/freqman_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ std::string freqman_entry_get_step_string_short(freqman_index_t step);
* ensure app memory stability. */
constexpr size_t freqman_default_max_entries = 150;

/* Limiting description to 30 as specified by the format */
constexpr size_t freqman_max_desc_size = 30;

struct freqman_load_options {
/* Loads all entries when set to 0. */
size_t max_entries{freqman_default_max_entries};
Expand Down

0 comments on commit 910fd82

Please sign in to comment.