File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
micropython/drivers/imu/lsm6dsox Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 2525lsm .pedometer_config (debounce = 5 , int1_enable = True , int2_enable = True )
2626
2727# Register interrupt handler on a Pin. e.g. D8
28- # The interrupt pins are open-drain, so they will be pulled low when a step is detected.
29- # We configure the host pin with a pull-up resistor to ensure it stays high when not active .
30- interrupt_pin = Pin ("D8" , Pin .IN , Pin . PULL_UP )
31-
28+ # The interrupt pins are push-pull outputs by default that go low when a step is detected.
29+ # You can connect either INT1 or INT2 to the interrupt pin .
30+ interrupt_pin = Pin ("D8" , Pin .IN ) # Change this to your desired interrupt pin.
31+ interrupt_fired = False # Flag to indicate if the interrupt has been fired.
3232
3333def on_step_detected (pin ):
34- print ( "Steps detected!" )
35-
34+ global interrupt_fired
35+ interrupt_fired = True
3636
3737# Configure the interrupt pin to trigger on falling edge (active low) when a step is detected.
3838interrupt_pin .irq (trigger = Pin .IRQ_FALLING , handler = on_step_detected )
3939
4040last_steps = None # Keep track of the last step count to detect changes.
4141
4242while True :
43+ if interrupt_fired :
44+ print ("Step detected!" )
45+ interrupt_fired = False # Reset the flag after handling the interrupt.
46+
4347 steps = lsm .steps ()
4448
4549 if steps != last_steps :
You can’t perform that action at this time.
0 commit comments