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

Add step counter to IMU API #101

Merged
merged 1 commit into from
Jun 16, 2024
Merged

Conversation

Gregox273
Copy link
Contributor

Enables the step counter in the BMI270, exposing a step_counter_read method as part of the IMU API.

Example usage:

import app
import imu

from events.input import Buttons, BUTTON_TYPES


class ExampleApp(app.App):
    def __init__(self):
        self.button_states = Buttons(self)
        self.acc_read = None
        self.steps_read = None

    def update(self, delta):
        if self.button_states.get(BUTTON_TYPES["CANCEL"]):
            self.button_states.clear()
            self.minimise()
        else:
            self.steps_read = imu.step_counter_read()

    def draw(self, ctx):
        ctx.save()
        ctx.rgb(0.2,0,0).rectangle(-120,-120,240,240).fill()
        if self.steps_read:
            ctx.rgb(1,0,0).move_to(-80,-40).text("steps:\n{}\n".format(self.steps_read))
        else:
            ctx.rgb(1,0,0).move_to(-80,0).text("no readings yet")
        ctx.restore()

__app_export__ = ExampleApp

@ChrisDick
Copy link
Contributor

Thanks for this, it was on my to do list. I've given this a try and it is working for me. Can you add a stub for the sim in sim/fakes/imu.py, then I'll merge it.

@ChrisDick
Copy link
Contributor

I've created a branch for the doc update using your example.

@MatthewWilkes MatthewWilkes merged commit 2e932fd into emfcamp:main Jun 16, 2024
2 checks passed
@MatthewWilkes
Copy link
Member

Thank you for this, @Gregox273! I've added a simple stub to the simulator and merged this.

@Gregox273 Gregox273 deleted the step-counter branch June 18, 2024 21:48
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.

3 participants