Home made cellphone project.

 
 

So that’s all there is to it. Simple to use, extremely handy!


But how about delay()?

It seems that every newbie to Arduino programming jams one or more delay() calls into their loop() function. Then they wonder why everything seems so slow, or doesn’t work at all. Its because delay() stops EVERYTHING.


Seeing that most everything in the cellphone code is running in idle time, panels can give the user a sleep() method that stops the loop() of the current running panel, but leaves the background processes running.


Pretty slick huh?


So, who watches the phone?

There is a class, cellManager, that indirectly inherits from idler. Therefore, it runs in the background spending its time chatting with the FeatherFONA. When it sees a call come in? All it does is set the nextPanel variable to the phone panel ID. The phone panel knows what to do.

Things running behind the scenes..

Loading background processes

How does the phone know that there is a call coming in? Does every panel need to watch for this in its loop method?


Absolutely not!


How about the dreaded delay() function?


Wait and see!


Early on I’d developed a library that allowed creation of objects that would run in the background. Meaning? I don’t need to worry about what to do with them in my loop() function. GREATLY simplifying loop(). Its like switching from micromanaging every aspect of my code to letting most of it manage itself with very little input from me. This allows me to write much larger and more interesting programs.


idler is the class that gives everything that inherits it, an idle() method. In idle(), your object gets a slice of time to do something it needs to do. You gotta’ be quick about it because there are a LOT of other objects waiting for their little slices of time.


This library also supplies a function idle().. Wait that’s confusing. Lets get the straight.


Objects have methods. Programs have functions. They look and act pretty much the same, in that they are instructions in c++ going step by step. Its just the environments they “live in” that are different. A method only pertains to the object that owns it. A function pertains to the entire program. I guess you could think of a program as a super object? I hope this helps and doesn’t just confuse everyone even more.


Anyway, the idler library supplies a global function that you place in your main loop(). Calling idle() in your main loop() diverts time to all the “idlers”.