  * bus on port 2, and optionally there are 2 status LEDs on port 4
  * being independently controlled with the DIO and AIO pins. LED1
  * flashes once for the MAXM1 task, twice for the MAXM2 task to show
- * the correct task ran; LED2 flashes once per minute to show the
- * sketch is working.
+ * the correct task ran; LED2 flashes twice per minute when the
+ * lights are awake and once per minute when they are asleep.
  */
 
 // Uncomment for LEDs flashing for debug

// Length of first MaxM light cycle in seconds
// The light scripts on the MaxMs MUST be
// shorter than this value.
// const byte maxm1_cycle = 90;
const byte maxm1_cycle = 30;

// Seconds after starting first MaxM to start second
// const byte maxm2_offset = 30;
const byte maxm2_offset = 15;

// Length of time check cycle in seconds
// const byte check_cycle = 60;
const byte check_cycle = 15;

// LEDs
const byte led1 = 1;

DeviceI2C maxm1 (MaxMbus, maxm1Dev);
DeviceI2C maxm2 (MaxMbus, maxm2Dev);

// LEDs on port 4
Port ledPort (4);

// 1 = lights working, 0 = lights not
byte is_operational = 0;

// Set to 1 when the MaxMs are awake (active)
byte maxms_awake = 0;

// Wake periods. There are some serious constraints on this list
// which are not checked but violations will cause unintended
// results!
// 1. The entries must be in ascending order by day and 
//    start time.
// 2. The sleep time of one period must be earlier than the
//    wake time of the next period.
// 3. This implies that the periods cannot overlap.
Wakeperiod wps[] = {
    {1, hm2min(19, 59), hm2min(20, 18)},
    {1, hm2min(21, 31), hm2min(21, 32)},
    {1, hm2min(21, 34), hm2min(21, 36)},
    {1, hm2min(21, 39), hm2min(21, 42)},
    {1, hm2min(22, 17), hm2min(22, 20)},
    {1, hm2min(22, 22), hm2min(22, 24)},
    {2, hm2min(6, 40), hm2min(6, 58)},
    {2, hm2min(7, 40), hm2min(8, 3)},
    {2, hm2min(11, 40), hm2min(19, 59)},
};
byte num_wps = sizeof(wps) / sizeof(wps[0]);

// Add more tasks for second bench
enum { MAXM1, MAXM2, CHK_TIME, TASK_LIMIT };

static word schedBuf[TASK_LIMIT];
Scheduler scheduler (schedBuf, TASK_LIMIT);
