Replace some samples for one or all trends
void RtTrendChangeData( PtWidget_t *widget, short const *newdata, unsigned last_sample, unsigned nsamples); void RtTrendChangeTrendData( PtWidget_t *widget, unsigned tn, short const *newdata, unsigned last_sample, unsigned nsamples);
These functions allow you to replace some samples in one or more trends, without touching other data or other trends in the widget.
These functions are used to replace data that is already in a trend, not to add data to the end of the trends. |
RtTrendChangeTrendData() lets you change data for a single trend. The widget argument must be a widget of type RtTrend. The tn argument is the number of the trend to be changed, in the range 0 to trend count - 1, inclusive.
The newdata argument is a pointer to an array of the new data. last_sample is the index of the newest sample to replace, where 0 is considered to be the index of the most recently added sample. nsamples is the number of samples to be replaced. The diagram below shows how the samples are replaced.
Replacing trend samples with RtTrendChangeData() or RtTrendChangeTrendData().
The newdata array is ordered with the oldest sample at newdata[0], and the newest at newdata[nsamples - 1]. The oldest sample to be replaced will have an index of last_sample + nsamples - 1;
The samples in the trend are replaced as follows:
If last_sample + nsamples - 1 is outside the range of samples for the widget, some initial portion of the new data is discarded.
RtTrendChangeData() allows you to change the data for all the trends. Its arguments are similar to those of RtTrendChangeTrendData() with the following exceptions:
Calling RtTrendChangeData() is similar to calling RtTrendChangeTrendData() in the following loop:
for (i=0; i<TREND_COUNT; ++i) { RtTrendChangeTrendData (widget, i, newdata, last_sample, nsamples); newdata += nsamples; }
The only difference is that RtTrendChangeData() redraws the widget once; the loop would redraw it once per iteration.
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |