<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Release PHP PWM Module Wrapper]]></title><description><![CDATA[<h1>Using php PWM wrapper for use with <a href="https://onion.io/product/servo-pwm-expansion/" rel="nofollow">Servo PWM Module</a></h1>
<hr />
<h2>Q: How to use the wrapper?</h2>
<h2>Answer:</h2>
<pre><code>&lt;?php
 require 'PWM.php';
 $pwm = new PWM();
 $pwm-&gt;SetChan('all'); //set the channels
 /* The CHANNEL can be: 0 - 15 to control an individual channel
    The CHANNEL can be: all to control all channels at once
    
   Optional parameters: frequency If not specified, default of 50 Hz is used
   Frequency range is 24 Hz to 1526 Hz
   Adds a delay in the PWM signal, can be an integer or floating point number between 0 and 100, 0% delay by default
 */
 $data = $pwm-&gt;SetDuty(1.25); // sets duty_cycle 1.25 on all channel's
 echo explode(':',$data[1])[1]; // Parse just the responce
 
 ?&gt;

</code></pre>
<h2>Q: Where do I get it?</h2>
<h2>Answer: Right here!</h2>
<p dir="auto"><a href="https://gist.github.com/Immortal-/358501006e03c60ab573bde29dedac06" rel="nofollow">The Gist Link</a></p>
<pre><code>&lt;?php
/**
* @ Author: Chris McCaslin
* @ Date: 5/25/2016
* @ Disc: Hardware pwm wrapper!
*/
  class PWM
  {
    private $channel;
    private $duty_cycle;
    private $frequency;
    private $delay;
    
    // Need to intilize pwm
    function __constructor()
    {
      $this-&gt;consoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"init\"}'");
    }
    // The SetPeriod function https://github.com/OnionIoT/i2c-exp-driver#set-period-command
    public function SetPeriod($pulse, $period)
    {
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set-period\", \"params\":{\"channel\":$this-&gt;channel, \"pulse\":$pulse, \"periods\":$period}}'");
    }
    
    public function SetChan($chn)
    {
      $this-&gt;channel = $chn;
    }
    // The SetDuty Command https://github.com/OnionIoT/i2c-exp-driver#set-command
    public function SetDuty($dtyCycl)
    {
      if($dtyCycl &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($dtyCycl &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;duty_cycle = (float)$dtyCycl;
      }
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set\", \"params\":{\"channel\":\"$this-&gt;channel\",\"duty\":\"$this-&gt;duty_cycle\"} }'");
    }
    // The SetFreq Command Optional parameter
    public function SetFreq($dtyCycl, $freq)
    {
      if($dtyCycl &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($dtyCycl &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;duty_cycle = (float)$dtyCycl;
      }
      if($freq &lt; 24)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else if($freq &gt; 1526)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else
      {
        $this-&gt;frequency = $freq;
      }
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set\", \"params\":{\"channel\":\"$this-&gt;channel\", \"duty\":\"$this-&gt;duty_cycle\", \"frequency\":\"$this-&gt;frequency\"} }'");
    }
    // The SetDelay Command Optional parameter
    public function SetDelay($dtyCycl, $freq, $delay)
    {
      if($dtyCycl &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($dtyCycl &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;duty_cycle = (float)$dtyCycl;
      }
      if($freq &lt; 24)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else if($freq &gt; 1526)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else
      {
        $this-&gt;frequency = $freq;
      }
      if($delay &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($delay &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;delay = (float)$delay;
      }
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set\", \"params\":{\"channel\":\"$this-&gt;channel\", \"duty\":\"$this-&gt;duty_cycle\", \"frequency\":\"$this-&gt;frequency,  \"delay\":\"$this-&gt;delay\"} }'");
    }
    // The Sleep Command https://github.com/OnionIoT/i2c-exp-driver#sleep-command
    public function Sleep()
    {
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"sleep\"}'");
    }
    // A method so we can interface with console easy.
    private function ConsoleCmd($cmdToSend)
    {
      exec("$cmdToSend 2&gt;&amp;1", $output);
      return $output;
    }
  }
 ?&gt;

</code></pre>
<p dir="auto"><a href="https://github.com/OnionIoT/wiki/pull/30" rel="nofollow">the pull Request</a></p>
]]></description><link>http://community.onion.io/topic/828/release-php-pwm-module-wrapper</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 09:16:28 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/828.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Jun 2016 02:44:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Release PHP PWM Module Wrapper on Thu, 09 Jun 2016 05:43:32 GMT]]></title><description><![CDATA[<h1>Using php PWM wrapper for use with <a href="https://onion.io/product/servo-pwm-expansion/" rel="nofollow">Servo PWM Module</a></h1>
<hr />
<h2>Q: How to use the wrapper?</h2>
<h2>Answer:</h2>
<pre><code>&lt;?php
 require 'PWM.php';
 $pwm = new PWM();
 $pwm-&gt;SetChan('all'); //set the channels
 /* The CHANNEL can be: 0 - 15 to control an individual channel
    The CHANNEL can be: all to control all channels at once
    
   Optional parameters: frequency If not specified, default of 50 Hz is used
   Frequency range is 24 Hz to 1526 Hz
   Adds a delay in the PWM signal, can be an integer or floating point number between 0 and 100, 0% delay by default
 */
 $data = $pwm-&gt;SetDuty(1.25); // sets duty_cycle 1.25 on all channel's
 echo explode(':',$data[1])[1]; // Parse just the responce
 
 ?&gt;

