How would I get pin for jshSetOutputValue ? #6749
Replies: 1 comment
-
Posted at 2017-01-16 by @gfwilliams Is this for ESP32? Personally I'd just use JshPinFunction to store the pin number... So you have DAC_CH1,2,etc - just set the channel to be the pin number. As-is you can get up to 16 pins like that. If that's not enough, perhaps consider using JSH_TIMER1 for pins 0..15 and JSH_TIMER2 for pins 16..31. You should just be able to do that in jshAnalogOutput. However I can't believe that ESP32 actually has 32 DACs? Surely it's PWM? Usually what happens is jshardware.js (jshAnalogOutput) works out what PWM device to use on what pin, and sets it up. Then jshSetOutputValue updates the chosen device. Posted at 2017-01-16 by JumJum Would it be an option to have func and pin in UtilTimerTaskBuffer instead of a union ? Posted at 2017-01-16 by JumJum ESP32 supports PWM for all(at least most) pins. So we have the choice between more than 16 pins. Posted at 2017-01-16 by @gfwilliams Ok, so it's not DAC you want, just PWM?
Not really - it's just more memory usage, and it's taking code that works for all platforms and then adding loads of platform-specific definitions to it. Just do something like:
Posted at 2017-01-16 by Wilberforce As well as pwm there are 2 8 bit DAC available Posted at 2017-01-16 by @gfwilliams Ok, then that's probably ok - you have the stuff I posted above for PWM pins, and then you have each of the DAC channels done with DAC_CH1&2. You leave jshAnalogOutput to set the pins themselves up. The idea is that Posted at 2017-01-17 by Wilberforce There is also the sigma - delta -API : http://esp-idf.readthedocs.io/en/latest/api/sigmadelta.html This might be easier to implement Rather than the led API: http://esp-idf.readthedocs.io/en/latest/api/ledc.html Posted at 2017-01-19 by JumJum Oh, this really looks nice. And has less restrictions for freqency, compared to ledc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-01-16 by JumJum
In jshardware.c is a function, jshSetOutputValue, used for waveforms (and others ?) to set analog output.
To set the output, only a JshPinFunction is given.
This needs to be translated to a pin.
What is the best way to do that ?
Beta Was this translation helpful? Give feedback.
All reactions