changeset 3:d20600cfb6fd

Use ustruct in the micropython library
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 09 Oct 2016 00:15:54 +0200
parents 0488e0598c7c
children f614c50ac75a
files micropython/d1servo18ch.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/micropython/d1servo18ch.py	Sun Oct 09 00:11:27 2016 +0200
+++ b/micropython/d1servo18ch.py	Sun Oct 09 00:15:54 2016 +0200
@@ -1,7 +1,9 @@
+import ustruct
+
 class Servos:
     def __init__(self, i2c, address=0x0A):
         self.i2c = i2c
         self.address = address
 
     def __setitem__(self, channel, us):
-        self.i2c.writeto_mem(self.address, channel, us)
+        self.i2c.writeto_mem(self.address, channel, ustruct.pack("<H", us))