Failing to do this may theoretically cause trouble if a multi-bit
accessory spans a k83 module boundary. Sending a deactivation command
for the first bit would only turn off the first module but not the
second.
unsigned lowest_bit = changes&~(changes-1);
unsigned i;
for(i=0; (lowest_bit>>i)>1; ++i) ;
+ active_index = i;
acc.state.set(acc.state^lowest_bit);
PendingCommand cmd(acc, Accessory::ACTIVATE, i);
command_queue.push(cmd);
if(t>off_timeout)
{
off_timeout = Time::TimeStamp();
- PendingCommand cmd(*active_accessory, Accessory::DEACTIVATE);
+ PendingCommand cmd(*active_accessory, Accessory::DEACTIVATE, active_index);
command_queue.push(cmd);
}
}
AccessoryMap accessories;
AccessoryPtrList accessory_queue;
Accessory *active_accessory;
+ unsigned char active_index;
Msp::Time::TimeStamp off_timeout;
SensorMap sensors;