rotary almost works
This commit is contained in:
parent
1a2adbffdf
commit
8abf5ba17d
38
main.py
38
main.py
@ -5,11 +5,41 @@ import datetime
|
||||
import asyncio
|
||||
import os
|
||||
from itertools import cycle
|
||||
from RPi import GPIO
|
||||
from time import sleep
|
||||
from itertools import cycle
|
||||
from rotary import main_loop as rotary
|
||||
|
||||
|
||||
bands = {
|
||||
"80m":[3.5, 4],
|
||||
"40m":[7, 7.3],
|
||||
"20m":[14, 14.35],
|
||||
"10m":[28, 29.7],
|
||||
"2m":[144,146],
|
||||
"70cm":[430,440]
|
||||
}
|
||||
|
||||
# Setup for encoder
|
||||
band = cycle(bands)
|
||||
CURRENT_BAND = None
|
||||
step = 0.025
|
||||
|
||||
clk=17
|
||||
dt=27
|
||||
sw=22
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
GPIO.setup(sw, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
counter = 0
|
||||
clkLastState = GPIO.input(clk)
|
||||
|
||||
# 1. Hook up the screen and buttons
|
||||
# * the screen should show the frequency we're at
|
||||
# * read the buttons
|
||||
# 2. Encoder
|
||||
# 2. Encoder [x]
|
||||
# * Change frequency in the scope of a given band
|
||||
PTT_IS_ON:bool = False
|
||||
FREQUENCY:float = float(430)
|
||||
@ -40,16 +70,18 @@ async def button_press(gpio:int, level):
|
||||
|
||||
|
||||
|
||||
async def frequency(gpio):
|
||||
# TODO write this function after hooking up the encoder
|
||||
# async def frequency(gpio):
|
||||
# # TODO write this function after hooking up the encoder
|
||||
|
||||
async def main(freq:float):
|
||||
# TODO change after figuring out the logic
|
||||
task_created = False
|
||||
|
||||
asyncio.create_task(rotary)
|
||||
print("Ready")
|
||||
while True:
|
||||
await button_press(gpio, level)
|
||||
|
||||
if (PTT_IS_ON and not task_created):
|
||||
asyncio.create_task(run_command(MODULATION, str(freq)))
|
||||
task_created = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user