Skip to content

Commit 17b39de

Browse files
Ralimdiscip
andauthored
Use 3 count filter for MHP30 acceleromter (#1762)
* Use 3 count filter for MHP30 acceleromter Requires it to trip 3 times in a row to fire. So really only knocking the unit over trips it off. * Reset shutdown timer forwards on shutdown timeout Default shutdown mode off --------- Co-authored-by: discip <53649486+discip@users.noreply.github.com>
1 parent 3f880d9 commit 17b39de

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

source/Core/BSP/MHP30/configuration.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
* How many seconds/minutes we wait until going to sleep/shutdown.
3030
* Values -> SLEEP_TIME * 10; i.e. 5*10 = 50 Seconds!
3131
*/
32-
#define SLEEP_TIME 5 // x10 Seconds
33-
#define SHUTDOWN_TIME 10 // Minutes
32+
#define SLEEP_TIME 5 // x10 Seconds
33+
#define SHUTDOWN_TIME 0 // Minutes -- Default shutdown to being off
3434

3535
/**
3636
* Auto start off for safety.

source/Core/Threads/MOVThread.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ void startMOVTask(void const *argument __unused) {
159159
int16_t tx = 0, ty = 0, tz = 0;
160160
int32_t avgx, avgy, avgz;
161161
Orientation rotation = ORIENTATION_FLAT;
162+
#ifdef ACCEL_EXITS_ON_MOVEMENT
163+
uint16_t tripCounter = 0;
164+
#endif
162165
for (;;) {
163166
int32_t threshold = 1500 + (9 * 200);
164167
threshold -= getSettingValue(SettingsOptions::Sensitivity) * 200; // 200 is the step size
@@ -197,10 +200,23 @@ void startMOVTask(void const *argument __unused) {
197200
// than the threshold
198201

199202
// If movement has occurred then we update the tick timer
200-
if (error > threshold) {
203+
bool overThreshold = error > threshold;
204+
#ifdef ACCEL_EXITS_ON_MOVEMENT
205+
if (overThreshold) {
206+
tripCounter++;
207+
if (tripCounter > 2) {
208+
lastMovementTime = xTaskGetTickCount();
209+
}
210+
} else if (tripCounter > 0) {
211+
tripCounter = 0;
212+
}
213+
#else
214+
if (overThreshold) {
201215
lastMovementTime = xTaskGetTickCount();
202216
}
203217

218+
#endif
219+
204220
vTaskDelay(TICKS_100MS); // Slow down update rate
205221
}
206222
}

source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ bool checkExitSoldering(void) {
9494
// If we have moved recently; in the last second
9595
// Then exit soldering mode
9696

97-
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND)) {
97+
// Movement occurred in last update
98+
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND / 5)) {
9899
currentTempTargetDegC = 0;
100+
lastMovementTime = 0;
99101
return true;
100102
}
101103
}
@@ -108,6 +110,8 @@ bool checkExitSoldering(void) {
108110
if (shouldShutdown()) {
109111
// shutdown
110112
currentTempTargetDegC = 0;
113+
lastMovementTime = xTaskGetTickCount(); // We manually move the movement time to now such that shutdown timer is reset
114+
111115
return true; // we want to exit soldering mode
112116
}
113117
#endif

0 commit comments

Comments
 (0)