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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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.