infrared_protocol_nec.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "infrared_protocol_nec_i.h"
  2. const InfraredCommonProtocolSpec infrared_protocol_nec = {
  3. .timings =
  4. {
  5. .preamble_mark = INFRARED_NEC_PREAMBLE_MARK,
  6. .preamble_space = INFRARED_NEC_PREAMBLE_SPACE,
  7. .bit1_mark = INFRARED_NEC_BIT1_MARK,
  8. .bit1_space = INFRARED_NEC_BIT1_SPACE,
  9. .bit0_mark = INFRARED_NEC_BIT0_MARK,
  10. .bit0_space = INFRARED_NEC_BIT0_SPACE,
  11. .preamble_tolerance = INFRARED_NEC_PREAMBLE_TOLERANCE,
  12. .bit_tolerance = INFRARED_NEC_BIT_TOLERANCE,
  13. .silence_time = INFRARED_NEC_SILENCE,
  14. .min_split_time = INFRARED_NEC_MIN_SPLIT_TIME,
  15. },
  16. .databit_len[0] = 42,
  17. .databit_len[1] = 32,
  18. .no_stop_bit = false,
  19. .decode = infrared_common_decode_pdwm,
  20. .encode = infrared_common_encode_pdwm,
  21. .interpret = infrared_decoder_nec_interpret,
  22. .decode_repeat = infrared_decoder_nec_decode_repeat,
  23. .encode_repeat = infrared_encoder_nec_encode_repeat,
  24. };
  25. static const InfraredProtocolVariant infrared_protocol_variant_nec = {
  26. .name = "NEC",
  27. .address_length = 8,
  28. .command_length = 8,
  29. .frequency = INFRARED_COMMON_CARRIER_FREQUENCY,
  30. .duty_cycle = INFRARED_COMMON_DUTY_CYCLE,
  31. .repeat_count = INFRARED_NEC_REPEAT_COUNT_MIN,
  32. };
  33. static const InfraredProtocolVariant infrared_protocol_variant_necext = {
  34. .name = "NECext",
  35. .address_length = 16,
  36. .command_length = 16,
  37. .frequency = INFRARED_COMMON_CARRIER_FREQUENCY,
  38. .duty_cycle = INFRARED_COMMON_DUTY_CYCLE,
  39. .repeat_count = INFRARED_NEC_REPEAT_COUNT_MIN,
  40. };
  41. static const InfraredProtocolVariant infrared_protocol_variant_nec42 = {
  42. .name = "NEC42",
  43. .address_length = 13,
  44. .command_length = 8,
  45. .frequency = INFRARED_COMMON_CARRIER_FREQUENCY,
  46. .duty_cycle = INFRARED_COMMON_DUTY_CYCLE,
  47. .repeat_count = INFRARED_NEC_REPEAT_COUNT_MIN,
  48. };
  49. static const InfraredProtocolVariant infrared_protocol_variant_nec42ext = {
  50. .name = "NEC42ext",
  51. .address_length = 26,
  52. .command_length = 16,
  53. .frequency = INFRARED_COMMON_CARRIER_FREQUENCY,
  54. .duty_cycle = INFRARED_COMMON_DUTY_CYCLE,
  55. .repeat_count = INFRARED_NEC_REPEAT_COUNT_MIN,
  56. };
  57. const InfraredProtocolVariant* infrared_protocol_nec_get_variant(InfraredProtocol protocol) {
  58. if(protocol == InfraredProtocolNEC)
  59. return &infrared_protocol_variant_nec;
  60. else if(protocol == InfraredProtocolNECext)
  61. return &infrared_protocol_variant_necext;
  62. else if(protocol == InfraredProtocolNEC42)
  63. return &infrared_protocol_variant_nec42;
  64. else if(protocol == InfraredProtocolNEC42ext)
  65. return &infrared_protocol_variant_nec42ext;
  66. else
  67. return NULL;
  68. }