diff --git a/src/AtomBabies.cpp b/src/AtomBabies.cpp index 951f048..4100ec8 100644 --- a/src/AtomBabies.cpp +++ b/src/AtomBabies.cpp @@ -145,12 +145,13 @@ bool AtomBabies::begin(void) { } bool AtomBabies::update(void) { + bool result = false; M5.update(); - updateOrientation(); + result |= updateOrientation(); for (size_t p = 0; p < this->_n_plugins; ++p) { - this->_plugins[p]->update(*this); + result |= this->_plugins[p]->update(*this); } - return true; + return result; } void AtomBabies::openEyes(void) { @@ -360,18 +361,18 @@ void AtomBabies::displayDigit(const CRGB& color, uint8_t digit) { displayData(color, pos, size); } -bool AtomBabies::isTouched(float threthold) { +bool AtomBabies::isTouched(float threshold) { float ax, ay, az; M5.IMU.getAccelData(&ax, &ay, &az); // SERIAL_PRINTF_LN("Accel: x = %.1f y = %.1f, z = %.1f", ax, ay, az); if (this->_orientation == OrientationNormal || this->_orientation == OrientationUpsideDown) { - return (abs(ax) >= threthold || 1.0 - abs(ay) >= threthold || - abs(az) >= threthold); + return (abs(ax) >= threshold || 1.0 - abs(ay) >= threshold || + abs(az) >= threshold); } else if (this->_orientation == OrientationLeft || this->_orientation == OrientationRight) { - return (1.0 - abs(ax) >= threthold || abs(ay) >= threthold || - abs(az) >= threthold); + return (1.0 - abs(ax) >= threshold || abs(ay) >= threshold || + abs(az) >= threshold); } return false; } diff --git a/src/AtomBabies.h b/src/AtomBabies.h index 1858d2e..d6085d1 100644 --- a/src/AtomBabies.h +++ b/src/AtomBabies.h @@ -106,7 +106,7 @@ class AtomBabies { virtual void scrollDigits(const CRGB& color, uint16_t val, uint16_t interval); - virtual bool isTouched(float threthold = DEFAULT_TOUCH_THRESHOLD); + virtual bool isTouched(float threshold = DEFAULT_TOUCH_THRESHOLD); virtual bool addPlugin(AbstractAtomBabiesPlugin& plugin);