]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - src/busio.py
politely cope with strings of bytes
[Adafruit_Blinka-hackapet.git] / src / busio.py
index 3523acd7289e172357725233f5a55439558f35a4..0d23b337f678a3765bf83cfac3fd08f4bf45c264 100755 (executable)
@@ -53,6 +53,8 @@ class I2C(Lockable):
         return self._i2c.readfrom_into(address, buffer, stop)
 
     def writeto(self, address, buffer, start=0, end=None, stop=True):
+        if isinstance(buffer, str):
+            buffer = bytes([ord(x) for x in buffer])
         if start is not 0 or end is not None:
             if end is None:
                 return self._i2c.writeto(address, memoryview(buffer)[start:], stop)