void turnPointLeft (float mRot, float mRotPerSec) { nxtDisplayCenteredTextLine(5, "TPL(%.2f,%.2f)", mRot, mRotPerSec); if (moveModeType != MMAllMoveTypes && moveModeType != MMTurnsOnly && moveModeType != MMPointTurnsOnly) { return; } if (moveModeTiming == MMOneMoveAtATime) { waitForTouch(); } if (stepThroughMode == stepThroughModeOn) { waitForTouch(); } checkParameterRange(mRot, mRotPerSec); int leftWheelInitial = nMotorEncoder[leftWheelMotor]; int rightWheelInitial = nMotorEncoder[rightWheelMotor]; int leftWheelTarget = nMotorEncoder[leftWheelMotor] - 360 * mRot; int rightWheelTarget = nMotorEncoder[rightWheelMotor] + 360 * mRot; ClearTimer(T1); float motorPower = revolutionsPerSecondToMotorPower(mRotPerSec); motor[leftWheelMotor] = -1 * motorPower; motor[rightWheelMotor] = motorPower; while ((nMotorEncoder[leftWheelMotor] > leftWheelTarget) && (nMotorEncoder[rightWheelMotor] < rightWheelTarget)) { nxtDisplayCenteredTextLine(7, "%d", nMotorEncoder[leftWheelMotor]); } motor[leftWheelMotor] = 0; motor[rightWheelMotor] = 0; int leftWheelChange = nMotorEncoder[leftWheelMotor] - leftWheelInitial; int rightWheelChange = nMotorEncoder[rightWheelMotor] - rightWheelInitial; float revolutionsWheelsRotated = ((float) ( abs(leftWheelChange) > abs(rightWheelChange) ? leftWheelChange : rightWheelChange )) / 360.0; nxtDisplayCenteredTextLine(2, "TPL(%.2f,%.2f)", mRot, mRotPerSec); nxtDisplayCenteredTextLine(3, "%.2frev %.2fsec", (float) revolutionsWheelsRotated, (float) time10(T1) / 100); nxtDisplayCenteredTextLine(5, ""); nxtDisplayCenteredTextLine(7, ""); }
void ECCalibrateScreen::dryCalibration() { myUTFT.clrScr(); myUTFT.setColor(255, 0, 0); myUTFT.fillRect(0, 0, 220, 13); myUTFT.setColor(255, 255, 255); myUTFT.setBackColor(255, 0, 0); myUTFT.drawLine(0, 14, 320, 14); myUTFT.print("EC Calibration", CENTER, 1); myUTFT.setBackColor(0, 0, 0); myUTFT.print("Do NOT put sensor in any Liquid you are", LEFT, 30); myUTFT.print("going to calibrate for a dry condition", LEFT, 42); myUTFT.print("This is much like setting a TARE on a", LEFT, 54); myUTFT.print("scale", LEFT, 66); myUTFT.print("", LEFT, 78); myUTFT.print("Please make sure that the EC sensor is", LEFT, 90); myUTFT.print("connected to the BNC connector before", LEFT, 102); myUTFT.print("you continue", LEFT, 114); //myUTFT.print("crosshairs in sequence.", LEFT, 126); myUTFT.print("Touch screen to continue", CENTER, 162); waitForTouch(); myUTFT.clrScr(); inputstring = "Z0\r"; //Command to get info Serial3.print(inputstring); //send command to sensor. }
void ECCalibrateScreen::highCalibration() { myUTFT.clrScr(); myUTFT.setColor(255, 0, 0); myUTFT.fillRect(0, 0, 220, 13); myUTFT.setColor(255, 255, 255); myUTFT.setBackColor(255, 0, 0); myUTFT.drawLine(0, 14, 320, 14); myUTFT.print("EC Calibration", CENTER, 1); myUTFT.setBackColor(0, 0, 0); myUTFT.print("Calibrate now with the high side liquid", LEFT, 30); myUTFT.print("Place the sensor in the 3,000Us ", LEFT, 42); myUTFT.print("calibration liquid. This process", LEFT, 54); myUTFT.print("will take 5 minutes to complete", LEFT, 66); myUTFT.print("Wait for process to finish before ", LEFT, 78); myUTFT.print("removing the sensor from the liquid", LEFT, 90); myUTFT.print("", LEFT, 102); myUTFT.print("************************************", LEFT, 114); myUTFT.print("Touch screen to continue", CENTER, 162); waitForTouch(); myUTFT.clrScr(); inputstring = "C\r"; //set in continious mode myUTFT.clrScr(); String thisSt = String(iSeconds); myUTFT.print("Calibration in Progress", CENTER, 30); myUTFT.print("Seconds left until ready " + thisSt, CENTER, 42); simpleTimer.setTimer(3000, updateWaitScreen, /*100*/ 4); //Update screen every 3 seconds for 5 minues. }
/*********************************************************************************** * @fn TouchScreen * * @brief Main Function, called by App_Layer to get the co-ordinates (touched or not) of TouchScreen. * * @param none * * @return none */ void TouchScreen(void) { Initialize_TouchScreen(); // Initialize device waitForTouch(); // Wait for touch on screen touched = 1; // Screen is touched while(1) { // Loop while screen is touched readXY(); // Get X,Y coordinates index 0 // Take 2 values and see the difference between them. // If value is greater than 5 steps, discard packet. // This code is designed to take a majority vote of 2 packets. if(x > 1100 && x < 4600 && y > 700 && y < 5300) sendData(x,y); // Send data to host } }
void movesStart (WaitFor waitForRoutine, float waitForParam) { nxtDisplayCenteredTextLine(5, "Starting"); if (moveModeTiming == MMOneMoveAtATime || stepThroughMode == stepThroughModeOn) { } else { switch (waitForRoutine) { case WFTouch: waitForTouch(); break; case WFLoud: waitForLoud(waitForParam); break; case WFTime: waitForTime(waitForParam); break; case WFNothing: default: break; } } }
/** * Arc turn has the center point to the left or right of the wheel in line * with the axel. The idea is that the Rotations Per Second difference is * the ratio between the outside and inside circle circumference. * * The only reason we really ask for both wheel numbers is to facilitate * the teaching of algebra concepts. A more useful function would just * use the robot dimensions and the number of degrees to turn. * * There isn't a left and right function because the only difference is which * wheel has to travel the furthest distance. */ void turnArcBackwards (float mRotLeft, float mRotLeftPerSec, float mRotRight, float mRotRightPerSec) { nxtDisplayCenteredTextLine(5, "TAL(%.2f,%.2f)",mRotLeft, mRotLeftPerSec); nxtDisplayCenteredTextLine(6, "TAL(%.2f,%.2f)",mRotRight, mRotRightPerSec); if (moveModeType != MMAllMoveTypes && moveModeType != MMTurnsOnly && moveModeType != MMArcTurnsOnly) { return; } if (moveModeTiming == MMOneMoveAtATime) { waitForTouch(); } if (stepThroughMode == stepThroughModeOn) { waitForTouch(); } checkParameterRange(mRotLeft, mRotLeftPerSec); checkParameterRange(mRotRight, mRotRightPerSec); int leftWheelInitial = nMotorEncoder[leftWheelMotor]; int leftWheelTarget = nMotorEncoder[leftWheelMotor] - 360 * mRotLeft; int rightWheelInitial = nMotorEncoder[rightWheelMotor]; int rightWheelTarget = nMotorEncoder[rightWheelMotor] - 360 * mRotRight; ClearTimer(T1); float leftMotorPower = revolutionsPerSecondToMotorPower(mRotLeftPerSec); float rightMotorPower = revolutionsPerSecondToMotorPower(mRotRightPerSec); motor[leftWheelMotor] = -1 * leftMotorPower; motor[rightWheelMotor] = -1 * rightMotorPower; while ( (nMotorEncoder[leftWheelMotor] > leftWheelTarget) && (nMotorEncoder[rightWheelMotor] > rightWheelTarget) ) { nxtDisplayCenteredTextLine(7, "%d", nMotorEncoder[leftWheelMotor]); } motor[leftWheelMotor] = 0; motor[rightWheelMotor] = 0; int leftWheelChange = nMotorEncoder[leftWheelMotor] - leftWheelInitial; float revolutionsWheelsRotatedLeft = ((float) leftWheelChange) / 360.0; int rightWheelChange = nMotorEncoder[rightWheelMotor] - rightWheelInitial; float revolutionsWheelsRotatedRight = ((float) rightWheelChange) / 360.0; nxtDisplayCenteredTextLine(2, "TAL(%.2f,%.2f)", mRotLeft, mRotLeftPerSec); nxtDisplayCenteredTextLine(3, "%.2frev %.2fsec", (float) revolutionsWheelsRotatedLeft, (float) time10(T1) / 100); nxtDisplayCenteredTextLine(4, "TAL(%.2f,%.2f)", mRotRight, mRotRightPerSec); nxtDisplayCenteredTextLine(5, "%.2frev %.2fsec", (float) revolutionsWheelsRotatedRight, (float) time10(T1) / 100); nxtDisplayCenteredTextLine(6, ""); nxtDisplayCenteredTextLine(7, ""); }