Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By Fasi Ada
#76416 Add write to any GIOP pin serial data pulse train.
Is it possible and will some coding guru add this feature taken from here:
https://nodemcu.readthedocs.io/en/maste ... gpioserout
What that does:
1: This allows 2 things good that I am interested in: sub-millisecond timings for pin output to high or low, down to 50micros and Non-task-blocking.
2: A callback function (event when done)
2B: This in it self solves an issue In the lua implantation of esp, that this feature does not allow writing serial data pulses to more than one pin at a time however thru the callback function of the async/non-blocking form I can chain as many pins to write to as I like in a row.
Why?
Making cool things possible such as writing multiple servos with the maximum number of steps possible to feed it in the shortest amount of time. the max a 180 deg servo can take in a pulse is 2.5millsecs. if we write that to ALL giop avaible we still have more time that writing just one PWM at a the servo clock of 50mhz, and with more step-resolution than the PWN module's 10bit resolution would allow since 2.5mils is ~ 10% of 20mils, the min 0.5mils is just 3% of that 20mils. This is painful, giving less than 50 slices the 10bit pwm can do. the PWM does not have a call back so making it shorter does no good since we can't turn it off in-time guaranteed. AND all those servos will stack up n time we waste.
IN my way of getting around lua esp's limits was to make a timer for 50hz, and then simply call a chained/nested serial outs to all my servos. All i got to do is update several variables in other functions when needed, like the receiving a packet. And I can stop my timer at any time.
The why for questioning nerd:
I want to move to esp-basic but want this level of detail. micro-seconds timers would be nice too, but this serial out function does the job for my needs. Please no philosophical cult of the OOP debates. OKAY? :twisted:

Excerpt:
"
gpio.serout(1,gpio.HIGH,{5000,995000},100, function() print("done") end) -- asynchronous 100 flashes 5 ms long every second with a callback function when done
gpio.serout(1,gpio.HIGH,{30,70},8) -- serial 30% pwm 10khz, lasts 8 cycles -- asynchronous 100 flashes 5 ms long, no callback
"