Merge branch 'master' of https://github.com/erikkaashoek/tinySA into DiSlord_test_branch

pull/4/head
DiSlord 6 years ago
commit 84ba285694

@ -5,7 +5,9 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -Og -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage USE_OPT = -Og -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage -fsingle-precision-constant
# -Wdouble-promotion
# USE_OPT = -O2 -fno-inline-small-functions -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 endif

@ -167,6 +167,7 @@ static THD_FUNCTION(Thread1, arg)
} }
continue; continue;
} }
// START_PROFILE
// Process UI inputs // Process UI inputs
if (!(sweep_mode & SWEEP_SELFTEST)) if (!(sweep_mode & SWEEP_SELFTEST))
ui_process(); ui_process();
@ -191,7 +192,9 @@ static THD_FUNCTION(Thread1, arg)
// plot trace and other indications as raster // plot trace and other indications as raster
draw_all(completed); // flush markmap only if scan completed to prevent draw_all(completed); // flush markmap only if scan completed to prevent
// remaining traces // remaining traces
// STOP_PROFILE
} }
} }
int int

@ -609,6 +609,7 @@ typedef struct setting
int8_t unit; int8_t unit;
float offset; float offset;
float trigger_level; float trigger_level;
int trigger_direction;
int trigger; int trigger;
int linearity_step; int linearity_step;
float level; float level;
@ -901,6 +902,6 @@ enum {
}; };
enum { enum {
T_AUTO, T_NORMAL, T_SINGLE, T_DONE T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN
}; };
/*EOF*/ /*EOF*/

@ -23,6 +23,11 @@
#include "chprintf.h" #include "chprintf.h"
#include "nanovna.h" #include "nanovna.h"
#pragma GCC push_options
// #pragma GCC optimize ("O2") // Makes the code just a bit faster, disable during debugging.
#ifdef __SCROLL__ #ifdef __SCROLL__
uint16_t _grid_y = NOSCROLL_GRIDY; uint16_t _grid_y = NOSCROLL_GRIDY;
int waterfall = false; int waterfall = false;
@ -454,6 +459,10 @@ draw_on_strut(int v0, int d, int color)
} }
#endif #endif
#define SQRT_50 ((float)7.0710678118654)
#define LOG_10_SQRT_50 ((float)0.84948500216800)
#define POW_30_20 ((float) 0.215443469)
#define POW_SQRT 1.5234153789
/* /*
* calculate log10(abs(gamma)) * calculate log10(abs(gamma))
*/ */
@ -463,13 +472,16 @@ value(const float v)
switch(setting.unit) switch(setting.unit)
{ {
case U_DBMV: case U_DBMV:
return v + 30.0 + 20.0*log10(sqrt(50)); // return v + 30.0 + 20.0*log10(sqrt(50));
return v + 30.0 + 20.0*LOG_10_SQRT_50; //TODO convert constants to single float number as GCC compiler does runtime calculation
break; break;
case U_DBUV: case U_DBUV:
return v + 90.0 + 20.0*log10(sqrt(50.0)); // return v + 90.0 + 20.0*log10(sqrt(50.0)); //TODO convert constants to single float number as GCC compiler does runtime calculation
return v + 90.0 + 20.0*LOG_10_SQRT_50;
break; break;
case U_VOLT: case U_VOLT:
return pow(10, (v-30.0)/20.0) * sqrt(50.0); return pow(10, (v-30.0)/20.0) * sqrt(50.0);
// return pow(10, v/20.0) * POW_SQRT; //TODO there is an error in this calculation as the outcome is different from the not optimized version
break; break;
case U_WATT: case U_WATT:
return pow(10, v/10.0)/1000.0; return pow(10, v/10.0)/1000.0;
@ -1370,6 +1382,7 @@ void
plot_into_index(measurement_t measured) plot_into_index(measurement_t measured)
{ {
int t, i; int t, i;
// START_PROFILE
for (t = 0; t < TRACES_MAX; t++) { for (t = 0; t < TRACES_MAX; t++) {
if (!trace[t].enabled) if (!trace[t].enabled)
continue; continue;
@ -1378,6 +1391,7 @@ plot_into_index(measurement_t measured)
for (i = 0; i < sweep_points; i++) for (i = 0; i < sweep_points; i++)
index[i] = trace_into_index(t, i, measured[ch]); index[i] = trace_into_index(t, i, measured[ch]);
} }
// STOP_PROFILE
#if 0 #if 0
for (t = 0; t < TRACES_MAX; t++) for (t = 0; t < TRACES_MAX; t++)
if (trace[t].enabled && trace[t].polar) if (trace[t].enabled && trace[t].polar)
@ -2295,3 +2309,6 @@ plot_init(void)
{ {
force_set_markmap(); force_set_markmap();
} }
#pragma GCC pop_options

@ -96,6 +96,7 @@ void reset_settings(int m)
setting.auto_IF = true; setting.auto_IF = true;
setting.offset = 0.0; setting.offset = 0.0;
setting.trigger = T_AUTO; setting.trigger = T_AUTO;
setting.trigger_direction = T_UP;
setting.level_sweep = 0.0; setting.level_sweep = 0.0;
setting.level = -15.0; setting.level = -15.0;
setting.trigger_level = -150.0; setting.trigger_level = -150.0;
@ -753,9 +754,13 @@ void set_trigger_level(float trigger_level)
void set_trigger(int trigger) void set_trigger(int trigger)
{ {
setting.trigger = trigger; if (trigger == T_UP || trigger == T_DOWN){
redraw_request |= REDRAW_TRIGGER; setting.trigger_direction = trigger;
sweep_mode = SWEEP_ENABLE; } else {
setting.trigger = trigger;
redraw_request |= REDRAW_TRIGGER;
sweep_mode = SWEEP_ENABLE;
}
dirty = true; dirty = true;
} }
@ -1552,8 +1557,9 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M
data_level = subRSSI < setting.trigger_level ? T_LEVEL_BELOW : T_LEVEL_ABOVE; data_level = subRSSI < setting.trigger_level ? T_LEVEL_BELOW : T_LEVEL_ABOVE;
// wait for rising edge // wait for rising edge
if (!(prev_data_level == T_LEVEL_BELOW && if (setting.trigger_direction == T_UP && !(prev_data_level == T_LEVEL_BELOW && data_level == T_LEVEL_ABOVE)) // trigger level change
data_level == T_LEVEL_ABOVE)) // trigger level change goto wait; // get next rssi
if (setting.trigger_direction == T_DOWN && !(prev_data_level == T_LEVEL_ABOVE && data_level == T_LEVEL_BELOW)) // trigger level change
goto wait; // get next rssi goto wait; // get next rssi
#ifdef __FAST_SWEEP__ #ifdef __FAST_SWEEP__
if (setting.spur == 0 && old_SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { if (setting.spur == 0 && old_SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {

@ -1498,10 +1498,12 @@ static const menuitem_t menu_unit[] =
}; };
static const menuitem_t menu_trigger[] = { static const menuitem_t menu_trigger[] = {
{ MT_CALLBACK,T_AUTO, "AUTO", menu_trigger_cb}, { MT_CALLBACK,T_AUTO, "AUTO", menu_trigger_cb},
{ MT_CALLBACK,T_NORMAL, "NORMAL", menu_trigger_cb}, { MT_CALLBACK,T_NORMAL, "NORMAL", menu_trigger_cb},
{ MT_CALLBACK,T_SINGLE, "SINGLE", menu_trigger_cb}, { MT_CALLBACK,T_SINGLE, "SINGLE", menu_trigger_cb},
{ MT_KEYPAD, KM_TRIGGER, "LEVEL", NULL}, { MT_KEYPAD, KM_TRIGGER, "LEVEL", NULL},
{ MT_CALLBACK,T_UP, "UP", menu_trigger_cb},
{ MT_CALLBACK,T_DOWN, "DOWN", menu_trigger_cb},
{ MT_CANCEL, 0, "\032 BACK",NULL }, { MT_CANCEL, 0, "\032 BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1666,6 +1668,9 @@ static void menu_item_modify_attribute(
if (data == setting.trigger){ if (data == setting.trigger){
mark = true; mark = true;
} }
if (data == setting.trigger_direction) {
mark = true;
}
} else if (menu == menu_display /* || menu == menu_displayhigh */) { } else if (menu == menu_display /* || menu == menu_displayhigh */) {
if (item ==0 && is_paused()){ if (item ==0 && is_paused()){
mark = true; mark = true;

Loading…
Cancel
Save

Powered by TurnKey Linux.