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; } }
ImageData &setDefaultSizes() { pitch = computePitch(format, size); pixelSize = format.size(); return *this; }