Output sweep time repaired and output on/off implemented

tinySA-v0.2
erikkaashoek 6 years ago
parent 492fbbed7f
commit a8a7209f9c

@ -2463,7 +2463,7 @@ static const GPTConfig gpt4cfg = {
void my_microsecond_delay(int t) void my_microsecond_delay(int t)
{ {
gptPolledDelay(&GPTD14, t); // t us delay if (t>0) gptPolledDelay(&GPTD14, t); // t us delay
} }
#if 0 #if 0
/* /*

@ -1,5 +1,4 @@
/* /* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* All rights reserved. * All rights reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
@ -127,6 +126,7 @@ double my_atof(const char *p);
int shell_printf(const char *fmt, ...); int shell_printf(const char *fmt, ...);
void toggle_sweep(void); void toggle_sweep(void);
void toggle_mute(void);
void load_default_properties(void); void load_default_properties(void);
extern float perform(bool b, int i, uint32_t f, int e); extern float perform(bool b, int i, uint32_t f, int e);
@ -585,6 +585,7 @@ typedef struct setting
int auto_IF; int auto_IF;
unsigned int unit_scale_index; unsigned int unit_scale_index;
float unit_scale; float unit_scale;
int mute;
uint32_t checksum; uint32_t checksum;
}setting_t; }setting_t;

@ -58,6 +58,7 @@ void reset_settings(int m)
setting.refer = -1; setting.refer = -1;
setting.unit_scale_index = 0; setting.unit_scale_index = 0;
setting.unit_scale = 0; setting.unit_scale = 0;
setting.mute = false;
#ifdef __SPUR__ #ifdef __SPUR__
setting.spur = 0; setting.spur = 0;
#endif #endif
@ -122,11 +123,14 @@ void reset_settings(int m)
float calc_min_sweep_time(void) // Calculate minimum sweep time in mS float calc_min_sweep_time(void) // Calculate minimum sweep time in mS
{ {
float t; float t;
float a = actualStepDelay + MEASURE_TIME; float a = (actualStepDelay + MEASURE_TIME)/1000.0;
if (MODE_OUTPUT(setting.mode))
if (FREQ_IS_CW()) t = 1000;
a = (float)MINIMUM_SWEEP_TIME / 290.0; // time per step in CW mode else {
t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME)); 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));
}
return t; return t;
} }
@ -205,6 +209,12 @@ void toggle_tracking_output(void)
dirty = true; dirty = true;
} }
void toggle_mute(void)
{
setting.mute = !setting.mute;
dirty = true;
}
void toggle_below_IF(void) void toggle_below_IF(void)
{ {
if (S_IS_AUTO(setting.below_IF )) if (S_IS_AUTO(setting.below_IF ))
@ -821,6 +831,7 @@ case M_ULTRA:
// SI4432_SetReference(setting.refer); // SI4432_SetReference(setting.refer);
break; break;
case M_HIGH: // Direct into 1 case M_HIGH: // Direct into 1
mute:
// SI4432_SetReference(-1); // Stop reference output // SI4432_SetReference(-1); // Stop reference output
SI4432_Sel = 0; // both as receiver to avoid spurs SI4432_Sel = 0; // both as receiver to avoid spurs
set_switch_receive(); set_switch_receive();
@ -833,6 +844,8 @@ case M_HIGH: // Direct into 1
break; break;
case M_GENLOW: // Mixed output from 0 case M_GENLOW: // Mixed output from 0
if (setting.mute)
goto mute;
SI4432_Sel = 0; SI4432_Sel = 0;
if (setting.step_atten) { if (setting.step_atten) {
set_switch_off(); set_switch_off();
@ -851,6 +864,8 @@ case M_GENLOW: // Mixed output from 0
} }
break; break;
case M_GENHIGH: // Direct output from 1 case M_GENHIGH: // Direct output from 1
if (setting.mute)
goto mute;
SI4432_Sel = 0; SI4432_Sel = 0;
SI4432_Receive(); SI4432_Receive();
set_switch_receive(); set_switch_receive();
@ -1376,17 +1391,21 @@ again:
repeats = 1000; // to avoid interrupting the tone during UI processing repeats = 1000; // to avoid interrupting the tone during UI processing
modulation_counter = 0; modulation_counter = 0;
} }
float t = calc_min_sweep_time(); float t = setting.sweep_time - calc_min_sweep_time(); // Time to delay in mS
if (t < 0)
t = 0;
t = t * 1000 / 290.0;
if (MODE_OUTPUT(setting.mode) && t < 500) // Minimum wait time to prevent LO from lockup
t = 500;
while (repeats--) { while (repeats--) {
for (int i = 0; i < sweep_points; i++) { for (int i = 0; i < sweep_points; i++) {
RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking); RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking);
if ( setting.sweep_time > t && !(MODE_OUTPUT(setting.mode) && setting.modulation != MO_NONE)) { if (MODE_INPUT(setting.mode) || setting.modulation == MO_NONE) {
float s = (setting.sweep_time - t) * (1000.0 / 290.0); if (t < 30000)
if (s < 30000) my_microsecond_delay((int)t);
my_microsecond_delay((int)s);
else else
osalThreadSleepMilliseconds(((int)s)/1000); osalThreadSleepMilliseconds(((int)t)/1000);
} }
// back to toplevel to handle ui operation // back to toplevel to handle ui operation
@ -1559,7 +1578,8 @@ again:
} }
} }
} else { } else {
if (r < setting.reflevel - setting.scale*NGRIDY || temp_min_level > setting.reflevel) { float u_minlevel = value(temp_min_level);
if (r < setting.reflevel - setting.scale*NGRIDY || u_minlevel > setting.reflevel) {
set_reflevel(setting.scale*(floor(r/setting.scale)+1)); set_reflevel(setting.scale*(floor(r/setting.scale)+1));
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
@ -1567,11 +1587,11 @@ again:
set_reflevel(setting.reflevel + setting.scale); set_reflevel(setting.reflevel + setting.scale);
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
} else if (temp_min_level < setting.reflevel - 10.1 * setting.scale && r < setting.reflevel - setting.scale * 1.5) { } else if (u_minlevel < setting.reflevel - 10.1 * setting.scale && r < setting.reflevel - setting.scale * 1.5) {
set_reflevel(setting.reflevel - setting.scale); set_reflevel(setting.reflevel - setting.scale);
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
} else if (temp_min_level > setting.reflevel - 8.8 * setting.scale) { } else if (u_minlevel > setting.reflevel - 8.8 * setting.scale) {
set_reflevel(setting.reflevel + setting.scale); set_reflevel(setting.reflevel + setting.scale);
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)

@ -605,6 +605,10 @@ static void menu_modulation_cb(int item, uint8_t data)
{ {
(void)item; (void)item;
//Serial.println(item); //Serial.println(item);
if (data) {
set_sweep_frequency(ST_SPAN, 0); // No other scanning allowed when modulation is on!!!!!
set_level_sweep(0);
}
set_modulation(data); set_modulation(data);
menu_move_back(); menu_move_back();
// ui_mode_normal(); // Stay in menu mode // ui_mode_normal(); // Stay in menu mode
@ -971,6 +975,13 @@ static void menu_pause_cb(int item, uint8_t data)
// draw_cal_status(); // draw_cal_status();
} }
static void menu_outputmode_cb(int item, uint8_t data)
{
(void) data;
(void) item;
toggle_mute();
draw_menu();
}
//const int menu_drive_value[]={5,10,15,20}; //const int menu_drive_value[]={5,10,15,20};
const char *menu_drive_text[]={"-38dBm","-35dBm","-33dBm","-30dBm","-27dBm","-24dBm","-21dBm"," -19dBm", " -7dBm"," -4dBm"," -2dBm"," 1dBm"," 4dBm"," 7dBm"," 10dBm"," 13dBm"}; const char *menu_drive_text[]={"-38dBm","-35dBm","-33dBm","-30dBm","-27dBm","-24dBm","-21dBm"," -19dBm", " -7dBm"," -4dBm"," -2dBm"," 1dBm"," 4dBm"," 7dBm"," 10dBm"," 13dBm"};
@ -1082,7 +1093,7 @@ const menuitem_t menu_modulation[] = {
}; };
const menuitem_t menu_lowoutputmode[] = { const menuitem_t menu_lowoutputmode[] = {
{ MT_FORM | MT_TITLE, 0, "LOW OUTPUT", NULL}, { MT_FORM | MT_CALLBACK, 0, "LOW OUTPUT %s", menu_outputmode_cb},
{ MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL},
{ MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
@ -1095,7 +1106,7 @@ const menuitem_t menu_lowoutputmode[] = {
}; };
const menuitem_t menu_highoutputmode[] = { const menuitem_t menu_highoutputmode[] = {
{ MT_FORM | MT_TITLE, 0, "HIGH OUTPUT", NULL}, { MT_FORM | MT_CALLBACK, 0, "HIGH OUTPUT %s", menu_outputmode_cb},
{ MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL},
{ MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide}, { MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
@ -1548,6 +1559,13 @@ static void menu_item_modify_attribute(
} else if (menu == menu_highoutputmode && item == 2) { } else if (menu == menu_highoutputmode && item == 2) {
plot_printf(uistat.text, sizeof uistat.text, menu_drive_text[setting.drive]); plot_printf(uistat.text, sizeof uistat.text, menu_drive_text[setting.drive]);
} else if (menu == menu_lowoutputmode || menu == menu_highoutputmode) { } else if (menu == menu_lowoutputmode || menu == menu_highoutputmode) {
if (item == 0) {
if (setting.mute)
strcpy(uistat.text, "OFF");
else
strcpy(uistat.text, "ON");
mark = true;
}
if (item == 3) { if (item == 3) {
plot_printf(uistat.text, sizeof uistat.text, menu_modulation_text[setting.modulation]); plot_printf(uistat.text, sizeof uistat.text, menu_modulation_text[setting.modulation]);
} }
@ -1800,6 +1818,7 @@ set_numeric_value(void)
set_sweep_frequency(ST_CENTER, uistat.value); set_sweep_frequency(ST_CENTER, uistat.value);
break; break;
case KM_SPAN: case KM_SPAN:
setting.modulation = MO_NONE;
set_sweep_frequency(ST_SPAN, uistat.value); set_sweep_frequency(ST_SPAN, uistat.value);
break; break;
case KM_CW: case KM_CW:
@ -1862,6 +1881,7 @@ set_numeric_value(void)
set_offset(uistat.value); set_offset(uistat.value);
break; break;
case KM_LEVELSWEEP: case KM_LEVELSWEEP:
setting.modulation = MO_NONE;
set_level_sweep(uistat.value); set_level_sweep(uistat.value);
break; break;
case KM_SWEEP_TIME: case KM_SWEEP_TIME:

Loading…
Cancel
Save

Powered by TurnKey Linux.