UI errors corrected and some code squeeze

tinySA-v0.2
erikkaashoek 6 years ago
parent 27313d4ea9
commit 76bb2d59dc

@ -2304,7 +2304,9 @@ static const VNAShellCommand commands[] =
{ "spur", cmd_spur, 0 },
{ "load", cmd_load, 0 },
{ "selftest", cmd_selftest, 0 },
#ifdef __ULTRA_SA__
{ "x", cmd_x, 0 },
#endif
{ "y", cmd_y, 0 },
{ "i", cmd_i, 0 },
{ "v", cmd_v, 0 },

@ -5,54 +5,49 @@ byte SI4432_Read_Byte( byte ADR );
int VFO = 0;
int points = 101; // For 's' and 'm' commands
VNA_SHELL_FUNCTION(cmd_mode)
{
static const char cmd_low_high[] = "low|high";
static const char cmd_in_out[] = "input|output";
if (argc != 2) {
usage:
shell_printf("usage: mode low|high input|output\r\n");
shell_printf("usage: mode %s %s\r\n", cmd_low_high,cmd_in_out);
return;
}
if (strcmp(argv[0],"low") == 0) {
if (strcmp(argv[1],"input") == 0)
set_mode(M_LOW);
else if(strcmp(argv[1],"output") == 0)
set_mode(M_GENLOW);
else
goto usage;
} else if (strcmp(argv[0],"high") == 0) {
if (strcmp(argv[1],"input") == 0)
set_mode(M_HIGH);
else if(strcmp(argv[1],"output") == 0)
set_mode(M_GENHIGH);
else
goto usage;
} else
int lh = get_str_index(argv[0], cmd_low_high);
int io = get_str_index(argv[1], cmd_in_out);
if (lh<0 || io<0)
goto usage;
switch(lh+io*2)
{
case 0:
set_mode(M_LOW);
break;
case 1:
set_mode(M_HIGH);
break;
case 2:
set_mode(M_GENLOW);
break;
case 3:
set_mode(M_GENHIGH);
break;
}
}
VNA_SHELL_FUNCTION(cmd_modulation )
{
static const char cmd_mod[] = "off|AM_1kHz|AM_10Hz|NFM|WFM|extern";
if (argc != 1) {
usage:
shell_printf("usage: modulation off|AM_1kHz|AM_10Hz|NFM|WFM|extern\r\n");
shell_printf("usage: modulation %s\r\n", cmd_mod);
return;
}
int m = MO_NONE;
if (strcmp(argv[0],"off") == 0) {
} else if (strcmp(argv[0],"AM_1kHz") == 0) {
m = MO_AM_1kHz;
} else if (strcmp(argv[0],"AM_10Hz") == 0) {
m = MO_AM_10Hz;
} else if (strcmp(argv[0],"NFM") == 0) {
m = MO_NFM;
} else if (strcmp(argv[0],"WFM") == 0) {
m = MO_WFM;
} else if (strcmp(argv[0],"extern") == 0) {
m = MO_EXTERNAL;
} else
goto usage;
set_modulation(m);
static const int cmd_mod_val[] = { MO_NONE, MO_AM_1kHz, MO_AM_10Hz, MO_NFM, MO_WFM, MO_EXTERNAL};
int m = get_str_index(argv[1], cmd_mod);
if (m<0)
goto usage;
set_modulation(cmd_mod_val[m]);
}
VNA_SHELL_FUNCTION(cmd_spur)
@ -140,7 +135,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
goto usage;
} else {
usage:
shell_printf("leveloffset [low|high <offset>]\r\n");
shell_printf("leveloffset [low|high] [<offset>]\r\n");
}
}
@ -166,7 +161,7 @@ VNA_SHELL_FUNCTION(cmd_if)
{
if (argc != 1) {
usage:
shell_printf("usage: if {freq}\r\n");
shell_printf("usage: if {433M..435M}\r\n");
return;
} else {
int a = my_atoi(argv[0]);
@ -240,7 +235,7 @@ VNA_SHELL_FUNCTION(cmd_selftest)
sweep_mode = SWEEP_SELFTEST;
}
#ifdef __ULTRA_SA__
VNA_SHELL_FUNCTION(cmd_x)
{
uint32_t reg;
@ -260,11 +255,11 @@ VNA_SHELL_FUNCTION(cmd_x)
reg &= ~0xc00000; // Force led to show lock
reg |= 0x400000;
}
#ifdef __ULTRA_SA__
ADF4351_WriteRegister32(VFO, reg);
#endif
shell_printf("x=%x\r\n", reg);
}
#endif
VNA_SHELL_FUNCTION(cmd_i)

