Merge branch 'DiSlord-V4-SI4463' into tinySA-V4-SI4463

Removed_REF_marker
erikkaashoek 5 years ago
commit a79ac2de2b

@ -194,8 +194,8 @@ static THD_FUNCTION(Thread1, arg)
redraw_request |= REDRAW_CELLS | REDRAW_BATTERY;
if (uistat.marker_tracking) {
int i = marker_search();
if (i != -1 && active_marker != -1) {
int i = marker_search_max();
if (i != -1 && active_marker != MARKER_INVALID) {
markers[active_marker].index = i;
markers[active_marker].frequency = frequencies[i];
@ -2025,7 +2025,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
}
redraw_request |= REDRAW_MARKER;
if (strcmp(argv[0], "off") == 0) {
active_marker = -1;
active_marker = MARKER_INVALID;
for (t = 0; t < MARKERS_MAX; t++)
markers[t].enabled = FALSE;
return;
@ -2044,7 +2044,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
static const char cmd_marker_list[] = "on|off|peak";
switch (get_str_index(argv[1], cmd_marker_list)) {
case 0: markers[t].enabled = TRUE; active_marker = t; return;
case 1: markers[t].enabled =FALSE; if (active_marker == t) active_marker = -1; return;
case 1: markers[t].enabled =FALSE; if (active_marker == t) active_marker = MARKER_INVALID; return;
case 2: markers[t].enabled = TRUE; active_marker = t;
int i = marker_search_max();
if (i == -1) i = 0;

@ -107,6 +107,8 @@
#define TRACE_ACTUAL 2
#define TRACE_STORED 1
#define TRACE_TEMP 0
#define TRACE_INVALID -1
// #define age_t measured[TRACE_AGE]
#define stored_t measured[TRACE_STORED]
#define actual_t measured[TRACE_ACTUAL]
@ -435,6 +437,9 @@ extern uint16_t graph_bottom;
#define GRID_X_TEXT (AREA_WIDTH_NORMAL - 7*5)
// Marker start drag distance (can be bigger for various display resolution)
#define MARKER_PICKUP_DISTANCE 20
// Smith/polar chart
//#define P_CENTER_X (CELLOFFSETX + WIDTH/2)
//#define P_CENTER_Y (HEIGHT/2)
@ -459,8 +464,8 @@ extern uint16_t graph_bottom;
// Num Input height at bottom
#define NUM_INPUT_HEIGHT 32
extern int16_t area_width;
extern int16_t area_height;
extern uint16_t area_width;
extern uint16_t area_height;
// Define marker size (can be 0 or 1)
#ifdef TINYSA3
@ -672,6 +677,7 @@ typedef struct {
} marker_t;
#define MARKERS_MAX 4
#define MARKER_INVALID -1
extern int8_t previous_marker;
extern int8_t marker_tracking;
@ -694,13 +700,10 @@ void draw_cal_status(void);
//void markmap_all_markers(void);
void marker_position(int m, int t, int *x, int *y);
int distance_to_index(int8_t t, uint16_t idx, int16_t x, int16_t y);
int search_nearest_index(int x, int y, int t);
void set_marker_search(int mode);
int marker_search(void);
int marker_search_max(void);
int marker_search_left(int from);
int marker_search_right(int from);
int marker_search_left_max(int from);
int marker_search_right_max(int from);
int marker_search_left_min(int from);

124
plot.c

@ -46,8 +46,8 @@ static int16_t grid_offset;
static int16_t grid_width;
static freq_t grid_span;
int16_t area_width = AREA_WIDTH_NORMAL;
int16_t area_height; // initialized in main() = AREA_HEIGHT_NORMAL;
uint16_t area_width = AREA_WIDTH_NORMAL;
uint16_t area_height; // initialized in main() = AREA_HEIGHT_NORMAL;
// Cell render use spi buffer
typedef uint16_t pixel_t;
@ -1369,125 +1369,23 @@ markmap_all_markers(void)
markmap_upperarea();
}
void
marker_position(int m, int t, int *x, int *y)
{
index_t index = trace_index[t][markers[m].index];
*x = CELL_X(index);
*y = CELL_Y(index);
}
static int greater(int x, int y, int d) { return x - d > y; }
static int lesser(int x, int y, int d) { return x - d < y; }
static int (*compare)(int x, int y, int d) = greater;
int
marker_search(void)
{
int i;
int found = 0;
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][0]);
for (i = 0; i < sweep_points; i++) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value, 0)) {
value = new_value;
found = i;
}
}
return found;
}
void
set_marker_search(int mode)
{
compare = (mode == 0) ? greater : lesser;
}
int
search_is_greater(void)
{
return(compare == greater);
}
#define MINMAX_DELTA 10
int
marker_search_left(int from)
distance_to_index(int8_t t, uint16_t idx, int16_t x, int16_t y)
{
int i;
int found = -1;
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from - 1; i >= 0; i--) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value, MINMAX_DELTA))
break;
}
for (; i >= 0; i--) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(new_value, value, -MINMAX_DELTA)) {
break;
}
if ((*compare)(value, new_value, 0)) {
found = i;
value = new_value;
}
}
return found;
}
int
marker_search_right(int from)
{
int i;
int found = -1;
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from + 1; i < sweep_points; i++) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value, MINMAX_DELTA))
break;
value = new_value;
}
for (; i < sweep_points; i++) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(new_value, value, -MINMAX_DELTA)) {
break;
}
if ((*compare)(value, new_value, 0)) {
found = i;
value = new_value;
}
}
return found;
index_t *index = trace_index[t];
x-= CELL_X(index[idx]);
y-= CELL_Y(index[idx]);
return x*x + y*y;
}
int
search_nearest_index(int x, int y, int t)
{
index_t *index = trace_index[t];
int min_i = -1;
int min_d = 1000;
int min_d = MARKER_PICKUP_DISTANCE * MARKER_PICKUP_DISTANCE;
int i;
for (i = 0; i < sweep_points; i++) {
int16_t dx = x - CELL_X(index[i]);
int16_t dy = y - CELL_Y(index[i]);
if (dx < 0) dx = -dx;
if (dy < 0) dy = -dy;
if (dx > 20 || dy > 20)
continue;
int d = dx*dx + dy*dy;
int d = distance_to_index(t, i, x , y);
if (d < min_d) {
min_d = d;
min_i = i;
@ -1532,9 +1430,9 @@ draw_cell(int m, int n)
int t;
uint16_t c;
// Clip cell by area
if (x0 + w > area_width)
if (w > area_width - x0)
w = area_width - x0;
if (y0 + h > area_height)
if (h > area_height - y0)
h = area_height - y0;
if (w <= 0 || h <= 0)
return;

@ -3550,7 +3550,7 @@ marker_search_left_max(int from)
{
int i;
int found = -1;
if (uistat.current_trace == -1)
if (uistat.current_trace == TRACE_INVALID)
return -1;
float value = actual_t[from];
@ -3580,7 +3580,7 @@ marker_search_right_max(int from)
int i;
int found = -1;
if (uistat.current_trace == -1)
if (uistat.current_trace == TRACE_INVALID)
return -1;
float value = actual_t[from];
for (i = from + 1; i < sweep_points; i++) {
@ -3626,7 +3626,7 @@ marker_search_left_min(int from)
{
int i;
int found = from;
if (uistat.current_trace == -1)
if (uistat.current_trace == TRACE_INVALID)
return -1;
int value_x10 = actual_t[from]*10;
@ -3656,7 +3656,7 @@ marker_search_right_min(int from)
int i;
int found = from;
if (uistat.current_trace == -1)
if (uistat.current_trace == TRACE_INVALID)
return -1;
int value_x10 = actual_t[from]*10;
for (i = from + 1; i < sweep_points; i++) {
@ -3701,80 +3701,84 @@ enum {
#define CAL_LEVEL -25
#endif
// TODO made more compact this structure (need use aligned data)
typedef struct test_case {
int kind;
int setup;
uint8_t kind;
uint8_t setup;
int16_t width;
float center; // In MHz
float span; // In MHz
float pass;
int width;
float stop;
} test_case_t;
// Use this data parser for init structure data
#define TEST_CASE_STRUCT(Condition, Preparation, Center, Span, Pass, Width, Stop) {Condition, Preparation, Width, Center, Span, Pass, Stop}
const test_case_t test_case [] =
#ifdef TINYSA4
{// Condition Preparation Center Span Pass Width(%)Stop
{TC_BELOW, TP_SILENT, 0.005, 0.01, 0, 0, 0}, // 1 Zero Hz leakage
{TC_BELOW, TP_SILENT, 0.015, 0.01, -30, 0, 0}, // 2 Phase noise of zero Hz
{TC_SIGNAL, TP_30MHZ, 30, 7, -30, 10, -90 }, // 3
{TC_SIGNAL, TP_30MHZ, 60, 7, -70, 10, -90 }, // 4
{// Condition Preparation Center Span Pass Width(%)Stop
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.005, 0.01, 0, 0, 0), // 1 Zero Hz leakage
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.015, 0.01, -30, 0, 0), // 2 Phase noise of zero Hz
TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ, 30, 7, -30, 10, -90), // 3
TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ, 60, 7, -70, 10, -90), // 4
#define TEST_SILENCE 4
{TC_BELOW, TP_SILENT, 200, 100, -75, 0, 0}, // 5 Wide band noise floor low mode
{TC_BELOW, TPH_SILENT, 600, 720, -75, 0, 0}, // 6 Wide band noise floor high mode
{TC_SIGNAL, TP_10MHZEXTRA, 30, 14, -20, 27, -80 }, // 7 BPF loss and stop band
{TC_FLAT, TP_10MHZEXTRA, 30, 14, -18, 9, -60}, // 8 BPF pass band flatness
{TC_BELOW, TP_30MHZ, 400, 60, -75, 0, -75}, // 9 LPF cutoff
{TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60 }, // 10 Switch isolation using high attenuation
{TC_DISPLAY, TP_30MHZ, 30, 0, -25, 145, -60 }, // 11 Measure atten step accuracy
{TC_ATTEN, TP_30MHZ, 30, 0, CAL_LEVEL, 145, -60 }, // 12 Measure atten step accuracy
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 200, 100, -75, 0, 0), // 5 Wide band noise floor low mode
TEST_CASE_STRUCT(TC_BELOW, TPH_SILENT, 600, 720, -75, 0, 0), // 6 Wide band noise floor high mode
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZEXTRA, 30, 14, -20, 27, -80), // 7 BPF loss and stop band
TEST_CASE_STRUCT(TC_FLAT, TP_10MHZEXTRA, 30, 14, -18, 9, -60), // 8 BPF pass band flatness
TEST_CASE_STRUCT(TC_BELOW, TP_30MHZ, 400, 60, -75, 0, -75), // 9 LPF cutoff
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60), // 10 Switch isolation using high attenuation
TEST_CASE_STRUCT(TC_DISPLAY, TP_30MHZ, 30, 0, -25, 145, -60), // 11 Measure atten step accuracy
TEST_CASE_STRUCT(TC_ATTEN, TP_30MHZ, 30, 0, CAL_LEVEL, 145, -60), // 12 Measure atten step accuracy
#define TEST_END 12
{TC_END, 0, 0, 0, 0, 0, 0},
TEST_CASE_STRUCT(TC_END, 0, 0, 0, 0, 0, 0),
#define TEST_POWER 13
{TC_MEASURE, TP_30MHZ, 30, 7, CAL_LEVEL, 10, -55 }, // 12 Measure power level and noise
{TC_MEASURE, TP_30MHZ, 270, 4, -50, 10, -75 }, // 13 Measure powerlevel and noise
{TC_MEASURE, TPH_30MHZ, 270, 4, -40, 10, -65 }, // 14 Calibrate power high mode
{TC_END, 0, 0, 0, 0, 0, 0},
TEST_CASE_STRUCT(TC_MEASURE, TP_30MHZ, 30, 7, CAL_LEVEL, 10, -55), // 12 Measure power level and noise
TEST_CASE_STRUCT(TC_MEASURE, TP_30MHZ, 270, 4, -50, 10, -75), // 13 Measure powerlevel and noise
TEST_CASE_STRUCT(TC_MEASURE, TPH_30MHZ, 270, 4, -40, 10, -65), // 14 Calibrate power high mode
TEST_CASE_STRUCT(TC_END, 0, 0, 0, 0, 0, 0),
#define TEST_RBW 17
{TC_MEASURE, TP_30MHZ, 30, 1, CAL_LEVEL, 10, -60 }, // 16 Measure RBW step time
{TC_END, 0, 0, 0, 0, 0, 0},
{TC_MEASURE, TPH_30MHZ, 300, 4, -48, 10, -65 }, // 14 Calibrate power high mode
{TC_MEASURE, TPH_30MHZ_SWITCH,300, 4, -40, 10, -65 }, // 14 Calibrate power high mode
TEST_CASE_STRUCT(TC_MEASURE, TP_30MHZ, 30, 1, CAL_LEVEL, 10, -60), // 16 Measure RBW step time
TEST_CASE_STRUCT(TC_END, 0, 0, 0, 0, 0, 0),
TEST_CASE_STRUCT(TC_MEASURE, TPH_30MHZ, 300, 4, -48, 10, -65), // 14 Calibrate power high mode
TEST_CASE_STRUCT(TC_MEASURE, TPH_30MHZ_SWITCH,300, 4, -40, 10, -65), // 14 Calibrate power high mode
#define TEST_ATTEN 21
{TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60 }, // 20 Measure atten step accuracy
TEST_CASE_STRUCT(TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60), // 20 Measure atten step accuracy
#define TEST_SPUR 22
{TC_BELOW, TP_SILENT, 144, 8, -95, 0, 0 }, // 22 Measure 48MHz spur
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 144, 8, -95, 0, 0), // 22 Measure 48MHz spur
};
#else
{// Condition Preparation Center Span Pass Width(%)Stop
{TC_BELOW, TP_SILENT, 0.005, 0.01, 0, 0, 0}, // 1 Zero Hz leakage
{TC_BELOW, TP_SILENT, 0.015, 0.01, -30, 0, 0}, // 2 Phase noise of zero Hz
{TC_SIGNAL, TP_10MHZ, 20, 7, -39, 10, -90 }, // 3
{TC_SIGNAL, TP_10MHZ, 30, 7, -34, 10, -90 }, // 4
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.005, 0.01, 0, 0, 0), // 1 Zero Hz leakage
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.015, 0.01, -30, 0, 0), // 2 Phase noise of zero Hz
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZ, 20, 7, -39, 10, -90), // 3
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZ, 30, 7, -34, 10, -90), // 4
#define TEST_SILENCE 4
{TC_BELOW, TP_SILENT, 200, 100, -75, 0, 0}, // 5 Wide band noise floor low mode
{TC_BELOW, TPH_SILENT, 600, 720, -75, 0, 0}, // 6 Wide band noise floor high mode
{TC_SIGNAL, TP_10MHZEXTRA, 10, 7, -20, 27, -80 }, // 7 BPF loss and stop band
{TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 9, -60}, // 8 BPF pass band flatness
{TC_BELOW, TP_30MHZ, 400, 60, -75, 0, -75}, // 9 LPF cutoff
{TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60 }, // 10 Switch isolation using high attenuation
{TC_DISPLAY, TP_30MHZ, 30, 0, -25, 145, -60 }, // 11 Measure atten step accuracy
{TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60 }, // 12 Measure atten step accuracy
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 200, 100, -75, 0, 0), // 5 Wide band noise floor low mode
TEST_CASE_STRUCT(TC_BELOW, TPH_SILENT, 600, 720, -75, 0, 0), // 6 Wide band noise floor high mode
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZEXTRA, 10, 7, -20, 27, -80), // 7 BPF loss and stop band
TEST_CASE_STRUCT(TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 9, -60), // 8 BPF pass band flatness
TEST_CASE_STRUCT(TC_BELOW, TP_30MHZ, 400, 60, -75, 0, -75), // 9 LPF cutoff
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60), // 10 Switch isolation using high attenuation
TEST_CASE_STRUCT(TC_DISPLAY, TP_30MHZ, 30, 0, -25, 145, -60), // 11 Measure atten step accuracy
TEST_CASE_STRUCT(TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60), // 12 Measure atten step accuracy
#define TEST_END 12
{TC_END, 0, 0, 0, 0, 0, 0},
TEST_CASE_STRUCT(TC_END, 0, 0, 0, 0, 0, 0),
#define TEST_POWER 13
{TC_MEASURE, TP_30MHZ, 30, 7, -25, 10, -55 }, // 12 Measure power level and noise
{TC_MEASURE, TP_30MHZ, 270, 4, -50, 10, -75 }, // 13 Measure powerlevel and noise
{TC_MEASURE, TPH_30MHZ, 270, 4, -40, 10, -65 }, // 14 Calibrate power high mode
{TC_END, 0, 0, 0, 0, 0, 0},
TEST_CASE_STRUCT(TC_MEASURE, TP_30MHZ, 30, 7, -25, 10, -55), // 12 Measure power level and noise
TEST_CASE_STRUCT(TC_MEASURE, TP_30MHZ, 270, 4, -50, 10, -75), // 13 Measure powerlevel and noise
TEST_CASE_STRUCT(TC_MEASURE, TPH_30MHZ, 270, 4, -40, 10, -65), // 14 Calibrate power high mode
TEST_CASE_STRUCT(TC_END, 0, 0, 0, 0, 0, 0),
#define TEST_RBW 17
{TC_MEASURE, TP_30MHZ, 30, 1, -20, 10, -60 }, // 16 Measure RBW step time
{TC_END, 0, 0, 0, 0, 0, 0},
{TC_MEASURE, TPH_30MHZ, 300, 4, -48, 10, -65 }, // 14 Calibrate power high mode
{TC_MEASURE, TPH_30MHZ_SWITCH,300, 4, -40, 10, -65 }, // 14 Calibrate power high mode
TEST_CASE_STRUCT(TC_MEASURE, TP_30MHZ, 30, 1, -20, 10, -60), // 16 Measure RBW step time
TEST_CASE_STRUCT(TC_END, 0, 0, 0, 0, 0, 0),
TEST_CASE_STRUCT(TC_MEASURE, TPH_30MHZ, 300, 4, -48, 10, -65), // 14 Calibrate power high mode
TEST_CASE_STRUCT(TC_MEASURE, TPH_30MHZ_SWITCH,300, 4, -40, 10, -65), // 14 Calibrate power high mode
#define TEST_ATTEN 21
{TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60 }, // 20 Measure atten step accuracy
TEST_CASE_STRUCT(TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60), // 20 Measure atten step accuracy
#define TEST_SPUR 22
{TC_BELOW, TP_SILENT, 96, 8, -95, 0, 0 }, // 22 Measure 48MHz spur
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 96, 8, -95, 0, 0), // 22 Measure 48MHz spur
};
#endif

