예제 #1
0
        if ($val > $max) {
            $max = $val;
        }
    }
    return $max;
}
$curve1 = fopen($argv[1], "r");
$curve2 = fopen($argv[2], "r");
$min = doubleval($argv[3]);
$max = doubleval($argv[4]);
$dt = doubleval($argv[5]);
$deadline = doubleval($argv[6]);
$dist_curve1 = read_curve($curve1, $argv[3], $argv[4], $argv[5]);
$reduced_curve1 = reduce_curve($dist_curve1, 60);
$scaled_curve1 = scale_curve($reduced_curve1, 60, 1000, 8);
$pcf = new PCF8574(1, 56);
foreach ($scaled_curve1 as $key => $val) {
    $pcf->set_range(0, intval($val) - 1);
    printf("%d, %d\n", $key, $val);
    usleep(1000000);
}
$pcf->set_range(0, 0 - 1);
exit;
printf("\$%.2f\n", get_max(get_demand($reduced_curve1)) * 0.008);
$reduced_curve2 = read_curve($curve2, $argv[3], $argv[4], $argv[5]);
printf("\$%.2f\n", get_max(get_demand($reduced_curve2)) * 0.008);
$combined_curves = add_curves($reduced_curve1, $reduced_curve2);
$min_demand = NULL;
$max_demand = NULL;
for ($i = $min; $i <= $deadline; $i++) {
    $demand = get_demand(add_curves($reduced_curve1, shift_curve($reduced_curve2, $i, $dt)));
예제 #2
0
<?php

require_once "../app/PCF8574.php";
use App\PCF8574;
$pcf = new PCF8574(1, PCF8574::S0);
$result = $pcf->direct_read();
printf("result: {$result}\n");
$result = $pcf->direct_write(255);
printf("{$result}\n");
예제 #3
0
 /**
  * Set the load on the meter.
  *
  * Sets the internal `$load` variable and calls `$pcf->set_range()` to
  * update the meter via i2c.
  *
  * @see PCF8574::set_range() PCF8574::set_range() function
  * @param int $load A load from 0 to 8 to set.
  * @return int|string The value written to the i2c bus or an error string.
  */
 public function set_load($load)
 {
     $this->load = $load;
     return $this->pcf->set_range(0, $load - 1);
 }