Fix irremote reporting incorrect NEC addresses and command codes (#422)

Change from reading MSB->LSB to LSB->MSB
Fixes https://github.com/tinygo-org/drivers/issues/422
This commit is contained in:
Neil Davis
2022-07-11 17:05:35 +01:00
committed by Ron Evans
parent 3edd8e413b
commit 13c43350a3
2 changed files with 23 additions and 23 deletions
+18 -18
View File
@@ -8,27 +8,27 @@ import (
)
var irCmdButtons = map[uint16]string{
0xA2: "POWER",
0xE2: "FUNC/STOP",
0x62: "VOL+",
0x22: "FAST BACK",
0x02: "PAUSE",
0xC2: "FAST FORWARD",
0xE0: "DOWN",
0xA8: "VOL-",
0x90: "UP",
0x98: "EQ",
0xB0: "ST/REPT",
0x68: "0",
0x30: "1",
0x45: "POWER",
0x47: "FUNC/STOP",
0x46: "VOL+",
0x44: "FAST BACK",
0x40: "PAUSE",
0x43: "FAST FORWARD",
0x07: "DOWN",
0x15: "VOL-",
0x09: "UP",
0x19: "EQ",
0x0D: "ST/REPT",
0x16: "0",
0x0C: "1",
0x18: "2",
0x7A: "3",
0x10: "4",
0x38: "5",
0x5E: "3",
0x08: "4",
0x1C: "5",
0x5A: "6",
0x42: "7",
0x4A: "8",
0x52: "9",
0x52: "8",
0x4A: "9",
}
var (
+5 -5
View File
@@ -151,7 +151,7 @@ func (ir *ReceiverDevice) pinChange(pin machine.Pin) {
ir.resetStateMachine()
} else {
// 562.5µs OR 1687.5µs space detected
mask := uint32((1 << (31 - ir.bitIndex)))
mask := uint32(1 << ir.bitIndex)
if duration > time.Microsecond*1000 {
// 1687.5µs space detected (logic 1) - Set bit
ir.data.Code |= mask
@@ -201,16 +201,16 @@ const (
func (ir *ReceiverDevice) decode() irDecodeError {
// Decode cmd and inverse cmd and perform validation check
cmd := uint8((ir.data.Code & 0xff00) >> 8)
invCmd := uint8(ir.data.Code & 0xff)
cmd := uint8((ir.data.Code & 0x00ff0000) >> 16)
invCmd := uint8((ir.data.Code & 0xff000000) >> 24)
if cmd != ^invCmd {
// Validation failure. cmd and inverse cmd do not match
return irDecodeErrorInverseCheckFail
}
// cmd validation pass, decode address
ir.data.Command = uint16(cmd)
addrLow := uint8((ir.data.Code & 0xff000000) >> 24)
addrHigh := uint8((ir.data.Code & 0x00ff0000) >> 16)
addrLow := uint8(ir.data.Code & 0xff)
addrHigh := uint8((ir.data.Code & 0xff00) >> 8)
if addrHigh == ^addrLow {
// addrHigh is inverse of addrLow. This is not a valid 16-bit address in extended NEC coding
// since it is indistinguishable from 8-bit address with inverse validation. Use the 8-bit address