Skip to content

Commit

Permalink
only write when data is available
Browse files Browse the repository at this point in the history
  • Loading branch information
henkwiedig committed Feb 24, 2025
1 parent d023c8a commit 3c4ea16
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions osd/util/subtitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,22 @@ void write_srt_file() {
uint32_t end_seconds = (end_time_ms % 60000) / 1000;
uint32_t end_milliseconds = end_time_ms % 1000;

// Write the subtitle to the file
fprintf(srt_file, "%u\n", sequence_number);
fprintf(srt_file, "%02u:%02u:%02u,%03u --> %02u:%02u:%02u,%03u\n",
start_hours, start_minutes, start_seconds, start_milliseconds,
end_hours, end_minutes, end_seconds, end_milliseconds);
if (msg_colour) { // ground mode
fprintf(srt_file, "%s\n\n", air_unit_info_msg);
} else { // air mode
remove_control_codes(ready_osdmsg);
fprintf(srt_file, "%s\n\n", ready_osdmsg);
if ( strlen(air_unit_info_msg) || strlen(ready_osdmsg) ) {
// Write the subtitle to the file
fprintf(srt_file, "%u\n", sequence_number);
fprintf(srt_file, "%02u:%02u:%02u,%03u --> %02u:%02u:%02u,%03u\n",
start_hours, start_minutes, start_seconds, start_milliseconds,
end_hours, end_minutes, end_seconds, end_milliseconds);
if (msg_colour) { // ground mode
fprintf(srt_file, "%s\n\n", air_unit_info_msg);
} else { // air mode
remove_control_codes(ready_osdmsg);
fprintf(srt_file, "%s\n\n", ready_osdmsg);
}
fflush(srt_file);
} else {
return;
}
fflush(srt_file);

// Increment the sequence number and update the last FlightTime written
sequence_number++;
Expand Down

0 comments on commit 3c4ea16

Please sign in to comment.