Afterall, we don’t have the luxury of having Node.js Event Loop. However, I have to remind you that there is still a little difference between the behaviors of my modules and Node.js style. I am not going to explain the details of the implementation of this nodemcu-timer here. That’s even greater if there is already a similar cure, which means I’m not the only one that suffered. This is why I wrote a more generic timer module myself to relieve the pain encountered. I was deeply tortured by the NodeMCU tmr module for a while. This module is actually created to resolve the timeout control of multiple requests for another project. NODEMCU SMART TIMER CODEIt ends up with a messy code that can not be reused and the coding progress could be as painful as you can imagine. And you have to well manage the situation when some of the timers are running repeatedly while the others are being released after timeout, then you will need to assign 1 or 2 variables as counters during tasking. For example, it is doing okay if you only got few timer tasks to run, while it can be very frustrated if you have more than 10 or 20 timer tasks to perform. The original timer modules provided by NodeMCU are enough for general cases, but it’s not that handy when it comes to certain cases. Those who use Node.js or Javascript a lot should find it very familiar. This timer module API is written in JavaScript language style and it’s similar to setTimeout(), setInterval(). Today I am going to introduce a timer module that can be utilized on NodeMCU (on ESP8266 WiFi SoC). Author: simen, Translator: Ivan Chang (sivann inc.)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |