-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
osc: Implement a way to provide custom algorithm for XY plot #474
Conversation
Usage example: /* define the routine with the algorithm */ static void my_xy_transform(gfloat *x_in, gfloat *y_in, gfloat *x_out, gfloat *y_out, unsigned int length, void *user_data) { unsigned int i; for (i = 0; i < length; ++i) { x_out[i] = some_custom_algorithm(x_in[i]); y_out[i] = some_custom_algorithm(y_in[i]); } } /* Look for an already created plot instance that is configured to display XY data. Then, configure it to call your routine. Make sure that the plot is stopped the first time you set the routine. This is to tell the plot to create some internal buffers first. */ bool plot_is_running = false; OscPlot *xy_plot = plugin_find_plot_with_domain(XY_PLOT); if (xy_plot) { plot_is_running = osc_plot_running_state(xy_plot); if (!plot_is_running) { osc_plot_set_xy_transform(xy_plot, my_xy_transform, NULL); } } Signed-off-by: Dan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM...
The only thing I see is that it would be nice to include an user of this already in this PR (as a separate commit). So it's clear we are not adding code that will never be used :)
This feature has been requested by someone on EngineerZone (https://ez.analog.com/linux-software-drivers/f/q-a/576469/does-it-possible-to-add-a-plugin-to-iio-oscilloscope-before-constellation-display) in order to modify iio-osc on their system only. |
FWIW, here it goes my 2 cents on this... IMHO, we should not be adding code to core parts of osc just because one wants to use it in some custom hack/code. It's just not how open source is supposed to work. They should do it in a way that's useful for everyone and send patches to us :). If they don't really want to do that, you already gave them an example on how it should be done, so up to them to maintain that code I would say. Anyways, it is what it is and you're the one maintaining this app so up to you in the end :) |
It kind of makes sense. I got excited about this since this implementation is similar to math channels. The difference is that users can customize the algorithm through math channels using the UI and at runtime while the implementation in this PR could offer the same thing but via an API. But this has never been requested until now. And now is just for XY plot and not for all types of plot. |
Closing this. See PR discussions. |
Usage example:
/* define the routine with the algorithm */
static void my_xy_transform(gfloat *x_in, gfloat *y_in, gfloat *x_out, gfloat *y_out,
unsigned int length, void *user_data)
{
unsigned int i;
for (i = 0; i < length; ++i) {
x_out[i] = some_custom_algorithm(x_in[i]);
y_out[i] = some_custom_algorithm(y_in[i]);
}
}
/* Look for an already created plot instance that is configured to display XY data. Then, configure it to call your routine. Make sure that the plot is stopped the first time you set the routine. This is to tell the plot to create some internal buffers first. */
bool plot_is_running = false;
OscPlot *xy_plot = plugin_find_plot_with_domain(XY_PLOT); if (xy_plot) {
plot_is_running = osc_plot_running_state(xy_plot);
if (!plot_is_running) {
osc_plot_set_xy_transform(xy_plot, my_xy_transform, NULL);
}
}