Skip to content

Commit

Permalink
Fixed center frequency >1GHz hang issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
AA6KL committed Feb 3, 2020
1 parent c21ec25 commit cc3106f
Showing 1 changed file with 65 additions and 76 deletions.
141 changes: 65 additions & 76 deletions plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,8 @@ void draw_all(bool flush)

void redraw_marker(int marker, int update_info)
{
if (marker < 0)
return;
// mark map on new position of marker
markmap_marker(marker);

Expand Down Expand Up @@ -1462,6 +1464,33 @@ void request_to_draw_cells_behind_numeric_input(void)
redraw_request |= REDRAW_CELLS;
}

static void frequency_string(char *buf, size_t len, int32_t freq)
{
int l, i;
if (freq < 0) {
freq = -freq;
*buf++ = '-';
len -= 1;
}
if (freq < 1000) {
chsnprintf(buf, len, "%d Hz", (int)freq);
} else if (freq < 1000000) {
chsnprintf(buf, len, "%d.%03d kHz",
(int)(freq / 1000),
(int)(freq % 1000));
} else {
chsnprintf(buf, len, "%d.%03d %03d MHz",
(int)(freq / 1000000),
(int)((freq / 1000) % 1000),
(int)(freq % 1000));
}
l = strlen(buf);
for (i=l; i<(int)len-1; i++) {
buf[i]=' ';
}
buf[len-1]=0;
return;
}

#if !(defined(ILI9488) || defined(ILI9486) || defined(ST7796S))
static void cell_drawchar_5x7(int w, int h, uint8_t ch, int x, int y, uint16_t fg, int invert)
Expand Down Expand Up @@ -1590,71 +1619,51 @@ static void cell_draw_marker_info(int m, int n, int w, int h)
}
}

static void frequency_string(char *buf, size_t len, int32_t freq)
{
if (freq < 0) {
freq = -freq;
*buf++ = '-';
len -= 1;
}
if (freq < 1000) {
chsnprintf(buf, len, "%d Hz", (int)freq);
} else if (freq < 1000000) {
chsnprintf(buf, len, "%d.%03d kHz",
(int)(freq / 1000),
(int)(freq % 1000));
} else {
chsnprintf(buf, len, "%d.%03d %03d MHz",
(int)(freq / 1000000),
(int)((freq / 1000) % 1000),
(int)(freq % 1000));
}
}

void draw_frequencies(void)
{
char buf[24];
const int BUF_LEN=28;
char buf[28];
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
if (frequency1 > 0) {
int start = frequency0;
int stop = frequency1;
strcpy(buf, "START ");
frequency_string(buf+6, 24-6, start);
strcat(buf, " ");
frequency_string(buf+6, BUF_LEN-6, start);
//strcat(buf, " ");
ili9341_drawstring_5x7(buf, OFFSETX, HEIGHT, 0xffff, 0x0000);
strcpy(buf, "STOP ");
frequency_string(buf+5, 24-5, stop);
strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, HEIGHT, 0xffff, 0x0000);
frequency_string(buf+5, BUF_LEN-5, stop);
//strcat(buf, " ");
ili9341_drawstring_5x7(buf, 195, HEIGHT, 0xffff, 0x0000);
} else if (frequency1 < 0) {
int fcenter = frequency0;
int fspan = -frequency1;
strcpy(buf, "CENTER ");
frequency_string(buf+7, 24-7, fcenter);
strcat(buf, " ");
frequency_string(buf+7, BUF_LEN-7, fcenter);
//strcat(buf, " ");
ili9341_drawstring_5x7(buf, OFFSETX, HEIGHT, 0xffff, 0x0000);
strcpy(buf, "SPAN ");
frequency_string(buf+5, 24-5, fspan);
strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, HEIGHT, 0xffff, 0x0000);
frequency_string(buf+5, BUF_LEN-5, fspan);
//strcat(buf, " ");
ili9341_drawstring_5x7(buf, 195, HEIGHT, 0xffff, 0x0000);
} else {
int fcenter = frequency0;
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ",
chsnprintf(buf, BUF_LEN, "CW %d.%03d %03d MHz ",
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000),
(int)(fcenter % 1000));
ili9341_drawstring_5x7(buf, OFFSETX, HEIGHT, 0xffff, 0x0000);
chsnprintf(buf, 24, " ");
ili9341_drawstring_5x7(buf, 205, HEIGHT, 0xffff, 0x0000);
chsnprintf(buf, BUF_LEN, " ");
ili9341_drawstring_5x7(buf, 195, HEIGHT, 0xffff, 0x0000);
}
} else {
strcpy(buf, "START 0s ");
ili9341_drawstring_5x7(buf, OFFSETX, HEIGHT, 0xffff, 0x0000);

strcpy(buf, "STOP ");
chsnprintf(buf+5, 24-5, "%d ns", (uint16_t)(time_of_index(POINT_COUNT-1) * 1e9));
chsnprintf(buf+5, BUF_LEN-5, "%d ns", (uint16_t)(time_of_index(POINT_COUNT-1) * 1e9));
strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, HEIGHT, 0xffff, 0x0000);
ili9341_drawstring_5x7(buf, 195, HEIGHT, 0xffff, 0x0000);
}
}

Expand Down Expand Up @@ -1830,71 +1839,51 @@ static void cell_draw_marker_info(int m, int n, int w, int h)

}

static void frequency_string(char *buf, size_t len, int32_t freq)
{
if (freq < 0) {
freq = -freq;
*buf++ = '-';
len -= 1;
}
if (freq < 1000) {
chsnprintf(buf, len, "%d Hz", (int)freq);
} else if (freq < 1000000) {
chsnprintf(buf, len, "%d.%03d kHz",
(int)(freq / 1000),
(int)(freq % 1000));
} else {
chsnprintf(buf, len, "%d.%03d %03d MHz",
(int)(freq / 1000000),
(int)((freq / 1000) % 1000),
(int)(freq % 1000));
}
}

void draw_frequencies(void)
{
char buf[24];
const int BUF_LEN=28;
char buf[28];
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
if (frequency1 > 0) {
int start = frequency0;
int stop = frequency1;
strcpy(buf, "START ");
frequency_string(buf+6, 24-6, start);
strcat(buf, " ");
frequency_string(buf+6, BUF_LEN-6, start);
//strcat(buf, " ");
ili9341_drawstring_7x13(buf, OFFSETX, HEIGHT+1, 0xffff, 0x0000);
strcpy(buf, "STOP ");
frequency_string(buf+5, 24-5, stop);
strcat(buf, " ");
ili9341_drawstring_7x13(buf, 310, HEIGHT+1, 0xffff, 0x0000);
frequency_string(buf+5, BUF_LEN-5, stop);
//strcat(buf, " ");
ili9341_drawstring_7x13(buf, 280, HEIGHT+1, 0xffff, 0x0000);
} else if (frequency1 < 0) {
int fcenter = frequency0;
int fspan = -frequency1;
strcpy(buf, "CENTER ");
frequency_string(buf+7, 24-7, fcenter);
strcat(buf, " ");
frequency_string(buf+7, BUF_LEN-7, fcenter);
//strcat(buf, " ");
ili9341_drawstring_7x13(buf, OFFSETX, HEIGHT+1, 0xffff, 0x0000);
strcpy(buf, "SPAN ");
frequency_string(buf+5, 24-5, fspan);
strcat(buf, " ");
ili9341_drawstring_7x13(buf, 310, HEIGHT+1, 0xffff, 0x0000);
frequency_string(buf+5, BUF_LEN-5, fspan);
//strcat(buf, " ");
ili9341_drawstring_7x13(buf, 280, HEIGHT+1, 0xffff, 0x0000);
} else {
int fcenter = frequency0;
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ",
chsnprintf(buf, BUF_LEN, "CW %d.%03d %03d MHz ",
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000),
(int)(fcenter % 1000));
ili9341_drawstring_7x13(buf, OFFSETX, HEIGHT+1, 0xffff, 0x0000);
chsnprintf(buf, 24, " ");
ili9341_drawstring_7x13(buf, 310, HEIGHT+1, 0xffff, 0x0000);
chsnprintf(buf, BUF_LEN, " ");
ili9341_drawstring_7x13(buf, 280, HEIGHT+1, 0xffff, 0x0000);
}
} else {
strcpy(buf, "START 0s ");
ili9341_drawstring_7x13(buf, OFFSETX, HEIGHT+1, 0xffff, 0x0000);

strcpy(buf, "STOP ");
chsnprintf(buf+5, 24-5, "%d ns", (uint16_t)(time_of_index(POINT_COUNT-1) * 1e9));
chsnprintf(buf+5, BUF_LEN-5, "%d ns", (uint16_t)(time_of_index(POINT_COUNT-1) * 1e9));
strcat(buf, " ");
ili9341_drawstring_7x13(buf, 310, HEIGHT+1, 0xffff, 0x0000);
ili9341_drawstring_7x13(buf, 280, HEIGHT+1, 0xffff, 0x0000);
}
}

Expand Down Expand Up @@ -1952,8 +1941,8 @@ void draw_battery_status(void)
uint8_t vbati = vbat2bati(vbat);
uint16_t col = vbati == 0 ? RGBHEX(0xff0000) : RGBHEX(0x1fe300);
if (palReadPort(GPIOA) & 0x0010) {
col = RGBHEX(0xffff00);
}
col = RGBHEX(0xffff00);
}
memset(spi_buffer, 0, w * h * 2);

// battery head
Expand Down

0 comments on commit cc3106f

Please sign in to comment.