RaspiQRP/rotary.py

43 lines
1.4 KiB
Python
Raw Normal View History

2022-07-29 17:49:26 +01:00
def next_band():
global CURRENT_BAND
CURRENT_BAND = next(band)
counter = bands[CURRENT_BAND][0]
print(counter)
print(CURRENT_BAND)
return counter
def prev_band():
global CURRENT_BAND
CURRENT_BAND = list(bands.keys())[list(bands.keys()).index(CURRENT_BAND)-1]
print(CURRENT_BAND)
counter = bands[CURRENT_BAND][0] + 1
return counter
def main_loop():
try:
counter = next_band()
while True:
clkState = GPIO.input(clk)
dtState = GPIO.input(dt)
swState = GPIO.input(sw)
if swState == GPIO.HIGH:
print("yeet")
if clkState != clkLastState:
if counter > bands[CURRENT_BAND][1]:
counter = next_band()
if counter < bands[CURRENT_BAND][0]:
counter = prev_band()
if dtState != clkState:
counter += step
else:
counter -= step
print(round(counter, 3))
clkLastState = clkState
sleep(0.01)
except KeyboardInterrupt:
print("\nBye")
finally:
print("AAAAA")
GPIO.cleanup()