RSSI repeat added

tinySA-v0.2
erikkaashoek 6 years ago
parent 48ce35ea04
commit 2d63ad9aa4

@ -31,7 +31,10 @@ int setting_noise;
float actual_rbw = 0;
float setting_vbw = 0;
int setting_tracking_output;
int setting_repeat;
uint32_t setting_frequency0;
uint32_t setting_frequency1;
uint32_t setting_frequency_IF;
int setting_measurement;
int vbwSteps = 1;
@ -70,6 +73,7 @@ void reset_settings(int m)
setting_decay=20;
setting_noise=5;
setting_below_IF = false;
setting_repeat = 1;
setting_tracking_output = false;
trace[TRACE_STORED].enabled = false;
trace[TRACE_TEMP].enabled = false;
@ -136,6 +140,17 @@ void reset_settings(int m)
dirty = true;
}
void menu_load_preset_cb(int item, uint8_t data)
{
}
void menu_store_preset_cb(int item, uint8_t data)
{
}
void set_refer_output(int v)
{
setting_refer = v;
@ -196,6 +211,15 @@ void SetModulation(int m)
setting_modulation = m;
dirty = true;
}
void set_repeat(int r)
{
if (r > 0 && r < 50) {
setting_repeat = r;
dirty = true;
}
}
void SetIF(int f)
{
frequency_IF = f;
@ -485,7 +509,10 @@ void SetMode(int m)
void apply_settings(void)
{
PE4302_Write_Byte(setting_attenuate * 2);
if (setting_mode == M_HIGH)
PE4302_Write_Byte(40);
else
PE4302_Write_Byte(setting_attenuate * 2);
#if 0
if (setting_modulation == MO_NFM ) {
SI4432_Sel = 1;
@ -558,6 +585,11 @@ void SetSwitchReceive(void) {
SI4432_Write_Byte(0x0c, 0x1f);
}
void SetSwitchOff(void) {
SI4432_Write_Byte(0x0b, 0x1d);// Set both switch off
SI4432_Write_Byte(0x0c, 0x1f);
}
void SetAGCLNA(void) {
unsigned char v = 0x40;
if (setting_agc) v |= 0x20;
@ -585,7 +617,7 @@ case M_ULTRA:
if (setting_tracking_output)
SetSwitchTransmit();
else
SetSwitchReceive();
SetSwitchOff();
// SI4432_Receive(); For noise testing only
SI4432_Transmit(setting_drive);
// SI4432_SetReference(setting_refer);
@ -605,7 +637,7 @@ case M_HIGH: // Direct into 1
case M_GENLOW: // Mixed output from 0
SI4432_Sel = 0;
if (setting_step_atten) {
SetSwitchReceive();
SetSwitchOff();
} else {
SetSwitchTransmit();
}
@ -616,7 +648,7 @@ case M_GENLOW: // Mixed output from 0
SetSwitchTransmit(); // High input for external LO scuh as tracking output of other tinySA
SI4432_Receive();
} else {
SetSwitchReceive();
SetSwitchOff();
SI4432_Transmit(12); // Fix LO drive a 10dBm
}
break;
@ -627,7 +659,7 @@ case M_GENHIGH: // Direct output from 1
SI4432_Sel = 1;
if (setting_drive < 8) {
SetSwitchReceive();
SetSwitchOff();
} else {
SetSwitchTransmit();
}
@ -999,7 +1031,7 @@ again:
if (setting_mode == M_LOW)
signal_path_loss = -5.5; // Loss in dB, -9.5 for v0.1, -12.5 for v0.2
else
signal_path_loss = -3; // Loss in dB (+ is gain)
signal_path_loss = +7; // Loss in dB (+ is gain)
float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+ setting_attenuate - signal_path_loss;
#ifdef __ULTRA__
if (setting_spur == 1) { // First pass

@ -362,7 +362,7 @@ void SI4432_Set_Frequency ( long Freq ) {
}
int actualStepDelay = 1500;
extern int setting_repeat;
float SI4432_RSSI(uint32_t i, int s)
{
@ -378,7 +378,11 @@ float SI4432_RSSI(uint32_t i, int s)
//START_PROFILE
SI4432_Sel = s;
chThdSleepMicroseconds(actualStepDelay);
RSSI_RAW = (unsigned char)SI4432_Read_Byte( 0x26 ) ;
i = setting_repeat;
RSSI_RAW = 0;
while (i-->0)
RSSI_RAW += (unsigned char)SI4432_Read_Byte( 0x26 ) ;
RSSI_RAW = RSSI_RAW / setting_repeat;
// if (MODE_INPUT(setting_mode) && RSSI_RAW == 0)
// SI4432_Init();
float dBm = (RSSI_RAW-240)/2.0 - SI4432_RSSI_correction;

@ -25,6 +25,8 @@ void SetRBW(int);
void SetDrive(int d);
void SetIF(int f);
void SetStepDelay(int t);
void set_repeat(int);
extern int setting_repeat;
extern int setting_rbw;
#ifdef __ULTRA__
extern int setting_spur;
@ -49,6 +51,8 @@ void redrawHisto(void);
void self_test(int);
void set_decay(int);
void set_noise(int);
void menu_load_preset_cb(int,int);
void menu_store_preset_cb(int,int);
void toggle_tracking_output(void);
extern int32_t frequencyExtra;
extern int setting_tracking;
@ -344,7 +348,7 @@ const uint16_t right_icons [] =
enum {
KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ, KM_REPEAT,
};
@ -453,6 +457,7 @@ static const keypads_t * const keypads_mode_tbl[] = {
keypads_level, // KM_DECAY
keypads_level, // KM_NOISE
keypads_level, // KM_10MHz
keypads_level, // KM_REPEA
};
#ifdef __VNA__
@ -463,7 +468,7 @@ static const char * const keypad_mode_label[] = {
#ifdef __SA__
static const char * const keypad_mode_label[] = {
"error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "SCALE", // 0-7
"\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", "OFFSET" // 8-16
"\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", "OFFSET" , "REPEATS"// 8-17
};
#endif
@ -944,6 +949,28 @@ const char *menu_drive_text[]={"-36dBm","-34dBm","-32dBm","-30dBm","-28dBm","-26
// ===[MENU DEFINITION]=========================================================
static const menuitem_t menu_store_preset[] =
{
{ MT_CALLBACK, 1, "STORE 1" , menu_store_preset_cb},
{ MT_CALLBACK, 2, "STORE 2" , menu_store_preset_cb},
{ MT_CALLBACK, 3, "STORE 3" , menu_store_preset_cb},
{ MT_CALLBACK, 4, "STORE 4" , menu_store_preset_cb},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_load_preset[] =
{
{ MT_CALLBACK, 0, "DEFAULTS" , menu_load_preset_cb},
{ MT_CALLBACK, 1, "LOAD 1" , menu_load_preset_cb},
{ MT_CALLBACK, 2, "LOAD 2" , menu_load_preset_cb},
{ MT_CALLBACK, 3, "LOAD 3" , menu_load_preset_cb},
{ MT_CALLBACK, 4, "LOAD 4" , menu_load_preset_cb},
{ MT_SUBMENU, 0, "STORE" , menu_store_preset},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_drive[] = {
{ MT_CALLBACK, 15, " 20dBm", menu_drive_cb},
{ MT_CALLBACK, 14, " 16dBm", menu_drive_cb},
@ -1204,6 +1231,7 @@ static const menuitem_t menu_settings[] =
{ MT_KEYPAD, KM_ACTUALPOWER, "\2ACTUAL\0POWER", NULL},
{ MT_KEYPAD, KM_IF, "\2IF\0FREQ", NULL},
{ MT_KEYPAD, KM_SAMPLETIME, "\2SAMPLE\0TIME", NULL},
{ MT_KEYPAD, KM_REPEAT, "REPEATS", NULL},
{ MT_SUBMENU,0, "\2LO\0DRIVE", menu_drive},
#ifdef __ULTRA__
{ MT_SUBMENU,0, "HARMONIC", menu_harmonic},
@ -1238,6 +1266,7 @@ static const menuitem_t menu_settingshigh[] =
{
{ MT_KEYPAD, KM_ACTUALPOWER, "\2ACTUAL\0POWER", NULL},
{ MT_KEYPAD, KM_SAMPLETIME, "\2SAMPLE\0TIME", NULL},
{ MT_KEYPAD, KM_REPEAT, "REPEATS", NULL},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settingshigh2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
@ -1609,6 +1638,10 @@ static void fetch_numeric_target(void)
uistat.value = setting_step_delay;
plot_printf(uistat.text, sizeof uistat.text, "%3duS", ((int32_t)uistat.value));
break;
case KM_REPEAT:
uistat.value = setting_repeat;
plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value));
break;
case KM_DRIVE:
uistat.value = setting_drive;
plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value));
@ -1685,6 +1718,9 @@ set_numeric_value(void)
case KM_SAMPLETIME:
SetStepDelay(uistat.value);
break;
case KM_REPEAT:
set_repeat(uistat.value);
break;
case KM_DRIVE:
SetDrive(uistat.value);
break;

Loading…
Cancel
Save

Powered by TurnKey Linux.