mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-02 02:51:53 +08:00
only available gpio modes
This commit is contained in:
@@ -32,6 +32,8 @@ from .... import tools
|
||||
|
||||
from ....plugins.atx import BaseAtx
|
||||
|
||||
from ....plugins.ugpio import UserGpioModes
|
||||
|
||||
from ..info import InfoManager
|
||||
from ..ugpio import UserGpio
|
||||
|
||||
@@ -59,7 +61,7 @@ class ExportApi:
|
||||
self.__append_prometheus_rows(rows, atx_state["enabled"], "pikvm_atx_enabled")
|
||||
self.__append_prometheus_rows(rows, atx_state["leds"]["power"], "pikvm_atx_power")
|
||||
|
||||
for mode in ["input", "output"]:
|
||||
for mode in sorted(UserGpioModes.ALL):
|
||||
for (channel, ch_state) in gpio_state[f"{mode}s"].items():
|
||||
for key in ["online", "state"]:
|
||||
self.__append_prometheus_rows(rows, ch_state["state"], f"pikvm_gpio_{mode}_{key}_{channel}")
|
||||
|
||||
@@ -34,6 +34,7 @@ from ...logging import get_logger
|
||||
from ...plugins.ugpio import GpioError
|
||||
from ...plugins.ugpio import GpioOperationError
|
||||
from ...plugins.ugpio import GpioDriverOfflineError
|
||||
from ...plugins.ugpio import UserGpioModes
|
||||
from ...plugins.ugpio import BaseUserGpioDriver
|
||||
from ...plugins.ugpio import get_ugpio_driver_class
|
||||
|
||||
@@ -250,7 +251,7 @@ class UserGpio:
|
||||
|
||||
for (channel, ch_config) in tools.sorted_kvs(config.scheme):
|
||||
driver = self.__drivers[ch_config.driver]
|
||||
if ch_config.mode == "input":
|
||||
if ch_config.mode == UserGpioModes.INPUT:
|
||||
self.__inputs[channel] = _GpioInput(channel, ch_config, driver)
|
||||
else: # output:
|
||||
self.__outputs[channel] = _GpioOutput(channel, ch_config, driver, self.__notifier)
|
||||
@@ -331,12 +332,12 @@ class UserGpio:
|
||||
if parts:
|
||||
if parts[0] in self.__inputs:
|
||||
items.append({
|
||||
"type": "input",
|
||||
"type": UserGpioModes.INPUT,
|
||||
"channel": parts[0],
|
||||
})
|
||||
elif parts[0] in self.__outputs:
|
||||
items.append({
|
||||
"type": "output",
|
||||
"type": UserGpioModes.OUTPUT,
|
||||
"channel": parts[0],
|
||||
"text": (parts[1] if len(parts) > 1 else "Click"),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user