mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 12:53:23 +00:00
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:
+18
-18
@@ -8,27 +8,27 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var irCmdButtons = map[uint16]string{
|
var irCmdButtons = map[uint16]string{
|
||||||
0xA2: "POWER",
|
0x45: "POWER",
|
||||||
0xE2: "FUNC/STOP",
|
0x47: "FUNC/STOP",
|
||||||
0x62: "VOL+",
|
0x46: "VOL+",
|
||||||
0x22: "FAST BACK",
|
0x44: "FAST BACK",
|
||||||
0x02: "PAUSE",
|
0x40: "PAUSE",
|
||||||
0xC2: "FAST FORWARD",
|
0x43: "FAST FORWARD",
|
||||||
0xE0: "DOWN",
|
0x07: "DOWN",
|
||||||
0xA8: "VOL-",
|
0x15: "VOL-",
|
||||||
0x90: "UP",
|
0x09: "UP",
|
||||||
0x98: "EQ",
|
0x19: "EQ",
|
||||||
0xB0: "ST/REPT",
|
0x0D: "ST/REPT",
|
||||||
0x68: "0",
|
0x16: "0",
|
||||||
0x30: "1",
|
0x0C: "1",
|
||||||
0x18: "2",
|
0x18: "2",
|
||||||
0x7A: "3",
|
0x5E: "3",
|
||||||
0x10: "4",
|
0x08: "4",
|
||||||
0x38: "5",
|
0x1C: "5",
|
||||||
0x5A: "6",
|
0x5A: "6",
|
||||||
0x42: "7",
|
0x42: "7",
|
||||||
0x4A: "8",
|
0x52: "8",
|
||||||
0x52: "9",
|
0x4A: "9",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ func (ir *ReceiverDevice) pinChange(pin machine.Pin) {
|
|||||||
ir.resetStateMachine()
|
ir.resetStateMachine()
|
||||||
} else {
|
} else {
|
||||||
// 562.5µs OR 1687.5µs space detected
|
// 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 {
|
if duration > time.Microsecond*1000 {
|
||||||
// 1687.5µs space detected (logic 1) - Set bit
|
// 1687.5µs space detected (logic 1) - Set bit
|
||||||
ir.data.Code |= mask
|
ir.data.Code |= mask
|
||||||
@@ -201,16 +201,16 @@ const (
|
|||||||
|
|
||||||
func (ir *ReceiverDevice) decode() irDecodeError {
|
func (ir *ReceiverDevice) decode() irDecodeError {
|
||||||
// Decode cmd and inverse cmd and perform validation check
|
// Decode cmd and inverse cmd and perform validation check
|
||||||
cmd := uint8((ir.data.Code & 0xff00) >> 8)
|
cmd := uint8((ir.data.Code & 0x00ff0000) >> 16)
|
||||||
invCmd := uint8(ir.data.Code & 0xff)
|
invCmd := uint8((ir.data.Code & 0xff000000) >> 24)
|
||||||
if cmd != ^invCmd {
|
if cmd != ^invCmd {
|
||||||
// Validation failure. cmd and inverse cmd do not match
|
// Validation failure. cmd and inverse cmd do not match
|
||||||
return irDecodeErrorInverseCheckFail
|
return irDecodeErrorInverseCheckFail
|
||||||
}
|
}
|
||||||
// cmd validation pass, decode address
|
// cmd validation pass, decode address
|
||||||
ir.data.Command = uint16(cmd)
|
ir.data.Command = uint16(cmd)
|
||||||
addrLow := uint8((ir.data.Code & 0xff000000) >> 24)
|
addrLow := uint8(ir.data.Code & 0xff)
|
||||||
addrHigh := uint8((ir.data.Code & 0x00ff0000) >> 16)
|
addrHigh := uint8((ir.data.Code & 0xff00) >> 8)
|
||||||
if addrHigh == ^addrLow {
|
if addrHigh == ^addrLow {
|
||||||
// addrHigh is inverse of addrLow. This is not a valid 16-bit address in extended NEC coding
|
// 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
|
// since it is indistinguishable from 8-bit address with inverse validation. Use the 8-bit address
|
||||||
|
|||||||
Reference in New Issue
Block a user