mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	Merge d177d6d7a5 into 4bdb6216d3
				
					
				
			This commit is contained in:
		@@ -7,6 +7,7 @@
 | 
			
		||||
            "resistor": "Resistor?",
 | 
			
		||||
            "readinitial": "Read initial state of pin on deploy/restart?",
 | 
			
		||||
            "type": "Type",
 | 
			
		||||
            "freq": "Frequency",
 | 
			
		||||
            "initpin": "Initialise pin state?",
 | 
			
		||||
            "debounce": "Debounce",
 | 
			
		||||
            "limits": "Limits",
 | 
			
		||||
@@ -32,7 +33,7 @@
 | 
			
		||||
            "pin": "<b>Pins in Use</b>: ",
 | 
			
		||||
            "in": "Only Digital Input is supported - input must be 0 or 1.",
 | 
			
		||||
            "dig": "Digital output - input must be 0 or 1.",
 | 
			
		||||
            "pwm": "PWM output - input must be between 0 to 100.",
 | 
			
		||||
            "pwm": "PWM output - input must be between 0 to 100.<br/>Frequency must be in between 5 and 40000 Hz.",
 | 
			
		||||
            "ser": "Servo output - input must be between 0 to 100. 50 is centre.<br/>Min must be 500uS or more, Max must be 2500uS or less."
 | 
			
		||||
        },
 | 
			
		||||
        "types": {
 | 
			
		||||
 
 | 
			
		||||
@@ -381,6 +381,10 @@
 | 
			
		||||
            <option value="ser" data-i18n="pi-gpiod.servo"></option>
 | 
			
		||||
        </select>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row" id="node-set-frequency">
 | 
			
		||||
        <label>    <span data-i18n="pi-gpiod.label.freq"></label>
 | 
			
		||||
        <input type="text" id="node-input-freq" style="width:70px;"> Hz
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row" id="node-set-minimax">
 | 
			
		||||
        <label>    <span data-i18n="pi-gpiod.label.limits"></label>
 | 
			
		||||
        <span data-i18n="pi-gpiod.label.min"></span> <input type="text" id="node-input-sermin" style="width:70px;"> uS
 | 
			
		||||
@@ -449,6 +453,7 @@
 | 
			
		||||
            set: { value:"" },
 | 
			
		||||
            level: { value:"0" },
 | 
			
		||||
            out: { value:"out" },
 | 
			
		||||
            freq: { value:"800" },
 | 
			
		||||
            sermin: { value:"1000" },
 | 
			
		||||
            sermax: { value:"2000" }
 | 
			
		||||
        },
 | 
			
		||||
@@ -480,8 +485,9 @@
 | 
			
		||||
                if ($("#node-input-out").val() === "pwm") {
 | 
			
		||||
                    $('#node-set-tick').hide();
 | 
			
		||||
                    $('#node-set-state').hide();
 | 
			
		||||
                    $('#node-set-minimax').hide();
 | 
			
		||||
                    $('#node-input-set').prop('checked', false);
 | 
			
		||||
                    $("#node-set-frequency").show();
 | 
			
		||||
                    $('#node-set-minimax').hide();
 | 
			
		||||
                    $("#dig-tip").hide();
 | 
			
		||||
                    $("#pwm-tip").show();
 | 
			
		||||
                    $("#ser-tip").hide();
 | 
			
		||||
@@ -489,14 +495,16 @@
 | 
			
		||||
                else if ($("#node-input-out").val() === "ser") {
 | 
			
		||||
                    $('#node-set-tick').hide();
 | 
			
		||||
                    $('#node-set-state').hide();
 | 
			
		||||
                    $('#node-set-minimax').show();
 | 
			
		||||
                    $('#node-input-set').prop('checked', false);
 | 
			
		||||
                    $("#node-set-frequency").hide();
 | 
			
		||||
                    $('#node-set-minimax').show();
 | 
			
		||||
                    $("#dig-tip").hide();
 | 
			
		||||
                    $("#pwm-tip").hide();
 | 
			
		||||
                    $("#ser-tip").show();
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    $('#node-set-tick').show();
 | 
			
		||||
                    $("#node-set-frequency").hide();
 | 
			
		||||
                    $('#node-set-minimax').hide();
 | 
			
		||||
                    $("#dig-tip").show();
 | 
			
		||||
                    $("#pwm-tip").hide();
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,9 @@ module.exports = function(RED) {
 | 
			
		||||
        this.set = n.set || false;
 | 
			
		||||
        this.level = parseInt(n.level || 0);
 | 
			
		||||
        this.out = n.out || "out";
 | 
			
		||||
        this.freq = Number(n.freq || 800);
 | 
			
		||||
        if (this.freq < 5) { this.freq = 5; }
 | 
			
		||||
        if (this.freq > 40000) { this.freq = 40000; }
 | 
			
		||||
        this.sermin = Number(n.sermin)/100;
 | 
			
		||||
        this.sermax = Number(n.sermax)/100;
 | 
			
		||||
        if (this.sermin > this.sermax) {
 | 
			
		||||
@@ -155,10 +158,10 @@ module.exports = function(RED) {
 | 
			
		||||
                        } else {
 | 
			
		||||
                            node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
 | 
			
		||||
                        }
 | 
			
		||||
                        // if (node.out === "pwm") {
 | 
			
		||||
                        //     PiGPIO.set_PWM_frequency(1000);
 | 
			
		||||
                        //     PiGPIO.set_PWM_range(1000);
 | 
			
		||||
                        // }
 | 
			
		||||
                        if (node.out === "pwm") {
 | 
			
		||||
                            PiGPIO.set_PWM_frequency(node.pin,node.freq);
 | 
			
		||||
                            //PiGPIO.set_PWM_range(node.pin,1000);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user