diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index c65f2cb..7cb2221 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/chprintf.c b/chprintf.c index 3b9f66b..07f52f4 100644 --- a/chprintf.c +++ b/chprintf.c @@ -32,6 +32,10 @@ //#include "memstreams.h" #include + +#pragma GCC optimize ("Og") + + // Enable [flags], support: // ' ' Prepends a space for positive signed-numeric types. positive = ' ', negative = '-'. This flag is ignored if the + flag exists. #define CHPRINTF_USE_SPACE_FLAG @@ -164,7 +168,7 @@ ulong_freq(char *p, ulong_t freq, uint32_t width, uint32_t precision) return p; } -#if CHPRINTF_USE_FLOAT +//#if CHPRINTF_USE_FLOAT static char *ftoa(char *p, float num, uint32_t precision) { // Check precision limit if (precision > FLOAT_PRECISION) @@ -222,7 +226,26 @@ static char *ftoaS(char *p, float num, int precision) { *p++ = prefix; return p; } -#endif + +static char *etoa(char *p, float num, uint32_t precision) { + int exp = 0; + if (num == 0) { *p++ = '0'; return p; } + while (num < 10) { num *= 10.0; exp--; } + while (num > 10) { num /= 10.0; exp++; } + *p++ = ((int)num) + '0'; num *=10.0; + *p++ = '.'; + if (precision == 0) precision = 6; + while (precision--) { *p++ = (((int)num) % 10) + '0'; num *=10.0; } + *p++ = 'e'; + if (exp < 0) { *p++ = '-'; exp = -exp;} else *p++ = '+'; + *p++ = (((int)exp) / 10 ) + '0'; + *p++ = (((int)exp) % 10 ) + '0'; + return p; +} + + + +//#endif /** * @brief System formatted output function. @@ -405,9 +428,10 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) { precision = MAX_FREQ_PRESCISION; p=ulong_freq(p, value.ux, width, precision); break; -#if CHPRINTF_USE_FLOAT +//#if CHPRINTF_USE_FLOAT case 'F': case 'f': + case 'e': if (state & _32_BIT_FLOAT) value.u = va_arg(ap, uint32_t); else @@ -427,9 +451,9 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) { *p++ = 0x19; break; } - p = (c=='F') ? ftoaS(p, value.f, precision) : ftoa(p, value.f, state&DEFAULT_PRESCISION ? FLOAT_PRECISION : precision); + p = (c=='F') ? ftoaS(p, value.f, precision) : ((c=='e') ? etoa(p, value.f, precision) : ftoa(p, value.f, state&DEFAULT_PRESCISION ? FLOAT_PRECISION : precision)); break; -#endif +//#endif case 'X': case 'x': c = 16; diff --git a/flash.c b/flash.c index bc4117b..aa69d5f 100644 --- a/flash.c +++ b/flash.c @@ -237,8 +237,8 @@ caldata_recall(uint16_t id) set_reflevel(setting.reflevel); set_waterfall(); set_level_meter(); - if (setting.show_stored) - enableTracesAtComplete(TRACE_STORED_FLAG); +// if (setting.show_stored) +// enableTracesAtComplete(TRACE_STORED_FLAG); return 0; } #if 0 diff --git a/main.c b/main.c index a9ee24e..e30d297 100644 --- a/main.c +++ b/main.c @@ -739,7 +739,7 @@ VNA_SHELL_FUNCTION(cmd_data) static const uint8_t sel_conv[]={TRACE_TEMP, TRACE_STORED, TRACE_ACTUAL}; float *data = measured[sel_conv[sel]]; for (i = 0; i < sweep_points; i++) - shell_printf("%f\r\n", value(data[i])); + shell_printf("%e\r\n", value(data[i])); return; } usage: @@ -1138,9 +1138,9 @@ do_scan: if (mask) { for (i = 0; i < sweep_points; i++) { if (mask & 1) shell_printf("%U ", getFrequency(i)); - if (mask & 2) shell_printf("%f %f ", value(measured[TRACE_ACTUAL][i]), 0.0); - if (mask & 4) shell_printf("%f %f ", value(measured[TRACE_STORED][i]), 0.0); - if (mask & 8) shell_printf("%f %f ", value(measured[TRACE_TEMP][i]), 0.0); + if (mask & 2) shell_printf("%e %f ", value(measured[TRACE_ACTUAL][i]), 0.0); + if (mask & 4) shell_printf("%e %f ", value(measured[TRACE_STORED][i]), 0.0); + if (mask & 8) shell_printf("%e %f ", value(measured[TRACE_TEMP][i]), 0.0); shell_printf("\r\n"); } } @@ -1632,7 +1632,7 @@ show_one: goto usage; float v = my_atof(argv[next_arg]); measured[t][i] = v; - goto update; + return; } } goto usage; @@ -1654,7 +1654,7 @@ VNA_SHELL_FUNCTION(cmd_marker) if (argc == 0) { for (t = 0; t < MARKERS_MAX; t++) { if (markers[t].enabled) { - shell_printf("%d %d %D %.2f\r\n", t+1, markers[t].index, markers[t].frequency, marker_to_value(t)); + shell_printf("%d %d %D %.2e\r\n", t+1, markers[t].index, markers[t].frequency, marker_to_value(t)); } } return; @@ -1673,7 +1673,7 @@ VNA_SHELL_FUNCTION(cmd_marker) goto usage; if (argc == 1) { display_marker: - shell_printf("%d %d %D %.2f\r\n", t+1, markers[t].index, markers[t].frequency, marker_to_value(t)); + shell_printf("%d %d %D %.2e\r\n", t+1, markers[t].index, markers[t].frequency, marker_to_value(t)); active_marker = t; // select active marker markers[t].enabled = TRUE; diff --git a/nanovna.h b/nanovna.h index 5c8d1d2..518baa9 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" #endif @@ -26,7 +26,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 @@ -1104,7 +1104,7 @@ typedef struct setting bool auto_reflevel; // bool bool auto_attenuation; // bool bool mirror_masking; // bool - bool show_stored; // bool +// bool show_stored; // bool bool tracking_output; // bool bool mute; // bool bool auto_IF; // bool @@ -1345,7 +1345,7 @@ typedef struct properties { //sizeof(properties_t) == 0x1200 -#define CONFIG_MAGIC 0x434f4e59 /* 'CONF' */ +#define CONFIG_MAGIC 0x434f4e5A /* 'CONF' */ extern int16_t lastsaveid; //extern properties_t *active_props; diff --git a/sa_cmd.c b/sa_cmd.c index ffaff9c..215e22e 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -370,19 +370,25 @@ VNA_SHELL_FUNCTION(cmd_leveloffset) { // 0 1 2 #ifdef TINYSA4 - static const char cmd_mode_list[] = "low|high|switch|receive_switch|out_switch|lna|harmonic|shift1|shift2|shift3|drive1|drive2|drive3|direct|direct_lna|ultra|ultra_lna"; + static const char cmd_mode_list[] = "low|switch|receive_switch|out_switch|lna|harmonic|shift1|shift2|shift3|drive1|drive2|drive3|direct|direct_lna|ultra|ultra_lna"; #else static const char cmd_mode_list[] = "low|high|switch|receive_switch"; #endif if (argc == 0) { const char *p = "leveloffset %s %.1f\r\n"; +#ifdef TINYSA3 shell_printf(p, "low", config.low_level_offset); shell_printf(p, "high", config.high_level_offset); shell_printf(p, "low output", config.low_level_output_offset); shell_printf(p, "high output", config.high_level_output_offset); shell_printf(p, "switch", config.switch_offset); shell_printf(p, "receive_switch",config.receive_switch_offset); +#endif #ifdef TINYSA4 + shell_printf(p, "low", config.low_level_offset); + shell_printf(p, "low output", config.low_level_output_offset); + shell_printf(p, "switch", config.switch_offset); + shell_printf(p, "receive_switch",config.receive_switch_offset); shell_printf(p, "out_switch", config.out_switch_offset); shell_printf(p, "lna", config.lna_level_offset); shell_printf(p, "harmonic", config.harmonic_level_offset); @@ -408,24 +414,29 @@ VNA_SHELL_FUNCTION(cmd_leveloffset) if (argc == 2){ v = my_atof(argv[1]); switch (mode){ +#ifdef TINYSA3 case 0: config.low_level_offset = v; break; case 1: config.high_level_offset = v; break; case 2: config.switch_offset = v; break; case 3: config.receive_switch_offset = v; break; +#endif #ifdef TINYSA4 - case 4: config.out_switch_offset = v; break; - case 5: config.lna_level_offset = v; break; - case 6: config.harmonic_level_offset = v; break; - case 7: config.shift1_level_offset = v; break; - case 8: config.shift2_level_offset = v; break; - case 9: config.shift3_level_offset = v; break; - case 10: config.drive1_level_offset = v; break; - case 11: config.drive2_level_offset = v; break; - case 12: config.drive3_level_offset = v; break; - case 13: config.direct_level_offset = v; break; - case 14: config.direct_lna_level_offset = v; break; - case 15: config.ultra_level_offset = v; break; - case 16: config.ultra_lna_level_offset = v; break; + case 0: config.low_level_offset = v; break; + case 1: config.switch_offset = v; break; + case 2: config.receive_switch_offset = v; break; + case 3: config.out_switch_offset = v; break; + case 4: config.lna_level_offset = v; break; + case 5: config.harmonic_level_offset = v; break; + case 6: config.shift1_level_offset = v; break; + case 7: config.shift2_level_offset = v; break; + case 8: config.shift3_level_offset = v; break; + case 9: config.drive1_level_offset = v; break; + case 10: config.drive2_level_offset = v; break; + case 11: config.drive3_level_offset = v; break; + case 12: config.direct_level_offset = v; break; + case 13: config.direct_lna_level_offset = v; break; + case 14: config.ultra_level_offset = v; break; + case 15: config.ultra_lna_level_offset = v; break; #endif default: goto usage; } diff --git a/sa_core.c b/sa_core.c index ca10a88..60b1e17 100644 --- a/sa_core.c +++ b/sa_core.c @@ -588,7 +588,7 @@ void reset_settings(int m) #ifdef __DRAW_LINE__ setting.draw_line = false; #endif - setting.show_stored = 0; +// setting.show_stored = 0; setting.auto_attenuation = false; setting.normalize_level = 0.0; setting.normalized_trace = -1; @@ -1418,7 +1418,7 @@ void store_trace(int f, int t) void set_clear_storage(void) { - setting.show_stored = false; +// setting.show_stored = false; // setting.subtract = false; TRACE_DISABLE(TRACE_STORED_FLAG); // dirty = true; // No HW update required, only status panel refresh