Skip to content

Commit

Permalink
Merge pull request #6 from 3110/develop
Browse files Browse the repository at this point in the history
resolve 3 commits ahead
  • Loading branch information
3110 authored Jun 27, 2022
2 parents 1841c7d + c53b62e commit d7fff7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/AtomBabies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/AtomBabies.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d7fff7f

Please sign in to comment.