From 0aeadaa213e16c60e3044fd4cccb45fe60551714 Mon Sep 17 00:00:00 2001 From: TT Date: Sun, 29 Sep 2019 11:19:20 +0900 Subject: [PATCH 1/5] fix: #52. Previous fix 4e2036b was incomplete. --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index a9adaf0..52cb0a6 100644 --- a/main.c +++ b/main.c @@ -758,8 +758,10 @@ set_frequencies(uint32_t start, uint32_t stop, int16_t points) { int i; float span = stop - start; - for (i = 0; i < points; i++) - frequencies[i] = start + i * span / (float)(points - 1); + for (i = 0; i < points; i++) { + float offset = i * span / (float)(points - 1); + frequencies[i] = start + (uint32_t)offset; + } // disable at out of sweep range for (; i < sweep_points; i++) frequencies[i] = 0; From ea1c74240a18fe4d1dd94f2088d67875af23caba Mon Sep 17 00:00:00 2001 From: TT Date: Sat, 28 Sep 2019 23:20:14 +0900 Subject: [PATCH 2/5] fix: update display in pause --- main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 52cb0a6..1132ca0 100644 --- a/main.c +++ b/main.c @@ -74,10 +74,8 @@ static THD_FUNCTION(Thread1, arg) chMtxLock(&mutex); ui_process(); - chMtxUnlock(&mutex); if (sweep_enabled) { - chMtxLock(&mutex); if (vbat != -1) { adc_stop(ADC1); vbat = adc_vbat_read(ADC1); @@ -90,12 +88,11 @@ static THD_FUNCTION(Thread1, arg) plot_into_index(measured); redraw_request |= REDRAW_CELLS; } - - /* plot trace and other indications as raster */ - draw_all(completed); // flush markmap only if scan completed to prevent remaining traces - - chMtxUnlock(&mutex); } + + /* plot trace and other indications as raster */ + draw_all(completed); // flush markmap only if scan completed to prevent remaining traces + chMtxUnlock(&mutex); } } From 65a36fbf9195b8c479959bfe4a4c93b8a04f9786 Mon Sep 17 00:00:00 2001 From: TT Date: Sun, 29 Sep 2019 06:42:45 +0900 Subject: [PATCH 3/5] feat: from clicking trace menu, change active, but not make disable --- ui.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui.c b/ui.c index bc4acd0..d3948fa 100644 --- a/ui.c +++ b/ui.c @@ -587,15 +587,17 @@ menu_trace_cb(int item) if (item < 0 || item >= 4) return; if (trace[item].enabled) { - trace[item].enabled = FALSE; - choose_active_trace(); + if (item == uistat.current_trace) { + // disable if active trace is selected + trace[item].enabled = FALSE; + choose_active_trace(); + } else { + // make active selected trace + uistat.current_trace = item; + } } else { trace[item].enabled = TRUE; uistat.current_trace = item; - //menu_move_back(); - //request_to_redraw_grid(); - //ui_mode_normal(); - //redraw_all(); } request_to_redraw_grid(); draw_menu(); From 0f24a6bd7f6fb9cb3a26fb87e213efcc29889b9a Mon Sep 17 00:00:00 2001 From: TT Date: Sun, 29 Sep 2019 07:01:23 +0900 Subject: [PATCH 4/5] feat: select active on marker menu, disable if the item is active --- ui.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/ui.c b/ui.c index d3948fa..8cccb6d 100644 --- a/ui.c +++ b/ui.c @@ -834,15 +834,38 @@ menu_marker_op_cb(int item) //redraw_all(); } +void +active_marker_select(int item) +{ + if (item == -1) { + active_marker = previous_marker; + previous_marker = -1; + if (active_marker == -1) { + choose_active_marker(); + } + } else { + if (previous_marker != active_marker) + previous_marker = active_marker; + active_marker = item; + } +} + static void menu_marker_sel_cb(int item) { if (item >= 0 && item < 4) { - // enable specified marker - markers[item].enabled = TRUE; - if (previous_marker != active_marker) - previous_marker = active_marker; - active_marker = item; + if (markers[item].enabled) { + if (item == active_marker) { + // disable if active trace is selected + markers[item].enabled = FALSE; + active_marker_select(-1); + } else { + active_marker_select(item); + } + } else { + markers[item].enabled = TRUE; + active_marker_select(item); + } } else if (item == 4) { /* all off */ markers[0].enabled = FALSE; markers[1].enabled = FALSE; @@ -851,10 +874,8 @@ menu_marker_sel_cb(int item) previous_marker = -1; active_marker = -1; } - if (active_marker >= 0) - redraw_marker(active_marker, TRUE); + redraw_marker(active_marker, TRUE); draw_menu(); - //ui_mode_normal(); } const menuitem_t menu_calop[] = { From 30d33571fa3929ff697bf410d3b7f25145cc6e45 Mon Sep 17 00:00:00 2001 From: TT Date: Sun, 29 Sep 2019 13:19:42 +0900 Subject: [PATCH 5/5] fixed: freeze on touching in boot #57 --- plot.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plot.c b/plot.c index 18f4dbb..ad43241 100644 --- a/plot.c +++ b/plot.c @@ -942,11 +942,15 @@ search_index_range_x(int x, uint32_t index[101], int *i0, int *i1) i = (head + tail) / 2; if (x == CELL_X0(index[i])) break; - - if (x < CELL_X0(index[i])) - tail = i+1; - else + else if (x < CELL_X0(index[i])) { + if (tail == i+1) + break; + tail = i+1; + } else { + if (head == i) + break; head = i; + } } if (x != CELL_X0(index[i]))