bigger fonts, beta version

This commit is contained in:
Dennis Real (DL9CAT) 2019-10-03 19:21:01 +02:00
parent ce9fed2914
commit acb3609244
5 changed files with 97 additions and 89 deletions

View file

@ -26,7 +26,7 @@ const uint8_t x8x8_bits[][8]={
{0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00}, /* 0x2D '-' */ {0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00}, /* 0x2D '-' */
{0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00}, /* 0x2E '.' */ {0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00}, /* 0x2E '.' */
{0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00}, /* 0x2F '/' */ {0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00}, /* 0x2F '/' */
{0x78,0xCC,0xDC,0xFC,0xEC,0xCC,0x78,0x00}, /* 0x30 '0' */ {0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00}, /* 0x30 '0' */
{0x30,0xF0,0x30,0x30,0x30,0x30,0xFC,0x00}, /* 0x31 '1' */ {0x30,0xF0,0x30,0x30,0x30,0x30,0xFC,0x00}, /* 0x31 '1' */
{0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00}, /* 0x32 '2' */ {0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00}, /* 0x32 '2' */
{0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00}, /* 0x33 '3' */ {0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00}, /* 0x33 '3' */

15
main.c
View file

@ -544,7 +544,6 @@ static void cmd_capture(BaseSequentialStream *chp, int argc, char *argv[])
} }
len -= PART; len -= PART;
} }
//*/
chMtxUnlock(&mutex); chMtxUnlock(&mutex);
} }
@ -602,9 +601,9 @@ config_t config = {
/* grid_color */ 0x1084, /* grid_color */ 0x1084,
/* menu_normal_color */ 0xffff, /* menu_normal_color */ 0xffff,
/* menu_active_color */ 0x7777, /* menu_active_color */ 0x7777,
/* trace_colors[4] */ { RGB565(0,255,255), RGB565(255,0,40), RGB565(0,0,255), RGB565(50,255,0) }, /* trace_color[4] */ { RGB_565(255,255,0), RGB_565(0,40,255), RGB_565(0,255,0), RGB_565(255,200,20) },
///* touch_cal[4] */ { 620, 600, 160, 190 }, /* trace_colors[4] */ // { RGB565(0,255,255), RGB565(255,0,40), RGB565(0,0,255), RGB565(50,255,0) },
/* touch_cal[4] */ { 693, 605, 124, 171 }, /* touch_cal[4] */ { 411, 592, 151, 189 },
/* default_loadcal */ 0, /* default_loadcal */ 0,
/* checksum */ 0 /* checksum */ 0
}; };
@ -1421,17 +1420,17 @@ const struct {
uint16_t refpos; uint16_t refpos;
float scale_unit; float scale_unit;
} trace_info[] = { } trace_info[] = {
{ "LGMG", 7, 10 }, { "LMG", 7, 10 },
{ "PHA", 4, 90 }, { "PHA", 4, 90 },
{ "DEL", 4, 1 }, { "DEL", 4, 1 },
{ "SMI", 0, 1 }, { "SMI", 0, 1 },
{ "PLR", 0, 1 }, { "POL", 0, 1 },
{ "LIN", 0, 0.125 }, { "LIN", 0, 0.125 },
{ "SWR", 0, 1 }, { "SWR", 0, 1 },
{ "REAL", 4, 0.25 }, { "REAL", 4, 0.25 },
{ "IMAG", 4, 0.25 }, { "IMAG", 4, 0.25 },
{ "R", 0, 100 }, { "RES", 0, 100 },
{ "X", 4, 100 } { "REA", 4, 100 }
}; };
const char * const trc_channel_name[] = { const char * const trc_channel_name[] = {

View file

@ -243,7 +243,7 @@ void redraw_frame(void);
void request_to_draw_cells_behind_menu(void); void request_to_draw_cells_behind_menu(void);
void request_to_draw_cells_behind_numeric_input(void); void request_to_draw_cells_behind_numeric_input(void);
void redraw_marker(int marker, int update_info); void redraw_marker(int marker, int update_info);
void trace_get_info(int t, char *buf, int len); uint16_t trace_get_info(int t, char *buf, uint16_t len);
void plot_into_index(float measured[2][101][2]); void plot_into_index(float measured[2][101][2]);
void force_set_markmap(void); void force_set_markmap(void);
void draw_all(bool flush); void draw_all(bool flush);
@ -269,6 +269,7 @@ extern int16_t vbat;
* ili9341.c * ili9341.c
*/ */
#define RGB565(b,r,g) ( (((b)<<8)&0xfc00) | (((r)<<2)&0x03e0) | (((g)>>3)&0x001f) ) #define RGB565(b,r,g) ( (((b)<<8)&0xfc00) | (((r)<<2)&0x03e0) | (((g)>>3)&0x001f) )
#define RGB_565(r, g, b) ( (((b)<<8)&0xfc00) | (((r)<<2)&0x03e0) | (((g)>>3)&0x001f) )
typedef struct { typedef struct {
uint16_t width; uint16_t width;

164
plot.c
View file

@ -641,15 +641,15 @@ trace_get_value_string(int t, char *buf, int len, float coeff[2], uint32_t frequ
if (v == -INFINITY) if (v == -INFINITY)
chsnprintf(buf, len, "-INF dB"); chsnprintf(buf, len, "-INF dB");
else else
chsnprintf(buf, len, "%.2fdB", v); chsnprintf(buf, len, "%.1fdB", v);
break; break;
case TRC_PHASE: case TRC_PHASE:
v = phase(coeff); v = phase(coeff);
chsnprintf(buf, len, "%.2f" S_DEGREE, v); chsnprintf(buf, len, "%.1f" S_DEGREE, v);
break; break;
case TRC_LINEAR: case TRC_LINEAR:
v = linear(coeff); v = linear(coeff);
chsnprintf(buf, len, "%.2f", v); chsnprintf(buf, len, "%.1f", v);
break; break;
case TRC_SWR: case TRC_SWR:
v = swr(coeff); v = swr(coeff);
@ -672,35 +672,43 @@ trace_get_value_string(int t, char *buf, int len, float coeff[2], uint32_t frequ
break; break;
//case TRC_ADMIT: //case TRC_ADMIT:
case TRC_POLAR: case TRC_POLAR:
chsnprintf(buf, len, "%.2f %.2fj", coeff[0], coeff[1]); chsnprintf(buf, len, "%.1f %.1fj", coeff[0], coeff[1]);
break; break;
} }
} }
void
trace_get_info(int t, char *buf, int len)
uint16_t
trace_get_info(int t, char *buf, uint16_t len)
{ {
const char *type = get_trace_typename(t); const char *type = get_trace_typename(t);
int n; uint16_t n = 0;
switch (trace[t].type) {
switch ( trace[t].type )
{
case TRC_LOGMAG: case TRC_LOGMAG:
chsnprintf(buf, len, "%s %ddB/", type, (int)get_trace_scale(t)); n = chsnprintf(buf, len, "%s %ddB/", type, (int)get_trace_scale(t));
break; break;
case TRC_PHASE: case TRC_PHASE:
chsnprintf(buf, len, "%s %d" S_DEGREE "/", type, (int)get_trace_scale(t)); n = chsnprintf(buf, len, "%s %d" S_DEGREE "/", type, (int)get_trace_scale(t));
break; break;
case TRC_SMITH: case TRC_SMITH:
//case TRC_ADMIT: //case TRC_ADMIT:
case TRC_POLAR: case TRC_POLAR:
chsnprintf(buf, len, "%s %.1fFS", type, get_trace_scale(t)); n = chsnprintf(buf, len, "%s %.1fFS", type, get_trace_scale(t));
break; break;
default: default:
n = chsnprintf(buf, len, "%s ", type); n = chsnprintf(buf, len, "%s ", type);
string_value_with_prefix(buf+n, len-n, get_trace_scale(t), '/'); string_value_with_prefix(buf+n, len-n, get_trace_scale(t), '/');
break; break;
} }
return n;
} }
static float time_of_index(int idx) { static float time_of_index(int idx) {
return 1.0 / (float)(frequencies[1] - frequencies[0]) / (float)FFT_SIZE * idx; return 1.0 / (float)(frequencies[1] - frequencies[0]) / (float)FFT_SIZE * idx;
} }
@ -1205,7 +1213,9 @@ draw_cell(int m, int n)
{ {
memset(spi_buffer, 0, sizeof spi_buffer); memset(spi_buffer, 0, sizeof spi_buffer);
} }
if (grid_mode & (GRID_SMITH|GRID_ADMIT|GRID_POLAR)) {
if (grid_mode & (GRID_SMITH|GRID_ADMIT|GRID_POLAR))
{
for (y = 0; y < h; y++) for (y = 0; y < h; y++)
{ {
@ -1227,18 +1237,21 @@ draw_cell(int m, int n)
#if 1 #if 1
/* draw rectanglar plot */ /* draw rectanglar plot */
for (t = 0; t < TRACES_MAX; t++) { for (t = 0; t < TRACES_MAX; t++)
{
if (!trace[t].enabled) if (!trace[t].enabled)
continue; continue;
if (trace[t].type == TRC_SMITH || trace[t].type == TRC_POLAR) if (trace[t].type == TRC_SMITH || trace[t].type == TRC_POLAR)
continue; continue;
if (search_index_range_x(x0, trace_index[t], &i0, &i1)) { if (search_index_range_x(x0, trace_index[t], &i0, &i1))
{
if (i0 > 0) if (i0 > 0)
i0--; i0--;
if (i1 < 101-1) if (i1 < 101-1)
i1++; i1++;
for (i = i0; i < i1; i++) { for (i = i0; i < i1; i++)
{
int x1 = CELL_X(trace_index[t][i]); int x1 = CELL_X(trace_index[t][i]);
int x2 = CELL_X(trace_index[t][i+1]); int x2 = CELL_X(trace_index[t][i+1]);
int y1 = CELL_Y(trace_index[t][i]); int y1 = CELL_Y(trace_index[t][i]);
@ -1251,14 +1264,16 @@ draw_cell(int m, int n)
#endif #endif
#if 1 #if 1
/* draw polar plot */ /* draw polar plot */
for (t = 0; t < TRACES_MAX; t++) { for (t = 0; t < TRACES_MAX; t++)
{
int c = config.trace_color[t]; int c = config.trace_color[t];
if (!trace[t].enabled) if (!trace[t].enabled)
continue; continue;
if (trace[t].type != TRC_SMITH && trace[t].type != TRC_POLAR) if (trace[t].type != TRC_SMITH && trace[t].type != TRC_POLAR)
continue; continue;
for (i = 1; i < sweep_points; i++) { for (i = 1; i < sweep_points; i++)
{
//uint32_t index = trace_index[t][i]; //uint32_t index = trace_index[t][i];
//uint32_t pindex = trace_index[t][i-1]; //uint32_t pindex = trace_index[t][i-1];
//if (!CELL_P(index, x0, y0) && !CELL_P(pindex, x0, y0)) //if (!CELL_P(index, x0, y0) && !CELL_P(pindex, x0, y0))
@ -1408,18 +1423,30 @@ cell_drawstring_invert_5x7(int w, int h, char *str, int x, int y, uint16_t fg, i
unsigned char uint16_t
cell_drawchar_8x8(int w, int h, uint8_t ch, int x, int y, uint16_t fg, uint8_t var, int invert) cell_drawchar_8x8(int w, int h, uint8_t ch, int x, int y, uint16_t fg, uint8_t var, uint8_t invert)
{ {
uint8_t bits, charlen = 8; uint8_t bits;
uint16_t charwidthpx = 8;
int cline, r; int cline, r;
// fixme // fixme
// if (y <= -8 || y >= h || x <= -8 || x >= w) // if (y <= -8 || y >= h || x <= -8 || x >= w)
// return 0; // return 0;
ch = x8x8_map_char_table(ch); ch = x8x8_map_char_table(ch);
if ( var != FALSE )
{
charwidthpx = x8x8_len[ch];
}
// if (y <= -8 || y >= h || x >= w ) // fixme x <= -(charlen) || x >= w)
// return 0;
for (cline = 0; cline < 8; cline++) for (cline = 0; cline < 8; cline++)
{ {
if ((y + cline) < 0 || (y + cline) >= h) if ((y + cline) < 0 || (y + cline) >= h)
@ -1430,12 +1457,8 @@ cell_drawchar_8x8(int w, int h, uint8_t ch, int x, int y, uint16_t fg, uint8_t v
if (invert) if (invert)
bits = ~bits; bits = ~bits;
if ( var != FALSE )
{
charlen = x8x8_len[ch];
}
for (r = 0; r < charlen; r++) for (r = 0; r < charwidthpx; r++)
{ {
if ( (x+r) >= 0 && (x+r) < w && (0x80 & bits) ) if ( (x+r) >= 0 && (x+r) < w && (0x80 & bits) )
spi_buffer[(y+cline)*w + (x+r)] = fg; spi_buffer[(y+cline)*w + (x+r)] = fg;
@ -1444,63 +1467,44 @@ cell_drawchar_8x8(int w, int h, uint8_t ch, int x, int y, uint16_t fg, uint8_t v
} }
} }
return x8x8_len[ch]; return charwidthpx;
} }
void uint16_t
cell_drawstring_8x8(int w, int h, char *str, int x, int y, uint16_t fg) cell_drawstring_8x8(int w, int h, char *str, int x, int y, uint16_t fg, uint8_t invert)
{ {
uint16_t strwidthpx = 0;
while (*str) while (*str)
{ {
cell_drawchar_8x8(w, h, *str, x, y, fg, FALSE, FALSE); strwidthpx += cell_drawchar_8x8(w, h, *str, x, y, fg, FALSE, invert);
x += 8; x += 8;
str++; str++;
} }
return strwidthpx;
} }
void uint16_t
cell_drawstring_invert_8x8(int w, int h, char *str, int x, int y, uint16_t fg, int invert) cell_drawstring_8x8_var(int w, int h, char *str, int x, int y, uint16_t fg, uint8_t invert)
{
while (*str)
{
cell_drawchar_8x8(w, h, *str, x, y, fg, FALSE, invert);
x += 8;
str++;
}
}
void
cell_drawstring_8x8_var(int w, int h, char *str, int x, int y, uint16_t fg)
{
unsigned char clength = 0;
while (*str)
{
clength = cell_drawchar_8x8(w, h, *str, x, y, fg, TRUE, FALSE);
x += clength;
str++;
}
}
void
cell_drawstring_invert_8x8_var(int w, int h, char *str, int x, int y, uint16_t fg, int invert)
{ {
unsigned char clength = 0; unsigned char clength = 0;
uint16_t strwidthpx = 0;
while (*str) while (*str)
{ {
clength = cell_drawchar_8x8(w, h, *str, x, y, fg, TRUE, invert); clength = cell_drawchar_8x8(w, h, *str, x, y, fg, TRUE, invert);
x += clength; x += clength;
strwidthpx += clength;
str++; str++;
} }
return strwidthpx;
} }
@ -1510,6 +1514,7 @@ cell_draw_marker_info(int m, int n, int w, int h)
{ {
char buf[24]; char buf[24];
int t; int t;
uint16_t slen, strwidthpx = 0;
if (n != 0) if (n != 0)
return; return;
@ -1525,55 +1530,58 @@ cell_draw_marker_info(int m, int n, int w, int h)
if (!trace[t].enabled) if (!trace[t].enabled)
continue; continue;
int xpos = 1 + (j%2)*146; int xpos = 1 + (j%2)*160;
int ypos = 1 + (j/2)*8; int ypos = 1 + (j/2)*8;
xpos -= m * CELLWIDTH - CELLOFFSETX; xpos -= m * CELLWIDTH - CELLOFFSETX;
ypos -= n * CELLHEIGHT; ypos -= n * CELLHEIGHT;
chsnprintf(buf, sizeof buf, "CH%d:", trace[t].channel);
cell_drawstring_invert_5x7(w, h, buf, xpos, ypos, config.trace_color[t], t == uistat.current_trace);
xpos += 20; chsnprintf(buf, sizeof buf, "C%d:", trace[t].channel);
trace_get_info(t, buf, sizeof buf); strwidthpx = cell_drawstring_8x8_var(w, h, buf, xpos, ypos, config.trace_color[t], t == uistat.current_trace);
cell_drawstring_5x7(w, h, buf, xpos, ypos, config.trace_color[t]);
xpos += 64; xpos += strwidthpx + 4;
trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel][idx], frequencies[idx]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, config.trace_color[t]); slen = trace_get_info(t, buf, sizeof buf);
trace_get_value_string(t, buf+slen, (sizeof(buf))-slen, measured[trace[t].channel][idx], frequencies[idx]);
cell_drawstring_8x8_var(w, h, buf, xpos, ypos, config.trace_color[t], FALSE);
j++; j++;
} }
// draw marker frequency // draw marker frequency
int xpos = 165; int xpos = 160;
int ypos = 1 + (j/2)*8; int ypos = 1 + (j/2)*8;
xpos -= m * CELLWIDTH - CELLOFFSETX; xpos -= m * CELLWIDTH - CELLOFFSETX;
ypos -= n * CELLHEIGHT; ypos -= n * CELLHEIGHT;
chsnprintf(buf, sizeof buf, "%d:", active_marker + 1); chsnprintf(buf, sizeof buf, "%d:", active_marker + 1);
cell_drawstring_8x8_var(w, h, buf, xpos, ypos, 0xffff); strwidthpx = cell_drawstring_8x8_var(w, h, buf, xpos, ypos, 0xffff, FALSE);
xpos += 16; xpos += strwidthpx + 4;
if ( (domain_mode & DOMAIN_MODE) == DOMAIN_FREQ ) if ( (domain_mode & DOMAIN_MODE) == DOMAIN_FREQ )
{ {
frequency_string(buf, sizeof buf, frequencies[idx]); frequency_string(buf, sizeof buf, frequencies[idx]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); cell_drawstring_8x8_var(w, h, buf, xpos, ypos, 0xffff, FALSE);
} }
else else
{ {
chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9), distance_of_index(idx)); chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9), distance_of_index(idx));
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); cell_drawstring_8x8_var(w, h, buf, xpos, ypos, 0xffff, FALSE);
} }
// draw marker delta // draw marker delta
if ( previous_marker >= 0 && active_marker != previous_marker && markers[previous_marker].enabled ) if ( previous_marker >= 0 && active_marker != previous_marker && markers[previous_marker].enabled )
{ {
int idx0 = markers[previous_marker].index; int idx0 = markers[previous_marker].index;
xpos = 192; xpos = 160;
xpos -= m * CELLWIDTH - CELLOFFSETX; xpos -= m * CELLWIDTH - CELLOFFSETX;
ypos += 7; ypos += 8;
chsnprintf(buf, sizeof buf, "\001%d:", previous_marker+1); chsnprintf(buf, sizeof buf, "\001%d:", previous_marker+1);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); strwidthpx = cell_drawstring_8x8(w, h, buf, xpos, ypos, 0xffff, FALSE);
xpos += 16; xpos += strwidthpx + 4;
frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]); frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); cell_drawstring_8x8_var(w, h, buf, xpos, ypos, 0xffff, FALSE);
} }
} }

2
ui.c
View file

@ -329,7 +329,7 @@ touch_cal_exec(void)
ili9341_fill(0, 0, 320, 240, 0); 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-1, 240-32, 0xffff);
ili9341_line(320-1, 240-1, 320-32, 240-1, 0xffff); ili9341_line(320-1, 240-1, 320-32, 240-1, 0xffff);
ili9341_drawstring_8x8_var("TOUCH LOWER RIGHT", 200, 220, 0xffff, 0x0000); ili9341_drawstring_8x8_var("TOUCH LOWER RIGHT", 190, 220, 0xffff, 0x0000);
do { do {
status = touch_check(); status = touch_check();