show time domain range

This commit is contained in:
cho45 2019-09-11 21:22:42 +09:00
parent 6bad9de606
commit a3b511f468
2 changed files with 47 additions and 31 deletions

77
plot.c
View file

@ -701,12 +701,17 @@ trace_get_info(int t, char *buf, int len)
} }
} }
static float time_of_index(int idx) {
return 1.0 / (float)(frequencies[1] - frequencies[0]) / 128.0 * idx;
}
static float distance_of_index(int idx) { static float distance_of_index(int idx) {
#define SPEED_OF_LIGHT 299792458 #define SPEED_OF_LIGHT 299792458
float distance = ((float)idx * (float)SPEED_OF_LIGHT) / ( (float)(frequencies[1] - frequencies[0]) * 128.0 * 2.0); float distance = ((float)idx * (float)SPEED_OF_LIGHT) / ( (float)(frequencies[1] - frequencies[0]) * 128.0 * 2.0);
return distance * (velocity_factor / 100.0); return distance * (velocity_factor / 100.0);
} }
static inline void static inline void
mark_map(int x, int y) mark_map(int x, int y)
{ {
@ -1377,7 +1382,7 @@ cell_draw_marker_info(int m, int n, int w, int h)
frequency_string(buf, sizeof buf, frequencies[idx]); frequency_string(buf, sizeof buf, frequencies[idx]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
} else { } else {
chsnprintf(buf, sizeof buf, "%.1f m (VF=%d%%)", distance_of_index(idx), velocity_factor); chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9), distance_of_index(idx));
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
} }
@ -1421,37 +1426,47 @@ void
draw_frequencies(void) draw_frequencies(void)
{ {
char buf[24]; char buf[24];
if (frequency1 > 0) { if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
int start = frequency0; if (frequency1 > 0) {
int stop = frequency1; int start = frequency0;
strcpy(buf, "START "); int stop = frequency1;
frequency_string(buf+6, 24-6, start); strcpy(buf, "START ");
strcat(buf, " "); frequency_string(buf+6, 24-6, start);
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000); strcat(buf, " ");
strcpy(buf, "STOP "); ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
frequency_string(buf+5, 24-5, stop); strcpy(buf, "STOP ");
strcat(buf, " "); frequency_string(buf+5, 24-5, stop);
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000); strcat(buf, " ");
} else if (frequency1 < 0) { ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
int fcenter = frequency0; } else if (frequency1 < 0) {
int fspan = -frequency1; int fcenter = frequency0;
strcpy(buf, "CENTER "); int fspan = -frequency1;
frequency_string(buf+7, 24-7, fcenter); strcpy(buf, "CENTER ");
strcat(buf, " "); frequency_string(buf+7, 24-7, fcenter);
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000); strcat(buf, " ");
strcpy(buf, "SPAN "); ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
frequency_string(buf+5, 24-5, fspan); strcpy(buf, "SPAN ");
strcat(buf, " "); frequency_string(buf+5, 24-5, fspan);
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000); strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} else {
int fcenter = frequency0;
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ",
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000),
(int)(fcenter % 1000));
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
chsnprintf(buf, 24, " ");
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
}
} else { } else {
int fcenter = frequency0; strcpy(buf, "START 0s ");
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ", ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000), strcpy(buf, "STOP ");
(int)(fcenter % 1000)); chsnprintf(buf+5, 24-5, "%d ns", (uint16_t)(time_of_index(101) * 1e9));
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000); strcat(buf, " ");
chsnprintf(buf, 24, " "); ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} }
} }

1
ui.c
View file

@ -695,6 +695,7 @@ menu_transform_cb(int item)
} else { } else {
domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_TIME; domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_TIME;
} }
draw_frequencies();
ui_mode_normal(); ui_mode_normal();
break; break;
case 1: case 1: