Beispiel #1
0
void CalibrateTouch()
{
	DisplayField *oldRoot = mgr.GetRoot();
	touchCalibInstruction->SetValue("Touch the spot");				// in case the user didn't need to press the reset button last time
	mgr.SetRoot(touchCalibInstruction);
	mgr.ClearAll();
	mgr.RefreshAll(true);

	touch.init(DisplayX, DisplayY, DefaultTouchOrientAdjust);				// initialize the driver and clear any existing calibration

	// Draw spots on the edges of the screen, one at a time, and ask the user to touch them.
	// For the first two, we allow for the touch panel being the wrong way round.
	DoTouchCalib(DisplayX/2, touchCalibMargin, DisplayX/2, DisplayY - 1 - touchCalibMargin, true, nvData.ymin);
	if (nvData.ymin >= 4096/2)
	{
		touch.adjustOrientation(ReverseY);
		nvData.ymin = 4095 - nvData.ymin;
	}
	DoTouchCalib(DisplayX - touchCalibMargin - 1, DisplayY/2, touchCalibMargin, DisplayY/2, false, nvData.xmax);
	if (nvData.xmax < 4096/2)
	{
		touch.adjustOrientation(ReverseX);
		nvData.xmax = 4095 - nvData.xmax;
	}
	DoTouchCalib(DisplayX/2, DisplayY - 1 - touchCalibMargin, DisplayX/2, DisplayY - 1 - touchCalibMargin, true, nvData.ymax);
	DoTouchCalib(touchCalibMargin, DisplayY/2, touchCalibMargin, DisplayY/2, false, nvData.xmin);
	
	nvData.touchOrientation = touch.getOrientation();
	touch.calibrate(nvData.xmin, nvData.xmax, nvData.ymin, nvData.ymax, touchCalibMargin);
	
	mgr.SetRoot(oldRoot);
	mgr.ClearAll();
	mgr.RefreshAll(true);
}
Beispiel #2
0
// handler routine for timer1 to read the touch screen
void myTouchInt()
{
	static bool inTouch = false;
	if ((!inTouch)&&(myTouch.dataAvailable()))
	{
		inTouch = true;
		myTouch.read();
		xt = myTouch.getX();
		yt = myTouch.getY();
		ixt = xt; iyt = yt;
		myScreen.ETouch.TrigOn(xt,yt);
	}
	if ((inTouch)&&(myTouch.dataAvailable()))
	{
		myTouch.read();
		ixt = myTouch.getX();
		iyt = myTouch.getY();
		if ((ixt != xt)||(iyt != yt))
		myScreen.ESlide.TrigOn(ixt,iyt);
	}
	if ((inTouch)&&(!myTouch.dataAvailable()))
	{
		inTouch = false;
		myScreen.EunTouch.TrigOn(xt,yt);
	}
	myScreen.E100msecond.TrigOn();
}
void ECCalibrateScreen::SwaitForTouch()
{
  while (myTouch.dataAvailable() == true)
  {
	  myTouch.read();
  }
  while (myTouch.dataAvailable() == false) {}
  while (myTouch.dataAvailable() == true)
  {
	  myTouch.read();
  }
}
Beispiel #4
0
void TScreen::Begin()
{
	// Initialize the touch screen
	myTouch.InitTouch();
	myTouch.setPrecision(PREC_MEDIUM);
	if (!welcome) Welcome();
	// do not modify after
	//Activate and display screen
	userBegin();
	// starts the interrupts
	DueTimer::getAvailable().attachInterrupt(myTouchInt).start(TIMER1);  // for touch / untouch
	DueTimer::getAvailable().attachInterrupt(StatInt).start(TIMER2);     // for status bar computing
	DueTimer::getAvailable().attachInterrupt(TimeInt).start(TIMER3);;    // for user task and time task
	Show();
	Draw();
}
Beispiel #5
0
// Draw a spot and wait until the user touches it, returning the touch coordinates in tx and ty.
// The alternative X and Y locations are so that the caller can allow for the touch panel being possibly inverted.
void DoTouchCalib(PixelNumber x, PixelNumber y, PixelNumber altX, PixelNumber altY, bool wantY, uint16_t& rawRslt)
{
	const PixelNumber touchCircleRadius = 8;
	const PixelNumber touchCalibMaxError = 40;
	
	lcd.setColor(touchSpotColour);
	lcd.fillCircle(x, y, touchCircleRadius);
	
	for (;;)
	{
		uint16_t tx, ty, rawX, rawY;
		if (touch.read(tx, ty, &rawX, &rawY))
		{
			if (   (abs((int)tx - (int)x) <= touchCalibMaxError || abs((int)tx - (int)altX) <= touchCalibMaxError)
				&& (abs((int)ty - (int)y) <= touchCalibMaxError || abs((int)ty - (int)altY) <= touchCalibMaxError)
			   ) 
			{
				TouchBeep();
				rawRslt = (wantY) ? rawY : rawX;
				break;
			}
		}
	}
	
	lcd.setColor(defaultBackColour);
	lcd.fillCircle(x, y, touchCircleRadius);
}
void ECCalibrateScreen::begin()
{

	// Initial setup
	myUTFT.InitLCD();
	myUTFT.clrScr();

	myTouch.InitTouch();
	myTouch.setPrecision(PREC_MEDIUM);

	myUTFT.setFont(BigFont);
	myUTFT.setBackColor(0, 0, 255);
	myButtons.setTextFont(BigFont);

	resetButtons();

	sensorstring = "";
	sensorstring.reserve(30); //set aside some bytes for receiving data
	inputstring = "";

	waiting_for_info = false;
	waiting_for_single_reading = false;
	sensor_stringcomplete = false;
	factReset = false;
	inStopMode = false;
	waiting_for_dry = false;

	Serial3.begin(38400); //To communicate with the sensor.

	Serial.begin(115200);

	//Start Read straight away.
	inputstring = ( waterTempString + ",C\r");  //Start based on temp.
	Serial3.print(inputstring); //send command to sensor.

}
void HydroponicsUI::CheckForScreenTouch()
{
  if (myTouch.dataAvailable())
    {
      switch(whichScreen)
      {
        case MAIN_SCREEN:
        {
          handleButtons( iMainScreen->handleScreen() );
          break;
        }
         case ABOUT_SCREEN:
        {
          handleButtons( iAboutScreen->handleScreen() );
          break;
        }
          case SETUP_SCREEN:
        {
          handleButtons( iSetupScreen->handleScreen() );
          break;
        }
         case PH_SCREEN:
        {

          handleButtons( ipHScreen->handleScreen() );
          limitInfo.maxPHLevel = ipHScreen->getMax();
          limitInfo.minPHLevel = ipHScreen->getMin();
          break;
        }
          case EC_SCREEN:
        {

          handleButtons( iECScreen->handleScreen() );
          limitInfo.maxECLevel = iECScreen->getMax();
          limitInfo.minECLevel = iECScreen->getMin();
          break;
        }
          case AIR_SCREEN:
        {
        	handleButtons( iAirScreen->handleScreen() );
        	limitInfo.maxAirTemp = iAirScreen->getMax();
        	limitInfo.minAirTemp = iAirScreen->getMin();
        	limitInfo.airUnits = iAirScreen->getUnits();
          break;
        }
          case WATER_SCREEN:
        {
        	handleButtons( iWaterScreen->handleScreen() );
        	limitInfo.maxWaterTemp = iWaterScreen->getMax();
        	limitInfo.minWaterTemp = iWaterScreen->getMin();
          break;
        }
          case PLUGS_SCREEN:
        {
        	handleButtons( iPlugScreen->handleScreen() );
          break;
        }
          case CLOCK_SCREEN:
        {
        	handleButtons( iTimeScreen->handleScreen() );
          break;
        }
         case CALLIBRATE_EC_SCREEN:
        {
           Serial.println("handle EC Cal Screen();  \n");
           handleButtons( iECCalibrateScreen->handleScreen() );
           break;
        }
         case CALLIBRATE_PH_SCREEN:
        {
           Serial.println("handle PH Cal Screen();  \n");
           handleButtons( iPhCalibrateScreen->handleScreen() );
           break;
        }
         case PLUGS_SETTINGS_SCREEN:
        {
           Serial.println("handle Plug Settings Screen();  \n");
           handleButtons( iPlugSettingsScreen->handleScreen() );
           break;
        }
         case PUMP_SCREEN:
          {
          handleButtons( iPumpScreen->handleScreen() );
          break;
          }
         case PUMP_DURATION_SCREEN:
          {
          handleButtons( iPumpDurationScreen->handleScreen() );
          break;
          }
        default: //If Error, Just go back to main.
        {
        	Serial.println("ERROR :::: handleMainScreen();  \n");
        	handleButtons( iMainScreen->handleScreen() );
          break;
        }
        
      }
    }  
}