Skip to content

Commit f9e7b18

Browse files
Update NEC.py Reversed signal, as NEC first bit is the lowest 1, second 2, third 4...
1 parent 79cea5e commit f9e7b18

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

NEC.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ class NECDecoder:
2929
ir_pulseStart = 0
3030
timeFromNextPhase = 0
3131

32-
REMOTE_CONTROLLER_COMMANDS = {
33-
"00001100": "ON",
34-
"00011010": "OK",
35-
"01011010": "RIGHT"
36-
}
37-
38-
REMOTE_CONTROLLERS = {
39-
"10110100": "DVD",
40-
"00000000": "Custom"
41-
}
42-
4332
DEBUG = False
4433

4534
def initialize(self, timeQueue, DebugMode = False):
@@ -126,10 +115,12 @@ def getCommand(self):
126115
pulseArray = self.getBurst(32, self.ir_pulseStart, self.ir_pulseStart + self.AddressLengthSeconds + self.CommandLengthSeconds)
127116

128117
addressArray = self.getFirst16bitsOr27ms(pulseArray)
129-
address = self.fillInKnownValues(addressArray)
118+
binarySignalReversed = self.fillInKnownValues(addressArray)
119+
address = binarySignalReversed[::-1]
130120

131121
commandArray = pulseArray
132-
command = self.fillInKnownValues(commandArray)
122+
binarySignalReversed = self.fillInKnownValues(commandArray)
123+
command = binarySignalReversed[::-1]
133124

134125
if self.DEBUG:
135126
print("Address: {0}".format(address))
@@ -178,12 +169,7 @@ def bestMatch(self, command, arrayOfMatches):
178169
"score": bestScore,
179170
"value": bestValue
180171
}
181-
182-
def bestAddress(self, command):
183-
return self.bestMatch(command, self.REMOTE_CONTROLLERS)
184-
185-
def bestCommand(self, command):
186-
return self.bestMatch(command, self.REMOTE_CONTROLLER_COMMANDS)
172+
187173

188174
def ConvertString16ToHex(self, binaryStringValue):
189175
result = 0
@@ -455,5 +441,4 @@ def validateCombinationSignal(self, signalString):
455441

456442

457443
def fillInKnownValues(self, timeArray):
458-
commandDecoded = ''
459444
return self.enhanceArray(timeArray)

0 commit comments

Comments
 (0)