</code></pre>
<h2>Q: Where do I get it?</h2>
<h2>Answer: Right here!</h2>
<p dir="auto"><a href="https://gist.github.com/Immortal-/358501006e03c60ab573bde29dedac06" rel="nofollow">The Gist Link</a></p>
<pre><code>&lt;?php
/**
* @ Author: Chris McCaslin
* @ Date: 5/25/2016
* @ Disc: Hardware pwm wrapper!
*/
  class PWM
  {
    private $channel;
    private $duty_cycle;
    private $frequency;
    private $delay;
    
    // Need to intilize pwm
    function __constructor()
    {
      $this-&gt;consoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"init\"}'");
    }
    // The SetPeriod function https://github.com/OnionIoT/i2c-exp-driver#set-period-command
    public function SetPeriod($pulse, $period)
    {
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set-period\", \"params\":{\"channel\":$this-&gt;channel, \"pulse\":$pulse, \"periods\":$period}}'");
    }
    
    public function SetChan($chn)
    {
      $this-&gt;channel = $chn;
    }
    // The SetDuty Command https://github.com/OnionIoT/i2c-exp-driver#set-command
    public function SetDuty($dtyCycl)
    {
      if($dtyCycl &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($dtyCycl &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;duty_cycle = (float)$dtyCycl;
      }
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set\", \"params\":{\"channel\":\"$this-&gt;channel\",\"duty\":\"$this-&gt;duty_cycle\"} }'");
    }
    // The SetFreq Command Optional parameter
    public function SetFreq($dtyCycl, $freq)
    {
      if($dtyCycl &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($dtyCycl &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;duty_cycle = (float)$dtyCycl;
      }
      if($freq &lt; 24)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else if($freq &gt; 1526)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else
      {
        $this-&gt;frequency = $freq;
      }
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set\", \"params\":{\"channel\":\"$this-&gt;channel\", \"duty\":\"$this-&gt;duty_cycle\", \"frequency\":\"$this-&gt;frequency\"} }'");
    }
    // The SetDelay Command Optional parameter
    public function SetDelay($dtyCycl, $freq, $delay)
    {
      if($dtyCycl &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($dtyCycl &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;duty_cycle = (float)$dtyCycl;
      }
      if($freq &lt; 24)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else if($freq &gt; 1526)
      {
        return "Frequency range is 24 Hz to 1526 Hz";
      }
      else
      {
        $this-&gt;frequency = $freq;
      }
      if($delay &lt; 0.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      elseif ($delay &gt;100.0000)
      {
        return "The DUTY CYCLE can be an integer or floating point number between 0 and 100";
      }
      else
      {
        $this-&gt;delay = (float)$delay;
      }
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"set\", \"params\":{\"channel\":\"$this-&gt;channel\", \"duty\":\"$this-&gt;duty_cycle\", \"frequency\":\"$this-&gt;frequency,  \"delay\":\"$this-&gt;delay\"} }'");
    }
    // The Sleep Command https://github.com/OnionIoT/i2c-exp-driver#sleep-command
    public function Sleep()
    {
      return $this-&gt;ConsoleCmd("ubus call i2c_exp pwm-exp '{\"command\":\"sleep\"}'");
    }
    // A method so we can interface with console easy.
    private function ConsoleCmd($cmdToSend)
    {
      exec("$cmdToSend 2&gt;&amp;1", $output);
      return $output;
    }
  }
 ?&gt;

</code></pre>
<p dir="auto"><a href="https://github.com/OnionIoT/wiki/pull/30" rel="nofollow">the pull Request</a></p>
]]></description><link>http://community.onion.io/post/5808</link><guid isPermaLink="true">http://community.onion.io/post/5808</guid><dc:creator><![CDATA[Chris McCaslin]]></dc:creator><pubDate>Thu, 09 Jun 2016 05:43:32 GMT</pubDate></item><item><title><![CDATA[Reply to Release PHP PWM Module Wrapper on Tue, 07 Jun 2016 05:26:14 GMT]]></title><description><![CDATA[<p dir="auto">It is used for the  <a href="https://onion.io/product/servo-pwm-expansion/" rel="nofollow">Servo (PWM) Expansion</a> !</p>
<p dir="auto">I had to google what PWM means <img src="http://community.onion.io/plugins/nodebb-plugin-emoji/emoji/android/1f60a.png?v=ic093v0mjao" class="not-responsive emoji emoji-android emoji--blush" title=":blush:" alt="😊" /></p>
]]></description><link>http://community.onion.io/post/5814</link><guid isPermaLink="true">http://community.onion.io/post/5814</guid><dc:creator><![CDATA[Luciano S.]]></dc:creator><pubDate>Tue, 07 Jun 2016 05:26:14 GMT</pubDate></item><item><title><![CDATA[Reply to Release PHP PWM Module Wrapper on Thu, 09 Jun 2016 05:45:27 GMT]]></title><description><![CDATA[<p dir="auto">PWM is very interesting to me because how it reminds me of AC.</p>
]]></description><link>http://community.onion.io/post/5826</link><guid isPermaLink="true">http://community.onion.io/post/5826</guid><dc:creator><![CDATA[Chris McCaslin]]></dc:creator><pubDate>Thu, 09 Jun 2016 05:45:27 GMT</pubDate></item></channel></rss>