mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
make controlable marker with lever switch, test menu display
This commit is contained in:
parent
23f2b7f695
commit
5498d63751
1
dsp.c
1
dsp.c
|
|
@ -134,6 +134,7 @@ void calclate_gamma(float *gamma)
|
||||||
acc_ref += (float)rr*rr + (float)ri*ri;
|
acc_ref += (float)rr*rr + (float)ri*ri;
|
||||||
}
|
}
|
||||||
rn = sqrtf(acc_ref / len) * 2e3 * len;
|
rn = sqrtf(acc_ref / len) * 2e3 * len;
|
||||||
|
//rn = acc_ref;
|
||||||
gamma[0] = -acc_r / rn;
|
gamma[0] = -acc_r / rn;
|
||||||
gamma[1] = -acc_i / rn;
|
gamma[1] = -acc_i / rn;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
* @brief Enables the EXT subsystem.
|
* @brief Enables the EXT subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_EXT FALSE
|
#define HAL_USE_EXT TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
27
main.c
27
main.c
|
|
@ -45,8 +45,7 @@ void scan_lcd(void);
|
||||||
static MUTEX_DECL(mutex);
|
static MUTEX_DECL(mutex);
|
||||||
|
|
||||||
|
|
||||||
|
static THD_WORKING_AREA(waThread1, 400);
|
||||||
static THD_WORKING_AREA(waThread1, 384);
|
|
||||||
static THD_FUNCTION(Thread1, arg)
|
static THD_FUNCTION(Thread1, arg)
|
||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
@ -67,7 +66,7 @@ static THD_FUNCTION(Thread1, arg)
|
||||||
chMtxLock(&mutex);
|
chMtxLock(&mutex);
|
||||||
scan_lcd();
|
scan_lcd();
|
||||||
chMtxUnlock(&mutex);
|
chMtxUnlock(&mutex);
|
||||||
ui_process();
|
//ui_process();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -401,6 +400,7 @@ void scan_lcd(void)
|
||||||
;
|
;
|
||||||
palClearPad(GPIOC, GPIOC_LED);
|
palClearPad(GPIOC, GPIOC_LED);
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
/* calculate reflection coeficient */
|
||||||
calclate_gamma(measured[0][i]);
|
calclate_gamma(measured[0][i]);
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
|
||||||
|
|
@ -409,29 +409,20 @@ void scan_lcd(void)
|
||||||
while (wait_count)
|
while (wait_count)
|
||||||
;
|
;
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
/* calculate transmission coeficient */
|
||||||
calclate_gamma(measured[1][i]);
|
calclate_gamma(measured[1][i]);
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
|
||||||
delay = set_frequency(frequencies[(i+1)%sweep_points]);
|
delay = set_frequency(frequencies[(i+1)%sweep_points]);
|
||||||
#if 0
|
|
||||||
sweep_plot(frequencies[i], first, measured[0][i], measured[1][i]);
|
|
||||||
first = FALSE;
|
|
||||||
#endif
|
|
||||||
palSetPad(GPIOC, GPIOC_LED);
|
palSetPad(GPIOC, GPIOC_LED);
|
||||||
|
ui_process();
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
for (i = 0; i < sweep_points; i++) {
|
|
||||||
sweep_plot(frequencies[i], first, measured[0][i], measured[1][i]);
|
|
||||||
first = FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
sweep_tail();
|
|
||||||
polar_plot(measured);
|
|
||||||
#endif
|
|
||||||
if (cal_status & CALSTAT_APPLY)
|
if (cal_status & CALSTAT_APPLY)
|
||||||
apply_error_term();
|
apply_error_term();
|
||||||
|
|
||||||
plot_into_index(measured);
|
plot_into_index(measured);
|
||||||
|
|
||||||
draw_cell_all();
|
draw_cell_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1096,6 +1087,8 @@ int main(void)
|
||||||
i2sStart(&I2SD2, &i2sconfig);
|
i2sStart(&I2SD2, &i2sconfig);
|
||||||
i2sStartExchange(&I2SD2);
|
i2sStartExchange(&I2SD2);
|
||||||
|
|
||||||
|
ui_init();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shell manager initialization.
|
* Shell manager initialization.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
15
nanovna.h
15
nanovna.h
|
|
@ -70,10 +70,21 @@ void ili9341_drawstring_5x7(char *str, int x, int y, uint16_t fg, uint16_t bg);
|
||||||
/*
|
/*
|
||||||
* plot.c
|
* plot.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define OFFSETX 15
|
||||||
|
#define OFFSETY 0
|
||||||
|
#define WIDTH 291
|
||||||
|
#define HEIGHT 233
|
||||||
|
|
||||||
|
extern int area_width;
|
||||||
|
extern int area_height;
|
||||||
|
|
||||||
void plot_init(void);
|
void plot_init(void);
|
||||||
void set_sweep(int32_t start, int stop);
|
void set_sweep(int32_t start, int stop);
|
||||||
void redraw(void);
|
void redraw(void);
|
||||||
|
void force_draw_cells(void);
|
||||||
|
|
||||||
|
void redraw_marker(int marker);
|
||||||
|
|
||||||
|
|
||||||
#define TRACES_MAX 4
|
#define TRACES_MAX 4
|
||||||
|
|
@ -174,3 +185,7 @@ extern config_t current_config;
|
||||||
|
|
||||||
|
|
||||||
#define PULSE do { palClearPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);} while(0)
|
#define PULSE do { palClearPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);} while(0)
|
||||||
|
|
||||||
|
void ui_init(void);
|
||||||
|
void ui_show(void);
|
||||||
|
void ui_hide(void);
|
||||||
|
|
|
||||||
91
plot.c
91
plot.c
|
|
@ -11,11 +11,7 @@ void cell_draw_marker_info(int m, int n, int w, int h);
|
||||||
void draw_frequencies(void);
|
void draw_frequencies(void);
|
||||||
static inline void force_set_markmap(void);
|
static inline void force_set_markmap(void);
|
||||||
void frequency_string(char *buf, size_t len, uint32_t freq);
|
void frequency_string(char *buf, size_t len, uint32_t freq);
|
||||||
|
void markmap_all_markers(void);
|
||||||
#define OFFSETX 15
|
|
||||||
#define OFFSETY 0
|
|
||||||
#define WIDTH 291
|
|
||||||
#define HEIGHT 233
|
|
||||||
|
|
||||||
//#define GRID_COLOR 0x0863
|
//#define GRID_COLOR 0x0863
|
||||||
uint16_t grid_color = 0x1084;
|
uint16_t grid_color = 0x1084;
|
||||||
|
|
@ -500,9 +496,9 @@ void plot_into_index(float measured[2][101][2])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mark_cells_from_index();
|
mark_cells_from_index();
|
||||||
|
markmap_all_markers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cell_drawline(int w, int h, int x0, int y0, int x1, int y1, int c)
|
cell_drawline(int w, int h, int x0, int y0, int x1, int y1, int c)
|
||||||
{
|
{
|
||||||
|
|
@ -665,6 +661,50 @@ cell_draw_markers(int m, int n, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
markmap_marker(int marker)
|
||||||
|
{
|
||||||
|
int t;
|
||||||
|
if (!markers[marker].enabled)
|
||||||
|
return;
|
||||||
|
for (t = 0; t < TRACES_MAX; t++) {
|
||||||
|
if (!trace[t].enabled)
|
||||||
|
continue;
|
||||||
|
uint32_t index = trace_index[t][markers[marker].index];
|
||||||
|
int x = CELL_X(index);
|
||||||
|
int y = CELL_Y(index);
|
||||||
|
int m = x>>5;
|
||||||
|
int n = y>>5;
|
||||||
|
mark_map(m, n);
|
||||||
|
if ((x&31) < 6)
|
||||||
|
mark_map(m-1, n);
|
||||||
|
if ((x&31) > 32-6)
|
||||||
|
mark_map(m+1, n);
|
||||||
|
if ((y&31) < 12) {
|
||||||
|
mark_map(m, n-1);
|
||||||
|
if ((x&31) < 6)
|
||||||
|
mark_map(m-1, n-1);
|
||||||
|
if ((x&31) > 32-6)
|
||||||
|
mark_map(m+1, n-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
markmap_all_markers(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
if (!markers[i].enabled)
|
||||||
|
continue;
|
||||||
|
markmap_marker(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int area_width = WIDTH;
|
||||||
|
int area_height = HEIGHT;
|
||||||
|
|
||||||
void
|
void
|
||||||
draw_cell(int m, int n)
|
draw_cell(int m, int n)
|
||||||
{
|
{
|
||||||
|
|
@ -676,10 +716,10 @@ draw_cell(int m, int n)
|
||||||
int i0, i1;
|
int i0, i1;
|
||||||
int i;
|
int i;
|
||||||
int t;
|
int t;
|
||||||
if (x0 + w > WIDTH)
|
if (x0 + w > area_width)
|
||||||
w = WIDTH - x0;
|
w = area_width - x0;
|
||||||
if (y0 + h > HEIGHT)
|
if (y0 + h > area_height)
|
||||||
h = HEIGHT - y0;
|
h = area_height - y0;
|
||||||
|
|
||||||
PULSE;
|
PULSE;
|
||||||
/* draw grid */
|
/* draw grid */
|
||||||
|
|
@ -777,14 +817,41 @@ void
|
||||||
draw_cell_all(void)
|
draw_cell_all(void)
|
||||||
{
|
{
|
||||||
int m, n;
|
int m, n;
|
||||||
for (m = 0; m < (WIDTH+CELLWIDTH-1) / CELLWIDTH; m++)
|
for (m = 0; m < (area_width+CELLWIDTH-1) / CELLWIDTH; m++)
|
||||||
for (n = 0; n < (HEIGHT+CELLHEIGHT-1) / CELLHEIGHT; n++)
|
for (n = 0; n < (area_height+CELLHEIGHT-1) / CELLHEIGHT; n++) {
|
||||||
if (is_mapmarked(m, n))
|
if (is_mapmarked(m, n))
|
||||||
draw_cell(m, n);
|
draw_cell(m, n);
|
||||||
|
//ui_process();
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep current map for update
|
||||||
swap_markmap();
|
swap_markmap();
|
||||||
|
// clear map for next plotting
|
||||||
clear_markmap();
|
clear_markmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
redraw_marker(int marker)
|
||||||
|
{
|
||||||
|
// mark map on new position of marker
|
||||||
|
markmap_marker(marker);
|
||||||
|
|
||||||
|
// mark cells on marker info
|
||||||
|
markmap[current_mappage][0] = 0xffff;
|
||||||
|
|
||||||
|
draw_cell_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
force_draw_cells(void)
|
||||||
|
{
|
||||||
|
int n, m;
|
||||||
|
for (m = 7; m <= 9; m++)
|
||||||
|
for (n = 0; n < (area_height+CELLHEIGHT-1) / CELLHEIGHT; n++)
|
||||||
|
draw_cell(m, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cell_drawchar_5x7(int w, int h, uint8_t ch, int x, int y, uint16_t fg)
|
cell_drawchar_5x7(int w, int h, uint8_t ch, int x, int y, uint16_t fg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue