Skip to content

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

@Drewpom

Description

@Drewpom

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions