extern bool stopRepeatingFlag;
extern QMutex stopRepeatingMutex;
+// Total of all running commands
+extern bool commandInFlight;
+extern QMutex commandIFMutex;
+
// From what I understand (mostly from reading LIRC config files), NEC
// protocol based remotes mostly use a frequency of 38000 units and a
// duty cycle of 50%. They'll be set to these defaults here, and overridden
void PIRProtocol::addKey(
PIRKeyName key,
unsigned long command,
- unsigned int bits)
+ unsigned int size)
{
- appendToBitSeq(keycodes[key], command, bits);
+ // First, if key already exists, clear it out:
+ KeycodeCollection::iterator i = keycodes.find(key);
+ if (i != keycodes.end())
+ {
+ i->second.clear();
+ }
+
+ appendToBitSeq(keycodes[key], command, size);
}
-/*
-void PIRProtocol::setIndex(
- unsigned int i)
+void PIRProtocol::addSIRCKey(
+ PIRKeyName key,
+ unsigned int addressData,
+ unsigned int size,
+ unsigned int commandData)
{
- id = i;
+ // First, if key already exists, clear it out:
+ KeycodeCollection::iterator i = keycodes.find(key);
+ if (i != keycodes.end())
+ {
+ i->second.clear();
+ }
+
+ // First, append the address data:
+ appendToBitSeq(keycodes[key], addressData, size);
+
+ // Next, the command data. The size is always 7 bits:
+ appendToBitSeq(keycodes[key], commandData, 7);
+}
+
+
+void PIRProtocol::addSIRC20Key(
+ PIRKeyName key,
+ unsigned int secondaryAddressData,
+ unsigned int primaryAddressData,
+ unsigned int commandData)
+{
+ // First, if key already exists, clear it out:
+ KeycodeCollection::iterator i = keycodes.find(key);
+ if (i != keycodes.end())
+ {
+ i->second.clear();
+ }
+
+ // First, append the secondary address data:
+ appendToBitSeq(keycodes[key], secondaryAddressData, 8);
+
+ // Next, the primary address data:
+ appendToBitSeq(keycodes[key], primaryAddressData, 5);
+
+ // Next, the command data. The size is always 7 bits:
+ appendToBitSeq(keycodes[key], commandData, 7);
+}
+
+
+void PIRProtocol::addSharpKey(
+ PIRKeyName key,
+ unsigned int addressData,
+ unsigned int commandData)
+{
+ // First, if key already exists, clear it out:
+ KeycodeCollection::iterator i = keycodes.find(key);
+ if (i != keycodes.end())
+ {
+ i->second.clear();
+ }
+
+ // Sharp commands are all 5 bit address, 8 bit command:
+ appendToBitSeq(keycodes[key], addressData, 5);
+ appendToBitSeq(keycodes[key], commandData, 8);
}
-*/
void PIRProtocol::setCarrierFrequency(
}
+void PIRProtocol::setPreData(
+ unsigned long data,
+ unsigned int bits)
+{
+ // If the container is not empty, first clear it out:
+ if (!preData.empty())
+ {
+ preData.clear();
+ }
+
+ appendToBitSeq(preData, data, bits);
+}
+
+
+void PIRProtocol::setPostData(
+ unsigned long data,
+ unsigned int bits)
+{
+ // If the container is not empty, first clear it out:
+ if (!postData.empty())
+ {
+ postData.clear();
+ }
+
+ appendToBitSeq(postData, data, bits);
+}
+
+
bool PIRProtocol::isCommandSupported(
PIRKeyName command)
{
void PIRProtocol::appendToBitSeq(
CommandSequence &sequence,
unsigned int bits,
- int significantBits)
+ int size)
{
- if (significantBits == 0)
+ if (size == 0)
{
// This is bad, but just return silently for now...
return;
// For each bit in the char, append a 1 or a 0 into the sequence.
// Starting with the largest bit, move forward one bit at a time:
- unsigned int currentBit = 1 << (significantBits - 1);
+ unsigned int currentBit = 1 << (size - 1);
do
{
microseconds = gap - PIEROGI_OVERHEAD_HACK;
}
+/*
// Don't even bother sleeping if there's only a few microseconds:
if (microseconds < 1000)
{
return;
}
+*/
+ // For now, I'm going to enforce a minimum sleep of 10 ms, so that we
+ // don't get runaway commands:
+ if (microseconds < 10000)
+ {
+ microseconds = 10000;
+ }
timespec sleeptime;
sleeptime.tv_sec = 0;