Skip to content

Commit

Permalink
feat: paramterize number of y-grid, revert to 8
Browse files Browse the repository at this point in the history
  • Loading branch information
edy555 committed Feb 23, 2020
1 parent c89cd36 commit 7d2708a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
8 changes: 4 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,10 @@ properties_t current_props = {
._frequency1 = 900000000, // end = 900MHz
._sweep_points = POINTS_COUNT,
._trace = {/*enable, type, channel, reserved, scale, refpos*/
{ 1, TRC_LOGMAG, 0, 0, 10.0, 9.0 },
{ 1, TRC_LOGMAG, 1, 0, 10.0, 9.0 },
{ 1, TRC_SMITH, 0, 0, 1.0, 0.0 },
{ 1, TRC_PHASE, 1, 0, 90.0, 5.0 }
{ 1, TRC_LOGMAG, 0, 0, 10.0, NGRIDY-1 },
{ 1, TRC_LOGMAG, 1, 0, 10.0, NGRIDY-1 },
{ 1, TRC_SMITH, 0, 0, 1.0, 0 },
{ 1, TRC_PHASE, 1, 0, 90.0, NGRIDY/2 }
},
._markers = {
{ 1, 30, 0 }, { 0, 40, 0 }, { 0, 60, 0 }, { 0, 80, 0 }
Expand Down
17 changes: 13 additions & 4 deletions nanovna.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,26 @@ extern void tlv320aic3204_select(int channel);
/*
* plot.c
*/
// GRIDX calculated depends from frequency span
#define GRIDY 23

// Offset of plot area
#define OFFSETX 10
#define OFFSETY 0

// WIDTH better be n*(POINTS_COUNT-1)
#define WIDTH 300
// HEIGHT = 10*GRIDY
#define HEIGHT 230
// HEIGHT = 8*GRIDY
#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
Expand Down
12 changes: 6 additions & 6 deletions plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ trace_into_index(int t, int i, float array[POINTS_COUNT][2])
int y, x;

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

void
Expand Down
2 changes: 2 additions & 0 deletions ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,7 @@ static const GPTConfig gpt3cfg = {
0
};

#if 0
static void
test_touch(int *x, int *y)
{
Expand All @@ -2268,6 +2269,7 @@ test_touch(int *x, int *y)

touch_start_watchdog();
}
#endif

void
handle_touch_interrupt(void)
Expand Down

0 comments on commit 7d2708a

Please sign in to comment.