Replace some samples for one or all trends
void PtTrendChangeData( PtWidget_t *widget, short const *newdata, unsigned last_sample, unsigned nsamples); void PtTrendChangeTrendData( PtWidget_t *widget, unsigned tn, short const *newdata, unsigned last_sample, unsigned nsamples);
These functions let you 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's already in a trend, not to add data to the end of the trends. |
PtTrendChangeTrendData() lets you change data for a single trend. The widget argument must be a widget of type PtTrend. 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.
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.
PtTrendChangeData() lets you change the data for all the trends. Its arguments are similar to those of PtTrendChangeTrendData() with the following exceptions:
Calling PtTrendChangeData() is similar to calling PtTrendChangeTrendData() in the following loop:
for (i=0; i<TREND_COUNT; ++i) { PtTrendChangeTrendData (widget, i, newdata, last_sample, nsamples); newdata += nsamples; }
The only difference is that PtTrendChangeData() redraws the widget once; the loop redraws it once per iteration.
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |