feat: paramterize number of y-grid, revert to 8

This commit is contained in:
TT 2020-02-23 11:37:41 +09:00
parent c89cd36f19
commit 7d2708afce
4 changed files with 25 additions and 14 deletions

8
main.c
View file

@ -706,10 +706,10 @@ properties_t current_props = {
._frequency1 = 900000000, // end = 900MHz ._frequency1 = 900000000, // end = 900MHz
._sweep_points = POINTS_COUNT, ._sweep_points = POINTS_COUNT,
._trace = {/*enable, type, channel, reserved, scale, refpos*/ ._trace = {/*enable, type, channel, reserved, scale, refpos*/
{ 1, TRC_LOGMAG, 0, 0, 10.0, 9.0 }, { 1, TRC_LOGMAG, 0, 0, 10.0, NGRIDY-1 },
{ 1, TRC_LOGMAG, 1, 0, 10.0, 9.0 }, { 1, TRC_LOGMAG, 1, 0, 10.0, NGRIDY-1 },
{ 1, TRC_SMITH, 0, 0, 1.0, 0.0 }, { 1, TRC_SMITH, 0, 0, 1.0, 0 },
{ 1, TRC_PHASE, 1, 0, 90.0, 5.0 } { 1, TRC_PHASE, 1, 0, 90.0, NGRIDY/2 }
}, },
._markers = { ._markers = {
{ 1, 30, 0 }, { 0, 40, 0 }, { 0, 60, 0 }, { 0, 80, 0 } { 1, 30, 0 }, { 0, 40, 0 }, { 0, 60, 0 }, { 0, 80, 0 }

View file

@ -129,8 +129,6 @@ extern void tlv320aic3204_select(int channel);
/* /*
* plot.c * plot.c
*/ */
// GRIDX calculated depends from frequency span
#define GRIDY 23
// Offset of plot area // Offset of plot area
#define OFFSETX 10 #define OFFSETX 10
@ -138,8 +136,19 @@ extern void tlv320aic3204_select(int channel);
// WIDTH better be n*(POINTS_COUNT-1) // WIDTH better be n*(POINTS_COUNT-1)
#define WIDTH 300 #define WIDTH 300
// HEIGHT = 10*GRIDY // HEIGHT = 8*GRIDY
#define HEIGHT 230 #define HEIGHT 232
//#define NGRIDY 10
#define NGRIDY 8
#define FREQUENCIES_XPOS1 OFFSETX
#define FREQUENCIES_XPOS2 200
#define FREQUENCIES_YPOS (HEIGHT+1)
// GRIDX calculated depends from frequency span
//#define GRIDY 29
#define GRIDY (HEIGHT / NGRIDY)
// //
#define CELLOFFSETX 5 #define CELLOFFSETX 5

12
plot.c
View file

@ -508,7 +508,7 @@ trace_into_index(int t, int i, float array[POINTS_COUNT][2])
int y, x; int y, x;
float *coeff = array[i]; float *coeff = array[i];
float refpos = 10 - get_trace_refpos(t); float refpos = NGRIDY - get_trace_refpos(t);
float v = refpos; float v = refpos;
float scale = 1 / get_trace_scale(t); float scale = 1 / get_trace_scale(t);
switch (trace[t].type) { switch (trace[t].type) {
@ -545,8 +545,8 @@ trace_into_index(int t, int i, float array[POINTS_COUNT][2])
cartesian_scale(coeff[0], coeff[1], &x, &y, scale); cartesian_scale(coeff[0], coeff[1], &x, &y, scale);
goto set_index; goto set_index;
} }
if (v < 0) v = 0; if (v < 0) v = 0;
if (v > 10) v = 10; if (v > NGRIDY) v = NGRIDY;
x = (i * (WIDTH) + (sweep_points-1)/2) / (sweep_points-1) + CELLOFFSETX; x = (i * (WIDTH) + (sweep_points-1)/2) / (sweep_points-1) + CELLOFFSETX;
y = floatToInt(v * GRIDY); y = floatToInt(v * GRIDY);
set_index: set_index:
@ -1367,7 +1367,7 @@ draw_cell(int m, int n)
continue; continue;
int x = 0 - x0 + CELLOFFSETX - REFERENCE_X_OFFSET; int x = 0 - x0 + CELLOFFSETX - REFERENCE_X_OFFSET;
if (x+REFERENCE_WIDTH>=0 && x-REFERENCE_WIDTH<w){ if (x+REFERENCE_WIDTH>=0 && x-REFERENCE_WIDTH<w){
int y = 10*GRIDY - floatToInt((get_trace_refpos(t) * GRIDY)) - y0 - REFERENCE_Y_OFFSET; int y = HEIGHT - floatToInt((get_trace_refpos(t) * GRIDY)) - y0 - REFERENCE_Y_OFFSET;
if (y+REFERENCE_HEIGHT>=0 && y-REFERENCE_HEIGHT<h) if (y+REFERENCE_HEIGHT>=0 && y-REFERENCE_HEIGHT<h)
draw_refpos(w, h, x, y, config.trace_color[t]); draw_refpos(w, h, x, y, config.trace_color[t]);
} }
@ -1632,8 +1632,8 @@ draw_frequencies(void)
buf1[0] = S_SARROW[0]; buf1[0] = S_SARROW[0];
if (uistat.lever_mode == LM_SPAN) if (uistat.lever_mode == LM_SPAN)
buf2[0] = S_SARROW[0]; buf2[0] = S_SARROW[0];
ili9341_drawstring(buf1, OFFSETX, 232); ili9341_drawstring(buf1, FREQUENCIES_XPOS1, FREQUENCIES_YPOS);
ili9341_drawstring(buf2, 200, 232); ili9341_drawstring(buf2, FREQUENCIES_XPOS2, FREQUENCIES_YPOS);
} }
void void

2
ui.c
View file

@ -2258,6 +2258,7 @@ static const GPTConfig gpt3cfg = {
0 0
}; };
#if 0
static void static void
test_touch(int *x, int *y) test_touch(int *x, int *y)
{ {
@ -2268,6 +2269,7 @@ test_touch(int *x, int *y)
touch_start_watchdog(); touch_start_watchdog();
} }
#endif
void void
handle_touch_interrupt(void) handle_touch_interrupt(void)