From 85c8b5c893b863224bc2d84547d13f553c9ef3dc Mon Sep 17 00:00:00 2001 From: TT Date: Fri, 18 Oct 2019 00:03:13 +0900 Subject: [PATCH 1/4] fixed: update interpolation status on changing sweep freq from serial #84 --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 86e3055..2f46cb3 100644 --- a/main.c +++ b/main.c @@ -1325,6 +1325,7 @@ cal_interpolate(int s) } cal_status |= src->_cal_status | CALSTAT_APPLY | CALSTAT_INTERPOLATED; + redraw_request |= REDRAW_CAL_STATUS; } static void cmd_cal(BaseSequentialStream *chp, int argc, char *argv[]) From 87c6e64a2564b250626d2c4620afaffdace51a14 Mon Sep 17 00:00:00 2001 From: TT Date: Thu, 17 Oct 2019 23:49:40 +0900 Subject: [PATCH 2/4] fixed: fix resetting sweep range #83 --- python/nanovna.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/nanovna.py b/python/nanovna.py index 8ec3526..f98387d 100755 --- a/python/nanovna.py +++ b/python/nanovna.py @@ -36,7 +36,6 @@ class NanoVNA: self.filter = None # bandpassfilter_5khz self._frequencies = None self.points = 101 - self.set_sweep(1e6, 900e6) @property def frequencies(self): @@ -228,10 +227,12 @@ class NanoVNA: def logmag(self, x): pl.grid(True) + pl.xlim(self.frequencies[0], self.frequencies[-1]) pl.plot(self.frequencies, 20*np.log10(np.abs(x))) def linmag(self, x): pl.grid(True) + pl.xlim(self.frequencies[0], self.frequencies[-1]) pl.plot(self.frequencies, np.abs(x)) def phase(self, x, unwrap=False): @@ -241,21 +242,25 @@ class NanoVNA: a = np.unwrap(a) else: pl.ylim((-180,180)) + pl.xlim(self.frequencies[0], self.frequencies[-1]) pl.plot(self.frequencies, np.rad2deg(a)) def delay(self, x): pl.grid(True) delay = -np.unwrap(np.angle(x))/ (2*np.pi*np.array(self.frequencies)) + pl.xlim(self.frequencies[0], self.frequencies[-1]) pl.plot(self.frequencies, delay) def groupdelay(self, x): pl.grid(True) gd = np.convolve(np.unwrap(np.angle(x)), [1,-1], mode='same') + pl.xlim(self.frequencies[0], self.frequencies[-1]) pl.plot(self.frequencies, gd) def vswr(self, x): pl.grid(True) vswr = (1+np.abs(x))/(1-np.abs(x)) + pl.xlim(self.frequencies[0], self.frequencies[-1]) pl.plot(self.frequencies, vswr) def polar(self, x): @@ -426,7 +431,9 @@ if __name__ == '__main__': else: if opt.start or opt.stop: nv.set_sweep(opt.start, opt.stop) + nv.fetch_frequencies() s = nv.data(p) + nv.fetch_frequencies() if opt.smith: nv.smith(s) if opt.polar: From 65a07a7a274c02a13083015d3b948c8c0f18d034 Mon Sep 17 00:00:00 2001 From: TT Date: Fri, 18 Oct 2019 00:46:12 +0900 Subject: [PATCH 3/4] feat: show second marker position on time domain (fixed #85) --- plot.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/plot.c b/plot.c index 3fc6041..cd86255 100644 --- a/plot.c +++ b/plot.c @@ -1445,15 +1445,18 @@ cell_draw_marker_info(int m, int n, int w, int h) xpos -= m * CELLWIDTH -CELLOFFSETX; ypos -= n * CELLHEIGHT; chsnprintf(buf, sizeof buf, "%d:", active_marker + 1); + xpos += 5; cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); - xpos += 16; + xpos += 14; if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { - frequency_string(buf, sizeof buf, frequencies[idx]); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + frequency_string(buf, sizeof buf, frequencies[idx]); } else { - chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9), distance_of_index(idx)); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + //chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9), distance_of_index(idx)); + int n = string_value_with_prefix(buf, sizeof buf, time_of_index(idx), 's'); + buf[n++] = ' '; + string_value_with_prefix(&buf[n], sizeof buf-n, distance_of_index(idx), 'm'); } + cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); // draw marker delta if (previous_marker >= 0 && active_marker != previous_marker && markers[previous_marker].enabled) { @@ -1463,8 +1466,16 @@ cell_draw_marker_info(int m, int n, int w, int h) ypos += 7; chsnprintf(buf, sizeof buf, "\001%d:", previous_marker+1); cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); - xpos += 16; - frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]); + xpos += 19; + if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { + frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]); + } else { + //chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9 - time_of_index(idx0) * 1e9), + // distance_of_index(idx) - distance_of_index(idx0)); + int n = string_value_with_prefix(buf, sizeof buf, time_of_index(idx) - time_of_index(idx0), 's'); + buf[n++] = ' '; + string_value_with_prefix(&buf[n], sizeof buf - n, distance_of_index(idx) - distance_of_index(idx0), 'm'); + } cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); } } From 512d3c9523b10bfb36f3446b5bef0f35ab970825 Mon Sep 17 00:00:00 2001 From: TT Date: Fri, 18 Oct 2019 00:47:47 +0900 Subject: [PATCH 4/4] feat: reduce flash size by preventing inline function --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 908caff..e4b905b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ # Compiler options here. ifeq ($(USE_OPT),) - USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage + USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage endif # C specific options here (added to USE_OPT).