Skip to content

Commit

Permalink
Add GPS icon, fix overwrite bug (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo committed Mar 30, 2024
1 parent 6d9d5ad commit d29172f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
22 changes: 14 additions & 8 deletions firmware/application/ui_record_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ RecordView::RecordView(
&rect_background,
//&button_pitch_rssi,
&button_record,
&gps_icon,
&text_record_filename,
&text_record_dropped,
&text_time_available,
Expand All @@ -93,6 +94,7 @@ RecordView::RecordView(
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
this->on_tick_second();
};
gps_icon.hidden(true);
}

RecordView::~RecordView() {
Expand Down Expand Up @@ -180,6 +182,13 @@ void RecordView::start() {
}

std::filesystem::path base_path;

auto tmp_path = filename_stem_pattern; // store it, to be able to modify without causing permanent change
// check for geo data, if present append filename with _GEO
if (latitude != 0 && longitude != 0 && latitude < 200 && longitude < 200) {
tmp_path.append_filename(u"_GEO");
}

if (filename_date_frequency) {
rtc_time::now(datetime);

Expand All @@ -192,24 +201,19 @@ void RecordView::start() {
to_string_dec_uint(datetime.minute()) +
to_string_dec_uint(datetime.second());

base_path = filename_stem_pattern.string() + "_" + date_time + "_" +
base_path = tmp_path.string() + "_" + date_time + "_" +
trim(to_string_freq(receiver_model.target_frequency())) + "Hz";
base_path = folder / base_path;
} else if (filename_as_is) {
base_path = filename_stem_pattern.string();
base_path = tmp_path.string();
base_path = folder / base_path;
} else
base_path = next_filename_matching_pattern(folder / filename_stem_pattern);
base_path = next_filename_matching_pattern(folder / tmp_path);

if (base_path.empty()) {
return;
}

// check for geo data, if present append filename with _GEO
if (latitude != 0 && longitude != 0 && latitude < 200 && longitude < 200) {
base_path.append_filename(u"_GEO");
}

std::unique_ptr<stream::Writer> writer;
switch (file_type) {
case FileType::WAV: {
Expand Down Expand Up @@ -348,6 +352,8 @@ void RecordView::trim_capture() {
}

void RecordView::on_gps(const GPSPosDataMessage* msg) {
if (msg->lat == 0 || msg->lat > 399) return; // not valid one
if (latitude == 0) gps_icon.hidden(false); // prev was 0, so not shown already
latitude = msg->lat;
longitude = msg->lon;
satinuse = msg->satinuse;
Expand Down
6 changes: 6 additions & 0 deletions firmware/application/ui_record_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ class RecordView : public View {
"",
};

Image gps_icon{
{2 * 8 + 1, 0 * 16, 2 * 8, 1 * 16},
&bitmap_target,
Color::white(),
Color::black()};

std::unique_ptr<CaptureThread> capture_thread{};

MessageHandlerRegistration message_handler_capture_thread_error{
Expand Down

0 comments on commit d29172f

Please sign in to comment.