Esempio n. 1
0
ViewWidget::~ViewWidget()
{
	if (showAxes() && _sceneRoot)
		_sceneRoot->removeChild(getAxes());
	if (showGrids() && _sceneRoot)
		_sceneRoot->removeChild(getXYGrid());
	delete _widget;
	delete compassAxes;
}
Esempio n. 2
0
// sample configured channels and plot them
// this function is called from the sampling timer - there should be no y-axis showing
void Plotter::sample() {
	float xValue;									// x coordinate, value
	uint16_t xVal;									// x coordinate, screen pixels
	uint8_t eraseWidth;
	uint16_t xAxisPosition, yAxisPosition;

	switch (style) {
		case scan:
			xValue = millis() - startTime + xMin;		// ms elapsed since capture began
			if (xValue >= xMax) {					// if the time-axis has filled up
				startTime = millis();				// and reset the x-axis timer
				xValue = xMin;						// should wrap
			}
			xVal = getScreenX(xValue);
			eraseWidth = min(5,xo+width-xVal-1);						// clearing out previous data just ahead
			xAxisPosition = getScreenY(axesY);							// height of x-axis
			yAxisPosition = getScreenX(axesX);							// position of y-axis
			tft.fillRect(xVal+1, yo, eraseWidth, height, PLOTTER_BACKGROUND);
			if (axes) {
				tft.drawFastHLine(xVal+1, xAxisPosition, eraseWidth, PLOTTER_BORDER);			// replace possibly-erased x-axis segment
				if (yAxisPosition >= xVal && yAxisPosition < xVal + eraseWidth ) {tft.drawFastVLine(yAxisPosition, yo, height, PLOTTER_BORDER);}		// replace erased y-axis
			}
			break;
		case track:
			trackCounter++;
			if (trackCounter >= xo + width) {
				trackCounter = xo;
				clear();							// OK to take the time to clear the screen
				if (axes) { showAxes(); }			// tracking is not meant to be fast anyway
			}
			xVal = trackCounter;
			break;
		default:
			xVal = xo;
	}

	for (int i=0; i<nChannels; i++) {
		float yValue = channels[i].sample();
		tft.drawPixel(xVal, getScreenY(yValue), channels[i].getColor());
	}

	sampleTimer.reset();					// reset the timer for the next sample
}