more parts with bigger font

This commit is contained in:
Dennis Real (DL9CAT) 2019-09-27 17:28:26 +02:00
parent f5a8e8932d
commit 995f5592d4
3 changed files with 164 additions and 106 deletions

View file

@ -140,7 +140,6 @@ extern void tlv320aic3204_adc_filter_enable(int enable);
#define HEIGHT 233
#define CELLOFFSETX 5
#define CELLOFFSETX_8x8 8
#define AREA_WIDTH_NORMAL (WIDTH + CELLOFFSETX*2)
@ -250,6 +249,7 @@ void force_set_markmap(void);
void draw_all_cells(void);
void draw_cal_status(void);
void draw_frequencies(void);
void markmap_all_markers(void);

201
plot.c
View file

@ -744,7 +744,7 @@ clear_markmap(void)
memset(markmap[current_mappage], 0, sizeof markmap[current_mappage]);
}
void inline
inline void
force_set_markmap(void)
{
memset(markmap[current_mappage], 0xff, sizeof markmap[current_mappage]);
@ -1065,27 +1065,37 @@ search_nearest_index(int x, int y, int t)
return min_i;
}
void
cell_draw_markers(int m, int n, int w, int h)
{
int x0 = m * CELLWIDTH;
int y0 = n * CELLHEIGHT;
int t, i;
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
if (!markers[i].enabled)
continue;
for (t = 0; t < TRACES_MAX; t++) {
for (t = 0; t < TRACES_MAX; t++)
{
if (!trace[t].enabled)
continue;
uint32_t index = trace_index[t][markers[i].index];
int x = CELL_X(index) - x0;
int y = CELL_Y(index) - y0;
if (x > -6 && x < w+6 && y >= 0 && y < h+12)
draw_marker(w, h, x, y, config.trace_color[t], '1' + i);
}
}
}
void
markmap_marker(int marker)
{
@ -1143,13 +1153,16 @@ draw_cell(int m, int n)
if (x0off + w > area_width)
w = area_width - x0off;
if (y0 + h > area_height)
h = area_height - y0;
if (w <= 0 || h <= 0)
return;
uint16_t grid_mode = 0;
for (t = 0; t < TRACES_MAX; t++) {
for (t = 0; t < TRACES_MAX; t++)
{
if (!trace[t].enabled)
continue;
@ -1165,24 +1178,35 @@ draw_cell(int m, int n)
PULSE;
/* draw grid */
if (grid_mode & GRID_RECTANGULAR) {
for (x = 0; x < w; x++) {
if (grid_mode & GRID_RECTANGULAR)
{
for (x = 0; x < w; x++)
{
uint16_t c = rectangular_grid_x(x+x0off);
for (y = 0; y < h; y++)
spi_buffer[y * w + x] = c;
}
for (y = 0; y < h; y++) {
for (y = 0; y < h; y++)
{
uint16_t c = rectangular_grid_y(y+y0);
for (x = 0; x < w; x++)
{
if (x+x0off >= 0 && x+x0off <= WIDTH)
spi_buffer[y * w + x] |= c;
}
}
} else {
}
else
{
memset(spi_buffer, 0, sizeof spi_buffer);
}
if (grid_mode & (GRID_SMITH|GRID_ADMIT|GRID_POLAR)) {
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint16_t c = 0;
if (grid_mode & GRID_SMITH)
c = smith_grid(x+x0off, y+y0);
@ -1375,8 +1399,8 @@ cell_drawchar_8x8(int w, int h, uint8_t ch, int x, int y, uint16_t fg, uint8_t v
uint8_t bits, charlen = 8;
int cline, r;
if (y <= -8 || y >= h || x <= -8 || x >= w)
return 0;
// if (y <= -8 || y >= h || x <= -8 || x >= w)
// return 0;
ch = x8x8_map_char_table(ch);
@ -1503,12 +1527,12 @@ cell_draw_marker_info(int m, int n, int w, int h)
}
// draw marker frequency
int xpos = 192;
int xpos = 165;
int ypos = 1 + (j/2)*8;
xpos -= m * CELLWIDTH -CELLOFFSETX;
xpos -= m * CELLWIDTH - CELLOFFSETX;
ypos -= n * CELLHEIGHT;
chsnprintf(buf, sizeof buf, "%d:", active_marker + 1);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
cell_drawstring_8x8_var(w, h, buf, xpos, ypos, 0xffff);
xpos += 16;
if ( (domain_mode & DOMAIN_MODE) == DOMAIN_FREQ )
@ -1527,14 +1551,15 @@ cell_draw_marker_info(int m, int n, int w, int h)
{
int idx0 = markers[previous_marker].index;
xpos = 192;
xpos -= m * CELLWIDTH -CELLOFFSETX;
ypos += 8;
xpos -= m * CELLWIDTH - CELLOFFSETX;
ypos += 7;
chsnprintf(buf, sizeof buf, "\001%d:", previous_marker+1);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
xpos += 16;
frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
}
}
@ -1561,94 +1586,120 @@ frequency_string(char *buf, size_t len, int32_t freq)
}
}
void
draw_frequencies(void)
{
char buf[24];
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, " ");
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
strcpy(buf, "STOP ");
frequency_string(buf+5, 24-5, stop);
strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} else if (frequency1 < 0) {
int fcenter = frequency0;
int fspan = -frequency1;
strcpy(buf, "CENTER ");
frequency_string(buf+7, 24-7, fcenter);
strcat(buf, " ");
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
strcpy(buf, "SPAN ");
frequency_string(buf+5, 24-5, fspan);
strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} else {
int fcenter = frequency0;
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ",
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000),
(int)(fcenter % 1000));
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
chsnprintf(buf, 24, " ");
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
}
} else {
strcpy(buf, "START 0s ");
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
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, " ");
ili9341_drawstring_8x8_var(buf, OFFSETX, 233, 0xffff, 0x0000);
strcpy(buf, "STOP ");
chsnprintf(buf+5, 24-5, "%d ns", (uint16_t)(time_of_index(101) * 1e9));
strcat(buf, " ");
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
frequency_string(buf+5, 24-5, stop);
strcat(buf, " ");
ili9341_drawstring_8x8_var(buf, 165, 233, 0xffff, 0x0000);
}
else if (frequency1 < 0)
{
int fcenter = frequency0;
int fspan = -frequency1;
strcpy(buf, "CENTER ");
frequency_string(buf+7, 24-7, fcenter);
strcat(buf, " ");
ili9341_drawstring_8x8_var(buf, OFFSETX, 233, 0xffff, 0x0000);
strcpy(buf, "SPAN ");
frequency_string(buf+5, 24-5, fspan);
strcat(buf, " ");
ili9341_drawstring_8x8_var(buf, 170, 233, 0xffff, 0x0000);
}
else
{
int fcenter = frequency0;
chsnprintf(buf, 24, "CW %d.%03d %03d MHz ",
(int)(fcenter / 1000000),
(int)((fcenter / 1000) % 1000),
(int)(fcenter % 1000));
ili9341_drawstring_8x8_var(buf, OFFSETX, 233, 0xffff, 0x0000);
chsnprintf(buf, 24, " ");
ili9341_drawstring_8x8_var(buf, 165, 233, 0xffff, 0x0000);
}
}
else
{
strcpy(buf, "START 0s ");
ili9341_drawstring_8x8_var(buf, OFFSETX, 233, 0xffff, 0x0000);
strcpy(buf, "STOP ");
chsnprintf(buf+5, 24-5, "%d ns", (uint16_t)(time_of_index(101) * 1e9));
strcat(buf, " ");
ili9341_drawstring_8x8_var(buf, 165, 233, 0xffff, 0x0000);
}
}
void
draw_cal_status(void)
{
int x = 0;
int y = 100;
#define YSTEP 7
ili9341_fill(0, y, 10, 6*YSTEP, 0x0000);
if (cal_status & CALSTAT_APPLY) {
char c[3] = "C0";
c[1] += lastsaveid;
#define YSTEP 12
ili9341_fill(0, y, 10, 8*YSTEP, 0x0000);
if (cal_status & CALSTAT_APPLY)
{
char ch = 'C';
char ch2 = '0' + lastsaveid;
if (cal_status & CALSTAT_INTERPOLATED)
c[0] = 'c';
ch = 'c';
else if (active_props == &current_props)
c[1] = '*';
ili9341_drawstring_5x7(c, x, y, 0xffff, 0x0000);
ch2 = '*';
ili9341_drawchar_8x8(ch, x, y, 0xffff, 0x0000);
y += 8;
ili9341_drawchar_8x8(ch2, x+1, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ED) {
ili9341_drawstring_5x7("D", x, y, 0xffff, 0x0000);
if (cal_status & CALSTAT_ED)
{
ili9341_drawstring_8x8("D", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ER) {
ili9341_drawstring_5x7("R", x, y, 0xffff, 0x0000);
if (cal_status & CALSTAT_ER)
{
ili9341_drawstring_8x8("R", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ES) {
ili9341_drawstring_5x7("S", x, y, 0xffff, 0x0000);
if (cal_status & CALSTAT_ES)
{
ili9341_drawstring_8x8("S", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ET) {
ili9341_drawstring_5x7("T", x, y, 0xffff, 0x0000);
if (cal_status & CALSTAT_ET)
{
ili9341_drawstring_8x8("T", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_EX) {
ili9341_drawstring_5x7("X", x, y, 0xffff, 0x0000);
if (cal_status & CALSTAT_EX)
{
ili9341_drawstring_8x8("X", x, y, 0xffff, 0x0000);
y += YSTEP;
}
}
void
draw_battery_status(void)
{

67
ui.c
View file

@ -21,6 +21,7 @@
#include "ch.h"
#include "hal.h"
#include "nanovna.h"
#include "chprintf.h"
#include <stdlib.h>
#include <string.h>
@ -317,7 +318,7 @@ touch_cal_exec(void)
ili9341_fill(0, 0, 320, 240, 0);
ili9341_line(0, 0, 0, 32, 0xffff);
ili9341_line(0, 0, 32, 0, 0xffff);
ili9341_drawstring_5x7("TOUCH UPPER LEFT", 10, 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("TOUCH UPPER LEFT", 10, 10, 0xffff, 0x0000);
do {
status = touch_check();
@ -328,7 +329,7 @@ touch_cal_exec(void)
ili9341_fill(0, 0, 320, 240, 0);
ili9341_line(320-1, 240-1, 320-1, 240-32, 0xffff);
ili9341_line(320-1, 240-1, 320-32, 240-1, 0xffff);
ili9341_drawstring_5x7("TOUCH LOWER RIGHT", 230, 220, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("TOUCH LOWER RIGHT", 200, 220, 0xffff, 0x0000);
do {
status = touch_check();
@ -345,6 +346,17 @@ touch_cal_exec(void)
touch_start_watchdog();
}
void
touch_position(int *x, int *y)
{
*x = (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2];
*y = (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3];
}
void
touch_draw_test(void)
{
@ -355,7 +367,7 @@ touch_draw_test(void)
adc_stop(ADC1);
ili9341_fill(0, 0, 320, 240, 0);
ili9341_drawstring_5x7("TOUCH TEST: DRAG PANEL", OFFSETX, 233, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("TOUCH TEST: DRAG PANEL", OFFSETX, 232, 0xffff, 0x0000);
do {
status = touch_check();
@ -375,13 +387,6 @@ touch_draw_test(void)
}
void
touch_position(int *x, int *y)
{
*x = (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2];
*y = (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3];
}
void
show_version(void)
@ -394,21 +399,19 @@ show_version(void)
ili9341_drawstring_size(BOARD_NAME, x, y, 0xffff, 0x0000, 4);
y += 25;
ili9341_drawstring_5x7("2016-2019 Copyright @edy555", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Licensed under GPL. See: https://github.com/ttrftech/NanoVNA", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Version: " VERSION, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Build Time: " __DATE__ " - " __TIME__, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("2016-2019 Copyright @edy555", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Licensed under GPL.", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var(" see: https://github.com/ttrftech/NanoVNA", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Version: " VERSION, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Build Time: " __DATE__ " - " __TIME__, x, y += 10, 0xffff, 0x0000);
y += 5;
ili9341_drawstring_5x7("Kernel: " CH_KERNEL_VERSION, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Compiler: " PORT_COMPILER_NAME, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: " PORT_CORE_VARIANT_NAME, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Port Info: " PORT_INFO, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_5x7("Platform: " PLATFORM_NAME, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8("Hello world" S_PI S_MICRO S_OHM S_DEGREE S_LARROW S_RARROW, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Hello world" S_PI S_MICRO S_OHM S_DEGREE S_LARROW S_RARROW, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("ABCDEFGHIJKL MNOPQRSTUVWXYZ" S_PI S_MICRO S_OHM S_DEGREE S_LARROW S_RARROW, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("abcdefghijkl mnopqrstuvwxyz" S_PI S_MICRO S_OHM S_DEGREE S_LARROW S_RARROW, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("0123456790" S_PI S_MICRO S_OHM S_DEGREE S_LARROW S_RARROW, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Kernel: " CH_KERNEL_VERSION, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Compiler: " PORT_COMPILER_NAME, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: " PORT_CORE_VARIANT_NAME, x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("Port Info: " PORT_INFO, x, y += 10, 0xffff, 0x0000);
y += 5;
ili9341_drawstring_8x8_var("Platform: ", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var(PLATFORM_NAME, x, y += 10, 0xffff, 0x0000);
while (true) {
if (touch_check() == EVT_TOUCH_PRESSED)
@ -425,11 +428,15 @@ enter_dfu(void)
{
adc_stop(ADC1);
int x = 5, y = 5;
int x = 100, y = 20;
// leave a last message
ili9341_fill(0, 0, 320, 240, 0);
ili9341_drawstring_8x8_var("DFU: Device Firmware Update Mode", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_size("DFU", x+30, y, 0xffff, 0x0000, 4);
x = 5;
y += 50;
ili9341_drawstring_8x8_var("Device Firmware Update Mode", x, y += 10, 0xffff, 0x0000);
ili9341_drawstring_8x8_var("To exit DFU mode, please reset device yourself.", x, y += 10, 0xffff, 0x0000);
// see __early_init in ./NANOVNA_STM32_F072/board.c
@ -980,10 +987,10 @@ const menuitem_t menu_stimulus[] = {
};
const menuitem_t menu_marker_sel[] = {
{ MT_CALLBACK, "MARKER 1", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER 2", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER 3", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER 4", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER1", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER2", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER3", menu_marker_sel_cb },
{ MT_CALLBACK, "MARKER4", menu_marker_sel_cb },
{ MT_CALLBACK, "ALL OFF", menu_marker_sel_cb },
{ MT_CANCEL, S_LARROW" BACK", NULL },
{ MT_NONE, NULL, NULL } // sentinel