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

Store other program metadata in a Program class #28

Closed
jepler opened this issue Dec 22, 2021 · 2 comments · Fixed by #29
Closed

Store other program metadata in a Program class #28

jepler opened this issue Dec 22, 2021 · 2 comments · Fixed by #29

Comments

@jepler
Copy link
Member

jepler commented Dec 22, 2021

Sketch:

class Program:
    def __init__(self, text_program):
        """Converts pioasm text to encoded instruction bytes"""
        ... # all of old 'assemble()' is here
        self.assembled = array.array("H", assembled)
        self.sideset_count = sideset_count
        self.sideset_enable = sideset_enable
        # automatic loop target values, etc

    def make_state_machine(self, ...):
        import rp2pio # defer import so module can be used on std python
        return rp2pio.StateMachine(..., sideset_enable=self.sideset_enable, ...)


def assemble(text_program):
    return Program(text_program).assembled
@jepler
Copy link
Member Author

jepler commented Dec 22, 2021

This could also help when adding support for wrap / wrap_target, the values would be members of Program and passed to StateMachine via Program.make_state_machine.

@tannewt
Copy link
Member

tannewt commented Dec 23, 2021

The other thing I was considering was a function that produces the appropriate kwargs.

def get_kwargs(pio_source):
    ...

sm = rp2pio.StateMachine(pin=board.FOO, **get_kwargs(src))

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 a pull request may close this issue.

2 participants