RIAEvangelist / node-phidget-API

Node.JS Phidget API supporting all phidgets!
Other
10 stars 7 forks source link

error in sample code #64

Open alfalabs opened 7 years ago

alfalabs commented 7 years ago

@RIAEvangelist This API is great! There is a small problem with sample code in docs: https://github.com/RIAEvangelist/node-phidget-API/blob/master/docs/Phidget.md here is a fix:

// var Phidget = require('phidgetapi').Phidget;
// var IK888=new phidget();// <--- in original code phidget() function is undefined
var IK888 = require('phidgetapi').Phidget(); 

IK888.on("error", function(data){ console.log('error ',data); });

IK888.on('phidgetReady', function(){
        console.log('IK888 phidget ready');
        console.log(IK888.data);

        IK888.set({
                type:'Output',
                key:'0',
                value:'1'
            });

        IK888.on('changed', update );
    }
);

var update = function(data){
    console.log('phidget state changed');
    console.log('data ',data);

    if(data.type=='Sensor'){

        IK888.set({
                type:'Output',
                key:'0',
                value:'1'
            });

        setTimeout( function(){
               // phidget.set({ <-- in original code phidget var is undefined
                IK888.set({ 
                        type:'Output',
                        key:'0',
                        value:'0'
                    });
            },
            200
        );
    }
};

/*
* Connect to Phidget
*/
IK888.connect({type: 'PhidgetInterfaceKit' });
RIAEvangelist commented 7 years ago

Awesome! Thanks!, can you submit this as a PR? Thanks!

On Mon, Mar 27, 2017 at 8:22 AM, alfalabs notifications@github.com wrote:

@RIAEvangelist https://github.com/RIAEvangelist This API is great! There is a small problem with sample code in docs: https://github.com/ RIAEvangelist/node-phidget-API/blob/master/docs/Phidget.md http://url here is a fix:

var IK888 = require('phidgetapi').Phidget(); // <--- in original code phidget() function is undefined IK888.on("error", function(data){ console.log('error ',data); }); IK888.on('phidgetReady', function(){ console.log('IK888 phidget ready'); console.log(IK888.data);

    IK888.set({
            type:'Output',
            key:'0',
            value:'1'
        });

    IK888.on('changed', update );
}

); var update = function(data){ console.log('phidget state changed'); console.log('data ',data);

if(data.type=='Sensor'){

    IK888.set({
            type:'Output',
            key:'0',
            value:'1'
        });

    setTimeout( function(){
            IK888.set({ // <-- in original code phidget var is undefined
                    type:'Output',
                    key:'0',
                    value:'0'
                });
        },
        200
    );
}

}; /* Connect to Phidget/IK888.connect({type: 'PhidgetInterfaceKit' });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RIAEvangelist/node-phidget-API/issues/64, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWhkSEWl_HDx7XBnifMlNJYl2PVxdzvks5rp9ROgaJpZM4MqbFr .