mirror of https://github.com/LedFx/LedFx.git
Add COM port API & List COM ports for adalight
This commit is contained in:
parent
36954be7e8
commit
16dd429e31
|
@ -2,6 +2,13 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
Version 0.10.4
|
||||
==============
|
||||
|
||||
- Fix Device Add bug on FireFox - Thanks again @MPM1107
|
||||
- List COM Ports instead of free text entry for Adalight devices.
|
||||
- This list is populated on launch.
|
||||
|
||||
Version 0.10.3
|
||||
==============
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
import logging
|
||||
|
||||
import serial.tools.list_ports
|
||||
from aiohttp import web
|
||||
|
||||
from ledfx.api import RestEndpoint
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InfoEndpoint(RestEndpoint):
|
||||
|
||||
ENDPOINT_PATH = "/api/comports"
|
||||
|
||||
async def get(self) -> web.Response:
|
||||
|
||||
ports = serial.tools.list_ports.comports()
|
||||
|
||||
available_ports = []
|
||||
|
||||
for p in ports:
|
||||
available_ports.append(p.device)
|
||||
|
||||
return web.json_response(data=available_ports, status=200)
|
|
@ -3,6 +3,7 @@ from enum import Enum
|
|||
|
||||
import numpy as np
|
||||
import serial
|
||||
import serial.tools.list_ports
|
||||
import voluptuous as vol
|
||||
|
||||
from ledfx.devices import Device
|
||||
|
@ -29,6 +30,15 @@ COLOR_ORDERS = {
|
|||
}
|
||||
|
||||
|
||||
class AvailableCOMPorts:
|
||||
ports = serial.tools.list_ports.comports()
|
||||
|
||||
available_ports = []
|
||||
|
||||
for p in ports:
|
||||
available_ports.append(p.device)
|
||||
|
||||
|
||||
class AdalightDevice(Device):
|
||||
"""Adalight device support"""
|
||||
|
||||
|
@ -36,8 +46,8 @@ class AdalightDevice(Device):
|
|||
{
|
||||
vol.Required(
|
||||
"com_port",
|
||||
description="COM port",
|
||||
): str,
|
||||
description="COM port for Adalight compatible device",
|
||||
): vol.In(list(AvailableCOMPorts.available_ports)),
|
||||
vol.Required(
|
||||
"baudrate", description="baudrate", default=500000
|
||||
): vol.All(vol.Coerce(int), vol.Range(min=115200)),
|
||||
|
|
2
win.spec
2
win.spec
|
@ -13,7 +13,7 @@ a = Analysis([f'{spec_root}\\ledfx\\__main__.py'],
|
|||
hiddenimports=['sacn', 'pyaudio', 'aubio', 'numpy', 'math', 'voluptuous', 'numpy', 'aiohttp', 'aiohttp_jinja2',
|
||||
'sentry_sdk', 'sentry_sdk.integrations.django','sentry_sdk.integrations.flask','sentry_sdk.integrations.bottle','sentry_sdk.integrations.falcon','sentry_sdk.integrations.sanic',
|
||||
'sentry_sdk.integrations.celery','sentry_sdk.integrations.aiohttp','sentry_sdk.integrations.rq','sentry_sdk.integrations.tornado','sentry_sdk.integrations.sqlalchemy',
|
||||
'sentry_sdk.integrations.boto3','_cffi_backend','serial'],
|
||||
'sentry_sdk.integrations.boto3','_cffi_backend','serial','serial.tools.list_ports'],
|
||||
hookspath=[f'{venv_root}\\lib\\site-packages\\pyupdater\\hooks'],
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
|
|
Loading…
Reference in New Issue