mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2024-11-15 17:40:57 +00:00
import util as namespace
This commit is contained in:
parent
467b769ea4
commit
265c26eb67
@ -1,9 +1,8 @@
|
|||||||
import abc
|
import abc
|
||||||
|
|
||||||
from . import kinds
|
from . import kinds, util
|
||||||
from .errors import XAirRemoteError
|
from .errors import XAirRemoteError
|
||||||
from .meta import bool_prop
|
from .meta import bool_prop
|
||||||
from .util import _get_level_val, _set_level_val, lin_get, lin_set
|
|
||||||
|
|
||||||
|
|
||||||
class IConfig(abc.ABC):
|
class IConfig(abc.ABC):
|
||||||
@ -91,13 +90,14 @@ class Config(IConfig):
|
|||||||
return f"{root}/solo"
|
return f"{root}/solo"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@util.from_db
|
||||||
def level(self) -> float:
|
def level(self) -> float:
|
||||||
retval = self.getter("level")[0]
|
return self.getter("level")[0]
|
||||||
return _get_level_val(retval)
|
|
||||||
|
|
||||||
@level.setter
|
@level.setter
|
||||||
|
@util.to_db
|
||||||
def level(self, val: float):
|
def level(self, val: float):
|
||||||
_set_level_val(self, val)
|
self.setter("level", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source(self) -> int:
|
def source(self) -> int:
|
||||||
@ -109,13 +109,13 @@ class Config(IConfig):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def sourcetrim(self) -> float:
|
def sourcetrim(self) -> float:
|
||||||
return round(lin_get(-18, 18, self.getter("sourcetrim")[0]), 1)
|
return round(util.lin_get(-18, 18, self.getter("sourcetrim")[0]), 1)
|
||||||
|
|
||||||
@sourcetrim.setter
|
@sourcetrim.setter
|
||||||
def sourcetrim(self, val: float):
|
def sourcetrim(self, val: float):
|
||||||
if not -18 <= val <= 18:
|
if not -18 <= val <= 18:
|
||||||
raise XAirRemoteError("expected value in range -18.0 to 18.0")
|
raise XAirRemoteError("expected value in range -18.0 to 18.0")
|
||||||
self.setter("sourcetrim", lin_set(-18, 18, val))
|
self.setter("sourcetrim", util.lin_set(-18, 18, val))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def chmode(self) -> bool:
|
def chmode(self) -> bool:
|
||||||
@ -135,13 +135,13 @@ class Config(IConfig):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def dimgain(self) -> int:
|
def dimgain(self) -> int:
|
||||||
return int(lin_get(-40, 0, self.getter("dimatt")[0]))
|
return int(util.lin_get(-40, 0, self.getter("dimatt")[0]))
|
||||||
|
|
||||||
@dimgain.setter
|
@dimgain.setter
|
||||||
def dimgain(self, val: int):
|
def dimgain(self, val: int):
|
||||||
if not -40 <= val <= 0:
|
if not -40 <= val <= 0:
|
||||||
raise XAirRemoteError("expected value in range -40 to 0")
|
raise XAirRemoteError("expected value in range -40 to 0")
|
||||||
self.setter("dimatt", lin_set(-40, 0, val))
|
self.setter("dimatt", util.lin_set(-40, 0, val))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dim(self) -> bool:
|
def dim(self) -> bool:
|
||||||
|
Loading…
Reference in New Issue
Block a user