コード例 #1
0
ファイル: ExampleCallback.php プロジェクト: han5010/dc-brick
    if ($velocity == 32767) {
        echo "Velocity: Full Speed forward, turning backward\n";
        $dc->setVelocity(-32767);
    } elseif ($velocity == -32767) {
        echo "Velocity: Full Speed backward, turning forward\n";
        $dc->setVelocity(32767);
    } else {
        echo "Error\n";
        // Can only happen if another program sets velocity
    }
}
$ipcon = new IPConnection();
// Create IP connection
$dc = new BrickDC(UID, $ipcon);
// Create device object
$ipcon->connect(HOST, PORT);
// Connect to brickd
// Don't use device before ipcon is connected
// Register "velocity reached callback" to cb_reached
// cb_reached will be called every time a velocity set with
// set_velocity is reached
$dc->registerCallback(BrickDC::CALLBACK_VELOCITY_REACHED, 'cb_reached', $dc);
$dc->enable();
// The acceleration has to be smaller or equal to the maximum acceleration
// of the DC motor, otherwise cb_reached will be called too early
$dc->setAcceleration(5000);
// Slow acceleration
$dc->setVelocity(32767);
// Full speed forward
echo "Press ctrl+c to exit\n";
$ipcon->dispatchCallbacks(-1);
コード例 #2
0
ファイル: websocket.php プロジェクト: nemiah/fheME
			echo "\n";
		}
		
	}
	$connections[$T->getID()]->dispatchCallbacks(-1);
	$connections[$T->getID()]->disconnect();
}*/
$nextRequest = array();
$counter = array();
while (true) {
    $AC = anyC::get("Tinkerforge");
    while ($T = $AC->getNextEntry()) {
        #echo "go\n";
        try {
            $connection = new IPConnection();
            $connection->connect($T->A("TinkerforgeServerIP"), $T->A("TinkerforgeServerPort"));
        } catch (Exception $e) {
            echo $e->getMessage();
            continue;
        }
        $ACB = anyC::get("TinkerforgeBricklet", "TinkerforgeBrickletTinkerforgeID", $T->getID());
        while ($B = $ACB->getNextEntry()) {
            $Type = "Tinkerforge\\" . $B->A("TinkerforgeBrickletType");
            if (!isset($counter[$B->getID()])) {
                $counter[$B->getID()] = 0;
            }
            try {
                switch ($B->A("TinkerforgeBrickletType")) {
                    case "BrickletTemperatureIR":
                        if (isset($nextRequest[$B->getID()]) and $nextRequest[$B->getID()] > time()) {
                            continue;
コード例 #3
0
ファイル: ofen.php プロジェクト: nemiah/fheME
	$BLight->setVoltage(($trigger == "1" AND $lastVolt !== false) ? $lastVolt : 0);
	
	$shmid = shmop_open(1, "w", 0644, 1);
	shmop_write($shmid, substr(decbin($valueMask), -1, 1), 0);
	shmop_close($shmid);
}*/
use Tinkerforge\IPConnection;
use Tinkerforge\BrickletTemperatureIR;
#use Tinkerforge\BrickletAnalogOut;
#use Tinkerforge\BrickletIO4;
$host = '192.168.7.227';
$port = 4223;
$uid = '9nA';
$ipcon = new IPConnection();
$BTemp = new BrickletTemperatureIR($uid, $ipcon);
$ipcon->connect($host, $port);
#$BTemp->setDebouncePeriod(60000);
$BTemp->setObjectTemperatureCallbackPeriod(20000);
#$tir->setAmbientTemperatureCallbackPeriod(1000);
$BTemp->registerCallback(BrickletTemperatureIR::CALLBACK_OBJECT_TEMPERATURE, 'cb_temp');
#$BTemp->setObjectTemperatureCallbackThreshold('>', 30*10, 0);
$ipcon->dispatchCallbacks(-1);
$ipcon->disconnect();
/*
$pid = pcntl_fork();

$shmid = shmop_open(0xff3, "c", 0644, 4);
shmop_write($shmid, "0000", 0);
shmop_close($shmid);
		
switch($pid) {
コード例 #4
0
<?php

require_once 'Tinkerforge/IPConnection.php';
require_once 'Tinkerforge/BrickletAmbientLight.php';
require_once 'Tinkerforge/BrickletAmbientLightV2.php';
require_once 'Tinkerforge/BrickletHumidity.php';
require_once 'Tinkerforge/BrickletBarometer.php';
use Tinkerforge\IPConnection;
use Tinkerforge\BrickletAmbientLight;
use Tinkerforge\BrickletAmbientLightV2;
use Tinkerforge\BrickletHumidity;
use Tinkerforge\BrickletBarometer;
$ipcon = new IPConnection();
// NOTE: if you have a first generation Ambient Light Bricklet,
// then uncomment the next line and comment the line after that
//$brickletAmbientLight = new BrickletAmbientLight("apy", $ipcon);
$brickletAmbientLightV2 = new BrickletAmbientLightV2("bhL", $ipcon);
$brickletHumidity = new BrickletHumidity("7bA", $ipcon);
$brickletBarometer = new BrickletBarometer("d99", $ipcon);
$ipcon->connect("localhost", 4223);
// NOTE: if you have a first generation Ambient Light Bricklet,
// then uncomment the next line and comment the line after that
//$illuminance = $brickletAmbientLight->getIlluminance()/10.0;
$illuminance = $brickletAmbientLightV2->getIlluminance() / 100.0;
$humidity = $brickletHumidity->getHumidity() / 10.0;
$air_pressure = $brickletBarometer->getAirPressure() / 1000.0;
$temperature = $brickletBarometer->getChipTemperature() / 100.0;
$response = array("illuminance" => "Illuminance: {$illuminance} Lux", "humidity" => "Humidity: {$humidity} %RH", "air_pressure" => "Air Pressure: {$air_pressure} mbar", "temperature" => "Temperature: {$temperature} &deg;C");
print_r(json_encode($response));