Use car package and ghetto singleton motor/servo.

This commit is contained in:
Piv
2019-09-29 21:14:16 +09:30
parent aef30f9f2f
commit 7884766410
2 changed files with 9 additions and 5 deletions

View File

@@ -6,17 +6,21 @@ from concurrent import futures
import grpc import grpc
import motorService_pb2 import car.MotorControl.motorService_pb2 as motorService_pb2
import motorService_pb2_grpc import car.MotorControl.motorService_pb2_grpc as motorService_pb2_grpc
from MotorControl.gpiozero.motor_session import Motor from MotorControl.gpiozero.motor_session import Motor
servo_pin = 18 servo_pin = 18
timeout_length = 3 timeout_length = 3
motor = Motor()
servo = Servo()
class MotorServicer(motorService_pb2_grpc.CarControlServicer): class MotorServicer(motorService_pb2_grpc.CarControlServicer):
def __init__(self): def __init__(self):
self.motor = Motor() global motor, servo
self.servo = Servo(servo_pin) self.motor = motor
self.servo = servo
self._timer = None self._timer = None
def SetThrottle(self, request_iterator, context): def SetThrottle(self, request_iterator, context):

View File

@@ -1,7 +1,7 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc import grpc
import motorService_pb2 as motorService__pb2 import car.MotorControl.motorService_pb2 as motorService__pb2
class CarControlStub(object): class CarControlStub(object):