-
Notifications
You must be signed in to change notification settings - Fork 18
/
notes
170 lines (168 loc) · 7.72 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Mavlink elements
uint32_t x_center = buf->width / 2;
if (osd_vars.osd_mode > 0){
// Artificial Horizon
int32_t offset_pitch = osd_vars.telemetry_pitch * 4;
int32_t offset_roll = osd_vars.telemetry_roll * 4;
int32_t y_pos_left = ((int32_t)buf->height / 2 - 2 + offset_pitch + offset_roll);
int32_t y_pos_right = ((int32_t)buf->height / 2 - 2 + offset_pitch - offset_roll);
-
for (int i = 0; i < 4; i++) {
if (y_pos_left > 0 && y_pos_left < buf->height &&
y_pos_right > 0 && y_pos_right < buf->height) {
//fbg_line(cr, x_center - 180, y_pos_left + i, x_center + 180, y_pos_right + i, 255, 255, 255);
}
}
-
// Vertical Speedometer
int32_t offset_vspeed = osd_vars.telemetry_vspeed * 5;
int32_t y_pos_vspeed = ((int32_t)buf->height / 2 - offset_vspeed);
for (int i = 0; i < 8; i++) {
if (y_pos_vspeed > 0 && y_pos_vspeed < buf->height) {
//fbg_line(cr, x_center + 242 + i, buf->height / 2, x_center + 242 + i, y_pos_vspeed, 255, 255, 255);
}
}
-
for (int i = 0; i < 25; i++) {
uint32_t width = (i == 12) ? 10 : 0;
-
// fbg_line(cr, x_center - 240 - width,
// buf->height / 2 - 120 + i * 10, x_center - 220,
// buf->height / 2 - 120 + i * 10, 255, 255, 255);
// fbg_line(cr, x_center - 240 - width,
// buf->height / 2 - 120 + i * 10 + 1, x_center - 220,
// buf->height / 2 - 120 + i * 10 + 1, 255, 255, 255);
-
// fbg_line(cr, x_center + 220, buf->height / 2 - 120 + i * 10,
// x_center + 240 + width, buf->height / 2 - 120 + i * 10, 255, 255, 255);
// fbg_line(cr, x_center + 220, buf->height / 2 - 120 + i * 10 + 1,
// x_center + 240 + width, buf->height / 2 - 120 + i * 10 + 1, 255, 255, 255);
}
-
// OSD telemetry
sprintf(msg, "ALT:%.00fM", osd_vars.telemetry_altitude);
cairo_move_to(cr, x_center + (20) + 260, buf->height / 2 - 8);
cairo_show_text(cr, msg);
sprintf(msg, "SPD:%.00fKM/H", osd_vars.telemetry_gspeed);
cairo_move_to(cr, x_center - (16 * 3) - 360, buf->height / 2 - 8);
cairo_show_text(cr, msg);
sprintf(msg, "VSPD:%.00fM/S", osd_vars.telemetry_vspeed);
cairo_move_to(cr, x_center + (20) + 260, buf->height / 2 + 22);
cairo_show_text(cr, msg);
}
-
sprintf(msg, "BAT:%.02fV", osd_vars.telemetry_battery / 1000);
cairo_move_to(cr, 40, buf->height - 30);
cairo_show_text(cr, msg);
sprintf(msg, "CONS:%.00fmAh", osd_vars.telemetry_current_consumed);
cairo_move_to(cr, 40, buf->height - 60);
cairo_show_text(cr, msg);
sprintf(msg, "CUR:%.02fA", osd_vars.telemetry_current / 100);
cairo_move_to(cr, 40, buf->height - 90);
cairo_show_text(cr, msg);
sprintf(msg, "THR:%.00f%%", osd_vars.telemetry_throttle);
cairo_move_to(cr, 40, buf->height - 120);
cairo_show_text(cr, msg);
if (osd_vars.osd_mode > 0){
sprintf(msg, "SATS:%.00f", osd_vars.telemetry_sats);
cairo_move_to(cr,buf->width - 140, buf->height - 30);
cairo_show_text(cr, msg);
sprintf(msg, "HDG:%.00f", osd_vars.telemetry_hdg);
cairo_move_to(cr,buf->width - 140, buf->height - 120);
cairo_show_text(cr, msg);
sprintf(osd_vars.c1, "%.00f", osd_vars.telemetry_lat);
-
if (osd_vars.telemetry_lat < 10000000) {
insertString(osd_vars.c1, "LAT:0.", 0);
}
-
if (osd_vars.telemetry_lat > 9999999) {
if (numOfChars(osd_vars.c1) == 8) {
insertString(osd_vars.c1, ".", 1);
} else {
insertString(osd_vars.c1, ".", 2);
}
insertString(osd_vars.c1, "LAT:", 0);
}
cairo_move_to(cr, buf->width - 240, buf->height - 90);
cairo_show_text(cr, osd_vars.c1);
-
sprintf(osd_vars.c2, "%.00f", osd_vars.telemetry_lon);
if (osd_vars.telemetry_lon < 10000000) {
insertString(osd_vars.c2, "LON:0.", 0);
}
if (osd_vars.telemetry_lon > 9999999) {
if (numOfChars(osd_vars.c2) == 8) {
insertString(osd_vars.c2, ".", 1);
} else {
insertString(osd_vars.c2, ".", 2);
}
insertString(osd_vars.c2, "LON:", 0);
}
cairo_move_to(cr, buf->width - 240, buf->height - 60);
cairo_show_text(cr, osd_vars.c2);
//sprintf(msg, "PITCH:%.00f", telemetry_pitch);
//cairo_move_to(cr, msg, x_center + 440, buf->height - 140);
//sprintf(msg, "ROLL:%.00f", telemetry_roll);
//cairo_move_to(cr, msg, x_center + 440, buf->height - 170);
sprintf(msg, "DIST:%.03fM", osd_vars.telemetry_distance);
cairo_move_to(cr, x_center - 350, buf->height - 30);
cairo_show_text(cr, msg);
}
sprintf(msg, "RSSI:%.00f", osd_vars.telemetry_rssi);
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, ¤t_timestamp)) {
double interval = getTimeInterval(¤t_timestamp, &last_timestamp);
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;
}
}
-
uint64_t diff;
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC, &start);
sleep(1);
clock_gettime(CLOCK_MONOTONIC, &end);
diff = BILLION * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec;
-
char hud_frames_rx[32];
if (osd_vars.osd_mode > 0){
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 (osd_vars.telemetry_arm > 1700){
seconds = seconds + diff/1000000000;
}
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.osd_mode > 0){
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);
}