void doMagMinMaxCal() { uint64_t displayTimer; uint64_t now; char input; magCal->magCalInit(); magMinMaxDone = false; // now collect data printf("\n\nMagnetometer min/max calibration\n"); printf("--------------------------------\n"); printf("Waggle the IMU chip around, ensuring that all six axes\n"); printf("(+x, -x, +y, -y and +z, -z) go through their extrema.\n"); printf("When all extrema have been achieved, enter 's' to save, 'r' to reset\n"); printf("or 'x' to abort and discard the data.\n"); printf("\nPress any key to start..."); getchar(); displayTimer = RTMath::currentUSecsSinceEpoch(); while (1) { // poll at the rate recommended by the IMU usleep(imu->IMUGetPollInterval() * 1000); while (pollIMU()) { magCal->newMinMaxData(imuData.compass); now = RTMath::currentUSecsSinceEpoch(); // display 10 times per second if ((now - displayTimer) > 100000) { displayMagMinMax(); displayTimer = now; } } if ((input = getUserChar()) != 0) { switch (input) { case 's' : printf("\nSaving min/max data.\n\n"); magCal->magCalSaveMinMax(); magMinMaxDone = true; return; case 'x' : printf("\nAborting.\n"); return; case 'r' : printf("\nResetting min/max data.\n"); magCal->magCalReset(); break; } } } }
void doMagEllipsoidCal() { uint64_t displayTimer; uint64_t now; char input; if (!magMinMaxDone) { printf("\nYou cannot collect ellipsoid data until magnetometer min/max\n"); printf("calibration has been performed.\n"); return; } printf("\n\nMagnetometer ellipsoid calibration\n"); printf("\n\n----------------------------------\n"); printf("Move the magnetometer around in as many poses as possible.\n"); printf("The counts for each of the 8 pose quadrants will be displayed.\n"); printf("When enough data (%d samples per octant) has been collected,\n", RTIMUCALDEFS_OCTANT_MIN_SAMPLES); printf("ellipsoid processing will begin.\n"); printf("Enter 'x' at any time to abort and discard the data.\n"); printf("\nPress any key to start..."); getchar(); displayTimer = RTMath::currentUSecsSinceEpoch(); while (1) { // poll at the rate recommended by the IMU usleep(imu->IMUGetPollInterval() * 1000); while (pollIMU()) { magCal->newEllipsoidData(imuData.compass); if (magCal->magCalEllipsoidValid()) { magCal->magCalSaveRaw(ELLIPSOID_FIT_DIR); processEllipsoid(); return; } now = RTMath::currentUSecsSinceEpoch(); // display 10 times per second if ((now - displayTimer) > 100000) { displayMagEllipsoid(); displayTimer = now; } } if ((input = getUserChar()) != 0) { switch (input) { case 'x' : printf("\nAborting.\n"); return; } } } }
void moreOrLess(char **arr,int arraySizeX,int givinglineNum) { int i=0; int arraySize1=0; int arraySize2=givinglineNum; int key = getUserChar(); system("clear"); /*kullanici calitridiginda once verdigi satir kadar basar */ printBetweenSize(arr,arraySizeX,arraySize1,arraySize2,givinglineNum); //printf("%d\n",times); char c; //scanf("%c",&c); /*q girerse program biter*/ while(key!='q') { /*eger esc up or down tusuna basarsa bu kosula girer*/ if(key=='\e'){ /* up ve down tuslari uc karakter oldguu icin iki key daha alinir*/ int key2=getUserChar(); int key3=getUserChar(); if(key2=='[' && key3=='B' ) { arraySize1+=1; arraySize2+=1; system("clear"); system("clear"); printBetweenSize(arr,arraySizeX,arraySize1,arraySize2,givinglineNum); } else if(key2=='['&& key3=='A') { arraySize1-=1; arraySize2-=1; system("clear"); system("clear"); if(arraySize2<givinglineNum) arraySize2=givinglineNum; printBetweenSize(arr,arraySizeX,arraySize1,arraySize2,givinglineNum); } /*escape tusu icin */ else { if(arraySizeX>arraySize1+givinglineNum) arraySize1+=givinglineNum; if(arraySizeX>arraySize2+1) arraySize2+=givinglineNum; system("clear"); system("clear"); printBetweenSize(arr,arraySizeX,arraySize1,arraySize2,givinglineNum); } } /*Enter tusu icin*/ else if(key=='\n')
void doAccelCal() { uint64_t displayTimer; uint64_t now; char input; printf("\n\nAccelerometer Calibration\n"); printf("-------------------------\n"); printf("The code normally ignores readings until an axis has been enabled.\n"); printf("The idea is to orient the IMU near the current extrema (+x, -x, +y, -y, +z, -z)\n"); printf("and then enable the axis, moving the IMU very gently around to find the\n"); printf("extreme value. Now disable the axis again so that the IMU can be inverted.\n"); printf("When the IMU has been inverted, enable the axis again and find the extreme\n"); printf("point. Disable the axis again and press the space bar to move to the next\n"); printf("axis and repeat. The software will display the current axis and enable state.\n"); printf("Available options are:\n"); printf(" e - enable the current axis.\n"); printf(" d - disable the current axis.\n"); printf(" space bar - move to the next axis (x then y then z then x etc.\n"); printf(" r - reset the current axis (if enabled).\n"); printf(" s - save the data once all 6 extrema have been collected.\n"); printf(" x - abort and discard the data.\n"); printf("\nPress any key to start..."); getchar(); // perform all axis reset for (int i = 0; i < 3; i++) accelCal->accelCalEnable(i, true); accelCal->accelCalReset(); for (int i = 0; i < 3; i++) accelCal->accelCalEnable(i, false); accelCurrentAxis = 0; for (int i = 0; i < 3; i++) accelEnables[i] = false; displayTimer = RTMath::currentUSecsSinceEpoch(); while (1) { // poll at the rate recommended by the IMU usleep(imu->IMUGetPollInterval() * 1000); while (pollIMU()) { for (int i = 0; i < 3; i++) accelCal->accelCalEnable(i, accelEnables[i]); accelCal->newAccelCalData(imuData.accel); now = RTMath::currentUSecsSinceEpoch(); // display 10 times per second if ((now - displayTimer) > 100000) { displayAccelMinMax(); displayTimer = now; } } if ((input = getUserChar()) != 0) { switch (input) { case 'e' : accelEnables[accelCurrentAxis] = true; break; case 'd' : accelEnables[accelCurrentAxis] = false; break; case 'r' : accelCal->accelCalReset(); break; case ' ' : if (++accelCurrentAxis == 3) accelCurrentAxis = 0; break; case 's' : accelCal->accelCalSave(); printf("\nAccelerometer calibration data saved to file.\n"); return; case 'x' : printf("\nAborting.\n"); return; } } } }