136
ui.c

@ -66,7 +66,7 @@ static uint32_t last_button_repeat_ticks;
volatile uint8_t operation_requested = OP_NONE;
int8_t previous_marker = -1;
int8_t previous_marker = MARKER_INVALID;
enum {
UI_NORMAL, UI_MENU, UI_KEYPAD
@ -81,7 +81,6 @@ enum {
#define NUMINPUT_LEN 10
static uint8_t ui_mode = UI_NORMAL;
static uint8_t keypad_mode;
static uint8_t keypads_last_index;
static char kp_buf[NUMINPUT_LEN+1];
static int8_t kp_index = 0;
static char *kp_help_text = NULL;
@ -858,7 +857,7 @@ static UI_FUNCTION_CALLBACK(menu_marker_op_cb)
break;
case 3: /* MARKERS->SPAN */
{
if (previous_marker == -1 || active_marker == previous_marker) {
if (previous_marker == MARKER_INVALID || active_marker == previous_marker) {
// if only 1 marker is active, keep center freq and make span the marker comes to the edge
freq_t center = get_sweep_frequency(ST_CENTER);
freq_t span = center > freq ? center - freq : freq - center;
@ -905,7 +904,7 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
{
(void)item;
int i = -1;
if (active_marker == -1)
if (active_marker == MARKER_INVALID)
return;
markers[active_marker].mtype &= ~M_TRACKING;
switch (data) {
@ -915,13 +914,6 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
case 1: /* search right */
i = marker_search_right_min(markers[active_marker].index);
break;
#if 0
case 0: /* maximum */
case 1: /* minimum */
set_marker_search(data);
i = marker_search();
break;
#endif
case 2: /* search Left */
i = marker_search_left_max(markers[active_marker].index);
break;
@ -939,7 +931,6 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
else
markers[active_marker].frequency = frequencies[i];
}
draw_menu();
redraw_marker(active_marker);
// if (data == 4)
select_lever_mode(LM_MARKER); // Allow any position with level
@ -950,13 +941,12 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
static UI_FUNCTION_ADV_CALLBACK(menu_marker_tracking_acb){
(void)item;
(void)data;
if (active_marker == -1) return;
if (active_marker == MARKER_INVALID) return;
if(b){
b->icon = markers[active_marker].mtype & M_TRACKING ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK;
return;
}
markers[active_marker].mtype ^= M_TRACKING;
draw_menu();
}
#ifdef __VNA__
@ -975,8 +965,8 @@ active_marker_select(int item) // used only to select an active marker from the
{
if (item == -1) {
active_marker = previous_marker;
previous_marker = -1;
if (active_marker == -1) {
previous_marker = MARKER_INVALID;
if (active_marker == MARKER_INVALID) {
choose_active_marker();
}
} else {
@ -1292,8 +1282,6 @@ menu_move_back(void)
redraw_request |= REDRAW_AREA | REDRAW_FREQUENCY | REDRAW_CAL_STATUS | REDRAW_BATTERY;
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
}
draw_menu();
}
static void
@ -1328,7 +1316,6 @@ menu_push_submenu(const menuitem_t *submenu)
// request_to_redraw_grid();
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
}
draw_menu();
}
void
@ -1415,6 +1402,9 @@ menu_invoke(int item)
redraw_request |= REDRAW_CAL_STATUS;
break;
}
// Redraw menu after if UI in menu mode
if (ui_mode == UI_MENU)
draw_menu();
}
#ifdef __VNA__
@ -1604,11 +1594,10 @@ draw_numeric_input(const char *buf)
{
int i;
int x;
int focused = FALSE;
uint16_t xsim = 0b0010010000000000;
uint16_t fg = LCD_INPUT_TEXT_COLOR;
uint16_t bg = LCD_INPUT_BG_COLOR;
ili9341_set_foreground(LCD_INPUT_TEXT_COLOR);
ili9341_set_background(LCD_INPUT_BG_COLOR);
for (i = 0, x = 64; i < 10 && buf[i]; i++, xsim<<=1) {
int c = buf[i];
if (c == '.')
@ -1618,23 +1607,16 @@ draw_numeric_input(const char *buf)
else// if (c >= '0' && c <= '9')
c = c - '0';
ili9341_set_foreground(fg);
ili9341_set_background(bg);
if (c >= 0) // c is number
ili9341_drawfont(c, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4);
else if (focused) // c not number, but focused
ili9341_drawfont(0, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4);
else // erase
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_WIDTH+2+8);
break;
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
}
// erase last
// ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color);
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, LCD_WIDTH-x-1, NUM_FONT_GET_WIDTH+2+8);
if (buf[0] == 0 && kp_help_text != NULL) {
ili9341_set_foreground(fg);
ili9341_set_background(bg);
int lines = menu_is_multiline(kp_help_text);
ili9341_drawstring_7x13(kp_help_text, 64+NUM_FONT_GET_WIDTH+2, LCD_HEIGHT-(lines*bFONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
}
@ -2154,13 +2136,11 @@ nogo:
static void
menu_apply_touch(void)
menu_apply_touch(int touch_x, int touch_y)
{
int touch_x, touch_y;
const menuitem_t *menu = menu_stack[menu_current_level];
int i;
int y = 0;
touch_position(&touch_x, &touch_y);
for (i = 0; i < MENU_BUTTON_MAX; i++) {
if (menuDisabled(menu[i].type)) //not applicable to mode
continue;
@ -2391,7 +2371,7 @@ lever_move_marker(int status)
}
status = btn_wait_release();
} while (status != 0);
if (active_marker >= 0)
if (active_marker != MARKER_INVALID)
redraw_marker(active_marker);
}
@ -2399,7 +2379,7 @@ static void
lever_search_marker(int status)
{
int i = -1;
if (active_marker >= 0) {
if (active_marker != MARKER_INVALID) {
if (status & EVT_DOWN)
i = marker_search_left_max(markers[active_marker].index);
else if (status & EVT_UP)
@ -2776,51 +2756,52 @@ drag_marker(int t, int m)
}
static int
touch_pickup_marker(void)
touch_pickup_marker(int touch_x, int touch_y)
{
int touch_x, touch_y;
int m, t;
touch_position(&touch_x, &touch_y);
touch_x -= OFFSETX;
touch_y -= OFFSETY;
for (m = 0; m < MARKERS_MAX; m++) {
if (!markers[m].enabled)
int i = MARKER_INVALID, mt;
int min_dist = MARKER_PICKUP_DISTANCE * MARKER_PICKUP_DISTANCE;
// Search closest marker to touch position
for (t = 0; t < TRACES_MAX; t++) {
if (!trace[t].enabled)
continue;
for (t = 0; t < TRACES_MAX; t++) {
int x, y;
if (!trace[t].enabled)
for (m = 0; m < MARKERS_MAX; m++) {
if (!markers[m].enabled)
continue;
marker_position(m, t, &x, &y);
x -= touch_x;
y -= touch_y;
if ((x * x + y * y) < 20 * 20) {
if (active_marker != m) {
previous_marker = active_marker;
active_marker = m;
redraw_marker(active_marker);
}
// select trace
uistat.current_trace = t;
select_lever_mode(LM_MARKER);
markers[m].mtype &= ~M_TRACKING; // Disable tracking when dragging marker
// drag marker until release
drag_marker(t, m);
return TRUE;
// Get distance to marker from touch point
int dist = distance_to_index(t, markers[m].index, touch_x, touch_y);
if (dist < min_dist) {
min_dist = dist;
i = m;
mt = t;
}
}
}
return FALSE;
// Marker not found
if (i == MARKER_INVALID)
return FALSE;
// Marker found, set as active and start drag it
if (active_marker != i) {
previous_marker = active_marker;
active_marker = i;
}
// Disable tracking
markers[i].mtype &= ~M_TRACKING; // Disable tracking when dragging marker
// Leveler mode = marker move
select_lever_mode(LM_MARKER);
// select trace
uistat.current_trace = mt;
// drag marker until release
drag_marker(mt, i);
return TRUE;
}
static int touch_quick_menu(void)
static int touch_quick_menu(int touch_x, int touch_y)
{
int touch_x, touch_y;
touch_position(&touch_x, &touch_y);
if (ui_mode != UI_KEYPAD && touch_x <OFFSETX)
if (touch_x <OFFSETX)
{
touch_wait_release();
return invoke_quick_menu(touch_y);
@ -2829,10 +2810,8 @@ static int touch_quick_menu(void)
}
static int
touch_lever_mode_select(void)
touch_lever_mode_select(int touch_x, int touch_y)
{
int touch_x, touch_y;
touch_position(&touch_x, &touch_y);
if (touch_y > HEIGHT) {
if (touch_x < FREQUENCIES_XPOS2 -50 && uistat.lever_mode == LM_CENTER) {
touch_wait_release();
@ -2885,11 +2864,9 @@ touch_lever_mode_select(void)
}
static int
touch_marker_select(void)
touch_marker_select(int touch_x, int touch_y)
{
int selected_marker = 0;
int touch_x, touch_y;
touch_position(&touch_x, &touch_y);
if (current_menu_is_form() || touch_x > LCD_WIDTH-MENU_BUTTON_WIDTH || touch_x < 25 || touch_y > 30)
return FALSE;
if (touch_y > 15)
@ -2933,20 +2910,21 @@ void ui_process_touch(void)
{
// awd_count++;
adc_stop();
int touch_x, touch_y;
int status = touch_check();
if (status == EVT_TOUCH_PRESSED || status == EVT_TOUCH_DOWN) {
touch_position(&touch_x, &touch_y);
switch (ui_mode) {
case UI_NORMAL:
if (touch_quick_menu())
if (touch_quick_menu(touch_x, touch_y))
break;
// Try drag marker
if (touch_pickup_marker())
if (touch_pickup_marker(touch_x, touch_y))
break;
if (touch_marker_select())
if (touch_marker_select(touch_x, touch_y))
break;
// Try select lever mode (top and bottom screen)
if (touch_lever_mode_select()) {
if (touch_lever_mode_select(touch_x, touch_y)) {
// touch_wait_release();
break;
}
@ -2958,7 +2936,7 @@ void ui_process_touch(void)
ui_mode_menu();
break;
case UI_MENU:
menu_apply_touch();
menu_apply_touch(touch_x, touch_y);
break;
}
}

@ -563,10 +563,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_load_preset_acb)
if (caldata_recall(data) == -1) {
if (data == 0)
reset_settings(setting.mode); // Restore factory defaults
else {
draw_menu();
return;
}
}
menu_move_back_and_leave_ui();
}
@ -623,7 +619,6 @@ static UI_FUNCTION_CALLBACK(menu_calibrate_cb)
break;
case 2:
reset_calibration();
draw_menu();
break;
}
}
@ -652,13 +647,11 @@ static UI_FUNCTION_CALLBACK(menu_config_cb)
touch_cal_exec();
redraw_frame();
request_to_redraw_grid();
draw_menu();
break;
case CONFIG_MENUITEM_TOUCH_TEST:
touch_draw_test();
redraw_frame();
request_to_redraw_grid();
draw_menu();
break;
case CONFIG_MENUITEM_SELFTEST:
sweep_mode = 0; // Suspend sweep to save time
@ -671,7 +664,6 @@ static UI_FUNCTION_CALLBACK(menu_config_cb)
show_version();
redraw_frame();
request_to_redraw_grid();
draw_menu();
}
}
@ -1148,13 +1140,12 @@ static UI_FUNCTION_ADV_CALLBACK(menu_marker_select_acb)
active_marker_select(data-1);
menu_push_submenu(menu_marker_modify);
redraw_marker(active_marker);
draw_menu();
}
static UI_FUNCTION_ADV_CALLBACK(menu_marker_modify_acb)
{
(void)item;
if (active_marker == -1) return;
if (active_marker == MARKER_INVALID) return;
if(b){
if (markers[active_marker].enabled == M_ENABLED) {
b->icon = BUTTON_ICON_NOCHECK;
@ -1188,7 +1179,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_marker_modify_acb)
markmap_all_markers();
// redraw_marker(active_marker, TRUE);
// menu_move_back();
draw_menu();
}
static UI_FUNCTION_CALLBACK(menu_marker_delete_cb)
@ -1277,7 +1267,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_trigger_acb)
// menu_move_back();
ui_mode_normal();
}
draw_menu();
completed = true;
}
@ -1303,7 +1292,7 @@ static void choose_active_marker(void)
active_marker = i;
return;
}
active_marker = -1;
active_marker = MARKER_INVALID;
}
#ifdef __HARMONIC__
@ -1315,7 +1304,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_harmonic_acb)
return;
}
set_harmonic(data);
draw_menu();
}
#endif
@ -1335,7 +1323,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_agc_acb){
return;
}
toggle_AGC();
draw_menu();
}
static UI_FUNCTION_ADV_CALLBACK(menu_settings_lna_acb){
@ -1349,7 +1336,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_lna_acb){
return;
}
toggle_LNA();
draw_menu();
}
static UI_FUNCTION_ADV_CALLBACK(menu_settings_bpf_acb){
@ -1360,7 +1346,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_bpf_acb){
return;
}
toggle_tracking();
draw_menu();
}
#ifdef __HAM_BAND__
@ -1372,7 +1357,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_ham_bands){
return;
}
toggle_hambands();
draw_menu();
}
#endif
@ -1387,7 +1371,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_below_if_acb){
return;
}
toggle_below_IF();
draw_menu();
}
#ifdef TINYSA4
@ -1402,7 +1385,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_ultra_acb){
return;
}
toggle_ultra();
draw_menu();
}
#endif
@ -1414,7 +1396,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_lo_output_acb){
return;
}
toggle_tracking_output();
draw_menu();
}
static UI_FUNCTION_ADV_CALLBACK(menu_pause_acb)
@ -1428,7 +1409,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_pause_acb)
toggle_sweep();
// menu_move_back();
// ui_mode_normal();
draw_menu();
// draw_cal_status();
}
@ -1444,7 +1424,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_send_display_acb)
auto_capture = ! auto_capture;
// menu_move_back();
// ui_mode_normal();
draw_menu();
// draw_cal_status();
}
#endif
@ -1458,7 +1437,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_outputmode_acb)
return;
}
toggle_mute();
draw_menu();
}
#ifdef TINYSA4
@ -1474,7 +1452,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_points_acb){
return;
}
set_sweep_points(points_setting[data]);
draw_menu();
}
#ifdef __USE_SERIAL_CONSOLE__
@ -1488,7 +1465,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_serial_speed_acb)
}
config._serial_speed = data;
shell_update_speed();
draw_menu();
}
static UI_FUNCTION_ADV_CALLBACK(menu_connection_acb)
@ -1501,7 +1477,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_connection_acb)
config._mode&=~_MODE_CONNECTION_MASK;
config._mode|=data;
shell_reset_console();
draw_menu();
}
#endif
// ===[MENU DEFINITION]=========================================================

Loading…
Cancel
Save

Powered by TurnKey Linux.