mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 12:51:22 +04:00
Add support for Pioneer SR IR remotes (#3308)
* add support for Pioneer SR IR remotes * fix minor issues * fix repeat * Fix protocol enumeration order * Add unit tests for Pioneer IR protocol * Clean up raw test data * Add encoder/decoder tests, modify parser * Remove dead code * Use loops where appropriate Co-authored-by: Georgii Surkov <37121527+gsurkov@users.noreply.github.com> Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
This commit is contained in:
@@ -426,53 +426,53 @@ MU_TEST(infrared_test_decoder_mixed) {
|
|||||||
infrared_test_run_decoder(InfraredProtocolSIRC, 3);
|
infrared_test_run_decoder(InfraredProtocolSIRC, 3);
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 1);
|
infrared_test_run_decoder(InfraredProtocolKaseikyo, 1);
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 1);
|
infrared_test_run_decoder(InfraredProtocolRCA, 1);
|
||||||
|
infrared_test_run_decoder(InfraredProtocolPioneer, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_nec) {
|
MU_TEST(infrared_test_decoder_nec) {
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 1);
|
for(uint32_t i = 1; i <= 3; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 2);
|
infrared_test_run_decoder(InfraredProtocolNEC, i);
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 3);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_unexpected_end_in_sequence) {
|
MU_TEST(infrared_test_decoder_unexpected_end_in_sequence) {
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 1);
|
for(uint32_t i = 1; i <= 2; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 1);
|
infrared_test_run_decoder(InfraredProtocolNEC, i);
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 2);
|
infrared_test_run_decoder(InfraredProtocolNEC, i);
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC, 2);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_necext1) {
|
MU_TEST(infrared_test_decoder_necext1) {
|
||||||
|
for(uint32_t i = 0; i < 2; ++i) {
|
||||||
|
UNUSED(i);
|
||||||
infrared_test_run_decoder(InfraredProtocolNECext, 1);
|
infrared_test_run_decoder(InfraredProtocolNECext, 1);
|
||||||
infrared_test_run_decoder(InfraredProtocolNECext, 1);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_long_packets_with_nec_start) {
|
MU_TEST(infrared_test_decoder_long_packets_with_nec_start) {
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC42ext, 1);
|
for(uint32_t i = 1; i <= 2; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolNEC42ext, 2);
|
infrared_test_run_decoder(InfraredProtocolNEC42ext, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_encoder_sirc) {
|
MU_TEST(infrared_test_encoder_sirc) {
|
||||||
infrared_test_run_encoder(InfraredProtocolSIRC, 1);
|
for(uint32_t i = 1; i <= 2; ++i) {
|
||||||
infrared_test_run_encoder(InfraredProtocolSIRC, 2);
|
infrared_test_run_encoder(InfraredProtocolSIRC, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_sirc) {
|
MU_TEST(infrared_test_decoder_sirc) {
|
||||||
infrared_test_run_decoder(InfraredProtocolSIRC, 3);
|
for(uint32_t i = 1; i <= 5; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolSIRC, 1);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolSIRC, 2);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolSIRC, 4);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolSIRC, 5);
|
infrared_test_run_decoder(InfraredProtocolSIRC, 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_rc5) {
|
MU_TEST(infrared_test_decoder_rc5) {
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5X, 1);
|
infrared_test_run_decoder(InfraredProtocolRC5X, 1);
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 1);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 2);
|
for(uint32_t i = 1; i <= 7; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 3);
|
infrared_test_run_decoder(InfraredProtocolRC5, i);
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 4);
|
}
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 5);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 6);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolRC5, 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_encoder_rc5x) {
|
MU_TEST(infrared_test_encoder_rc5x) {
|
||||||
@@ -492,21 +492,21 @@ MU_TEST(infrared_test_encoder_rc6) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_kaseikyo) {
|
MU_TEST(infrared_test_decoder_kaseikyo) {
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 1);
|
for(uint32_t i = 1; i <= 6; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 2);
|
infrared_test_run_decoder(InfraredProtocolKaseikyo, i);
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 3);
|
}
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 4);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 5);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolKaseikyo, 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_decoder_rca) {
|
MU_TEST(infrared_test_decoder_rca) {
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 1);
|
for(uint32_t i = 1; i <= 6; ++i) {
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 2);
|
infrared_test_run_decoder(InfraredProtocolRCA, i);
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 3);
|
}
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 4);
|
}
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 5);
|
|
||||||
infrared_test_run_decoder(InfraredProtocolRCA, 6);
|
MU_TEST(infrared_test_decoder_pioneer) {
|
||||||
|
for(uint32_t i = 1; i <= 11; ++i) {
|
||||||
|
infrared_test_run_decoder(InfraredProtocolPioneer, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST(infrared_test_encoder_decoder_all) {
|
MU_TEST(infrared_test_encoder_decoder_all) {
|
||||||
@@ -520,6 +520,7 @@ MU_TEST(infrared_test_encoder_decoder_all) {
|
|||||||
infrared_test_run_encoder_decoder(InfraredProtocolSIRC, 1);
|
infrared_test_run_encoder_decoder(InfraredProtocolSIRC, 1);
|
||||||
infrared_test_run_encoder_decoder(InfraredProtocolKaseikyo, 1);
|
infrared_test_run_encoder_decoder(InfraredProtocolKaseikyo, 1);
|
||||||
infrared_test_run_encoder_decoder(InfraredProtocolRCA, 1);
|
infrared_test_run_encoder_decoder(InfraredProtocolRCA, 1);
|
||||||
|
infrared_test_run_encoder_decoder(InfraredProtocolPioneer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_TEST_SUITE(infrared_test) {
|
MU_TEST_SUITE(infrared_test) {
|
||||||
@@ -539,6 +540,7 @@ MU_TEST_SUITE(infrared_test) {
|
|||||||
MU_RUN_TEST(infrared_test_decoder_necext1);
|
MU_RUN_TEST(infrared_test_decoder_necext1);
|
||||||
MU_RUN_TEST(infrared_test_decoder_kaseikyo);
|
MU_RUN_TEST(infrared_test_decoder_kaseikyo);
|
||||||
MU_RUN_TEST(infrared_test_decoder_rca);
|
MU_RUN_TEST(infrared_test_decoder_rca);
|
||||||
|
MU_RUN_TEST(infrared_test_decoder_pioneer);
|
||||||
MU_RUN_TEST(infrared_test_decoder_mixed);
|
MU_RUN_TEST(infrared_test_decoder_mixed);
|
||||||
MU_RUN_TEST(infrared_test_encoder_decoder_all);
|
MU_RUN_TEST(infrared_test_encoder_decoder_all);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
Filetype: IR tests file
|
||||||
|
Version: 1
|
||||||
|
#
|
||||||
|
name: decoder_input1
|
||||||
|
type: raw
|
||||||
|
data: 25557 8437 4188 571 1538 595 1514 567 1542 570 1539 573 501 565 1544 568 506 571 1539 573 501 565 509 568 508 569 506 571 1538 574 501 565 1543 569 506 571 504 573 1536 566 1544 568 506 592 1517 574 1535 567 507 570 505 572 1537 575 500 566 508 600 1509 572 503 574 501 565 1544 568 1540 593
|
||||||
|
#
|
||||||
|
name: decoder_expected1
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AF 00 00 00
|
||||||
|
command: 36 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input2
|
||||||
|
type: raw
|
||||||
|
data: 25609 8444 4152 564 1568 544 1565 547 1561 541 1568 544 530 547 1536 566 510 567 1567 545 529 548 526 540 535 542 508 569 1539 573 527 539 1543 569 506 571 504 573 1561 541 508 569 507 570 1538 564 1545 567 507 570 505 572 1537 565 509 568 1541 571 1538 564 511 566 509 568 1539 573 1537 596
|
||||||
|
#
|
||||||
|
name: decoder_expected2
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AF 00 00 00
|
||||||
|
command: 32 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input3
|
||||||
|
type: raw
|
||||||
|
data: 25582 8448 4176 571 1537 565 1544 568 1540 572 1537 575 500 566 1542 570 505 572 1537 575 500 566 508 569 506 571 504 573 1536 565 510 567 1542 570 504 573 1536 566 1543 569 506 571 504 573 1536 566 1543 569 506 571 504 573 502 575 500 566 1542 570 1539 573 502 575 500 566 1542 570 1540 572
|
||||||
|
#
|
||||||
|
name: decoder_expected3
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AF 00 00 00
|
||||||
|
command: 33 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input4
|
||||||
|
type: raw
|
||||||
|
data: 25594 8443 4181 568 1542 570 505 572 1538 564 1545 567 508 569 1540 572 504 573 1536 566 510 567 1542 571 505 572 504 573 1562 540 510 567 1543 570 506 571 504 573 503 574 501 565 510 567 509 568 507 570 1539 573 502 565 1545 568 1542 571 1539 573 1536 566 1544 569 1541 572 503 574 1537 565
|
||||||
|
#
|
||||||
|
name: decoder_expected4
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 40 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input5
|
||||||
|
type: raw
|
||||||
|
data: 25556 8475 4150 597 1512 600 476 601 1509 603 1506 595 480 597 1512 600 476 601 1508 594 482 595 1515 597 478 599 477 600 1510 602 473 604 1506 595 480 597 1513 599 476 601 475 602 474 603 472 594 482 595 1514 598 477 600 476 601 1508 594 1516 596 1513 599 1510 602 1507 595 480 597 1513 599
|
||||||
|
#
|
||||||
|
name: decoder_expected5
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 41 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input6
|
||||||
|
type: raw
|
||||||
|
data: 25567 8471 4155 604 1506 596 480 597 1513 599 1510 603 473 594 1515 597 478 599 1511 602 474 603 1507 595 480 597 479 598 1511 602 474 603 1506 596 480 597 478 599 1511 602 474 603 472 594 481 596 479 598 1512 601 474 603 1506 596 479 598 1511 602 1508 594 1515 598 1512 600 475 602 1507 595
|
||||||
|
#
|
||||||
|
name: decoder_expected6
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 42 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input7
|
||||||
|
type: raw
|
||||||
|
data: 25584 8444 4180 569 1541 572 504 573 1536 566 1544 569 507 570 1539 574 501 566 1569 596 455 570 1540 573 502 575 501 565 1544 569 507 570 1565 548 503 574 1535 567 1543 570 506 571 529 548 502 565 511 566 1543 601 475 571 504 573 503 574 1536 566 1543 570 1539 574 1536 566 509 568 1541 572
|
||||||
|
#
|
||||||
|
name: decoder_expected7
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 43 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input8
|
||||||
|
type: raw
|
||||||
|
data: 25562 8445 4181 568 1543 570 505 572 1538 575 1535 567 508 569 1539 573 503 595 1514 567 508 600 1509 572 503 595 481 596 1513 568 507 601 1508 573 502 575 501 566 1543 570 506 571 504 573 1536 566 510 567 508 600 475 571 1539 573 502 575 1534 568 1542 571 505 572 1537 575 1534 568 1542 571
|
||||||
|
#
|
||||||
|
name: decoder_expected8
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 12 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input9
|
||||||
|
type: raw
|
||||||
|
data: 25558 8470 4152 597 1513 600 476 601 1508 594 1515 598 478 599 1509 593 483 594 1515 598 478 599 1510 603 474 592 482 595 1514 599 477 600 1509 593 483 594 481 596 1513 600 476 601 1508 594 1515 598 478 599 476 601 474 593 1517 596 479 598 1512 601 474 603 472 594 1515 598 1511 602 1508 594
|
||||||
|
#
|
||||||
|
name: decoder_expected9
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 1A 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input10
|
||||||
|
type: raw
|
||||||
|
data: 25587 8442 4179 601 1507 595 481 565 1544 600 1509 593 482 595 1513 568 507 570 1539 594 481 565 1544 600 476 570 505 593 1516 597 479 598 1511 591 484 593 481 575 1534 600 476 570 1539 595 480 597 478 599 476 570 505 593 1517 564 511 597 1511 602 474 572 1537 597 1513 600 1509 572 1537 565
|
||||||
|
#
|
||||||
|
name: decoder_expected10
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 0A 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: decoder_input11
|
||||||
|
type: raw
|
||||||
|
data: 25554 8474 4149 600 1510 603 472 594 1515 597 1512 601 475 602 1507 595 480 597 1513 599 475 602 1508 594 481 596 479 598 1512 601 474 603 1506 596 479 598 1512 601 1508 594 481 596 1513 599 476 601 474 603 472 594 481 596 480 597 478 599 1510 603 473 593 1515 597 1512 601 1509 603 1506 596
|
||||||
|
#
|
||||||
|
name: decoder_expected11
|
||||||
|
type: parsed_array
|
||||||
|
count: 1
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 0B 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
name: encoder_decoder_input1
|
||||||
|
type: parsed_array
|
||||||
|
count: 11
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AF 00 00 00
|
||||||
|
command: 36 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AF 00 00 00
|
||||||
|
command: 32 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AF 00 00 00
|
||||||
|
command: 33 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 40 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 41 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 42 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 43 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 12 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 1A 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 0A 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
|
protocol: Pioneer
|
||||||
|
address: AD 00 00 00
|
||||||
|
command: 0B 00 00 00
|
||||||
|
repeat: false
|
||||||
|
#
|
||||||
@@ -18,7 +18,6 @@ typedef InfraredStatus (
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
InfraredTimings timings;
|
InfraredTimings timings;
|
||||||
bool manchester_start_from_space;
|
bool manchester_start_from_space;
|
||||||
bool no_stop_bit;
|
|
||||||
uint8_t databit_len[4];
|
uint8_t databit_len[4];
|
||||||
InfraredCommonDecode decode;
|
InfraredCommonDecode decode;
|
||||||
InfraredCommonDecodeRepeat decode_repeat;
|
InfraredCommonDecodeRepeat decode_repeat;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "sirc/infrared_protocol_sirc.h"
|
#include "sirc/infrared_protocol_sirc.h"
|
||||||
#include "kaseikyo/infrared_protocol_kaseikyo.h"
|
#include "kaseikyo/infrared_protocol_kaseikyo.h"
|
||||||
#include "rca/infrared_protocol_rca.h"
|
#include "rca/infrared_protocol_rca.h"
|
||||||
|
#include "pioneer/infrared_protocol_pioneer.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
InfraredAlloc alloc;
|
InfraredAlloc alloc;
|
||||||
@@ -114,6 +115,20 @@ static const InfraredEncoderDecoder infrared_encoder_decoder[] = {
|
|||||||
.free = infrared_encoder_sirc_free},
|
.free = infrared_encoder_sirc_free},
|
||||||
.get_protocol_variant = infrared_protocol_sirc_get_variant,
|
.get_protocol_variant = infrared_protocol_sirc_get_variant,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.decoder =
|
||||||
|
{.alloc = infrared_decoder_pioneer_alloc,
|
||||||
|
.decode = infrared_decoder_pioneer_decode,
|
||||||
|
.reset = infrared_decoder_pioneer_reset,
|
||||||
|
.check_ready = infrared_decoder_pioneer_check_ready,
|
||||||
|
.free = infrared_decoder_pioneer_free},
|
||||||
|
.encoder =
|
||||||
|
{.alloc = infrared_encoder_pioneer_alloc,
|
||||||
|
.encode = infrared_encoder_pioneer_encode,
|
||||||
|
.reset = infrared_encoder_pioneer_reset,
|
||||||
|
.free = infrared_encoder_pioneer_free},
|
||||||
|
.get_protocol_variant = infrared_protocol_pioneer_get_variant,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.decoder =
|
.decoder =
|
||||||
{.alloc = infrared_decoder_kaseikyo_alloc,
|
{.alloc = infrared_decoder_kaseikyo_alloc,
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ typedef enum {
|
|||||||
InfraredProtocolSIRC20,
|
InfraredProtocolSIRC20,
|
||||||
InfraredProtocolKaseikyo,
|
InfraredProtocolKaseikyo,
|
||||||
InfraredProtocolRCA,
|
InfraredProtocolRCA,
|
||||||
|
InfraredProtocolPioneer,
|
||||||
|
/* Add new protocols here */
|
||||||
InfraredProtocolMAX,
|
InfraredProtocolMAX,
|
||||||
} InfraredProtocol;
|
} InfraredProtocol;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const InfraredCommonProtocolSpec infrared_protocol_kaseikyo = {
|
|||||||
.min_split_time = INFRARED_KASEIKYO_MIN_SPLIT_TIME,
|
.min_split_time = INFRARED_KASEIKYO_MIN_SPLIT_TIME,
|
||||||
},
|
},
|
||||||
.databit_len[0] = 48,
|
.databit_len[0] = 48,
|
||||||
.no_stop_bit = false,
|
|
||||||
.decode = infrared_common_decode_pdwm,
|
.decode = infrared_common_decode_pdwm,
|
||||||
.encode = infrared_common_encode_pdwm,
|
.encode = infrared_common_encode_pdwm,
|
||||||
.interpret = infrared_decoder_kaseikyo_interpret,
|
.interpret = infrared_decoder_kaseikyo_interpret,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const InfraredCommonProtocolSpec infrared_protocol_nec = {
|
|||||||
},
|
},
|
||||||
.databit_len[0] = 42,
|
.databit_len[0] = 42,
|
||||||
.databit_len[1] = 32,
|
.databit_len[1] = 32,
|
||||||
.no_stop_bit = false,
|
|
||||||
.decode = infrared_common_decode_pdwm,
|
.decode = infrared_common_decode_pdwm,
|
||||||
.encode = infrared_common_encode_pdwm,
|
.encode = infrared_common_encode_pdwm,
|
||||||
.interpret = infrared_decoder_nec_interpret,
|
.interpret = infrared_decoder_nec_interpret,
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
#include "infrared_protocol_pioneer_i.h"
|
||||||
|
#include <core/check.h>
|
||||||
|
|
||||||
|
InfraredMessage* infrared_decoder_pioneer_check_ready(void* ctx) {
|
||||||
|
return infrared_common_decoder_check_ready(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool infrared_decoder_pioneer_interpret(InfraredCommonDecoder* decoder) {
|
||||||
|
furi_assert(decoder);
|
||||||
|
|
||||||
|
uint32_t* data = (void*)&decoder->data[0];
|
||||||
|
uint8_t address = 0;
|
||||||
|
uint8_t command = 0;
|
||||||
|
InfraredProtocol protocol = InfraredProtocolUnknown;
|
||||||
|
|
||||||
|
if(decoder->databit_cnt == decoder->protocol->databit_len[0] ||
|
||||||
|
decoder->databit_cnt == decoder->protocol->databit_len[1]) {
|
||||||
|
address = *data & 0xFF;
|
||||||
|
uint8_t real_address_checksum = ~address;
|
||||||
|
uint8_t address_checksum = (*data >> 8) & 0xFF;
|
||||||
|
command = (*data >> 16) & 0xFF;
|
||||||
|
uint8_t real_command_checksum = ~command;
|
||||||
|
uint8_t command_checksum = (*data >> 24) & 0xFF;
|
||||||
|
if(address_checksum != real_address_checksum) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(command_checksum != real_command_checksum) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
protocol = InfraredProtocolPioneer;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder->message.protocol = protocol;
|
||||||
|
decoder->message.address = address;
|
||||||
|
decoder->message.command = command;
|
||||||
|
decoder->message.repeat = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* infrared_decoder_pioneer_alloc(void) {
|
||||||
|
return infrared_common_decoder_alloc(&infrared_protocol_pioneer);
|
||||||
|
}
|
||||||
|
|
||||||
|
InfraredMessage* infrared_decoder_pioneer_decode(void* decoder, bool level, uint32_t duration) {
|
||||||
|
return infrared_common_decode(decoder, level, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_decoder_pioneer_free(void* decoder) {
|
||||||
|
infrared_common_decoder_free(decoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_decoder_pioneer_reset(void* decoder) {
|
||||||
|
infrared_common_decoder_reset(decoder);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#include "infrared_protocol_pioneer_i.h"
|
||||||
|
#include <core/check.h>
|
||||||
|
|
||||||
|
void infrared_encoder_pioneer_reset(void* encoder_ptr, const InfraredMessage* message) {
|
||||||
|
furi_assert(encoder_ptr);
|
||||||
|
furi_assert(message);
|
||||||
|
|
||||||
|
InfraredCommonEncoder* encoder = encoder_ptr;
|
||||||
|
infrared_common_encoder_reset(encoder);
|
||||||
|
|
||||||
|
uint8_t* data = encoder->data;
|
||||||
|
|
||||||
|
if(message->protocol == InfraredProtocolPioneer) {
|
||||||
|
data[0] = message->address & 0xFF;
|
||||||
|
data[1] = ~(message->address & 0xFF);
|
||||||
|
data[2] = message->command & 0xFF;
|
||||||
|
data[3] = ~(message->command & 0xFF);
|
||||||
|
data[4] = 0;
|
||||||
|
encoder->bits_to_encode = encoder->protocol->databit_len[0];
|
||||||
|
} else {
|
||||||
|
furi_crash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void* infrared_encoder_pioneer_alloc(void) {
|
||||||
|
return infrared_common_encoder_alloc(&infrared_protocol_pioneer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_encoder_pioneer_free(void* encoder_ptr) {
|
||||||
|
infrared_common_encoder_free(encoder_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
InfraredStatus infrared_encoder_pioneer_encode_repeat(
|
||||||
|
InfraredCommonEncoder* encoder,
|
||||||
|
uint32_t* duration,
|
||||||
|
bool* level) {
|
||||||
|
furi_assert(encoder);
|
||||||
|
|
||||||
|
*duration = INFRARED_PIONEER_SILENCE;
|
||||||
|
*level = false;
|
||||||
|
|
||||||
|
encoder->timings_sum = 0;
|
||||||
|
encoder->timings_encoded = 1;
|
||||||
|
encoder->bits_encoded = 0;
|
||||||
|
encoder->state = InfraredCommonEncoderStatePreamble;
|
||||||
|
|
||||||
|
return InfraredStatusOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
InfraredStatus
|
||||||
|
infrared_encoder_pioneer_encode(void* encoder_ptr, uint32_t* duration, bool* level) {
|
||||||
|
InfraredCommonEncoder* encoder = encoder_ptr;
|
||||||
|
|
||||||
|
InfraredStatus status = infrared_common_encode(encoder, duration, level);
|
||||||
|
if((status == InfraredStatusOk) && (encoder->bits_encoded == encoder->bits_to_encode)) {
|
||||||
|
furi_assert(!*level);
|
||||||
|
status = InfraredStatusDone;
|
||||||
|
encoder->state = InfraredCommonEncoderStateEncodeRepeat;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#include "infrared_protocol_pioneer_i.h"
|
||||||
|
|
||||||
|
const InfraredCommonProtocolSpec infrared_protocol_pioneer = {
|
||||||
|
.timings =
|
||||||
|
{
|
||||||
|
.preamble_mark = INFRARED_PIONEER_PREAMBLE_MARK,
|
||||||
|
.preamble_space = INFRARED_PIONEER_PREAMBLE_SPACE,
|
||||||
|
.bit1_mark = INFRARED_PIONEER_BIT1_MARK,
|
||||||
|
.bit1_space = INFRARED_PIONEER_BIT1_SPACE,
|
||||||
|
.bit0_mark = INFRARED_PIONEER_BIT0_MARK,
|
||||||
|
.bit0_space = INFRARED_PIONEER_BIT0_SPACE,
|
||||||
|
.preamble_tolerance = INFRARED_PIONEER_PREAMBLE_TOLERANCE,
|
||||||
|
.bit_tolerance = INFRARED_PIONEER_BIT_TOLERANCE,
|
||||||
|
.silence_time = INFRARED_PIONEER_SILENCE,
|
||||||
|
.min_split_time = INFRARED_PIONEER_MIN_SPLIT_TIME,
|
||||||
|
},
|
||||||
|
.databit_len[0] = 33,
|
||||||
|
.databit_len[1] = 32,
|
||||||
|
.decode = infrared_common_decode_pdwm,
|
||||||
|
.encode = infrared_common_encode_pdwm,
|
||||||
|
.interpret = infrared_decoder_pioneer_interpret,
|
||||||
|
.decode_repeat = NULL,
|
||||||
|
.encode_repeat = infrared_encoder_pioneer_encode_repeat,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const InfraredProtocolVariant infrared_protocol_variant_pioneer = {
|
||||||
|
.name = "Pioneer",
|
||||||
|
.address_length = 8,
|
||||||
|
.command_length = 8,
|
||||||
|
.frequency = INFRARED_PIONEER_CARRIER_FREQUENCY,
|
||||||
|
.duty_cycle = INFRARED_PIONEER_DUTY_CYCLE,
|
||||||
|
.repeat_count = INFRARED_PIONEER_REPEAT_COUNT_MIN,
|
||||||
|
};
|
||||||
|
|
||||||
|
const InfraredProtocolVariant* infrared_protocol_pioneer_get_variant(InfraredProtocol protocol) {
|
||||||
|
if(protocol == InfraredProtocolPioneer)
|
||||||
|
return &infrared_protocol_variant_pioneer;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../infrared_i.h"
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Pioneer SR protocol description
|
||||||
|
* http://www.adrian-kingston.com/IRFormatPioneer.htm
|
||||||
|
****************************************************************************************************
|
||||||
|
* Preamble Preamble Pulse Width Modulation Pause Entirely repeat
|
||||||
|
* mark space up to period message..
|
||||||
|
*
|
||||||
|
* 8500 4250 33 bits (500, 1500) ...26000 8500 4250
|
||||||
|
* __________ _ _ _ _ _ _ _ _ _ _ _ _ _ __________ _ _
|
||||||
|
* ____ __________ _ _ _ __ __ __ _ _ __ __ _ _ ____________________ __________ _
|
||||||
|
*
|
||||||
|
* In 33 bits of data there is:
|
||||||
|
* - 8 bits address
|
||||||
|
* - 8 bits address inverse
|
||||||
|
* - 8 bits command
|
||||||
|
* - 8 bits command inverse
|
||||||
|
* - 1 stop bit
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
void* infrared_decoder_pioneer_alloc(void);
|
||||||
|
void infrared_decoder_pioneer_reset(void* decoder);
|
||||||
|
InfraredMessage* infrared_decoder_pioneer_check_ready(void* decoder);
|
||||||
|
void infrared_decoder_pioneer_free(void* decoder);
|
||||||
|
InfraredMessage* infrared_decoder_pioneer_decode(void* decoder, bool level, uint32_t duration);
|
||||||
|
|
||||||
|
void* infrared_encoder_pioneer_alloc(void);
|
||||||
|
void infrared_encoder_pioneer_reset(void* encoder_ptr, const InfraredMessage* message);
|
||||||
|
void infrared_encoder_pioneer_free(void* decoder);
|
||||||
|
InfraredStatus
|
||||||
|
infrared_encoder_pioneer_encode(void* encoder_ptr, uint32_t* duration, bool* polarity);
|
||||||
|
|
||||||
|
const InfraredProtocolVariant* infrared_protocol_pioneer_get_variant(InfraredProtocol protocol);
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../common/infrared_common_i.h"
|
||||||
|
|
||||||
|
#define INFRARED_PIONEER_CARRIER_FREQUENCY 40000
|
||||||
|
#define INFRARED_PIONEER_DUTY_CYCLE 0.33
|
||||||
|
#define INFRARED_PIONEER_PREAMBLE_MARK 8500
|
||||||
|
#define INFRARED_PIONEER_PREAMBLE_SPACE 4225
|
||||||
|
#define INFRARED_PIONEER_BIT1_MARK 500
|
||||||
|
#define INFRARED_PIONEER_BIT1_SPACE 1500
|
||||||
|
#define INFRARED_PIONEER_BIT0_MARK 500
|
||||||
|
#define INFRARED_PIONEER_BIT0_SPACE 500
|
||||||
|
#define INFRARED_PIONEER_PREAMBLE_TOLERANCE 200 // us
|
||||||
|
#define INFRARED_PIONEER_BIT_TOLERANCE 120 // us
|
||||||
|
#define INFRARED_PIONEER_SILENCE 26000
|
||||||
|
#define INFRARED_PIONEER_MIN_SPLIT_TIME (INFRARED_PIONEER_SILENCE)
|
||||||
|
#define INFRARED_PIONEER_REPEAT_COUNT_MIN 2
|
||||||
|
|
||||||
|
extern const InfraredCommonProtocolSpec infrared_protocol_pioneer;
|
||||||
|
|
||||||
|
bool infrared_decoder_pioneer_interpret(InfraredCommonDecoder* decoder);
|
||||||
|
InfraredStatus infrared_encoder_pioneer_encode_repeat(
|
||||||
|
InfraredCommonEncoder* encoder,
|
||||||
|
uint32_t* duration,
|
||||||
|
bool* level);
|
||||||
@@ -15,7 +15,6 @@ const InfraredCommonProtocolSpec infrared_protocol_rca = {
|
|||||||
.min_split_time = INFRARED_RCA_MIN_SPLIT_TIME,
|
.min_split_time = INFRARED_RCA_MIN_SPLIT_TIME,
|
||||||
},
|
},
|
||||||
.databit_len[0] = 24,
|
.databit_len[0] = 24,
|
||||||
.no_stop_bit = false,
|
|
||||||
.decode = infrared_common_decode_pdwm,
|
.decode = infrared_common_decode_pdwm,
|
||||||
.encode = infrared_common_encode_pdwm,
|
.encode = infrared_common_encode_pdwm,
|
||||||
.interpret = infrared_decoder_rca_interpret,
|
.interpret = infrared_decoder_rca_interpret,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const InfraredCommonProtocolSpec infrared_protocol_samsung32 = {
|
|||||||
.min_split_time = INFRARED_SAMSUNG_MIN_SPLIT_TIME,
|
.min_split_time = INFRARED_SAMSUNG_MIN_SPLIT_TIME,
|
||||||
},
|
},
|
||||||
.databit_len[0] = 32,
|
.databit_len[0] = 32,
|
||||||
.no_stop_bit = false,
|
|
||||||
.decode = infrared_common_decode_pdwm,
|
.decode = infrared_common_decode_pdwm,
|
||||||
.encode = infrared_common_encode_pdwm,
|
.encode = infrared_common_encode_pdwm,
|
||||||
.interpret = infrared_decoder_samsung32_interpret,
|
.interpret = infrared_decoder_samsung32_interpret,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const InfraredCommonProtocolSpec infrared_protocol_sirc = {
|
|||||||
.databit_len[0] = 20,
|
.databit_len[0] = 20,
|
||||||
.databit_len[1] = 15,
|
.databit_len[1] = 15,
|
||||||
.databit_len[2] = 12,
|
.databit_len[2] = 12,
|
||||||
.no_stop_bit = true,
|
|
||||||
.decode = infrared_common_decode_pdwm,
|
.decode = infrared_common_decode_pdwm,
|
||||||
.encode = infrared_common_encode_pdwm,
|
.encode = infrared_common_encode_pdwm,
|
||||||
.interpret = infrared_decoder_sirc_interpret,
|
.interpret = infrared_decoder_sirc_interpret,
|
||||||
|
|||||||
Reference in New Issue
Block a user