Added trigger cmd and level cmd in high output mode

pull/4/head
erikkaashoek 6 years ago
parent 3db1738e0b
commit 7d259443ab

@ -452,9 +452,15 @@ calculate:
c = *p++ - '0';
// c = to_upper(*p) - 'A' + 10
if (c >= 'A' - '0') c = (c&(~0x20)) - ('A' - '0') + 10;
if (c >= radix) return value;
if (c >= radix) break;
value = value * radix + c;
}
switch (*(--p)) {
case 'k': value *= 1000; break;
case 'M': value *= 1000000; break;
case 'G': value *= 1000000000; break;
}
return value;
}
double
@ -2277,6 +2283,7 @@ static const VNAShellCommand commands[] =
{"recall" , cmd_recall , CMD_WAIT_MUTEX},
#endif
{"trace" , cmd_trace , 0},
{"trigger" , cmd_trigger , 0},
{"marker" , cmd_marker , 0},
#ifdef __VNA__
{"edelay" , cmd_edelay , 0},
@ -2562,7 +2569,7 @@ int mySerialReadline(unsigned char *buf, int len)
// Main thread stack size defined in makefile USE_PROCESS_STACKSIZE = 0x200
// Profile stack usage (enable threads command by def ENABLE_THREADS_COMMAND) show:
// Stack maximum usage = 472 bytes (need test more and run all commands), free stack = 40 bytes
//
int main(void)
{
halInit();

@ -138,7 +138,10 @@ VNA_SHELL_FUNCTION(cmd_attenuate)
VNA_SHELL_FUNCTION(cmd_level)
{
if (argc != 1) {
if (setting.mode==M_GENLOW)
shell_printf("usage: level -76..-6\r\n");
if (setting.mode==M_GENHIGH)
shell_printf("usage: level -38..13\r\n");
return;
}
float f = my_atof(argv[0]);
@ -222,6 +225,37 @@ VNA_SHELL_FUNCTION(cmd_if)
}
VNA_SHELL_FUNCTION(cmd_trigger)
{
if (argc == 0)
goto usage;
if (( '0' <= argv[0][0] && argv[0][0] <= '9') || argv[0][0] == '-') {
float t = my_atof(argv[0]);
if (setting.trigger == T_AUTO )
set_trigger(T_NORMAL);
set_trigger_level(t);
goto update;
}
static const char cmd_trigger_list[] = "auto|normal|single";
if (argc == 1) {
int type = get_str_index(argv[0], cmd_trigger_list);
if (type >= 0) {
set_trigger(type);
goto update;
}
goto usage;
}
update:
redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA;
completed = true;
return;
usage:
shell_printf("trigger {value}\r\n"\
"trigger {%s}\r\n" , cmd_trigger_list);
}
VNA_SHELL_FUNCTION(cmd_v)
@ -339,8 +373,9 @@ VNA_SHELL_FUNCTION(cmd_d)
{
(void) argc;
(void) argv;
// int32_t a = my_atoi(argv[0]);
// setting.drive = a;
int32_t a = my_atoi(argv[0]);
setting.drive=a;
dirty = true;
}

@ -38,8 +38,22 @@ int const reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 20000
int in_selftest = false;
const char *dummy = "this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available\
this is a very long string only used to fill memory so I know when the memory is full and I can remove some of this string to make more memory available"
;
void reset_settings(int m)
{
strcpy((char *)spi_buffer, dummy);
setting.mode = m;
setting.unit_scale_index = 0;
setting.unit_scale = 1;
@ -301,10 +315,21 @@ float get_attenuation(void)
return(setting.attenuate);
}
static const int drive_dBm [16] = {-38,-35,-33,-30,-27,-24,-21,-19,-7,-4,-2, 1, 4, 7, 10, 13};
void set_level(float v)
{
if (setting.mode == M_GENHIGH) {
int d = 0;
while (drive_dBm[d] < v - 1 && d < 16)
d++;
if (d == 8 && v < -12) // Round towards closest level
d = 7;
set_drive(d);
} else {
setting.level = v;
set_attenuation((int)v);
}
dirty = true;
}
@ -424,8 +449,10 @@ void set_RBW(int v)
}
#ifdef __SPUR__
void SetSpur(int v)
void set_spur(int v)
{
if (setting.mode!=M_LOW)
return;
setting.spur = v;
if (setting.spur && actual_rbw > 360)
set_RBW(300);

@ -742,9 +742,9 @@ static void menu_spur_cb(int item, uint8_t data)
(void)data;
(void)item;
if (setting.spur)
SetSpur(0);
set_spur(0);
else
SetSpur(1); // must be 0 or 1 !!!!
set_spur(1); // must be 0 or 1 !!!!
// menu_move_back();
ui_mode_normal();
redraw_request |= REDRAW_CAL_STATUS;

Loading…
Cancel
Save

Powered by TurnKey Linux.