from machine import Pin
 from agnostic import board as boardId
-from mcp import Enum
+from mcp import Enum,ContextManaged
 
 
 class DriveMode(Enum):
 #Pull.NONE = Pull()
 
 
-class DigitalInOut(object):
+class DigitalInOut(ContextManaged):
     _pin = None
 
     def __init__(self, pin):
     def deinit(self):
         del self._pin
 
-    def __enter__(self):
-        return self
-
-    def __exit__(self, exc_type, exc_value, traceback):
-        self.deinit()
-
     @property
     def direction(self):
         return self.__direction