webiopi学习笔记(三)

来源:互联网 发布:txt编辑软件 编辑:程序博客网 时间:2024/05/09 21:14

1.python函数:

(1)基础:

import webiopiGPIO = webiopi.GPIOGPIO.setFunction(LIGHT, GPIO.OUT)GPIO.digitalWrite(LIGHT, GPIO.HIGH)GPIO.digitalRead(LIGHT)webiopi.sleep(1)

(2)python宏:

import webiopi@webiopi.macrodef getLightHours():        return "%d;%d" % (HOUR_ON, HOUR_OFF)@webiopi.macrodef setLightHours(on, off):       global HOUR_ON, HOUR_OFF         HOUR_ON = int(on)         HOUR_OFF = int(off)         return getLightHours()

 

2.JS函数

(1)基础:

<script type="text/javascript" src="/webiopi.js"></script>var button = webiopi().createGPIOButton(17, "Light");webiopi().refreshGPIO(true);

(2)js中使用宏

webiopi().callMacro("getLightHours", [], updateLightHours);</span>
var sendButton = webiopi().createButton("sendButton", "Send", function() {                   // Arguments sent to the macro  var hours = [$("#inputOn").val(), $("#inputOff").val()];                    // Call the macro                    webiopi().callMacro("setLightHours", hours, updateLightHours);               });


 

0 0
原创粉丝点击