You are reading a single comment by @enaon and its replies. Click here to read the full conversation.
  • I am not sure where to post this, it is about an interesting rgb led controller, that is controller by advertising manufacturer data. It is interesting because it is programmable, one can set patterns and store them as profiles, and a lot of them can be controlled at the same time, since no connection is needed.

    if one happens to find such a controller, this is the code I use to control it from espruino.

    if (!global.ledBT){
    global.ledBT={
    	busy:0,
    	tid:0,
        cnt:1,
        val:0,
    	run:0,
    	solid:0,
    	patern:0,
        preset:0,
    	do:function(c){
            //print("in",c);
    		if (this.busy) {print(1);ledBT.busy=0;return false;}
            this.busy=1;
            if (ledBT.cmd(c)) NRF.setAdvertising({},{manufacturerData:[ledBT.cmd(c)]});
            else {ledBT.busy=0;return;}
            if (ledBT.tid) clearTimeout(ledBT.tid);
            this.tid=setTimeout((c)=>{
                if (!ledBT.val) ledBT.val=c;
    			ledBT.tid=0;
                //print("check",ledBT.val+ledBT.cnt);
                ledBT.busy=0;  
                if (ledBT.cmd(ledBT.val+ledBT.cnt)) {ledBT.do(ledBT.val+ledBT.cnt); ledBT.cnt++;}
                else { ledBT.tid=setTimeout(()=>{ledBT.tid=0;NRF.setAdvertising({},{manufacturerData:[]});},2000); ledBT.val=0;ledBT.cnt=1;}
    		},50,c);
    	},
    	cmd:function(o){
    		if (o=="bri100") return new Uint8Array([109, 182, 67, 213, 174, 14, 5, 147, 229, 29, 255, 184, 88, 241, 145, 188]).buffer;
    		else if (o=="bri101") return   new Uint8Array([109, 182, 67, 213, 174, 14, 5, 147, 229, 29, 255, 184, 88, 241, 146, 189]).buffer;
    		else if (o=="bri50") return  new Uint8Array(  [109, 182, 67, 213, 174, 14, 5, 147, 229, 29, 255, 83, 91, 241, 254, 182]).buffer;
    		else if (o=="bri05") return  new Uint8Array(  [109, 182, 67, 213, 174, 14, 5, 147, 229, 29, 255, 83, 91, 241, 254, 182]).buffer;
    
    		else if (o=="on") {ledBT.run=1;return   new Uint8Array([109, 182, 67, 213, 174, 14, 5, 147, 228, 28, 254, 184, 88, 253, 41, 101]).buffer;}
    		else if (o=="off") {ledBT.run=0;return   new Uint8Array([109, 182, 67, 213, 174, 14, 5, 147, 228, 28, 254, 184, 91, 253, 65, 79]).buffer;}
    
    		else if (o=="whiteOnce") return new Uint8Array([109, 182, 67, 213, 174, 14, 5, 146, 229, 29, 254, 185, 88, 249, 107, 233]).buffer;
    		else if (o=="blue") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 226, 254, 71, 90, 240, 156, 229]).buffer;
    		else if (o=="purple") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 226, 1, 184, 89, 240, 213, 204]).buffer;
    		else if (o=="white") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 226, 1, 71, 88, 240, 254, 19]).buffer;
    											
    		else if (o=="yellow") return new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 29, 1, 71, 88, 240, 164, 230]).buffer ;
    		else if (o=="green") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 29, 254, 71, 91, 240, 30, 9]).buffer;
    		else if (o=="red") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 29, 1, 184, 91, 240, 63, 10]).buffer;
    
    		else if (o=="PO1") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 212, 228, 29, 3, 79, 88, 251, 208, 247]).buffer;
    		else if (o=="PO11") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 109, 26, 226, 13, 153, 91, 248, 130, 5]).buffer;
    		else if (o=="PO12") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 4, 229, 29, 255, 188, 90, 254, 123, 224]).buffer;
    
    		else if (o=="PO2") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 214, 228, 63, 1, 239, 89, 251, 11, 153]).buffer;
    		else if (o=="PO21") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 109, 26, 226, 1, 248, 88, 248, 79, 231]).buffer;
    		else if (o=="PO22") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 86, 229, 29, 254, 188, 91, 254, 108, 160]).buffer;
    
    		else if (o=="PO3") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 215, 231, 16, 254, 71, 88, 251, 209, 21]).buffer;
    		else if (o=="PO31") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 109, 26, 226, 254, 184, 91, 248, 131, 14]).buffer;
    		else if (o=="PO32") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 146, 229, 9, 4, 187, 90, 254, 9, 41]).buffer;
    
    		else if (o=="PO4") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 214, 228, 63, 1, 239, 90, 251, 99, 179]).buffer;
    		else if (o=="PO41") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 109, 26, 226, 1, 248, 89, 248, 151, 254]).buffer;
    		else if (o=="PO42") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 86, 229, 29, 254, 188, 88, 254, 4, 138]).buffer;
    		
    		else if (o=="RWB") return new Uint8Array([109, 182, 67, 213, 174, 14, 5, 215, 228, 29, 1, 184, 90, 251, 73, 85]).buffer;
    		else if (o=="RWB1") return new Uint8Array([109, 182, 67, 213, 174, 14, 5, 109, 26, 226, 4, 184, 89, 248, 182, 150]).buffer;
    		else if (o=="RWB2") return new Uint8Array([109, 182, 67, 213, 174, 14, 5, 246, 229, 23, 131, 188, 88, 254, 248, 242]).buffer;
    		
    		else if (o=="RWG") return  new Uint8Array([109, 182, 67, 213, 174, 14, 5, 215, 228, 29, 1, 184, 89, 251, 33, 127]).buff
    

    1 Attachment

    • unnamed.jpg
About

Avatar for enaon @enaon started