Skip to content
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

Use 3 count filter for MHP30 acceleromter #1762

Merged
merged 8 commits into from
Aug 4, 2023
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 source/Core/BSP/MHP30/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
* How many seconds/minutes we wait until going to sleep/shutdown.
* Values -> SLEEP_TIME * 10; i.e. 5*10 = 50 Seconds!
*/
#define SLEEP_TIME 5 // x10 Seconds
#define SHUTDOWN_TIME 10 // Minutes
#define SLEEP_TIME 5 // x10 Seconds
#define SHUTDOWN_TIME 0 // Minutes -- Default shutdown to being off

/**
* Auto start off for safety.
Expand Down
18 changes: 17 additions & 1 deletion source/Core/Threads/MOVThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ void startMOVTask(void const *argument __unused) {
int16_t tx = 0, ty = 0, tz = 0;
int32_t avgx, avgy, avgz;
Orientation rotation = ORIENTATION_FLAT;
#ifdef ACCEL_EXITS_ON_MOVEMENT
uint16_t tripCounter = 0;
#endif
for (;;) {
int32_t threshold = 1500 + (9 * 200);
threshold -= getSettingValue(SettingsOptions::Sensitivity) * 200; // 200 is the step size
Expand Down Expand Up @@ -197,10 +200,23 @@ void startMOVTask(void const *argument __unused) {
// than the threshold

// If movement has occurred then we update the tick timer
if (error > threshold) {
bool overThreshold = error > threshold;
#ifdef ACCEL_EXITS_ON_MOVEMENT
if (overThreshold) {
tripCounter++;
if (tripCounter > 2) {
lastMovementTime = xTaskGetTickCount();
}
} else if (tripCounter > 0) {
tripCounter = 0;
}
#else
if (overThreshold) {
lastMovementTime = xTaskGetTickCount();
}

#endif

vTaskDelay(TICKS_100MS); // Slow down update rate
}
}
6 changes: 5 additions & 1 deletion source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ bool checkExitSoldering(void) {
// If we have moved recently; in the last second
// Then exit soldering mode

if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND)) {
// Movement occurred in last update
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND / 5)) {
currentTempTargetDegC = 0;
lastMovementTime = 0;
return true;
}
}
Expand All @@ -108,6 +110,8 @@ bool checkExitSoldering(void) {
if (shouldShutdown()) {
// shutdown
currentTempTargetDegC = 0;
lastMovementTime = xTaskGetTickCount(); // We manually move the movement time to now such that shutdown timer is reset

return true; // we want to exit soldering mode
}
#endif
Expand Down