button press bugfix
This commit is contained in:
parent
9c9e2820a8
commit
573b6d2ff7
@ -60,7 +60,7 @@ class ButtonDecoder:
|
||||
for byte in data:
|
||||
if byte == 0xFF:
|
||||
self._process_line(buffer)
|
||||
print(buffer)
|
||||
#print(buffer)
|
||||
buffer.clear()
|
||||
else:
|
||||
buffer.append(byte)
|
||||
|
@ -4,10 +4,12 @@
|
||||
# ANDROID AUTO: ENTER, LEFT, RIGHT, UP, DOWN, BACK, HOME, PHONE, CALL_END, PLAY, PAUSE, PREV_TRACK, NEXT_TRACK, TOGGLE_PLAY, VOICE, WHEEL_LEFT, WHEEL_RIGHT
|
||||
|
||||
def send_to_radio(btn):
|
||||
print("Sending to radio ", btn)
|
||||
tunerlist.send_button(btn)
|
||||
|
||||
def send_to_aa(btn):
|
||||
queue.put_nowait(dumps({"button": btn}))
|
||||
print("Sending to AA ", btn)
|
||||
queue.put_nowait({'button': {'btn': btn, 'state': 2}})
|
||||
|
||||
BUTTON_MAPPINGS = {
|
||||
"VOL_UP": (send_to_radio, "VOL_UP"),
|
||||
@ -96,10 +98,12 @@ async def button_listener():
|
||||
try:
|
||||
while True:
|
||||
button = await buttons.queue.get()
|
||||
print(button)
|
||||
if button in BUTTON_MAPPINGS:
|
||||
func, arg = BUTTON_MAPPINGS[button]
|
||||
func(arg)
|
||||
if button.button in BUTTON_MAPPINGS and button.state == 0:
|
||||
try:
|
||||
func, arg = BUTTON_MAPPINGS[button.button]
|
||||
func(arg)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
except CancelledError:
|
||||
pass
|
||||
|
||||
@ -157,7 +161,7 @@ async def state_endpoint():
|
||||
async def emulated_button(request: Request):
|
||||
btn = request.query_params.get("btn")
|
||||
print("CD Changer button: ", btn)
|
||||
buttons.queue.put_nowait(btn)
|
||||
buttons.queue.put_nowait(btn.strip())
|
||||
|
||||
@app.get("/settext", response_class=JSONResponse)
|
||||
async def set_text(request: Request):
|
||||
|
Loading…
x
Reference in New Issue
Block a user