Merge pull request #3 from ttrftech/master

This commit is contained in:
qrp73 2019-09-28 20:11:57 +03:00 committed by GitHub
commit 6fb41273c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

14
main.c
View file

@ -76,10 +76,12 @@ static THD_FUNCTION(Thread1, arg)
__WFI();
}
chMtxLock(&mutex);
ui_process();
chMtxUnlock(&mutex);
if (sweep_enabled) {
chMtxLock(&mutex);
ui_process();
if (vbat != -1) {
adc_stop(ADC1);
vbat = adc_vbat_read(ADC1);
@ -759,9 +761,10 @@ void
set_frequencies(uint32_t start, uint32_t stop, int16_t points)
{
int i;
uint32_t span = (stop - start) / 1000; /* prevents overflow because of maximum of int32_t(2.147e+9) */
float span = stop - start;
for (i = 0; i < points; i++)
frequencies[i] = start + span * i / (points - 1) * 1000;
frequencies[i] = start + i * span / (float)(points - 1);
// disable at out of sweep range
for (; i < sweep_points; i++)
frequencies[i] = 0;
}
@ -820,6 +823,7 @@ void
set_sweep_frequency(int type, float frequency)
{
int32_t freq = frequency;
int cal_applied = cal_status & CALSTAT_APPLY;
switch (type) {
case ST_START:
freq_mode_startstop();
@ -899,7 +903,7 @@ set_sweep_frequency(int type, float frequency)
break;
}
if (cal_auto_interpolate && (cal_status & CALSTAT_APPLY))
if (cal_auto_interpolate && cal_applied)
cal_interpolate(lastsaveid);
}