Module Name:    src
Committed By:   mbalmer
Date:           Sat Feb 25 09:13:38 UTC 2012

Modified Files:
        src/share/examples/lua: gpio.lua

Log Message:
GPIO pins are 0 based when accessed from Lua, not 1 based like Lua usually
is.  The pulse() has been removed, use gpiopwm(4) for that.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/lua/gpio.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/examples/lua/gpio.lua
diff -u src/share/examples/lua/gpio.lua:1.1 src/share/examples/lua/gpio.lua:1.2
--- src/share/examples/lua/gpio.lua:1.1	Sat Oct 15 12:58:43 2011
+++ src/share/examples/lua/gpio.lua	Sat Feb 25 09:13:38 2012
@@ -1,4 +1,4 @@
--- $NetBSD: gpio.lua,v 1.1 2011/10/15 12:58:43 mbalmer Exp $
+-- $NetBSD: gpio.lua,v 1.2 2012/02/25 09:13:38 mbalmer Exp $
 
 require 'gpio'
 
@@ -12,20 +12,17 @@ local npins = g:info()
 
 print('gpio0 has ' .. npins .. ' pins.')
 
-for n = 1, npins do
+for n = 0, npins - 1 do
 	print('pin ' .. n .. ': ' .. g:read(n))
 end
 
-local oldval = g:write(32, gpio.PIN_HIGH)
-print('pin 32: ' .. oldval .. ' -> ' .. g:read(32))
+local oldval = g:write(31, gpio.PIN_HIGH)
+print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
 
-oldval = g:toggle(32)
-print('pin 32: ' .. oldval .. ' -> ' .. g:read(32))
+oldval = g:toggle(31)
+print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
 
-g:pulse(32, 1, 50)
-g:write(1, gpio.PIN_LOW)
+g:write(31, gpio.PIN_LOW)
 
-g:write(32, gpio.PIN_LOW)
-
-g:write(32, 5)
+g:write(31, 5)
 

Reply via email to