THD info overlap bug solved

master
erikkaashoek 5 years ago
parent 7024300315
commit 0c0d62e131

@ -2133,33 +2133,29 @@ static void cell_draw_marker_info(int x0, int y0)
break; break;
plot_printf(buf, sizeof buf, "DEVIATION:%6.1qHz", dev); plot_printf(buf, sizeof buf, "DEVIATION:%6.1qHz", dev);
goto show_computed; goto show_computed;
} } else if (setting.measurement == M_THD && markers[0].enabled && (markers[0].index << 5) > sweep_points ) {
}
if (i >= 2 && setting.measurement == M_THD) {
if (i == 2 && (markers[0].index << 5) > sweep_points ) {
int old_unit = setting.unit; int old_unit = setting.unit;
setting.unit = U_WATT; setting.unit = U_WATT;
float p = index_to_value(markers[0].index); float p = index_to_value(markers[0].index);
int j = 2; int h_i = 2;
uint32_t f = markers[0].frequency; uint32_t f = markers[0].frequency;
float h = 0.0; float h = 0.0;
while (f * j < frequencies[sweep_points-1]) { while (f * h_i < frequencies[sweep_points-1]) {
if (search_maximum(1, f*j, 4*j) ) // use marker 1 for searching harmonics if (search_maximum(1, f*h_i, 4*h_i) ) // use marker 1 for searching harmonics
h += index_to_value(markers[1].index); h += index_to_value(markers[1].index);
j++; h_i++;
} }
float thd = 100.0 * sqrt(h/p); float thd = 100.0 * sqrt(h/p);
setting.unit = old_unit; setting.unit = old_unit;
ili9341_set_foreground(marker_color(markers[0].mtype));
plot_printf(buf, sizeof buf, "THD: %4.1f%%", thd); plot_printf(buf, sizeof buf, "THD: %4.1f%%", thd);
j = 1; // j = 1;
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(16) - y0; int ypos = 1 + (j/2)*(16) - y0;
cell_drawstring_7x13(buf, xpos, ypos); cell_drawstring_7x13(buf, xpos, ypos);
// cell_drawstring(buf, xpos, ypos); // cell_drawstring(buf, xpos, ypos);
break; break;
} }
break;
} else } else
if (i >= 2 && setting.measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) { if (i >= 2 && setting.measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) {
float il = index_to_value(markers[2].index); float il = index_to_value(markers[2].index);
@ -2202,14 +2198,6 @@ static void cell_draw_marker_info(int x0, int y0)
for (t = TRACE_ACTUAL; t <= TRACE_ACTUAL; t++) { // Only show info on actual trace for (t = TRACE_ACTUAL; t <= TRACE_ACTUAL; t++) { // Only show info on actual trace
if (!trace[t].enabled) if (!trace[t].enabled)
continue; continue;
#if 1
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
// int ypos = 1 + (j/2)*(13) - y0;
int ypos = 1 + (j/2)*(16) - y0;
#else
int xpos = 1 + CELLOFFSETX - x0;
int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0;
#endif
int k = 0; int k = 0;
if (i == active_marker) { if (i == active_marker) {
// ili9341_set_foreground(LCD_BG_COLOR); // ili9341_set_foreground(LCD_BG_COLOR);
@ -2248,6 +2236,14 @@ static void cell_draw_marker_info(int x0, int y0)
trace_get_value_string( trace_get_value_string(
t, &buf[k], (sizeof buf) - k, t, &buf[k], (sizeof buf) - k,
idx, measured[trace[t].channel], ridx, markers[i].mtype,markers[i].frequency, markers[ref_marker].frequency); idx, measured[trace[t].channel], ridx, markers[i].mtype,markers[i].frequency, markers[ref_marker].frequency);
#if 1
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
// int ypos = 1 + (j/2)*(13) - y0;
int ypos = 1 + (j/2)*(16) - y0;
#else
int xpos = 1 + CELLOFFSETX - x0;
int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0;
#endif
if (/* strlen(buf)*7> WIDTH/2 && */active > 1) if (/* strlen(buf)*7> WIDTH/2 && */active > 1)
cell_drawstring(buf, xpos, ypos); cell_drawstring(buf, xpos, ypos);
else else

@ -454,7 +454,6 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg
register uint16_t t_mode; register uint16_t t_mode;
uint16_t data_level = T_LEVEL_UNDEF; uint16_t data_level = T_LEVEL_UNDEF;
if (up_direction) if (up_direction)
t_mode = T_UP_MASK; t_mode = T_UP_MASK;
else else
@ -469,6 +468,9 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg
rssi = shiftIn(); rssi = shiftIn();
palSetPad(GPIOC, sel); palSetPad(GPIOC, sel);
age[i] = rssi; age[i] = rssi;
i++;
if (i >= sweep_points)
i = 0;
switch (waiting) { switch (waiting) {
case ST_ARMING: case ST_ARMING:
if (i == sweep_points-1) { if (i == sweep_points-1) {
@ -491,15 +493,12 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg
waiting = ST_FILLING; waiting = ST_FILLING;
switch (trigger_mode) { switch (trigger_mode) {
case T_PRE: // Trigger at the begin of the scan case T_PRE: // Trigger at the begin of the scan
buf_index = i - 1; buf_index = i;
if (buf_index < 0) goto fill_rest;
buf_index += sweep_points;
break; break;
case T_POST: // Trigger at the end of the scan case T_POST: // Trigger at the end of the scan
buf_index = i; buf_index = i;
if (buf_index >= sweep_points) goto done;
buf_index -= sweep_points;
goto store;
break; break;
case T_MID: // Trigger in the middle of the scan case T_MID: // Trigger in the middle of the scan
buf_index = i + sweep_points/2; buf_index = i + sweep_points/2;
@ -510,13 +509,10 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg
} }
break; break;
case ST_FILLING: case ST_FILLING:
store:
if (i == buf_index) if (i == buf_index)
goto done; goto done;
} }
i++; fill_rest:
if (i >= sweep_points)
i = 0;
if (t) if (t)
my_microsecond_delay(t); my_microsecond_delay(t);
}while(1); }while(1);

@ -1143,17 +1143,14 @@ static UI_FUNCTION_ADV_CALLBACK(menu_trigger_acb)
setting.trigger_mode += 1; setting.trigger_mode += 1;
if (setting.trigger_mode > T_MID) if (setting.trigger_mode > T_MID)
setting.trigger_mode = T_PRE; setting.trigger_mode = T_PRE;
data = setting.trigger_mode; set_trigger(setting.trigger_mode);
goto done; } else if (data != T_DONE) {
} else
if (data != T_DONE) {
done:
set_trigger(data); set_trigger(data);
// menu_move_back(); // menu_move_back();
ui_mode_normal(); ui_mode_normal();
draw_menu();
completed = true;
} }
draw_menu();
completed = true;
} }
#if 0 #if 0

Loading…
Cancel
Save

Powered by TurnKey Linux.