Esempio n. 1
0
AJ.onAttach = function() {
    print("AJ.onAttach");
    R = IO.digitalOut(IO.pin[1]);
    G = IO.digitalOut(IO.pin[2]);
    B = IO.digitalOut(IO.pin[3]);
    var RGB = convertHSBtoRGB(LampStateProperties.Hue, LampStateProperties.Saturation, LampStateProperties.Brightness);
    sendInfoToLightBulb(RGB);
}
Esempio n. 2
0
 *
 *    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 *    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 *    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 *    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 *    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 *    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ******************************************************************************/
var AJ = require('AllJoyn');
var IO = require('IO');

/* 
 * Configure light sensor ADC
 */
var pin = IO.digitalOut(IO.pin[10], 1)
var lightSensor = IO.analogIn(IO.pin[11]);

function lightCheck()
{
    var level = lightSensor.value;
    print("Light level=", level);
    if (level > 10000 && this.bright != true) {
        this.bright = true;
        this.dark = false;
        AJ.notification(AJ.notification.Info, "Light is too bright " + level).send(100);
    } else if (level < 1000 && this.dark != true) {
        this.bright = false;
        this.dark = true;
        AJ.notification(AJ.notification.Emergency, "Help mommy it's dark").send(100);
    }
Esempio n. 3
0
 *
 *    Permission to use, copy, modify, and/or distribute this software for any
 *    purpose with or without fee is hereby granted, provided that the above
 *    copyright notice and this permission notice appear in all copies.
 *
 *    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 *    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 *    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 *    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 *    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 *    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ******************************************************************************/
var IO = require('IO');

var led1=IO.digitalOut(IO.pin[0]);
var led2=IO.digitalOut(IO.pin[1], 0);
var led3=IO.digitalOut(IO.pin[2]);
var led4=IO.digitalOut(IO.pin[3], 0);

var in1=IO.digitalIn(IO.pin[4], IO.pullUp);
var in2=IO.digitalIn(IO.pin[5], IO.pullUp);
var in3=IO.digitalIn(IO.pin[6], IO.pullUp);
var in4=IO.digitalIn(IO.pin[7], IO.pullUp);

var pb1=IO.digitalIn(IO.pin[8], IO.pullUp);
var pb2=IO.digitalIn(IO.pin[9], IO.pullUp);
var pb3=IO.digitalIn(IO.pin[10], IO.pullUp);
var pb4=IO.digitalIn(IO.pin[11], IO.pullUp);

setInterval(function() {
Esempio n. 4
0
 *    You may obtain a copy of the License at
 *    
 *        http://www.apache.org/licenses/LICENSE-2.0
 *    
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *    
 *    Pursuant to Section 1 of the License, the work of authorship constituting
 *    a Work and any Contribution incorporated in the Work shall mean only that
 *    Contributor's code submissions authored by that Contributor.  Any rights
 *    granted under the License are conditioned upon acceptance of these
 *    clarifications.
 ******************************************************************************/
var AJ = require('AllJoyn');
var IO = require('IO');

var cp = AJ.controlPanel();

var c1 = cp.containerWidget(cp.VERTICAL, cp.HORIZONTAL);
var rate = c1.propertyWidget(cp.SLIDER, 50, "Brightness:");
rate.range = { min:0, max:100, increment:1 };

var led = IO.digitalOut(IO.pin[0]);

rate.onValueChanged = function(val) { led.pwm((100 - val) / 100, 100); }

AJ.onAttach = function() { cp.load(); }
Esempio n. 5
0
/*
 *Toggle the LED on pin 'PinID'
 */
function blinky(pinID) {
    var led = IO.digitalOut(IO.pin[pinID]);
    return function() { led.toggle(); }
}