I'll start by saying, i'm a PHP guy first and foremost. I've dabbled with C++ etc. over the years but never really coded something properly from scratch. This project is essentially, my first attempt.
As it currently stands, it's a basic proof-of-concept that fades up our main bedroom light via RF at a set time (to act as a S.A.D. light) but the plan was always to expand this to control more devices, of various manufacturers, both scheduled and on-demand. Project has been on the back burner for a while but I'm looking to get going with it again so...
Borrowing from the way Harmony remotes work, I intend to create a database and have tables for rooms, devices, functions, tasks and events. Database will probably be file based (SD) and a httpd will be used for monitoring/managing events/devices/etc.
In the main loop, the code will first check for any serial or web requests and act on them if necessary. Then it will check the DB for any scheduled events due to run and loop back with maybe a 10ms delay.
If a task requires a lot of functions and, more specifically, delays, instead of having the delay in the task, it should exit back out to the main loop and do nothing until it's time to run the next part of the task - to allow other requests or scheduled events to run (primitive multitasking?). I'd imagine setting a status flag and a timeout in the DB would accomplish this best? If there were any event collisions, there would be some kind of priority system in place.
The rest would just be input/output functions, DB management, RF protocol defs etc.
What I want to avoid, as much as I can, is unresponsiveness due to an already running task. That and bloating the program out so much that I run out of EPROM space! I have an extra 32k of SPI memory so should be ok there so long as i'm careful with leaks.
Does this sound like i'm on the right track?