Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add support for PWM resolutions other than 8-bit #1495

Merged
merged 1 commit into from Sep 18, 2018

Conversation

dtex
Copy link
Collaborator

@dtex dtex commented Aug 26, 2018

Required for ESP32. Addresses #1275, #1276, and #1280

@@ -646,7 +646,7 @@ Motor.prototype.setPin = function(pin, value) {
};

Motor.prototype.setPWM = function(pin, value) {
this.io.analogWrite(pin, value);
this.io.analogWrite(pin, __.map(value, 0, 255, 0, this.board.RESOLUTION.PWM));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do a pass on this file and change __ to Fn? Probably in another patch?

@rwaldron rwaldron merged commit fc7cb1f into rwaldron:master Sep 18, 2018
@DanHartman
Copy link

I do not understand how to access the 12 bit resolution of the PCA9685.
I suspect that I have misinterpreted what pwmRange does.
Given the following code, I expected to see a duty cycle on my oscilloscope that is a fraction of full on.
What I see is near full scale output that would imply that my value of 254 is almost max 8 bit resolution.
What have I done wrong?

const five = require('johnny-five')

five.Board().on('ready', function() {
  var led = new five.Led({
    pin: 0,
    controller: 'PCA9685',
    pwmRange: [0, 4095]
  })
  led.brightness(254)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants