MiLightRadioFactory.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <RF24.h>
  2. #include <PL1167_nRF24.h>
  3. #include <MiLightRadioConfig.h>
  4. #include <MiLightRadio.h>
  5. #include <NRF24MiLightRadio.h>
  6. #include <LT8900MiLightRadio.h>
  7. #include <RF24PowerLevel.h>
  8. #include <RF24Channel.h>
  9. #include <Settings.h>
  10. #include <vector>
  11. #ifndef _MILIGHT_RADIO_FACTORY_H
  12. #define _MILIGHT_RADIO_FACTORY_H
  13. class MiLightRadioFactory {
  14. public:
  15. virtual ~MiLightRadioFactory() { };
  16. virtual MiLightRadio* create(const MiLightRadioConfig& config) = 0;
  17. static MiLightRadioFactory* fromSettings(const Settings& settings);
  18. };
  19. class NRF24Factory : public MiLightRadioFactory {
  20. public:
  21. NRF24Factory(
  22. uint8_t cePin,
  23. uint8_t csnPin,
  24. RF24PowerLevel rF24PowerLevel,
  25. const std::vector<RF24Channel>& channels,
  26. RF24Channel listenChannel
  27. );
  28. virtual MiLightRadio* create(const MiLightRadioConfig& config);
  29. protected:
  30. RF24 rf24;
  31. const std::vector<RF24Channel>& channels;
  32. const RF24Channel listenChannel;
  33. };
  34. class LT8900Factory : public MiLightRadioFactory {
  35. public:
  36. LT8900Factory(uint8_t csPin, uint8_t resetPin, uint8_t pktFlag);
  37. virtual MiLightRadio* create(const MiLightRadioConfig& config);
  38. protected:
  39. uint8_t _csPin;
  40. uint8_t _resetPin;
  41. uint8_t _pktFlag;
  42. };
  43. #endif