Rewrite progress bar update/remove dead code/use buffering in cmd_scanraw

cmd_vbat now run in sweep thread
pull/52/head
DiSlord Live 3 years ago
parent 63a26eb112
commit 6148013c54

@ -2069,7 +2069,7 @@ static const VNAShellCommand commands[] =
{"touch" , cmd_touch , 0}, {"touch" , cmd_touch , 0},
{"release" , cmd_release , 0}, {"release" , cmd_release , 0},
#endif #endif
{"vbat" , cmd_vbat , 0}, // Uses same adc as touch!!!!! {"vbat" , cmd_vbat , CMD_WAIT_MUTEX}, // Uses same adc as touch!!!!!
#ifdef ENABLE_VBAT_OFFSET_COMMAND #ifdef ENABLE_VBAT_OFFSET_COMMAND
{"vbat_offset" , cmd_vbat_offset , CMD_RUN_IN_LOAD}, {"vbat_offset" , cmd_vbat_offset , CMD_RUN_IN_LOAD},
#endif #endif
@ -2415,10 +2415,9 @@ static void VNAShell_executeLine(char *line)
shell_function = scp->sc_function; shell_function = scp->sc_function;
operation_requested|=OP_CONSOLE; // this will abort current sweep to give priority to the new request operation_requested|=OP_CONSOLE; // this will abort current sweep to give priority to the new request
// Wait execute command in sweep thread // Wait execute command in sweep thread
osalThreadEnqueueTimeoutS(&shell_thread, TIME_INFINITE); do {
// do { osalThreadEnqueueTimeoutS(&shell_thread, TIME_INFINITE);
// osalThreadSleepMilliseconds(10); } while (shell_function);
// } while (shell_function);
} else { } else {
operation_requested = false; // otherwise commands will be aborted operation_requested = false; // otherwise commands will be aborted
scp->sc_function(shell_nargs - 1, &shell_args[1]); scp->sc_function(shell_nargs - 1, &shell_args[1]);

@ -1245,37 +1245,39 @@ VNA_SHELL_FUNCTION(cmd_scanraw)
float f_step = (stop-start)/ points; float f_step = (stop-start)/ points;
setting.frequency_step = (freq_t)f_step; setting.frequency_step = (freq_t)f_step;
streamPut(shell_stream, '{');
static freq_t old_start=0, old_stop=0;
static uint32_t old_points=0;
if (old_start != start || old_stop != stop || old_points != points) { // To prevent dirty for every sweep
dirty = true;
old_start = start;
old_stop = stop;
old_points = points;
}
operation_requested = false; operation_requested = false;
dirty = true; dirty = true;
// adc_stop_analog_watchdog();
for (uint32_t i = 0; i<points; i++) { int oldpos = 0;
ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1);
ili9341_set_background(LCD_SWEEP_LINE_COLOR);
#define BUFFER_SIZE 64
uint8_t buf[BUFFER_SIZE];
int idx = 0;
buf[idx++] = '{';
for (uint32_t i = 0; i < points; i++) {
int val = perform(false, i, start +(freq_t)(f_step * i), false) + float_TO_PURE_RSSI(config.ext_zero_level); int val = perform(false, i, start +(freq_t)(f_step * i), false) + float_TO_PURE_RSSI(config.ext_zero_level);
if (operation_requested || SDU1.config->usbp->state != USB_ACTIVE) // break on operation in perform if (operation_requested || SDU1.config->usbp->state != USB_ACTIVE) // break on operation in perform
break; break;
streamPut(shell_stream, 'x'); buf[idx++] = 'x';
streamPut(shell_stream, (uint8_t)(val & 0xFF)); buf[idx++] = (uint8_t)(val & 0xFF);
streamPut(shell_stream, (uint8_t)((val>>8) & 0xFF)); buf[idx++] = (uint8_t)((val>>8) & 0xFF);
if ((i & 0x07) == 0) { // if required if (idx >= BUFFER_SIZE - 4) {
int pos = i * (WIDTH+1) / points; streamWrite(shell_stream, buf, idx);
ili9341_set_background(LCD_SWEEP_LINE_COLOR); idx = 0;
ili9341_fill(OFFSETX, CHART_BOTTOM+1, pos, 1); // update sweep progress bar }
ili9341_set_background(LCD_BG_COLOR); int pos = i * (WIDTH+1) / points;
ili9341_fill(OFFSETX+pos, CHART_BOTTOM+1, WIDTH-pos, 1); if (pos - oldpos > 8) {
ili9341_fill(OFFSETX + oldpos, CHART_BOTTOM+1, pos - oldpos, 1); // update sweep progress bar
oldpos = pos;
} }
} }
buf[idx++] = '}';
streamWrite(shell_stream, buf, idx);
// adc_start_analog_watchdog();
ili9341_set_background(LCD_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1);
streamPut(shell_stream, '}');
setting.frequency_step = old_step; setting.frequency_step = old_step;
dirty = true; dirty = true;
redraw_request = 0; // disable screen update in this mode redraw_request = 0; // disable screen update in this mode

Loading…
Cancel
Save

Powered by TurnKey Linux.