I'm working on a project which basically does 2 jobs, which both have different outputs depending on the current time of day:
continuously watch pin for sensor data, and perform function A whenever it arrives
perform function B on fixed schedule (e.g. every minute)
I currently have a setwatch() for 1 and a function start() for 2. But both require the same function for checking the time of day and doing different things depending on it.
What's the best way to structure this code? I'm happy doing either one, but I feel like I'm missing something in my approach to combine them.
Sorry if I've not explained this well - thought it would be better as an abstract question, than sharing my mess of code.
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.
I'm working on a project which basically does 2 jobs, which both have different outputs depending on the current time of day:
I currently have a setwatch() for 1 and a function start() for 2. But both require the same function for checking the time of day and doing different things depending on it.
What's the best way to structure this code? I'm happy doing either one, but I feel like I'm missing something in my approach to combine them.
Sorry if I've not explained this well - thought it would be better as an abstract question, than sharing my mess of code.