feat: минорые изменения после тестирования

This commit is contained in:
2025-11-28 14:20:24 +03:00
parent 5ff0384def
commit d50557a581
12 changed files with 80 additions and 28 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ LED_COUNT=9
LED_PIN=23
GAMMA=2.2
TIMEOUT=5
TIMEOUT_SECONDS=300
IDLE_BRIGHTNESS=0.30
IDLE_R=0
+2 -1
View File
@@ -1 +1,2 @@
!.env
!.env
venv
+9 -2
View File
@@ -34,7 +34,7 @@ LED_PIN_NUM = get_env_int("LED_PIN")
LED_PIN = getattr(board, f"D{LED_PIN_NUM}")
GAMMA = get_env_float("GAMMA")
TIMEOUT = get_env_float("TIMEOUT")
TIMEOUT_SECONDS = get_env_float("TIMEOUT_SECONDS")
IDLE_SPEED = get_env_float("IDLE_SPEED")
IDLE_BRIGHTNESS = get_env_float("IDLE_BRIGHTNESS")
@@ -579,7 +579,7 @@ class LightsDaemon(lights_pb2_grpc.LightsServicer):
def loop(self):
while self._running:
with self._lock:
if self._control_mode and time.time() - self._last_ping > TIMEOUT:
if self._control_mode and time.time() - self._last_ping > TIMEOUT_SECONDS:
self._control_mode = False
self._pixels.brightness = IDLE_BRIGHTNESS
self._animation = IdleAnimation()
@@ -597,6 +597,13 @@ class LightsDaemon(lights_pb2_grpc.LightsServicer):
self._control_mode = True
self._last_ping = time.time()
def Disconnect(self, request, context):
with self._lock:
self._control_mode = False
self._pixels.brightness = IDLE_BRIGHTNESS
self._animation = IdleAnimation()
return lights_pb2.Empty()
def Ping(self, request, context):
self._update_last_ping()
return lights_pb2.Empty()
File diff suppressed because one or more lines are too long
@@ -39,6 +39,11 @@ class LightsStub(object):
request_serializer=lights__pb2.Empty.SerializeToString,
response_deserializer=lights__pb2.Empty.FromString,
_registered_method=True)
self.Disconnect = channel.unary_unary(
'/GSS2.LightsControl.Lights/Disconnect',
request_serializer=lights__pb2.Empty.SerializeToString,
response_deserializer=lights__pb2.Empty.FromString,
_registered_method=True)
self.SetOff = channel.unary_unary(
'/GSS2.LightsControl.Lights/SetOff',
request_serializer=lights__pb2.Empty.SerializeToString,
@@ -145,6 +150,12 @@ class LightsServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def Disconnect(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def SetOff(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -267,6 +278,11 @@ def add_LightsServicer_to_server(servicer, server):
request_deserializer=lights__pb2.Empty.FromString,
response_serializer=lights__pb2.Empty.SerializeToString,
),
'Disconnect': grpc.unary_unary_rpc_method_handler(
servicer.Disconnect,
request_deserializer=lights__pb2.Empty.FromString,
response_serializer=lights__pb2.Empty.SerializeToString,
),
'SetOff': grpc.unary_unary_rpc_method_handler(
servicer.SetOff,
request_deserializer=lights__pb2.Empty.FromString,
@@ -400,6 +416,33 @@ class Lights(object):
metadata,
_registered_method=True)
@staticmethod
def Disconnect(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/GSS2.LightsControl.Lights/Disconnect',
lights__pb2.Empty.SerializeToString,
lights__pb2.Empty.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)
@staticmethod
def SetOff(request,
target,
+1
View File
@@ -6,6 +6,7 @@ package GSS2.LightsControl;
service Lights {
rpc Ping (Empty) returns (Empty);
rpc Disconnect (Empty) returns (Empty);
rpc SetOff (Empty) returns (Empty);