@ -14,7 +14,7 @@ float minFreq = 0;
float maxFreq = 520000000;
//int setting.refer = -1; // Off by default
const int reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000};
int const reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000};
int in_selftest = false;
@ -124,13 +124,13 @@ void reset_settings(int m)
float calc_min_sweep_time(void) // Calculate minimum sweep time in mS
{
float t;
float a = (actualStepDelay + MEASURE_TIME)/1000.0;
float a = (actualStepDelay + MEASURE_TIME)/1000.0; // in mS
if (MODE_OUTPUT(setting.mode))
t = 1000;
else {
if (FREQ_IS_CW())
a = (float)MINIMUM_SWEEP_TIME / 290.0; // time per step in CW mode
t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME));
t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME/1000.0));
}
return t;
}
@ -235,7 +235,7 @@ void set_modulation(int m)
void set_repeat(int r)
{
if (r > 0 && r <= 1000) {
if (r > 0 && r <= 100) {
setting.repeat = r;
dirty = true;
}
@ -556,7 +556,7 @@ void set_unit(int u)
force_set_markmap();
dirty = true;
}
const float unit_scale_value[]={1,0.001,0.000001,0.000000001,0.000000000001};
float const unit_scale_value[]={1,0.001,0.000001,0.000000001,0.000000000001};
const char * const unit_scale_text[]= {"","m", "u", "n", "p"};
void user_set_reflevel(float level)
@ -1378,7 +1378,7 @@ again:
float subRSSI;
static float correct_RSSI = 0;
if (i == 0 || setting.frequency_step != 0 )
if (i == 0 || setting.frequency_step != 0 ) // only cases where the value can change
correct_RSSI = get_level_offset()+ setting.attenuate - signal_path_loss - setting.offset + get_frequency_correction(f);
wait:
subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ;
@ -1843,8 +1843,8 @@ marker_search_right_min(int from)
// -------------------------- CAL STATUS ---------------------------------------------
const char *averageText[] = { "OFF", "MIN", "MAX", "MAXD", " A 4", "A 16"};
const char *dBText[] = { "1dB/", "2dB/", "5dB/", "10dB/", "20dB/"};
const char * const averageText[] = { "OFF", "MIN", "MAX", "MAXD", " A 4", "A 16"};
const char * const dBText[] = { "1dB/", "2dB/", "5dB/", "10dB/", "20dB/"};
const int refMHz[] = { 30, 15, 10, 4, 3, 2, 1 };
float my_round(float v)
@ -1871,7 +1871,7 @@ float my_round(float v)
return v;
}
const char *unit_string[] = { "dBm", "dBmV", "dBuV", "V", "W" };
const char * const unit_string[] = { "dBm", "dBmV", "dBuV", "V", "W" };
static const float scale_value[]={50000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01,0.005,0.002, 0.001,0.0005,0.0002, 0.0001};
static const char * const scale_vtext[]= {"50000", "20000", "10000", "5000", "2000", "1000", "500", "200", "100", "50", "20","10","5","2","1","0.5","0.2","0.1","0.05","0.02","0.01", "0.005","0.002","0.001", "0.0005","0.0002","0.0001"};
@ -1889,7 +1889,7 @@ void draw_cal_status(void)
int rounding = false;
if (!UNIT_IS_LINEAR(setting.unit))
rounding = true;
const char *unit = unit_string[setting.unit];
const char * const unit = unit_string[setting.unit];
#define XSTEP 40

