chore: move loop of scan command into sweep thread

scan_delay_optimize
TT 6 years ago
parent 571e45d50b
commit 5fea75f92f

@ -49,6 +49,7 @@ int32_t frequency_offset = 5000;
int32_t frequency = 10000000; int32_t frequency = 10000000;
int8_t drive_strength = DRIVE_STRENGTH_AUTO; int8_t drive_strength = DRIVE_STRENGTH_AUTO;
int8_t sweep_enabled = TRUE; int8_t sweep_enabled = TRUE;
int8_t sweep_once = FALSE;
int8_t cal_auto_interpolate = TRUE; int8_t cal_auto_interpolate = TRUE;
uint16_t redraw_request = 0; // contains REDRAW_XXX flags uint16_t redraw_request = 0; // contains REDRAW_XXX flags
int16_t vbat = 0; int16_t vbat = 0;
@ -62,15 +63,16 @@ static THD_FUNCTION(Thread1, arg)
while (1) { while (1) {
bool completed = false; bool completed = false;
if (sweep_enabled) { if (sweep_enabled || sweep_once) {
chMtxLock(&mutex); chMtxLock(&mutex);
completed = sweep(true); completed = sweep(true);
sweep_once = FALSE;
chMtxUnlock(&mutex); chMtxUnlock(&mutex);
} else { } else {
__WFI(); __WFI();
} }
{ if (sweep_enabled) {
chMtxLock(&mutex); chMtxLock(&mutex);
ui_process(); ui_process();
@ -702,8 +704,12 @@ static void cmd_scan(BaseSequentialStream *chp, int argc, char *argv[])
pause_sweep(); pause_sweep();
chMtxLock(&mutex); chMtxLock(&mutex);
set_frequencies(start, stop, points); set_frequencies(start, stop, points);
sweep(false); sweep_once = TRUE;
chMtxUnlock(&mutex); chMtxUnlock(&mutex);
// wait finishing sweep
while (sweep_once)
chThdSleepMilliseconds(10);
} }
static void static void
@ -1872,7 +1878,7 @@ static void cmd_vbat(BaseSequentialStream *chp, int argc, char *argv[])
chprintf(chp, "%d mV\r\n", vbat); chprintf(chp, "%d mV\r\n", vbat);
} }
static THD_WORKING_AREA(waThread2, /* cmd_* max stack size + alpha */640); static THD_WORKING_AREA(waThread2, /* cmd_* max stack size + alpha */442);
static const ShellCommand commands[] = static const ShellCommand commands[] =
{ {

Loading…
Cancel
Save

Powered by TurnKey Linux.