Advertisement
Guest User

pir6.js

a guest
Nov 17th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. module.exports = function(helper) {
  2. var binaryToPulse, protocolInfo, pulsesToBinaryMapping;
  3. pulsesToBinaryMapping = {
  4. '10': '0',
  5. '01': '1',
  6. '02': '',
  7. '12': ''
  8. };
  9. binaryToPulse = {
  10. '0': '10',
  11. '1': '01',
  12. };
  13. return protocolInfo = {
  14. name: 'pir6',
  15. type: 'pir',
  16. values: {
  17. unit: {
  18. type: "number"
  19. },
  20. id: {
  21. type: "number"
  22. },
  23. presence: {
  24. type: "boolean"
  25. }
  26. },
  27. brands: [],
  28. pulseLengths: [172, 540, 5568],
  29. pulseCount: 50,
  30. decodePulses: function(pulses) {
  31. var binary, result;
  32. binary = helper.map(pulses, pulsesToBinaryMapping);
  33. return result = {
  34. id: helper.binaryToNumber(binary, 1, 19),
  35. unit: helper.binaryToNumber(binary, 20, 23),
  36. presence: true
  37. };
  38. }
  39. };
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement