Many updates

pull/34/head
erikkaashoek 3 years ago
parent adc3d94bd5
commit 5ac2dcab10

@ -280,7 +280,11 @@ enum {
};
enum {
MO_NONE, MO_AM, MO_NFM, MO_WFM, MO_EXTERNAL,
MO_NONE, MO_AM, MO_NFM,
#ifdef TINYSA4
MO_NFM2, MO_NFM3,
#endif
MO_WFM, MO_EXTERNAL, MO_MAX
};
#define MODE_OUTPUT(x) ((x) == M_GENLOW || (x) == M_GENHIGH )
@ -760,6 +764,10 @@ typedef struct config {
int8_t cor_am;
int8_t cor_wfm;
int8_t cor_nfm;
#ifdef TINYSA4
int8_t cor_nfm2;
int8_t cor_nfm3;
#endif
uint8_t _brightness;
#ifndef __NEW_SWITCHES__
uint8_t high_out_adf4350;
@ -1326,7 +1334,7 @@ typedef struct properties {
//sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e56 /* 'CONF' */
#define CONFIG_MAGIC 0x434f4e57 /* 'CONF' */
extern int16_t lastsaveid;
//extern properties_t *active_props;
@ -1383,9 +1391,9 @@ void clear_all_config_prop_data(void);
// Set structure align as WORD (save flash memory)
#pragma pack(push, 2)
typedef struct {
uint8_t type;
uint8_t data;
char *label;
const uint8_t type;
const uint8_t data;
const char *label;
const void *reference;
} menuitem_t;
#pragma pack(pop)

@ -1548,10 +1548,10 @@ static void trace_print_value_string( // Only used at one place
#else
if (bold) format++; // Skip small prefix for bold output
#endif
cell_printf(xpos, ypos, format, buf2, v, unit_string[unit_index], (mtype & M_NOISE?"/Hz":""), (mtype & M_AVER?"/T":""));
cell_printf(xpos, ypos, format, buf2, v, unit_string[unit_index], (mtype & M_NOISE?"c/Hz":""), (mtype & M_AVER?"/T":""));
#ifdef __LEVEL_METER__
if (level_text[0] == 0)
plot_printf(level_text, sizeof(level_text), &format[3], v, unit_string[unit_index], (mtype & M_NOISE?"/Hz":"") ,(mtype & M_AVER?"/T":""));
plot_printf(level_text, sizeof(level_text), &format[3], v, unit_string[unit_index], (mtype & M_NOISE?"c/Hz":"") ,(mtype & M_AVER?"/T":""));
#endif
}

@ -1326,9 +1326,11 @@ void limits_update(void)
int prev = -1;
if (setting.average[t] != AV_TABLE)
continue;
int count = 0;
for (int i = 0; i<LIMITS_MAX; i++)
{
if (setting.limits[t][i].enabled) {
count++;
while (j < sweep_points && (getFrequency(j) < setting.limits[t][i].frequency /* || setting.limits[t][i].frequency == 0 */)) {
if (prev < 0)
measured[t][j] = setting.limits[t][i].level;
@ -3133,41 +3135,49 @@ static const int am_modulation[MODULATION_STEPS] = { 5, 1, 0, 1, 5, 9, 11, 9 };
#define HND 8
#define LWD 96 // Total WFM deviation is LWD * 4 * 156.25 = 30kHz when below 600MHz
#define HWD 48
#define MODULATION_TABLES 4
#endif
#ifdef TINYSA4
//
// Offset is 14.4Hz when below 600MHz and 28.8 when above.
//
#define LND 96 // low range near FM
#define HND 48 // High range near FM
#define LWD 1024 // Low range wide FM
#define HWD 512 // High range wide FM
//#define LND 96 // low range near FM
#define HND 36 // High range near FM
#define HN2D 44 // High range near FM
#define HN3D 80 // High range near FM
//#define LWD 1024 // Low range wide FM
#define HWD 1300 // High range wide FM 512
#define MODULATION_TABLES 4
#endif
#define S1 1.5
static const int fm_modulation[4][MODULATION_STEPS] = // Avoid sign changes in NFM
static const int fm_modulation[MODULATION_TABLES][MODULATION_STEPS] = // Avoid sign changes in NFM
{
{ 2*LND,(int)( (2+S1)*LND ), 4*LND, (int)((2+S1)*LND), 2*LND, (int)((2-S1)*LND), 0, (int)((2-S1)*LND)}, // Low range, NFM
{ 0*LWD,(int)( S1*LWD ), 2*LWD, (int)(S1*LWD), 0*LWD, (int)(-S1*LWD), (int)-2*LWD, (int)(-S1*LWD)}, // Low range, WFM
{ 2*HND,(int)( 3.5*HND ), 4*HND, (int)(3.5*HND), 2*HND, (int)(0.5*HND), 0, (int)(0.5*HND)}, // High range, NFM
{ 0*HWD,(int)( 1.5*HWD ), 2*HWD, (int)(1.5*HWD), 0*HWD, (int)(-1.5*HWD), (int)-2*HWD, (int)(-1.5*HWD)}, // HIgh range, WFM
#ifdef TINYSA4
// { 0*LND,(int)( 1.5*LND ), 2*LND, (int)(1.5*LND), 0*LND, (int)(-1.5*LND), (int)-2*LND, (int)(-1.5*LND)}, // High range, MO_NFM
// { 0*LWD,(int)( S1*LWD ), 2*LWD, (int)(S1*LWD), 0*LWD, (int)(-S1*LWD), (int)-2*LWD, (int)(-S1*LWD)}, // Low range, MO_WFM
{ 0*HND,(int)( 1.5*HND ), 2*HND, (int)(1.5*HND), 0*HND, (int)(-1.5*HND), (int)-2*HND, (int)(-1.5*HND)}, // High range, NFM
{ 0*HN2D,(int)( 1.5*HN2D ), 2*HN2D, (int)(1.5*HN2D), 0*HN2D, (int)(-1.5*HN2D), (int)-2*HN2D, (int)(-1.5*HN2D)}, // High range, NFM2
{ 0*HN3D,(int)( 1.5*HN3D ), 2*HN3D, (int)(1.5*HN3D), 0*HN3D, (int)(-1.5*HN3D), (int)-2*HN3D, (int)(-1.5*HN3D)}, // High range, NFM3
{ 0*HWD,(int)( 1.5*HWD ), 2*HWD, (int)(1.5*HWD), 0*HWD, (int)(-1.5*HWD), (int)-2*HWD, (int)(-1.5*HWD)}, // HIgh range, MO_WFM
#else
{ 2*LND,(int)( (2+S1)*LND ), 4*LND, (int)((2+S1)*LND), 2*LND, (int)((2-S1)*LND), 0, (int)((2-S1)*LND)}, // Low range, MO_NFM
{ 0*LWD,(int)( S1*LWD ), 2*LWD, (int)(S1*LWD), 0*LWD, (int)(-S1*LWD), (int)-2*LWD, (int)(-S1*LWD)}, // Low range, MO_WFM
{ 2*HND,(int)( 3.5*HND ), 4*HND, (int)(3.5*HND), 2*HND, (int)(0.5*HND), 0, (int)(0.5*HND)}, // High range, MO_NFM
{ 0*HWD,(int)( 1.5*HWD ), 2*HWD, (int)(1.5*HWD), 0*HWD, (int)(-1.5*HWD), (int)-2*HWD, (int)(-1.5*HWD)}, // HIgh range, MO_WFM
#endif
}; // narrow FM modulation avoid sign changes
#undef S1
#ifdef TINYSA3
static const int fm_modulation_offset[4] =
{
#ifdef TINYSA4
5000, //85000,
0, //80000,
-2700, //165000,
0, //160000
#else
85000,
80000,
165000,
160000
#endif
};
#endif
deviceRSSI_t age[POINTS_COUNT]; // Array used for 1: calculating the age of any max and 2: buffer for fast sweep RSSI values;
@ -3256,7 +3266,7 @@ static float old_temp = 0.0;
pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup
{
int modulation_delay = 0;
int modulation_index = 0;
int modulation_index;
int modulation_count_iter = 0;
#ifdef __NEW_SWITCHES__
// int direct = ((setting.mode == M_LOW && config.direct && f > DIRECT_START && f<DIRECT_STOP) || (setting.mode == M_GENLOW && f >= MINIMUM_DIRECT_FREQ && f < ultra_start) );
@ -3545,9 +3555,25 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
#endif
modulation_delay = ((1000000-MO_FREQ_COR)/ MODULATION_STEPS ) / setting.modulation_frequency; // 8 steps so 1MHz/8
modulation_counter = 0;
modulation_index = 0;
if (setting.modulation == MO_AM) // -14 default
modulation_delay += config.cor_am;
else { // must be FM
else {
#ifdef TINYSA4
switch(setting.modulation){
case MO_NFM:
modulation_delay += config.cor_nfm;
break;
modulation_delay += config.cor_nfm2;
break;
modulation_delay += config.cor_nfm3;
break;
modulation_delay += config.cor_wfm;
break;
}
modulation_index = setting.modulation - MO_NFM;
#else
// must be FM
if (setting.modulation == MO_WFM) { // -17 default
modulation_delay += config.cor_wfm;
modulation_index = 1;
@ -3555,16 +3581,18 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
modulation_delay += config.cor_nfm; // -17 default
// modulation_index = 0; // default value
}
#endif
#ifdef TINYSA4
if ((setting.mode == M_GENLOW) ||
(setting.mode == M_GENHIGH && f > ((freq_t)480000000) ) )
if (false)
#else
if ((setting.mode == M_GENLOW && f > ((freq_t)480000000) - DEFAULT_IF) ||
(setting.mode == M_GENHIGH && f > ((freq_t)480000000) ) )
#endif
modulation_index += 2;
current_fm_modulation = (int *)fm_modulation[modulation_index];
#ifdef TINYSA3
f -= fm_modulation_offset[modulation_index]; // Shift output frequency
#endif
}
}
}
@ -4530,10 +4558,12 @@ static bool sweep(bool break_on_operation)
int refreshing = false;
if (MODE_OUTPUT(setting.mode) && config.cor_nfm == 0) { // Calibrate the modulation frequencies at first use
//#ifndef TINYSA4
calibrate_modulation(MO_AM, &config.cor_am); // No AM mondulation for now
//#endif
calibrate_modulation(MO_AM, &config.cor_am);
calibrate_modulation(MO_NFM, &config.cor_nfm);
#ifdef TINYSA4
calibrate_modulation(MO_NFM2, &config.cor_nfm2);
calibrate_modulation(MO_NFM3, &config.cor_nfm3);
#endif
calibrate_modulation(MO_WFM, &config.cor_wfm);
}
@ -6750,7 +6780,23 @@ static int R_table[R_TABLE_SIZE] = {1,3,-3,4,5};
perform(false,0, 30000000, false);
perform(false,1, 30000000, false);
config.cor_nfm = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8;
#ifdef TINYSA4
setting.modulation = MO_NFM2;
setting.modulation_frequency = 5000;
in_selftest = true;
config.cor_nfm2 = 0;
perform(false,0, 30000000, false);
perform(false,1, 30000000, false);
config.cor_nfm2 = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8;
setting.modulation = MO_NFM3;
setting.modulation_frequency = 5000;
in_selftest = true;
config.cor_nfm3 = 0;
perform(false,0, 30000000, false);
perform(false,1, 30000000, false);
config.cor_nfm3 = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8;
#endif
setting.modulation = MO_WFM;
setting.modulation_frequency = 5000;
in_selftest = true;
@ -7021,6 +7067,7 @@ void calibrate_modulation(int modulation, int8_t *correction)
in_selftest = false;
*correction = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency ))/8;
setting.modulation = M_OFF;
setting.modulation_frequency = 1000;
}
}

@ -1234,7 +1234,7 @@ draw_menu_buttons(const menuitem_t *menu, uint32_t mask)
text = button.text;
}
else
text = m->label;
text = (char *)m->label;
// Only keypad retrieves value
if (MT_MASK(m->type) == MT_KEYPAD) {
fetch_numeric_target(m->data);

@ -1048,12 +1048,22 @@ static UI_FUNCTION_ADV_CALLBACK(menu_lowoutput_settings_acb)
#endif
// const int menu_modulation_value[]={MO_NONE,MO_AM, MO_NFM, MO_WFM, MO_EXTERNAL};
const char *menu_modulation_text[]={"None", "AM", "NFM", "WFM", "External"};
const char *menu_modulation_text[MO_MAX]=
{ "None", "AM 30%",
#ifdef TINYSA4
"FM 2.5kHz",
"FM 3kHz",
"FM 5kHz",
#else
"FM 5kHz",
#endif
"FM 75kHz", "External"};
static UI_FUNCTION_ADV_CALLBACK(menu_modulation_acb)
{
(void)item;
if (b){
plot_printf(b->text, sizeof b->text, "%s", menu_modulation_text[data]);
b->icon = data == setting.modulation ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
@ -1063,9 +1073,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_modulation_acb)
set_level_sweep(0);
}
set_modulation(data);
menu_move_back(false);
// ui_mode_normal(); // Stay in menu mode
// draw_cal_status();
// menu_move_back(false); // Don't move back
}
static UI_FUNCTION_ADV_CALLBACK(menu_smodulation_acb){
@ -1075,7 +1083,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_smodulation_acb){
if (setting.modulation == MO_NONE || setting.modulation == MO_EXTERNAL)
plot_printf(b->text, sizeof b->text, "MOD: %s", menu_modulation_text[setting.modulation]);
else {
plot_printf(b->text, sizeof b->text, "MOD: %5.3fkHz %s", setting.modulation_frequency / 1000.0, menu_modulation_text[setting.modulation]);
plot_printf(b->text, sizeof b->text, "MOD: %4dHz %s", (int)(setting.modulation_frequency), menu_modulation_text[setting.modulation]);
}
return;
}
@ -1964,6 +1972,9 @@ static UI_FUNCTION_ADV_CALLBACK(menu_limit_select_acb)
{
(void)item;
if(b){
int count = 0;
for (int i=0;i<LIMITS_MAX;i++) {if (setting.limits[current_trace][i].enabled) count++; }
if (count == 0) setting.limits[current_trace][0].enabled = true;
plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.2F%s", (float)setting.limits[current_trace][data].frequency, value(setting.limits[current_trace][data].level),unit_string[setting.unit]);
b->icon = (setting.limits[current_trace][data].enabled?BUTTON_ICON_CHECK:BUTTON_ICON_NOCHECK) ;
return;
@ -2083,6 +2094,13 @@ static UI_FUNCTION_CALLBACK(menu_limit_disable_cb)
{
(void)item;
(void)data;
int count = 0;
for (int i=0;i<LIMITS_MAX;i++) {if (setting.limits[current_trace][i].enabled) count++; }
if (count == 1 && setting.limits[current_trace][active_limit].enabled) {
drawMessageBox("Error", "At least one entry",1000);
return;
}
if (active_limit<LIMITS_MAX){
setting.limits[current_trace][active_limit].enabled = false;
dirty = true;
@ -2562,11 +2580,17 @@ static const menuitem_t menu_lo_drive[] = {
static const menuitem_t menu_modulation[] = {
{ MT_FORM | MT_TITLE, 0, "MODULATION",NULL},
{ MT_FORM | MT_ADV_CALLBACK, MO_NONE, "None", menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_AM, "AM", menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK, MO_NFM, "Narrow FM", menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK, MO_WFM, "Wide FM", menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_EXTERNAL, "External", menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK, MO_NONE, MT_CUSTOM_LABEL, menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_AM, MT_CUSTOM_LABEL, menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK, MO_NFM, MT_CUSTOM_LABEL, menu_modulation_acb},
#ifdef TINYSA4
{ MT_FORM | MT_ADV_CALLBACK, MO_NFM2, MT_CUSTOM_LABEL, menu_modulation_acb},
{ MT_FORM | MT_ADV_CALLBACK, MO_NFM3, MT_CUSTOM_LABEL, menu_modulation_acb},
#endif
{ MT_FORM | MT_ADV_CALLBACK, MO_WFM, MT_CUSTOM_LABEL, menu_modulation_acb},
#ifndef TINYSA4
{ MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_EXTERNAL,MT_CUSTOM_LABEL, menu_modulation_acb},
#endif
{ MT_FORM | MT_KEYPAD, KM_MODULATION, "FREQ: %s", "50Hz..5kHz"},
{ MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back
};

Loading…
Cancel
Save

Powered by TurnKey Linux.