Skip to content

Set motion flag before callback #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/TheThingsNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ void onMotionStop(void(*callback)(unsigned long duration));
- `unsigned long duration`: Time since the motion began, in ms.

### Method: isMoving
Returns `true` if the device is currently moving. Requires the sensor to be enabled via `onMotionStart()`, `onMotionStop()` or `setMotion()`.
Returns `true` if the device is currently moving. Requires the sensor to be enabled via `onMotionStart()`, `onMotionStop()` or `configMotion()`.

### Method: getAcceleration
Returns the acceleration measured by the motion sensor in [units of g-force](https://en.wikipedia.org/wiki/G-force). Each of the values x, y and z falls in the range -2g to +2g. This function is useful to determine the orientation of the sensor relative to the earth, as gravity causes a 1g acceleration towards the centre of the earth. Requires the sensor to be enabled via `onMotionStart()`, `onMotionStop()` or `setMotion()`.
Returns the acceleration measured by the motion sensor in [units of g-force](https://en.wikipedia.org/wiki/G-force). Each of the values x, y and z falls in the range -2g to +2g. This function is useful to determine the orientation of the sensor relative to the earth, as gravity causes a 1g acceleration towards the centre of the earth. Requires the sensor to be enabled via `onMotionStart()`, `onMotionStop()` or `configMotion()`.

```c
void getAcceleration(float *x, float *y, float *z);
Expand Down
4 changes: 2 additions & 2 deletions src/TheThingsNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ void TheThingsNode::loop()
if (!this->motionStarted)
{
this->motionStartedAt = millis();
this->motionStarted = true;
if (this->motionEnabled && this->motionStartCallback)
{
this->motionStartCallback();
}
this->motionStarted = true;
}
TTN_MOTION_START = false;
}
Expand All @@ -177,11 +177,11 @@ void TheThingsNode::loop()
{
if (this->motionStarted)
{
this->motionStarted = false;
if (this->motionEnabled && this->motionStopCallback)
{
this->motionStopCallback(millis() - this->motionStartedAt);
}
this->motionStarted = false;
}
TTN_MOTION_STOP = false;
}
Expand Down