@ -64,6 +64,8 @@ void shiftOut(uint8_t val)
}
}
uint8_t shiftIn(void) {
uint8_t value = 0;
uint8_t i;
@ -187,7 +189,6 @@ void SI4432_Receive(void)
// Return the first entry of the following triple for the RBW actually achieved
static const short RBW_choices[] =
{ // Each quadrupple is: ndec, fils, WISH*10, corr*10
#if 1
5,1,26,-5,
5,2,28,-5,
5,3,31,0,
@ -245,124 +246,6 @@ static const short RBW_choices[] =
0,12,5188,-20,
0,13,5770,-15,
0,14,6207,-10,
#else
5,1,26,0,
5,2,28,0,
5,3,31,0,
5,4,32,0,
5,5,37,0,
5,6,42,0,
5,7,45,-5,
4,1,49,-5,
4,2,54,-10,
4,3,59,-10,
4,4,61,-10,
4,5,72,-10,
4,6,82,-5,
4,7,88,0,
3,1,95,0,
3,2,106,0,
3,3,115,-5,
3,4,121,-5,
3,5,142,-10,
3,6,162,0,
3,7,175,0,
2,1,189,0,
2,2,210,0,
2,3,227,0,
2,4,240,5,
2,5,282,-5,
2,6,322,0,
2,7,347,0,
1,1,377,0,
1,2,417,0,
1,3,452,0,
1,4,479,5,
1,5,562,0,
1,6,641,0,
1,7,692,0,
0,1,752,5,
0,2,832,5,
0,3,900,0,
0,4,953,5,
0,5,1121,0,
0,6,1279,0,
0,7,1379,0,
1,4,1428,-15,
1,5,1678,-25,
1,9,1811,50,
0,15,1915,105,
0,1,2251,-20,
0,2,2488,0,
0,3,2693,-15,
0,4,2849,-10,
0,8,3355,20,
0,9,3618,55,
0,10,4202,20,
0,11,4684,20,
0,12,5188,25,
0,13,5770,15,
0,14,6207,15,
#endif
#if 0
5,1,26,0,
5,2,28,0,
5,3,31,0,
5,4,32,0,
5,5,37,0,
5,6,42,10,
5,7,45,10,
4,1,49,10,
4,2,54,10,
4,3,59,10,
4,4,61,10,
4,5,72,10,
4,6,82,10,
4,7,88,10,
3,1,95,10,
3,2,106,5,
3,3,115,0,
3,4,121,0,
3,5,142,0,
3,6,162,10,
3,7,175,10,
2,1,189,10,
2,2,210,10,
2,3,227,10,
2,4,240,10,
2,5,282,5,
2,6,322,10,
2,7,347,10,
1,1,377,10,
1,2,417,10,
1,3,452,10,
1,4,479,5,
1,5,562,10,
1,6,641,10,
1,7,692,10,
0,1,752,10,
0,2,832,10,
0,3,900,5,
0,4,953,10,
0,5,1121,10,
0,6,1279,10,
0,7,1379,5,
1,4,1428,0,
1,5,1678,-10,
1,9,1811,65,
0,15,1915,120,
0,1,2251,-5,
0,2,2488,0,
0,3,2693,-5,
0,4,2849,0,
0,8,3355,30,
0,9,3618,60,
0,10,4202,25,
0,11,4684,25,
0,12,5188,35,
0,13,5770,35,
0,14,6207,35
#endif
};
static float SI4432_RSSI_correction = -120.0;
@ -513,20 +396,24 @@ void SI4432_Sub_Init(void)
// Register 0x77 Nominal Carrier Frequency
SI4432_Write_Byte(0x77, 0x00) ;
// RX MODEM SETTINGS
SI4432_Write_Byte(0x1C, 0x81) ;
SI4432_Write_Byte(0x1D, 0x3C) ;
SI4432_Write_Byte(0x1E, 0x02) ;
SI4432_Write_3_Byte(0x1C, 0x81, 0x3C, 0x02) ;
// SI4432_Write_Byte(0x1C, 0x81) ;
// SI4432_Write_Byte(0x1D, 0x3C) ;
// SI4432_Write_Byte(0x1E, 0x02) ;
SI4432_Write_Byte(0x1F, 0x03) ;
// SI4432_Write_Byte(0x20, 0x78) ;
SI4432_Write_Byte(0x21, 0x01) ;
SI4432_Write_Byte(0x22, 0x11) ;
SI4432_Write_Byte(0x23, 0x11) ;
SI4432_Write_3_Byte(0x21, 0x01, 0x11, 0x11) ;
// SI4432_Write_Byte(0x21, 0x01) ;
// SI4432_Write_Byte(0x22, 0x11) ;
// SI4432_Write_Byte(0x23, 0x11) ;
SI4432_Write_Byte(0x24, 0x01) ;
SI4432_Write_Byte(0x25, 0x13) ;
SI4432_Write_Byte(0x2A, 0xFF) ;
SI4432_Write_Byte(0x2C, 0x28) ;
SI4432_Write_Byte(0x2D, 0x0C) ;
SI4432_Write_Byte(0x2E, 0x28) ;
SI4432_Write_3_Byte(0x2C, 0x28, 0x0c, 0x28) ;
// SI4432_Write_Byte(0x2C, 0x28) ;
// SI4432_Write_Byte(0x2D, 0x0C) ;
// SI4432_Write_Byte(0x2E, 0x28) ;
SI4432_Write_Byte(0x69, 0x60); // AGC, no LNA, fast gain increment
@ -598,7 +485,7 @@ void PE4302_init(void) {
}
#define PE4302_DELAY 100
#if 0
void PE4302_shiftOut(uint8_t val)
{
uint8_t i;
@ -616,13 +503,15 @@ void PE4302_shiftOut(uint8_t val)
// chThdSleepMicroseconds(PE4302_DELAY);
}
}
#endif
void PE4302_Write_Byte(unsigned char DATA )
{
// chThdSleepMicroseconds(PE4302_DELAY);
SPI2_CLK_LOW;
// chThdSleepMicroseconds(PE4302_DELAY);
PE4302_shiftOut(DATA);
// PE4302_shiftOut(DATA);
shiftOut(DATA);
// chThdSleepMicroseconds(PE4302_DELAY);
CS_PE_HIGH;
// chThdSleepMicroseconds(PE4302_DELAY);

@ -2325,7 +2325,7 @@ ui_process_keypad(void)
break;
}
}
kp_help_text = NULL;
redraw_frame();
if (current_menu_is_form()) {
ui_mode_menu(); //Reactivate menu after keypad

@ -446,6 +446,10 @@ static const keypads_t keypads_plusmin[] = {
{ 0, 0, -1 }
};
// 7 8 9 n
// 4 5 6 u
// 1 2 3 m
// 0 . < x
static const keypads_t keypads_time[] = {
{ 1, 3, KP_PERIOD },
{ 0, 3, 0 },
@ -458,9 +462,9 @@ static const keypads_t keypads_time[] = {
{ 0, 0, 7 },
{ 1, 0, 8 },
{ 2, 0, 9 },
{ 3, 1, KP_u},
{ 3, 2, KP_m},
{ 3, 3, KP_MINUS },
{ 3, 1, KP_n},
{ 3, 2, KP_u},
{ 3, 3, KP_m },
{ 2, 3, KP_BS },
{ 0, 0, -1 }
};
@ -487,7 +491,7 @@ static const keypads_t * const keypads_mode_tbl[] = {
keypads_plusmin, // KM_OFFSET
keypads_plusmin_unit, // KM_TRIGGER
keypads_plusmin, // KM_LEVELSWEEP
keypads_positive, // KM_SWEEP_TIME
keypads_time, // KM_SWEEP_TIME
};
#ifdef __VNA__

Loading…
Cancel
Save

Powered by TurnKey Linux.