Skip to content

Commit

Permalink
Merge pull request ttrftech#3 from ttrftech/master
Browse files Browse the repository at this point in the history
  • Loading branch information
qrp73 committed Sep 28, 2019
2 parents e37ef6e + 0644772 commit 6fb4127
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions main.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6fb4127

Please sign in to comment.