diff --git a/Font5x7.c b/Font5x7.c index 0a3a828..a69bcc7 100644 --- a/Font5x7.c +++ b/Font5x7.c @@ -493,7 +493,7 @@ const uint8_t x5x7_bits[127*7] = |** | |* | +--------+ */ - 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000|CHAR5x7_WIDTH_4px, 0b11000000, 0b11100000, 0b11110000, @@ -645,7 +645,7 @@ const uint8_t x5x7_bits[127*7] = | | | | +--------+ */ - 0b00000000|CHAR5x7_WIDTH_3px, + 0b00000000|CHAR5x7_WIDTH_4px, 0b00000000, 0b00000000, 0b00000000, diff --git a/main.c b/main.c index 1a06fa7..c9c7e83 100644 --- a/main.c +++ b/main.c @@ -944,9 +944,9 @@ set_sweep_frequency(int type, uint32_t freq) break; case ST_CENTER: freq_mode_centerspan(); - uint32_t center = frequency0/2 + frequency1/2; + uint32_t center = FREQ_CENTER(); if (center != freq) { - uint32_t span = frequency0 - frequency1; + uint32_t span = FREQ_SPAN(); ensure_edit_config(); if (freq < START_MIN + span/2) { span = (freq - START_MIN) * 2; diff --git a/nanovna.h b/nanovna.h index 7df26ec..17add41 100644 --- a/nanovna.h +++ b/nanovna.h @@ -378,6 +378,14 @@ extern properties_t current_props; #define velocity_factor current_props._velocity_factor #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_recall(int id); const properties_t *caldata_ref(int id); diff --git a/plot.c b/plot.c index 3b89dbd..eb3de6d 100644 --- a/plot.c +++ b/plot.c @@ -610,7 +610,7 @@ trace_get_value_string(int t, char *buf, int len, float array[POINTS_COUNT][2], v = logmag(coeff); break; case TRC_PHASE: - format = "%.3f"S_DEGREE; + format = "%.1f"S_DEGREE; v = phase(coeff); break; case TRC_DELAY: @@ -1402,7 +1402,9 @@ draw_all_cells(bool flush_markmap) void 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); if (redraw_request & REDRAW_FREQUENCY) draw_frequencies(); @@ -1610,12 +1612,12 @@ draw_frequencies(void) char buf1[32]; char buf2[32];buf2[0]=0; if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { - if (frequency0 < frequency1) { + if (FREQ_IS_STARTSTOP()) { chsnprintf(buf1, sizeof(buf1), " START %qHz", frequency0); chsnprintf(buf2, sizeof(buf2), " STOP %qHz", frequency1); - } else if (frequency0 > frequency1) { - chsnprintf(buf1, sizeof(buf1), " CENTER %qHz", frequency0/2 + frequency1/2); - chsnprintf(buf2, sizeof(buf2), " SPAN %qHz", frequency0 - frequency1); + } else if (FREQ_IS_CENTERSPAN()) { + chsnprintf(buf1, sizeof(buf1), " CENTER %qHz", FREQ_CENTER()); + chsnprintf(buf2, sizeof(buf2), " SPAN %qHz", FREQ_SPAN()); } else { chsnprintf(buf1, sizeof(buf1), " CW %qHz", frequency0); } diff --git a/ui.c b/ui.c index 1753607..232a5b6 100644 --- a/ui.c +++ b/ui.c @@ -442,6 +442,15 @@ enter_dfu(void) 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 enum { MT_NONE, @@ -624,7 +633,7 @@ menu_transform_cb(int item, uint8_t data) (void)item; (void)data; domain_mode ^= DOMAIN_TIME; - uistat.lever_mode = LM_MARKER; + select_lever_mode(LM_MARKER); draw_frequencies(); ui_mode_normal(); } @@ -691,7 +700,6 @@ menu_stimulus_cb(int item, uint8_t data) case 2: /* CENTER */ case 3: /* SPAN */ case 4: /* CW */ - uistat.lever_mode = item == 3 ? LM_SPAN : LM_CENTER; status = btn_wait_release(); if (status & EVT_BUTTON_DOWN_LONG) { ui_mode_numeric(item); @@ -802,7 +810,7 @@ menu_marker_search_cb(int item, uint8_t data) } draw_menu(); redraw_marker(active_marker, TRUE); - uistat.lever_mode = LM_SEARCH; + select_lever_mode(LM_SEARCH); } static void @@ -859,7 +867,6 @@ menu_marker_sel_cb(int item, uint8_t data) } redraw_marker(active_marker, TRUE); draw_menu(); - uistat.lever_mode = LM_MARKER; } static const menuitem_t menu_calop[] = { @@ -1737,15 +1744,15 @@ lever_zoom_span(int status) } 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); span = step_round(span / 3); if (status & EVT_UP) { - set_sweep_frequency(ST_CENTER, center + span); + set_sweep_frequency(mode, center + span); } 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) { case LM_MARKER: lever_move_marker(status); break; case LM_SEARCH: lever_search_marker(status); break; - case LM_CENTER: lever_move_center(status); break; - case LM_SPAN: lever_zoom_span(status); break; + case LM_CENTER: + 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 uistat.current_trace = t; - + select_lever_mode(LM_MARKER); + // drag marker until release drag_marker(t, m); return TRUE; @@ -2126,6 +2141,27 @@ touch_pickup_marker(void) 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 void ui_process_touch(void) @@ -2140,6 +2176,10 @@ void ui_process_touch(void) if (touch_pickup_marker()) { break; + } else if (touch_lever_mode_select()) { + draw_all(FALSE); + touch_wait_release(); + break; } touch_wait_release();