Skip to content

Commit 2287f04

Browse files
oscplot: fix math feature
ensures that channels whose names end _i and _q are properly read and added when creating math channels Signed-off-by: Cristina Suteu <[email protected]>
1 parent 4441374 commit 2287f04

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

oscplot.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5361,7 +5361,7 @@ int osc_plot_ini_read_handler (OscPlot *plot, int line, const char *section,
53615361
gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(priv->builder, "labelYMax")));
53625362
gtk_widget_hide(priv->y_axis_min);
53635363
gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(priv->builder, "labelYMin")));
5364-
}
5364+
}
53655365
} else if (MATCH_NAME("user_y_axis_max"))
53665366
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->y_axis_max), atof(value));
53675367
else if (MATCH_NAME("user_y_axis_min"))
@@ -6109,18 +6109,31 @@ static gint channel_compare(gconstpointer a, gconstpointer b)
61096109
static GSList * math_expression_get_iio_channel_list(const char *expression, struct iio_context *ctx, const char *device, bool *has_invalid_ch)
61106110
{
61116111
GSList *chn_list = NULL;
6112-
GRegex *regex;
6112+
GRegex *regex, *regex_i, *regex_q;
61136113
GMatchInfo *info;
61146114
gchar *chn_name;
61156115
struct iio_device *iio_dev;
61166116
struct iio_channel *iio_chn;
6117-
gboolean invalid_list = false, is_match;
6117+
gboolean invalid_list = false, is_match = true, match_q, match_i, match;
61186118

61196119
if (!device || !(iio_dev = iio_context_find_device(ctx, device)))
61206120
return NULL;
61216121

61226122
regex = g_regex_new("voltage[0-9]+", 0, 0, NULL);
6123-
is_match = g_regex_match(regex, expression, 0, &info);
6123+
regex_i = g_regex_new("voltage[0-9]+_i", 0, 0 , NULL);
6124+
regex_q = g_regex_new("voltage[0-9]+_q", 0, 0 , NULL);
6125+
6126+
match_i = g_regex_match(regex_i, expression, 0, &info);
6127+
6128+
if (!match_i) {
6129+
match_q = g_regex_match(regex_q, expression, 0, &info);
6130+
if (!match_q) {
6131+
match = g_regex_match(regex, expression, 0, &info);
6132+
if (!match)
6133+
is_match = false;
6134+
}
6135+
}
6136+
61246137
if (!is_match) {
61256138
invalid_list = true;
61266139
} else {
@@ -6138,6 +6151,8 @@ static GSList * math_expression_get_iio_channel_list(const char *expression, str
61386151
}
61396152
g_match_info_free(info);
61406153
g_regex_unref(regex);
6154+
g_regex_unref(regex_i);
6155+
g_regex_unref(regex_q);
61416156

61426157
if (invalid_list) {
61436158
if (chn_list)
@@ -7039,7 +7054,7 @@ static void create_plot(OscPlot *plot)
70397054
g_error_free(err);
70407055
gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(plot->priv->provider),OSC_STYLE_FILE_PATH"styles.css",NULL);
70417056
}
7042-
7057+
70437058
//gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(plot->priv->provider),"styles.css",NULL);
70447059
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER(plot->priv->provider), GTK_STYLE_PROVIDER_PRIORITY_USER);
70457060
style_context = gtk_widget_get_style_context(GTK_WIDGET(priv->databox));

0 commit comments

Comments
 (0)