""" Implements a servo in MPF """

from collections import deque

from mpf.core.device import Device


class Servo(Device):
    """Represents a servo in a pinball machine.

    Args: Same as the Device parent class.
    """

    config_section = 'servos'
    collection = 'servos'
    class_label = 'servo'

    def __init__(self, machine, name, config, collection=None, validate=True):
        super().__init__(machine, name, config, collection,
                         validate=validate, platform_section='servo_controllers')

        for position in self.config['positions']:
            self.machine.events.add_handler(self.config['positions'][position],
                                            self._position_event,
                                            position=position)

    def reset(self, **kwargs):
        self.go_to_position(self.config['reset_position'])

    def _position_event(self, position, **kwargs):
        self.go_to_position(position)

    def go_to_position(self, position):
        position = self.config['servo_min'] + position * (
        self.config['servo_max'] - self.config['servo_min'])
        self.platform.servo_go_to_position(self.config['number'], position)

@@ -32,39 +32,8 @@
 %22%22%0A%0A
-from collections import deque%0A%0A
 from
@@ -775,32 +775,51 @@
 elf, **kwargs):%0A
+        del kwargs%0A
         self.go_
@@ -861,16 +861,16 @@
 tion'%5D)%0A
-
 %0A    def
@@ -905,32 +905,51 @@
 ion, **kwargs):%0A
+        del kwargs%0A
         self.go_
@@ -1011,16 +1011,68 @@
 ition):%0A
+        # linearly interpolate between servo limits%0A
         
@@ -1126,24 +1126,28 @@
 * (%0A        
+    
 self.config%5B
@@ -1186,16 +1186,66 @@
 o_min'%5D)
+%0A%0A        # call platform with calculated position
 %0A       

improve CS and comments