summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2023-08-04 21:38:41 +1000
committerGitHub <[email protected]>2023-08-04 21:38:41 +1000
commit17b39de9038346c7e945af6135928b8c72197d9b (patch)
tree319c42aa13ed967f292713c2e0d1b3642ec8b7e7
parent3f880d9e267ea2ac2625f298dfc8671543e5c3ab (diff)
downloadIronOS-17b39de9038346c7e945af6135928b8c72197d9b.tar.gz
IronOS-17b39de9038346c7e945af6135928b8c72197d9b.zip
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 <[email protected]>
-rw-r--r--source/Core/BSP/MHP30/configuration.h4
-rw-r--r--source/Core/Threads/MOVThread.cpp18
-rw-r--r--source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp6
3 files changed, 24 insertions, 4 deletions
diff --git a/source/Core/BSP/MHP30/configuration.h b/source/Core/BSP/MHP30/configuration.h
index c99afc64..17b803f5 100644
--- a/source/Core/BSP/MHP30/configuration.h
+++ b/source/Core/BSP/MHP30/configuration.h
@@ -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.
diff --git a/source/Core/Threads/MOVThread.cpp b/source/Core/Threads/MOVThread.cpp
index 456266bd..2b018837 100644
--- a/source/Core/Threads/MOVThread.cpp
+++ b/source/Core/Threads/MOVThread.cpp
@@ -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
@@ -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
}
}
diff --git a/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp b/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp
index 3db87dac..e8e457fa 100644
--- a/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp
+++ b/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp
@@ -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;
}
}
@@ -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