draw delta frequency of two markers

This commit is contained in:
TT 2017-09-16 00:48:34 +09:00
parent 95b3ac2a4b
commit c121731b04
3 changed files with 45 additions and 20 deletions

View file

@ -275,6 +275,8 @@ extern int16_t lastsaveid;
extern properties_t *active_props;
extern properties_t current_props;
extern uint8_t previous_marker;
#define frequency0 current_props._frequency0
#define frequency1 current_props._frequency1
#define sweep_points current_props._sweep_points

53
plot.c
View file

@ -9,7 +9,7 @@
void cell_draw_marker_info(int m, int n, int w, int h);
void draw_frequencies(void);
void frequency_string(char *buf, size_t len, uint32_t freq);
void frequency_string(char *buf, size_t len, int32_t freq);
void markmap_all_markers(void);
//#define GRID_COLOR 0x0863
@ -1266,15 +1266,40 @@ cell_draw_marker_info(int m, int n, int w, int h)
xpos += 16;
frequency_string(buf, sizeof buf, frequencies[idx]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
if (active_marker != previous_marker && markers[previous_marker].enabled) {
int idx0 = markers[previous_marker].index;
xpos = 192;
xpos -= m * CELLWIDTH -CELLOFFSETX;
ypos += 7;
chsnprintf(buf, sizeof buf, "\001%d:", previous_marker+1);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
xpos += 16;
frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
}
}
void
frequency_string(char *buf, size_t len, uint32_t freq)
frequency_string(char *buf, size_t len, int32_t freq)
{
if (freq < 0) {
freq = -freq;
*buf++ = '-';
len -= 1;
}
if (freq < 1000) {
chsnprintf(buf, len, "%d Hz", (int)freq);
} else if (freq < 1000000) {
chsnprintf(buf, len, "%d.%03d kHz",
(int)(freq / 1000),
(int)(freq % 1000));
} else {
chsnprintf(buf, len, "%d.%03d %03d MHz",
(int)(freq / 1000000),
(int)((freq / 1000) % 1000),
(int)(freq % 1000));
}
}
void
@ -1284,28 +1309,20 @@ draw_frequencies(void)
if (frequency1 > 0) {
int start = frequency0;
int stop = frequency1;
chsnprintf(buf, 24, "START %d.%03d %03d MHz ",
(int)(start / 1000000),
(int)((start / 1000) % 1000),
(int)(start % 1000));
strcpy(buf, "START ");
frequency_string(buf+6, 24-6, start);
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
chsnprintf(buf, 24, "STOP %d.%03d %03d MHz",
(int)(stop / 1000000),
(int)((stop / 1000) % 1000),
(int)(stop % 1000));
strcpy(buf, "STOP ");
frequency_string(buf+5, 24-5, stop);
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} else if (frequency1 < 0) {
int fcenter = frequency0;
int fspan = -frequency1;
chsnprintf(buf, 24, "CENTER %d.%03d %03d MHz ",
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000),
(int)(fcenter % 1000));
strcpy(buf, "CENTER ");
frequency_string(buf+7, 24-7, fcenter);
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
chsnprintf(buf, 24, "SPAN %d.%03d %03d MHz",
(int)(fspan / 1000000),
(int)((fspan / 1000) % 1000),
(int)(fspan % 1000));
strcpy(buf, "SPAN ");
frequency_string(buf+5, 24-5, fspan);
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} else {
int fcenter = frequency0;

8
ui.c
View file

@ -60,6 +60,8 @@ static uint32_t last_button_repeat_ticks;
enum { OP_NONE = 0, OP_LEVER, OP_TOUCH };
uint8_t operation_requested = OP_NONE;
uint8_t previous_marker = 0;
enum {
UI_NORMAL, UI_MENU, UI_KEYPAD
};
@ -630,8 +632,11 @@ menu_marker_sel_cb(int item)
if (item >= 0 && item < 4) {
if (active_marker == item) {
markers[active_marker].enabled = FALSE;
choose_active_marker();
active_marker = previous_marker;
previous_marker = 0;
//choose_active_marker();
} else {
previous_marker = active_marker;
active_marker = item;
markers[active_marker].enabled = TRUE;
}
@ -641,6 +646,7 @@ menu_marker_sel_cb(int item)
markers[1].enabled = FALSE;
markers[2].enabled = FALSE;
markers[3].enabled = FALSE;
previous_marker = 0;
active_marker = -1;
}