I am getting a pin error when trying to send a simple led.fade to a non-PWM pin. My understanding was that all pins should now use the software PWM by default.
Here's a reduced script:
const five = require("johnny-five");
const Raspi = require("raspi-io").RaspiIO;
const board = new five.Board({
io: new Raspi()
});
board.on("ready", () => {
new five.Led("P1-7").fade(255, 1000);
});
That works if I connect to one of the PWM pins (P1-12, P1-32 & P1-33) but fails on all the other GPIO pins I tried.
Here's an example error:
Error: Pin Error: 7 is not a valid PWM pin (Led)
at Function.Pins.Error (/usr/app/node_modules/johnny-five/lib/board.pins.js:81:9)
at Led.value (/usr/app/node_modules/johnny-five/lib/led/led.js:89:22)
at Led.(anonymous function) [as @@render] (/usr/app/node_modules/johnny-five/lib/led/led.js:349:15)
at Animation.loopFunction (/usr/app/node_modules/johnny-five/lib/animation.js:293:32)
at Immediate.processQueue (/usr/app/node_modules/temporal/lib/temporal.js:195:20)
at processImmediate (timers.js:637:19)
at process.topLevelDomainCallback (domain.js:120:23)
Am I doing something wrong or missing a step? This note from the 10.0.0 changelog makes me think the above should work.
BREAKING CHANGE: removed the enableSoftPwm and switched to using software PWM by default for all pins
Note: this means that hardware PWM is not used on the pins that support hardware PWM, we still use software PWM
My hardware is an old Raspberry Pi 2 Model B v 1.1. I don't think it matters, but the script runs in a Docker container.
Thank you for the report @joemaller. It was a bug on my part, I forgot to update the data structure that Johnny-Five looks at to tell it that all GPIO supports PWM. It's fixed in version 10.0.2.
I am getting a pin error when trying to send a simple
led.fade
to a non-PWM pin. My understanding was that all pins should now use the software PWM by default.Here's a reduced script:
That works if I connect to one of the PWM pins (
P1-12
,P1-32
&P1-33
) but fails on all the other GPIO pins I tried.Here's an example error:
Am I doing something wrong or missing a step? This note from the 10.0.0 changelog makes me think the above should work.
My hardware is an old Raspberry Pi 2 Model B v 1.1. I don't think it matters, but the script runs in a Docker container.