-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
new pwm2 module #2747
new pwm2 module #2747
Conversation
7eb5794
to
45c1dc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments inline. These are mostly Lua and NodeMCU Lua style issues. I leave it to @devsaurus and @pjsg to comment on the realtime aspects.
app/modules/pwm2.c
Outdated
iPin->pulseInterruptCcounter = (sPin->pulseResolutions + 1) * sPin->resolutionInterruptCounterMultiplier; | ||
} | ||
|
||
static uint8_t getDutyAdjustment(const uint32_t duty, const uint32_t pulse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conditional operator considered unhealthy 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not catching this up, what do you mean?
89190dc
to
bda634d
Compare
@pjsg "We had to add support for multiple users of the hw_timer as people didn't read the documentation closely enough and would complain that using module A and module B at the same time would not work." If I recall correctly ( #2494 #2497 ), multiple users functionality was added to allow gpio.pulse and pwm modules to work at the same time (this simultaneous functionality is critical to several of my projects). During the course of you providing this functionality, you discovered and corrected at least one bug and added clarification to the gpio.pulse docs. IMO, this had little to nothing to do with "not reading the documentation closely enough". Losing the multi-user hardware timer functionality (especially with gpio.pulse / pwm) would be detrimental to several of my ESP8266 based products already out in the field. |
@jmd13391 : i think no one is thinking of loosing current capabilities to share timer1 between modules. not me at least. |
This has failed Travis as a consequence of #2742. Have a look at the other modules, e.g. |
Just to be sure, this Module is not supposed to replace the PWM Module, right? |
@HHHartmann : i've added a small section in pwm2 doc about comparison with pwm. let me know how useful you're finding it. |
@TerryE : apparently i'm not getting how to return values from c to lua. what i am missing in get_timer_data? |
The return value to any C method called from the Lua VM is not a status; it's a return argument count. Typically this matches the number of responses that your routine has pushed onto the Lua stack, but the VM will ignore / push extra nils if needed. So |
ok, now to module is more or less ready. |
Nit pick: you're missing newlines at the end of most files. GitHub reports this if you look at https://github.com/nodemcu/nodemcu-firmware/pull/2747/files |
@marcelstoer : ok, i've added missing new lines. |
Documentation can be tested using mkdocs. You can install it using pip (for example |
@galjonsfigur : thanks, i've opted using "docker run -i --rm -v $(pwd):/docs -p 8000:8000 melopt/mkdocs serve" ... |
Documentation was correctly published at https://nodemcu.readthedocs.io/en/latest/modules/pwm2/ and the module is available in the cloud builder (given you select the dev branch). |
Fixes #2667, follow-up to #2669
dev
branch rather than formaster
.docs/*
.an implementation capable of running up to few x100kHz with varying periods, sub-Hz and fraction of frequencies, support for all gpio pins and compatible with CPU160MHz.