feat: add lever mode for electrical delay

This commit is contained in:
TT 2020-03-01 09:29:28 +09:00
commit f1cc60e99e
4 changed files with 41 additions and 13 deletions

1
main.c
View file

@ -1656,6 +1656,7 @@ void set_electrical_delay(float picoseconds)
electrical_delay = picoseconds;
force_set_markmap();
}
redraw_request |= REDRAW_MARKER;
}
float get_electrical_delay(void)

View file

@ -74,7 +74,7 @@ void cal_collect(int type);
void cal_done(void);
#define MAX_FREQ_TYPE 5
enum {
enum stimulus_type {
ST_START=0, ST_STOP, ST_CENTER, ST_SPAN, ST_CW
};
@ -109,7 +109,7 @@ extern int8_t sweep_enabled;
extern void ui_init(void);
extern void ui_process(void);
enum { OP_NONE = 0, OP_LEVER, OP_TOUCH, OP_FREQCHANGE };
enum opreq { OP_NONE = 0, OP_LEVER, OP_TOUCH, OP_FREQCHANGE };
extern uint8_t operation_requested;
/*
@ -208,7 +208,7 @@ extern const uint16_t numfont16x22[];
#define TRACES_MAX 4
#define MAX_TRACE_TYPE 12
enum {
enum trace_type {
TRC_LOGMAG=0, TRC_PHASE, TRC_DELAY, TRC_SMITH, TRC_POLAR, TRC_LINEAR, TRC_SWR, TRC_REAL, TRC_IMAG, TRC_R, TRC_X, TRC_OFF
};
// Mask for define rectangular plot
@ -224,7 +224,7 @@ enum {
// Electrical Delay
// Phase
typedef struct {
typedef struct trace {
uint8_t enabled;
uint8_t type;
uint8_t channel;
@ -233,7 +233,7 @@ typedef struct {
float refpos;
} trace_t;
typedef struct {
typedef struct config {
int32_t magic;
uint16_t dac_value;
uint16_t grid_color;
@ -269,7 +269,7 @@ float groupdelay_from_array(int i, float array[POINTS_COUNT][2]);
#define MARKERS_MAX 4
typedef struct {
typedef struct marker {
int8_t enabled;
int16_t index;
uint32_t frequency;
@ -367,7 +367,7 @@ void show_logo(void);
*/
#define SAVEAREA_MAX 5
typedef struct {
typedef struct properties {
uint32_t magic;
uint32_t _frequency0;
uint32_t _frequency1;
@ -434,16 +434,16 @@ void clear_all_config_prop_data(void);
*/
// lever_mode
enum {
LM_MARKER, LM_SEARCH, LM_CENTER, LM_SPAN
enum lever_mode {
LM_MARKER, LM_SEARCH, LM_CENTER, LM_SPAN, LM_EDELAY
};
// marker smith value format
enum {
enum marker_smithvalue {
MS_LIN, MS_LOG, MS_REIM, MS_RX, MS_RLC
};
typedef struct {
typedef struct uistat {
int8_t digit; /* 0~5 */
int8_t digit_mode;
int8_t current_trace; /* 0..3 */

4
plot.c
View file

@ -1574,6 +1574,10 @@ cell_draw_marker_info(int x0, int y0)
int xpos = 21 + CELLOFFSETX - x0;
int ypos = 1 + ((j+1)/2)*(FONT_GET_HEIGHT+1) - y0;
if (uistat.lever_mode == LM_EDELAY)
cell_drawstring(S_SARROW, xpos, ypos);
xpos += 5;
float light_speed_ps = 299792458e-12; //(m/ps)
plot_printf(buf, sizeof buf, "Edelay %Fs %Fm", electrical_delay * 1e-12,
electrical_delay * light_speed_ps * velocity_factor);

23
ui.c
View file

@ -1731,6 +1731,23 @@ lever_move(int status, int mode)
}
}
#define STEPRATIO 0.2
static void
lever_edelay(int status)
{
float value = get_electrical_delay();
float ratio = STEPRATIO;
if (value < 0)
ratio = -ratio;
if (status & EVT_UP) {
value = (1 - ratio) * value;
} else if (status & EVT_DOWN) {
value = (1 + ratio) * value;
}
set_electrical_delay(value);
}
static void
ui_process_normal(void)
{
@ -1751,6 +1768,9 @@ ui_process_normal(void)
else
lever_zoom_span(status);
break;
case LM_EDELAY:
lever_edelay(status);
break;
}
}
}
@ -2120,6 +2140,9 @@ touch_lever_mode_select(void)
return TRUE;
}
if (touch_y < 15) {
if (touch_x < FREQUENCIES_XPOS2 && get_electrical_delay() != 0.0) {
select_lever_mode(LM_EDELAY);
} else
select_lever_mode(LM_MARKER);
return TRUE;
}