Skip to content

Commit

Permalink
change keypads on scale, scale handling
Browse files Browse the repository at this point in the history
  • Loading branch information
edy555 committed Feb 3, 2017
1 parent c30a273 commit ee6f5a9
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 11 deletions.
9 changes: 9 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,15 @@ void set_trace_channel(int t, int channel)

void set_trace_scale(int t, float scale)
{
switch (trace[t].type) {
case TRC_LOGMAG:
scale /= 10;
break;
case TRC_PHASE:
scale /= 90;
break;
}

if (trace[t].scale != scale) {
trace[t].scale = scale;
force_set_markmap();
Expand Down
4 changes: 2 additions & 2 deletions plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ trace_into_index(int x, int t, int i, float coeff[2])
int y = 0;
float v = 0;
float refpos = 8 - trace[t].refpos;
float scale = trace[t].scale;
float scale = 1 / trace[t].scale;
switch (trace[t].type) {
case TRC_LOGMAG:
v = refpos - logmag(coeff) * scale;
Expand All @@ -498,7 +498,7 @@ trace_into_index(int x, int t, int i, float coeff[2])
case TRC_SMITH:
//case TRC_ADMIT:
case TRC_POLAR:
cartesian_scale(coeff[0], coeff[1], &x, &y, trace[t].scale);
cartesian_scale(coeff[0], coeff[1], &x, &y, scale);
return INDEX(x +CELLOFFSETX, y, i);
break;
}
Expand Down
58 changes: 49 additions & 9 deletions ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,15 @@ void menu_invoke(int item)
#define KP_INF 17
#define KP_DB 18

const struct {
typedef struct {
uint16_t x, y;
int8_t c;
} keypads[] = {
} keypads_t;

const keypads_t *keypads;
uint8_t keypads_last_index;

const keypads_t keypads_freq[] = {
{ KP_X(1), KP_Y(3), KP_PERIOD },
{ KP_X(0), KP_Y(3), 0 },
{ KP_X(0), KP_Y(2), 1 },
Expand All @@ -864,7 +869,39 @@ const struct {
{ KP_X(2), KP_Y(3), KP_BS },
{ 0, 0, -1 }
};
#define KEYPADS_LAST_INDEX 15

const keypads_t keypads_scale[] = {
{ KP_X(1), KP_Y(3), KP_PERIOD },
{ KP_X(0), KP_Y(3), 0 },
{ KP_X(0), KP_Y(2), 1 },
{ KP_X(1), KP_Y(2), 2 },
{ KP_X(2), KP_Y(2), 3 },
{ KP_X(0), KP_Y(1), 4 },
{ KP_X(1), KP_Y(1), 5 },
{ KP_X(2), KP_Y(1), 6 },
{ KP_X(0), KP_Y(0), 7 },
{ KP_X(1), KP_Y(0), 8 },
{ KP_X(2), KP_Y(0), 9 },
{ KP_X(3), KP_Y(3), KP_X1 },
{ KP_X(2), KP_Y(3), KP_BS },
{ 0, 0, -1 }
};

const keypads_t *keypads_mode_tbl[] = {
keypads_freq, // start
keypads_freq, // stop
keypads_freq, // center
keypads_freq, // span
keypads_freq, // cw freq
keypads_scale, // scale
keypads_scale, // respos
keypads_scale // electrical delay
};

const char *keypad_mode_label[] = {
"START", "STOP", "CENTER", "SPAN", "CW FREQ", "SCALE", "REFPOS", "EDELAY"
};


void
draw_keypad(void)
Expand All @@ -880,10 +917,6 @@ draw_keypad(void)
}
}

const char *keypad_mode_label[] = {
"START", "STOP", "CENTER", "SPAN", "CW FREQ", "SCALE", "REFPOS", "EDELAY"
};

void
draw_numeric_input(const char *buf)
{
Expand Down Expand Up @@ -1032,12 +1065,19 @@ ui_mode_keypad(int _keypad_mode)
if (ui_mode == UI_KEYPAD)
return;

// keypads array
keypad_mode = _keypad_mode;
keypads = keypads_mode_tbl[_keypad_mode];
int i;
for (i = 0; keypads[i+1].c >= 0; i++)
;
keypads_last_index = i;

ui_mode = UI_KEYPAD;
area_width = AREA_WIDTH_NORMAL - (64-8);
area_height = HEIGHT;
draw_menu();
draw_keypad();
keypad_mode = _keypad_mode;
draw_numeric_input("");
}

Expand Down Expand Up @@ -1207,7 +1247,7 @@ ui_process_keypad(void)
if (s & EVT_UP) {
selection--;
if (selection < 0)
selection = KEYPADS_LAST_INDEX;
selection = keypads_last_index;
draw_keypad();
}
if (s & EVT_DOWN) {
Expand Down

0 comments on commit ee6f5a9

Please sign in to comment.