# -------------------------------------------------- #
# This file is autogenerated by pioasm; do not edit! #
# -------------------------------------------------- #
import rp2
from rp2 import PIO
from machine import Pin
from time import sleep
# ------ #
# sevseg #
# ------ #
counter = 24
is_pause = False
flag = 0
@rp2.asm_pio(out_init=[PIO.OUT_LOW]*8, sideset_init=[PIO.OUT_LOW]*4)
def sevseg():
wrap_target()
label("0")
pull(noblock) .side(0) # 0
mov(x, osr) .side(0) # 1
out(pins, 8) .side(1) # 2
out(pins, 8) .side(2) # 3
out(pins, 8) .side(4) # 4
out(pins, 8) .side(8) # 5
jmp("0") .side(0) # 6
wrap()
sm = rp2.StateMachine(0, sevseg, freq=2000, out_base=Pin(2), sideset_base=Pin(10))
sm.active(1)
digits = [
0b11000000, # 0
0b11111001, # 1
0b10100100, # 2
0b10110000, # 3
0b10011001, # 4
0b10010010, # 5
0b10000010, # 6
0b11111000, # 7
0b10000000, # 8
0b10011000, # 9
]
def segmentize(num):
return (
digits[num % 10] | digits[num // 10 % 10] << 8
#digits[0b10011001] | digits[b10100100] <<
)
start_button = Pin(18, Pin.IN)
pause_button = Pin(17, Pin.IN)
reset24_button = Pin(21, Pin.IN)
reset14_button = Pin(26, Pin.IN)
inc_button = Pin(22, Pin.IN)
dec_button = Pin(27, Pin.IN)
'''
while counter >= 0:
sm.put(segmentize(counter))
counter -= 1
sleep(0.2)
'''
def start():
for i in reversed(range(counter+1)):
sm.put(segmentize(i))
sleep(0.2)
if start_button.value()==1:
flag == 1
if flag == 1:
start()