Question to the "setPluginTaskTimer" function
Posted: 06 Oct 2018, 23:17
Hello,
i'm currently developing a plugin called "_P081_DosingPump" to control some small dosing pump motors.
The 6 motor drivers for the dosing pumps are controlled via an 74HC595 shift register.
I basically copied the "_P001_Switch" plugin and modified it a little, so I can enter some calibration paramters for the dosing pump in the device section.
At the moment the plugin is supporting two types of command
- "dose_ms,pump_number,dosing_time"
- "dose_ml,pump_number,dosing_amount"
which basically turns on the pump "pump_number" on for "dosing_time" milliseconds or for a time which corresponds to "dosing_amount" millilitres using the calibration parameter from the device section.
Everything is working so far but now I want to change the code in this way that it is not using the "delay" function inside the WRITE part of the plugin and using timers instead.
So basically doing the same as using the "longpulse_ms" command in the "_P001_switch" plugin and not the "pulse" command which is also using the "delay" function.
This is the point where I don't know how to do this. I tried to figure out how the function
void setPluginTaskTimer(unsigned long timer, byte plugin, short taskIndex, int Par1, int Par2, int Par3, int Par4, int Par5)
works but I don't really understand it.
As far as I figured out the parameters of the function are
timer: length of the timer in ms
plugin: ID of the plugin
taskIndex:not really sure but maybe the tasknumber of the command which is executed at the time?
Par1-5 some parameter for code execution of the timer
But I don't see where the code is executed after the timer. For example in the switch module the parameters when calling the function are the duration of the pulse,
the gpio pin and the state of the gpio pin after the pulse, but where in the code is the "digitalWrite(gpio,value)" for doing this?
I attached my plugin to this question.
Thanks for any help in advance!
i'm currently developing a plugin called "_P081_DosingPump" to control some small dosing pump motors.
The 6 motor drivers for the dosing pumps are controlled via an 74HC595 shift register.
I basically copied the "_P001_Switch" plugin and modified it a little, so I can enter some calibration paramters for the dosing pump in the device section.
At the moment the plugin is supporting two types of command
- "dose_ms,pump_number,dosing_time"
- "dose_ml,pump_number,dosing_amount"
which basically turns on the pump "pump_number" on for "dosing_time" milliseconds or for a time which corresponds to "dosing_amount" millilitres using the calibration parameter from the device section.
Everything is working so far but now I want to change the code in this way that it is not using the "delay" function inside the WRITE part of the plugin and using timers instead.
So basically doing the same as using the "longpulse_ms" command in the "_P001_switch" plugin and not the "pulse" command which is also using the "delay" function.
This is the point where I don't know how to do this. I tried to figure out how the function
void setPluginTaskTimer(unsigned long timer, byte plugin, short taskIndex, int Par1, int Par2, int Par3, int Par4, int Par5)
works but I don't really understand it.
As far as I figured out the parameters of the function are
timer: length of the timer in ms
plugin: ID of the plugin
taskIndex:not really sure but maybe the tasknumber of the command which is executed at the time?
Par1-5 some parameter for code execution of the timer
But I don't see where the code is executed after the timer. For example in the switch module the parameters when calling the function are the duration of the pulse,
the gpio pin and the state of the gpio pin after the pulse, but where in the code is the "digitalWrite(gpio,value)" for doing this?
I attached my plugin to this question.
Thanks for any help in advance!