Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 11 additions & 38 deletions osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,52 +260,25 @@ void modeset_paint_buffer(struct modeset_buf *buf) {
cairo_move_to(cr, x_center - 50, buf->height - 30);
cairo_show_text(cr, msg);

// Print rate stats
struct timespec current_timestamp;
if (!clock_gettime(CLOCK_MONOTONIC_COARSE, &current_timestamp)) {
double interval = getTimeInterval(&current_timestamp, &last_timestamp);
if (osd_vars.telemetry_arm > 1700){
seconds = seconds + interval;
}
if (interval > 1) {
last_timestamp = current_timestamp;
rx_rate = ((float)stats_rx_bytes+(((float)stats_rx_bytes*25)/100)) / 1024.0f * 8;
stats_rx_bytes = 0;
}
}

char hud_frames_rx[32];
if (osd_vars.telemetry_level > 1){
cairo_move_to(cr, x_center - strlen(hud_frames_rx) / 2 * 16, 40);
cairo_show_text(cr, hud_frames_rx);
} else {
cairo_move_to(cr, buf->width - 300, buf->height - 60);
cairo_show_text(cr, hud_frames_rx);
sprintf(msg, "TIME:%.2d:%.2d", minutes,seconds);
cairo_move_to(cr, buf->width - 300, buf->height - 90);
cairo_show_text(cr, msg);
if(seconds > 59){
seconds = 0;
++minutes;
}
if(minutes > 59){
seconds = 0;
minutes = 0;
}
}
float percent = rx_rate / (1024 * 10);
if (percent > 1) {
percent = 1;
}

uint32_t width = (strlen(hud_frames_rx) * 16) * percent;
if (osd_vars.telemetry_level > 1){
cairo_set_source_rgba(cr, 255, 255, 255, 0.8); // R, G, B, A
cairo_rectangle(cr, x_center - strlen(hud_frames_rx) / 2 * 16, 64, width, 8);
} else {
cairo_set_source_rgba(cr, 255, 255, 255, 0.8); // R, G, B, A
cairo_rectangle(cr, buf->width - 300, buf->height - 36, width, 8);
}
sprintf(msg, "TIME:%.2d:%.2d", minutes,seconds);
cairo_move_to(cr, buf->width - 300, buf->height - 90);
cairo_show_text(cr, msg);
if(seconds > 59){
seconds = 0;
++minutes;
}
if(minutes > 59){
seconds = 0;
minutes = 0;
}
cairo_fill(cr);
}

Expand Down