Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Arduino library for decoding PPM receiver signal
  2. *
  3. * Copyright (c) 2020 Victor Glekler
  4. *
  5. * MIT License
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. /**
  25. * @file PPM.h
  26. * @brief Base class for PPM Decoder
  27. * @author Victor Glekler
  28. * Contact: victor.glekler@gmail.com
  29. * https://github.com/VICLER
  30. */
  31. #pragma once
  32. #include "Arduino.h"
  33. #define MAX_CHANNELS 8 // the maximum channel number
  34. #define MIN_PULSE 1000 // min valid impulse us
  35. #define MAX_PULSE 2000 // max valid impulse us
  36. class PPM
  37. {
  38. public:
  39. void begin(uint8_t max_channels);
  40. uint16_t get(uint8_t channel);
  41. uint8_t getPWM(uint8_t channel);
  42. uint16_t getServo_us(uint8_t channel);
  43. void increment_ovf_count();
  44. bool available();
  45. void process();
  46. private:
  47. uint16_t _channels[MAX_CHANNELS];
  48. volatile uint32_t _ovf_count;
  49. uint8_t _max_channels;
  50. uint32_t _micros_count;
  51. uint32_t _micros();
  52. bool _available;
  53. };
  54. extern PPM ppm;