Beispiel #1
0
int checkIfBalanced(){

    int xValue, yValue, zValue;
    float angle;
    //Read the X axis
    adcInit(ACCELEROMETER_X);
    xValue = adcRead();

    //Read the Y axis
    adcInit(ACCELEROMETER_Y);
    yValue = adcRead();

    //Read the Z axis
    adcInit(ACCELEROMETER_Z);
    zValue = adcRead();

    angle = computePitch(xValue, yValue, zValue);

    //check what the angle is and if we need to go forward or backward
    if(angle > FORWARD_THRESHOLD){
        motorForward();
        return FALSE;
    }else if(angle < REVERSE_THRESHOLD){
        motorReverse();
        return FALSE;
    }else{
        motorStop();
        return TRUE;
    }
}
Beispiel #2
0
 ImageData &setDefaultSizes()
 {
     pitch     = computePitch(format, size);
     pixelSize = format.size();
     return *this;
 }