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

Immediate Fire Flag on Timer does not seem to work #3

Open
Drewpom opened this issue May 1, 2022 · 0 comments
Open

Immediate Fire Flag on Timer does not seem to work #3

Drewpom opened this issue May 1, 2022 · 0 comments

Comments

@Drewpom
Copy link

Drewpom commented May 1, 2022

Hi,

I think the documentation may be wrong or the immediate flag is not working as documented. Currently, if I run this code:

        sub = metawear
            .publishWhenConnected()
            .first()
            .createTimedEvent(period: 2000, repetitions: 2, immediateFire: false, recordedEvent: {
                let command: MWCommand = .led(.blue, .blink(repetitions: 3))
                command.command(board: metawear.board)
            })
            .handleEvents(receiveOutput: { timer in
                mbl_mw_timer_start(timer)
            })
            .sink(
                receiveCompletion: { completion in
                    print("COMPLETED: \(completion)")
                },
                receiveValue: { value in
                    print("VALUE: ", value)
                }
            )

It runs as expected and the LED fires after 2 seconds. Yet, according to the docs, the immediateFire flag should negate the need to call mbl_mw_timer_start, however, if I run this:

        sub = metawear
            .publishWhenConnected()
            .first()
            .createTimedEvent(period: 2000, repetitions: 2, immediateFire: true, recordedEvent: {
                let command: MWCommand = .led(.blue, .blink(repetitions: 3))
                command.command(board: metawear.board)
            })
            .sink(
                receiveCompletion: { completion in
                    print("COMPLETED: \(completion)")
                },
                receiveValue: { value in
                    print("VALUE: ", value)
                }
            )

Nothing happens and the timer does not seem to run the specified LED command.

Additionally, it would be nice if createTimedEvent worked similarly to recordEvents where command closure has the board as an argument.

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

No branches or pull requests

1 participant