Time Input Widget values (start time, stop time, sunrise flag, sunset flag etc) can be processed in code using ‘TimeInputParam t(param)’ call as explained in “advanced” example.
I have several Time Input Widgets in my project and I don’t want to repeat the whole code for every widget.
So, how can I pass t(param) object values (“getStartHour”, “isStartSunset” and other) to function in order to use them inside the function?
Just assign each needed parameter to a global variable. But you may need some other way of differentiating for each widget if needed.
BLYNK_WRITE(V1) { // Time Input Widget
TimeInputParam t(param);
SThour = t.getStartHour();
STmin = t.getStartMinute();
SPhour = t.getStopHour();
SPmin = t.getStopMinute();
}
Thank you for giving me your time.
Using global variables is a working solution.
Apparently in addition to those global variables in your example I will need quite many more to pass to the function, like 3-4 booleans for time type testing (t.has…, t.is… -parameters), 2 return variables (ontime/offtime), 1 for widget differentiating etc.
I am wondering if it is possible to pass the t(param) variable to the function as one variable to avoid use of global variables, complex function call structure, and splitting repeating.
This t(param) variable is new to me and I don’t know what type it is and how to handle it in function calls etc. Also the list of all available parameters for t.??? would be helpful (maybe there are more than exposed in the examples).
I don’t think it is anything like a simple variable, more like a custom process. So, no, most likely not possible like you suggest.
Besides, using lots of global variables in not uncommon in any code, so no real problem there that I can see, as long as it fits the devices memory that is.