adafruit / Adafruit_CircuitPython_PIOASM

Simple assembler to convert pioasm to bytes
MIT License
27 stars 17 forks source link

Add audiobusio examples and fix simple test frequency #9

Closed tannewt closed 3 years ago

tannewt commented 3 years ago

This also uses newer pin auto-init.

These examples now need https://github.com/adafruit/circuitpython/pull/4251 in CircuitPython.

tannewt commented 3 years ago

Looks like it needs the duplicate-files checks neutered. Mind adding that in this PR?

I want to wait until we have an idea of what we're doing in every repo instead of hacking it for this one. Discussion here: https://github.com/adafruit/cookiecutter-adafruit-circuitpython/pull/111

Inne-Lemstra commented 3 years ago

Hi, I encountered the frequency 80 < minimum bug and wanted to make an issue but saw this PR.

The new frequency in the pioasm_simpletest.py of 2000 will make the 2 cycle on, 1 off pio blink not visible with the naked eye anymore.

might this be a solution?? The loops and longer cycle skips will slow the blink down to 0.1 sec.

squarewave = """
.program squarewave
    set x 10    ; counter for 10 loops of a 20 cycle instuction 
                     ; 20*10=200 cycles -> 0.1 sec "delay" with freq 2000
on:
    set pins 1 [19]     ; Drive pin high and then delay for 20 cycles
    jmp x--, on         ; x-- will loop if x not 0, then substract 1 from x
    set x 10            ; reset x fort he off loop    
off:   
    set pins 0  [19]    ; Drive pin low for 20 cyles
    jmp x--, off         ; x will be reset when script starts over
"""

Another thing is that board.D13 doesn't seem to work for me on a pico with circuitpython pico-en_US-20210227-24fdda0 board.LED does work and board.GP25 also works. Does the example in the REAME update automatically as this script does??

This is the first time I am posting a comment on a PR and I hope I am doing this the right way. If I am out of line or commenting somewhere I shouldn't, please disregard.

tannewt commented 3 years ago

Hi, I encountered the frequency 80 < minimum bug and wanted to make an issue but saw this PR.

The new frequency in the pioasm_simpletest.py of 2000 will make the 2 cycle on, 1 off pio blink not visible with the naked eye anymore.

The simple example isn't meant to make a visible blink. I added a comment saying so. It is nice to have it on an LED still because you can see when it is running.

might this be a solution?? The loops and longer cycle skips will slow the blink down to 0.1 sec.

squarewave = """
.program squarewave
    set x 10    ; counter for 10 loops of a 20 cycle instuction 
                     ; 20*10=200 cycles -> 0.1 sec "delay" with freq 2000
on:
    set pins 1 [19]     ; Drive pin high and then delay for 20 cycles
    jmp x--, on         ; x-- will loop if x not 0, then substract 1 from x
    set x 10            ; reset x fort he off loop    
off:   
    set pins 0  [19]    ; Drive pin low for 20 cyles
    jmp x--, off         ; x will be reset when script starts over
"""

This would be great to have as a pioasm_blink.py example!

Another thing is that board.D13 doesn't seem to work for me on a pico with circuitpython pico-en_US-20210227-24fdda0 board.LED does work and board.GP25 also works. Does the example in the REAME update automatically as this script does??

This is the nature of boards having different pin naming. board.D13 will work on our upcoming Adafruit boards because LED on D13 has been a standard for a while. Changing it to board.LED for pico is the way to fix it. These examples are meant to work on every board.

This is the first time I am posting a comment on a PR and I hope I am doing this the right way. If I am out of line or commenting somewhere I shouldn't, please disregard.

Totally fine! Thanks for the comments. It's good to know folks are using these examples. :-)

tannewt commented 3 years ago

Ok @jepler, I've merge in the latest main which fixes the duplicate code issue. Please take another look.

dglaude commented 3 years ago

Not sure if this can be a useful contribution. A few weeks ago I was playing with Blink on the PIO and found the solution to shake the Pico to see the blink. This was done late in the night, so in the dark (not sure how well it work in daylight).

This could be a suggestion for the guide or some comment in the code: https://twitter.com/DavidGlaude/status/1367571218698825734?s=20