mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
prefer sync api
This commit is contained in:
parent
1901af17c3
commit
2d44539484
@ -135,7 +135,7 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes
|
|||||||
return {
|
return {
|
||||||
"switch": self.__switch,
|
"switch": self.__switch,
|
||||||
"pulse": {
|
"pulse": {
|
||||||
"delay": self.__pulse_delay,
|
"delay": min(max(self.__pulse_delay, self.__min_pulse_delay), self.__max_pulse_delay),
|
||||||
"min_delay": (self.__min_pulse_delay if self.__pulse_delay else 0),
|
"min_delay": (self.__min_pulse_delay if self.__pulse_delay else 0),
|
||||||
"max_delay": (self.__max_pulse_delay if self.__pulse_delay else 0),
|
"max_delay": (self.__max_pulse_delay if self.__pulse_delay else 0),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -73,6 +73,9 @@ kvmd:
|
|||||||
mode: output
|
mode: output
|
||||||
initial: null
|
initial: null
|
||||||
driver: relay
|
driver: relay
|
||||||
|
pulse:
|
||||||
|
delay: 2
|
||||||
|
max_delay: 5
|
||||||
|
|
||||||
view:
|
view:
|
||||||
table:
|
table:
|
||||||
|
|||||||
@ -99,7 +99,8 @@ export function Gpio() {
|
|||||||
tools.setOnClick($(`gpio-switch-${channel}`), () => __switchChannel(channel));
|
tools.setOnClick($(`gpio-switch-${channel}`), () => __switchChannel(channel));
|
||||||
}
|
}
|
||||||
for (let channel of buttons) {
|
for (let channel of buttons) {
|
||||||
tools.setOnClick($(`gpio-button-${channel}`), () => __pulseChannel(channel));
|
let wait = (model.scheme.outputs[channel].pulse.delay <= 1);
|
||||||
|
tools.setOnClick($(`gpio-button-${channel}`), () => __pulseChannel(channel, wait));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.setState(__state);
|
self.setState(__state);
|
||||||
@ -149,8 +150,8 @@ export function Gpio() {
|
|||||||
__sendPost(`/api/gpio/switch?channel=${channel}&state=${to}`);
|
__sendPost(`/api/gpio/switch?channel=${channel}&state=${to}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
var __pulseChannel = function(channel) {
|
var __pulseChannel = function(channel, wait) {
|
||||||
__sendPost(`/api/gpio/pulse?channel=${channel}`);
|
__sendPost(`/api/gpio/pulse?channel=${channel}&wait=${wait ? "1" : "0"}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
var __sendPost = function(url) {
|
var __sendPost = function(url) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user