Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/share/examples/lua Pull up the following revisions(s) (re...



details:   https://anonhg.NetBSD.org/src/rev/c08ea3858cfb
branches:  netbsd-6
changeset: 773827:c08ea3858cfb
user:      sborrill <sborrill%NetBSD.org@localhost>
date:      Sat Feb 25 09:58:25 2012 +0000

description:
Pull up the following revisions(s) (requested by mbalmer in ticket #49):
        share/examples/lua/gpio.lua:    revision 1.2

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.

diffstat:

 share/examples/lua/gpio.lua |  19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diffs (37 lines):

diff -r a652bb881a8c -r c08ea3858cfb share/examples/lua/gpio.lua
--- a/share/examples/lua/gpio.lua       Fri Feb 24 17:50:35 2012 +0000
+++ b/share/examples/lua/gpio.lua       Sat Feb 25 09:58:25 2012 +0000
@@ -1,4 +1,4 @@
--- $NetBSD: gpio.lua,v 1.1 2011/10/15 12:58:43 mbalmer Exp $
+-- $NetBSD: gpio.lua,v 1.1.4.1 2012/02/25 09:58:25 sborrill Exp $
 
 require 'gpio'
 
@@ -12,20 +12,17 @@
 
 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))
-
-oldval = g:toggle(32)
-print('pin 32: ' .. oldval .. ' -> ' .. g:read(32))
+local oldval = g:write(31, gpio.PIN_HIGH)
+print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
 
-g:pulse(32, 1, 50)
-g:write(1, gpio.PIN_LOW)
+oldval = g:toggle(31)
+print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
 
-g:write(32, gpio.PIN_LOW)
+g:write(31, gpio.PIN_LOW)
 
-g:write(32, 5)
+g:write(31, 5)
 



Home | Main Index | Thread Index | Old Index