MiLightRadioConfig.cpp 868 B

123456789101112131415161718192021222324252627282930313233
  1. #include <MiLightRadioConfig.h>
  2. MiLightRadioConfig* MiLightRadioConfig::ALL_CONFIGS[] = {
  3. &MilightRgbwConfig,
  4. &MilightCctConfig,
  5. &MilightRgbCctConfig,
  6. &MilightRgbConfig
  7. };
  8. MiLightRadioConfig* MiLightRadioConfig::fromString(const String& s) {
  9. for (size_t i = 0; i < MiLightRadioConfig::NUM_CONFIGS; i++) {
  10. MiLightRadioConfig* config = MiLightRadioConfig::ALL_CONFIGS[i];
  11. if (s.equalsIgnoreCase(config->name)) {
  12. return config;
  13. }
  14. }
  15. return NULL;
  16. }
  17. MiLightRadioConfig* MiLightRadioConfig::fromType(MiLightRadioType type) {
  18. for (size_t i = 0; i < MiLightRadioConfig::NUM_CONFIGS; i++) {
  19. MiLightRadioConfig* config = MiLightRadioConfig::ALL_CONFIGS[i];
  20. if (config->type == type) {
  21. return config;
  22. }
  23. }
  24. return NULL;
  25. }
  26. size_t MiLightRadioConfig::getPacketLength() const {
  27. return packetFormatter->getPacketLength();
  28. }