fixed flip detection, circuit schema added

This commit is contained in:
Terra Gilbert 2022-09-08 23:48:03 -04:00
parent c51b2c1c18
commit b697164a1f
3 changed files with 4 additions and 10 deletions

View file

@ -442,12 +442,10 @@ uint8_t btnRepeatCounter = 0; // keeps track of how often a button press has bee
int getOrientation() int getOrientation()
{ {
int y = mpu6050.getAngleY(); int y = mpu6050.getAngleY();
#ifdef DEBUG // should be abt 0 if setting upright
Serial.println("======================================================="); // + or - more than 130 when turned over (abt 170)
Serial.print("angleY : ");Serial.print(y); // so if flipped, y should be less than -130, or greater than 130
Serial.println("=======================================================\n"); return (y < -130 || y > 130) ? 0 : 1; // 1 indicates right side up, 0 upside down
#endif
return (y <= 1) ? 1 : 0; // 1 indicates right side up, 0 upside down
} }
void checkFlip() void checkFlip()
{ {
@ -455,9 +453,7 @@ void checkFlip()
// if flipped over, toggle schema // if flipped over, toggle schema
if (ORIENTATION == 1 && currentOrientation == 0) if (ORIENTATION == 1 && currentOrientation == 0)
{ {
#ifdef DEBUG
Serial.println("flipped!"); Serial.println("flipped!");
#endif
// toggle pallet // toggle pallet
paletteSwitcher(); paletteSwitcher();
} }
@ -579,9 +575,7 @@ void setup()
#endif #endif
#ifdef USEGYRO #ifdef USEGYRO
#ifdef DEBUG
Serial.println(F("Setting up mpu6050...")); Serial.println(F("Setting up mpu6050..."));
#endif
Wire.begin(); Wire.begin();
mpu6050.begin(); mpu6050.begin();
mpu6050.calcGyroOffsets(true); mpu6050.calcGyroOffsets(true);

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB