changeset 6:bae09c8dd4da

Add nodemcu library
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 09 Oct 2016 12:44:58 +0200
parents 0c868a2c7cda
children fcfda0afdc3d
files nodemcu/d1servo18.lua
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nodemcu/d1servo18.lua	Sun Oct 09 12:44:58 2016 +0200
@@ -0,0 +1,13 @@
+function init_d1servo18(address)
+    d1servo18_address = address or 10
+    i2c.setup(0, 2, 1, i2c.SLOW)
+end
+
+function write_d1servo18(channel, us)
+    i2c.start(0)
+    i2c.address(0, d1servo18_address, i2c.TRANSMITTER)
+    i2c.write(0, channel)
+    i2c.write(0, bit.band(us, 255))
+    i2c.write(0, bit.rshift(us, 8))
+    i2c.stop(0)
+end