Merge branch 'levermode'

This commit is contained in:
TT 2020-02-23 00:09:28 +09:00
commit f581317d68
5 changed files with 71 additions and 21 deletions

View file

@ -493,7 +493,7 @@ const uint8_t x5x7_bits[127*7] =
|** | |** |
|* | |* |
+--------+ */ +--------+ */
0b10000000|CHAR5x7_WIDTH_5px, 0b10000000|CHAR5x7_WIDTH_4px,
0b11000000, 0b11000000,
0b11100000, 0b11100000,
0b11110000, 0b11110000,
@ -645,7 +645,7 @@ const uint8_t x5x7_bits[127*7] =
| | | |
| | | |
+--------+ */ +--------+ */
0b00000000|CHAR5x7_WIDTH_3px, 0b00000000|CHAR5x7_WIDTH_4px,
0b00000000, 0b00000000,
0b00000000, 0b00000000,
0b00000000, 0b00000000,

4
main.c
View file

@ -944,9 +944,9 @@ set_sweep_frequency(int type, uint32_t freq)
break; break;
case ST_CENTER: case ST_CENTER:
freq_mode_centerspan(); freq_mode_centerspan();
uint32_t center = frequency0/2 + frequency1/2; uint32_t center = FREQ_CENTER();
if (center != freq) { if (center != freq) {
uint32_t span = frequency0 - frequency1; uint32_t span = FREQ_SPAN();
ensure_edit_config(); ensure_edit_config();
if (freq < START_MIN + span/2) { if (freq < START_MIN + span/2) {
span = (freq - START_MIN) * 2; span = (freq - START_MIN) * 2;

View file

@ -378,6 +378,14 @@ extern properties_t current_props;
#define velocity_factor current_props._velocity_factor #define velocity_factor current_props._velocity_factor
#define marker_smith_format current_props._marker_smith_format #define marker_smith_format current_props._marker_smith_format
#define FREQ_IS_STARTSTOP() (frequency0 < frequency1)
#define FREQ_IS_CENTERSPAN() (frequency0 > frequency1)
#define FREQ_IS_CW() (frequency0 == frequency1)
#define FREQ_START() (frequency0)
#define FREQ_STOP() (frequency1)
#define FREQ_CENTER() (frequency0/2 + frequency1/2)
#define FREQ_SPAN() (frequency0 - frequency1)
int caldata_save(int id); int caldata_save(int id);
int caldata_recall(int id); int caldata_recall(int id);
const properties_t *caldata_ref(int id); const properties_t *caldata_ref(int id);

14
plot.c
View file

@ -610,7 +610,7 @@ trace_get_value_string(int t, char *buf, int len, float array[POINTS_COUNT][2],
v = logmag(coeff); v = logmag(coeff);
break; break;
case TRC_PHASE: case TRC_PHASE:
format = "%.3f"S_DEGREE; format = "%.1f"S_DEGREE;
v = phase(coeff); v = phase(coeff);
break; break;
case TRC_DELAY: case TRC_DELAY:
@ -1402,7 +1402,9 @@ draw_all_cells(bool flush_markmap)
void void
draw_all(bool flush) draw_all(bool flush)
{ {
if (redraw_request & REDRAW_CELLS) if (redraw_request & REDRAW_MARKER)
markmap_upperarea();
if (redraw_request & (REDRAW_CELLS | REDRAW_MARKER))
draw_all_cells(flush); draw_all_cells(flush);
if (redraw_request & REDRAW_FREQUENCY) if (redraw_request & REDRAW_FREQUENCY)
draw_frequencies(); draw_frequencies();
@ -1610,12 +1612,12 @@ draw_frequencies(void)
char buf1[32]; char buf1[32];
char buf2[32];buf2[0]=0; char buf2[32];buf2[0]=0;
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
if (frequency0 < frequency1) { if (FREQ_IS_STARTSTOP()) {
chsnprintf(buf1, sizeof(buf1), " START %qHz", frequency0); chsnprintf(buf1, sizeof(buf1), " START %qHz", frequency0);
chsnprintf(buf2, sizeof(buf2), " STOP %qHz", frequency1); chsnprintf(buf2, sizeof(buf2), " STOP %qHz", frequency1);
} else if (frequency0 > frequency1) { } else if (FREQ_IS_CENTERSPAN()) {
chsnprintf(buf1, sizeof(buf1), " CENTER %qHz", frequency0/2 + frequency1/2); chsnprintf(buf1, sizeof(buf1), " CENTER %qHz", FREQ_CENTER());
chsnprintf(buf2, sizeof(buf2), " SPAN %qHz", frequency0 - frequency1); chsnprintf(buf2, sizeof(buf2), " SPAN %qHz", FREQ_SPAN());
} else { } else {
chsnprintf(buf1, sizeof(buf1), " CW %qHz", frequency0); chsnprintf(buf1, sizeof(buf1), " CW %qHz", frequency0);
} }

62
ui.c
View file

@ -442,6 +442,15 @@ enter_dfu(void)
NVIC_SystemReset(); NVIC_SystemReset();
} }
static void
select_lever_mode(int mode)
{
if (uistat.lever_mode != mode) {
uistat.lever_mode = mode;
redraw_request |= REDRAW_FREQUENCY | REDRAW_MARKER;
}
}
// type of menu item // type of menu item
enum { enum {
MT_NONE, MT_NONE,
@ -624,7 +633,7 @@ menu_transform_cb(int item, uint8_t data)
(void)item; (void)item;
(void)data; (void)data;
domain_mode ^= DOMAIN_TIME; domain_mode ^= DOMAIN_TIME;
uistat.lever_mode = LM_MARKER; select_lever_mode(LM_MARKER);
draw_frequencies(); draw_frequencies();
ui_mode_normal(); ui_mode_normal();
} }
@ -691,7 +700,6 @@ menu_stimulus_cb(int item, uint8_t data)
case 2: /* CENTER */ case 2: /* CENTER */
case 3: /* SPAN */ case 3: /* SPAN */
case 4: /* CW */ case 4: /* CW */
uistat.lever_mode = item == 3 ? LM_SPAN : LM_CENTER;
status = btn_wait_release(); status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) { if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(item); ui_mode_numeric(item);
@ -802,7 +810,7 @@ menu_marker_search_cb(int item, uint8_t data)
} }
draw_menu(); draw_menu();
redraw_marker(active_marker, TRUE); redraw_marker(active_marker, TRUE);
uistat.lever_mode = LM_SEARCH; select_lever_mode(LM_SEARCH);
} }
static void static void
@ -859,7 +867,6 @@ menu_marker_sel_cb(int item, uint8_t data)
} }
redraw_marker(active_marker, TRUE); redraw_marker(active_marker, TRUE);
draw_menu(); draw_menu();
uistat.lever_mode = LM_MARKER;
} }
static const menuitem_t menu_calop[] = { static const menuitem_t menu_calop[] = {
@ -1737,15 +1744,15 @@ lever_zoom_span(int status)
} }
static void static void
lever_move_center(int status) lever_move(int status, int mode)
{ {
uint32_t center = get_sweep_frequency(ST_CENTER); uint32_t center = get_sweep_frequency(mode);
uint32_t span = get_sweep_frequency(ST_SPAN); uint32_t span = get_sweep_frequency(ST_SPAN);
span = step_round(span / 3); span = step_round(span / 3);
if (status & EVT_UP) { if (status & EVT_UP) {
set_sweep_frequency(ST_CENTER, center + span); set_sweep_frequency(mode, center + span);
} else if (status & EVT_DOWN) { } else if (status & EVT_DOWN) {
set_sweep_frequency(ST_CENTER, center - span); set_sweep_frequency(mode, center - span);
} }
} }
@ -1760,8 +1767,15 @@ ui_process_normal(void)
switch (uistat.lever_mode) { switch (uistat.lever_mode) {
case LM_MARKER: lever_move_marker(status); break; case LM_MARKER: lever_move_marker(status); break;
case LM_SEARCH: lever_search_marker(status); break; case LM_SEARCH: lever_search_marker(status); break;
case LM_CENTER: lever_move_center(status); break; case LM_CENTER:
case LM_SPAN: lever_zoom_span(status); break; lever_move(status, FREQ_IS_STARTSTOP() ? ST_START : ST_CENTER);
break;
case LM_SPAN:
if (FREQ_IS_STARTSTOP())
lever_move(status, ST_STOP);
else
lever_zoom_span(status);
break;
} }
} }
} }
@ -2115,7 +2129,8 @@ touch_pickup_marker(void)
} }
// select trace // select trace
uistat.current_trace = t; uistat.current_trace = t;
select_lever_mode(LM_MARKER);
// drag marker until release // drag marker until release
drag_marker(t, m); drag_marker(t, m);
return TRUE; return TRUE;
@ -2126,6 +2141,27 @@ touch_pickup_marker(void)
return FALSE; return FALSE;
} }
static int
touch_lever_mode_select(void)
{
int touch_x, touch_y;
touch_position(&touch_x, &touch_y);
if (touch_y > HEIGHT) {
if (touch_x < 160) {
select_lever_mode(LM_CENTER);
} else {
select_lever_mode(LM_SPAN);
}
return TRUE;
}
if (touch_y < 15) {
select_lever_mode(LM_MARKER);
return TRUE;
}
return FALSE;
}
static static
void ui_process_touch(void) void ui_process_touch(void)
@ -2140,6 +2176,10 @@ void ui_process_touch(void)
if (touch_pickup_marker()) { if (touch_pickup_marker()) {
break; break;
} else if (touch_lever_mode_select()) {
draw_all(FALSE);
touch_wait_release();
break;
} }
touch_wait_release(); touch_wait_release();