Skip to content

Add freefall detection safety feature#2208

Open
Hamspiced wants to merge 1 commit intoRalim:devfrom
Hamspiced:feature/freefall-detection
Open

Add freefall detection safety feature#2208
Hamspiced wants to merge 1 commit intoRalim:devfrom
Hamspiced:feature/freefall-detection

Conversation

@Hamspiced
Copy link
Copy Markdown

Summary

Adds accelerometer-based freefall detection that cuts heater power when the iron is dropped, displaying a warning screen before returning to idle.

How it works

The MOV task maintains a slow IIR gravity reference (~3.2 second time constant) that tracks the stable 1g baseline regardless of how the iron is oriented. On each 100ms accelerometer sample, the instantaneous magnitude of the acceleration vector is compared against this reference. A freefall event is triggered when the total magnitude drops below 10% of normal gravity for 5 consecutive samples (~500ms), ensuring only genuine sustained weightlessness qualifies rather than normal wrist movements or brief bumps.

When triggered:

  • Heater is cut immediately (currentTempTargetDegC = 0)
  • A "Freefall Detected" warning screen is displayed for 2.5 seconds
  • Any button press dismisses the screen early
  • Iron returns to the home screen

How to activate

The feature is disabled by default. To enable:

  1. Enter Settings
  2. Navigate to Advanced
  3. Scroll to Freefall detect
  4. Press the button to toggle the checkbox on

To disable, return to the same menu and toggle it off.

The setting has no effect if no accelerometer is detected at boot.

Files changed

  • source/Core/Threads/MOVThread.cpp — detection logic and slow gravity reference
  • source/Core/Threads/UI/logic/FreefallWarning.cpp — new warning screen mode (new file)
  • source/Core/Threads/UI/logic/Soldering.cpp — freefall check in soldering mode
  • source/Core/Threads/UI/logic/SolderingProfile.cpp — freefall check in profile mode
  • source/Core/Threads/UI/logic/Sleep.cpp — freefall check while sleeping
  • source/Core/Threads/GUIThread.cpp — dispatch for new FreefallWarning mode
  • source/Core/Threads/UI/logic/OperatingModes.hFreefallWarning mode enum value
  • source/Core/Inc/Settings.hFreefallDetection setting enum entry
  • source/Core/Inc/Translation.hWarningFreefallDetected string + FreefallDetection settings index
  • source/Core/Inc/main.hppfreefallDetected extern declaration
  • source/Core/Src/settingsGUI.cpp — Advanced menu entry
  • source/Settings/settings.yaml — setting definition
  • Translations/translation_EN.json — English strings
  • Translations/translations_definitions.json — schema definitions

Adds accelerometer-based freefall detection that cuts heater power and
displays a warning when the iron is dropped or enters sustained freefall.

Detection uses a slow IIR gravity reference (~3.2s time constant) to
establish a stable 1g baseline independent of iron orientation. On each
accelerometer sample the instantaneous magnitude is compared against this
reference. A freefall event is declared when the total acceleration vector
drops below 10% of normal gravity for 5 consecutive samples (~500ms),
requiring genuine sustained weightlessness rather than brief motion spikes.

When triggered, the heater is cut immediately and a 'Freefall Detected'
screen is shown for 2.5 seconds before returning to the home screen.
The warning can be dismissed early by pressing any button.

To activate:
  Settings -> Advanced -> Freefall detect (toggle checkbox on)

The feature is disabled by default. It requires a working accelerometer;
if no accelerometer is detected at boot the setting has no effect.
Copy link
Copy Markdown
Owner

@Ralim Ralim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very sensible.
Will have some minor fixups due to translations sadly but 👍🏼 once CI passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants