trap method
- int pos
Ensures offset stays within valid range.
pos
is the proposed offset value.
Returns clamped offset between 0 and maximum data points.
Implementation
int trap(int pos) {
if (pos < 0) return 0;
int max = test.bpmEntries!.length + pointsPerDiv - pointsPerPage;
if (max < 0) max = 0;
if (pos > max) pos = max;
if (pos != 0) pos = pos - (pos % pointsPerDiv);
print("$pos $pointsPerPage $pointsPerDiv");
return pos;
}