MiLightRemoteConfig.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <MiLightRemoteConfig.h>
  2. const MiLightRemoteConfig* MiLightRemoteConfig::ALL_REMOTES[] = {
  3. &FUT096Config,
  4. &FUT091Config,
  5. &FUT092Config,
  6. &FUT089Config,
  7. &FUT098Config
  8. };
  9. const MiLightRemoteConfig* MiLightRemoteConfig::fromType(const String& type) {
  10. if (type.equalsIgnoreCase("rgbw") || type.equalsIgnoreCase("fut096")) {
  11. return &FUT096Config;
  12. }
  13. if (type.equalsIgnoreCase("cct") || type.equalsIgnoreCase("fut091")) {
  14. return &FUT091Config;
  15. }
  16. if (type.equalsIgnoreCase("rgb_cct") || type.equalsIgnoreCase("fut092")) {
  17. return &FUT092Config;
  18. }
  19. if (type.equalsIgnoreCase("fut089")) {
  20. return &FUT089Config;
  21. }
  22. if (type.equalsIgnoreCase("rgb") || type.equalsIgnoreCase("fut098")) {
  23. return &FUT098Config;
  24. }
  25. return NULL;
  26. }
  27. const MiLightRemoteConfig* MiLightRemoteConfig::fromType(MiLightRemoteType type) {
  28. switch (type) {
  29. case REMOTE_TYPE_RGB:
  30. return &FUT096Config;
  31. case REMOTE_TYPE_CCT:
  32. return &FUT091Config;
  33. case REMOTE_TYPE_RGB_CCT:
  34. return &FUT092Config;
  35. case REMOTE_TYPE_FUT089:
  36. return &FUT089Config;
  37. default:
  38. return NULL;
  39. }
  40. }
  41. const MiLightRemoteConfig* MiLightRemoteConfig::fromReceivedPacket(
  42. const MiLightRadioConfig& radioConfig,
  43. const uint8_t* packet,
  44. const size_t len
  45. ) {
  46. for (size_t i = 0; i < MiLightRemoteConfig::NUM_REMOTES; i++) {
  47. const MiLightRemoteConfig* config = MiLightRemoteConfig::ALL_REMOTES[i];
  48. if (&config->radioConfig == &radioConfig
  49. && config->packetFormatter->canHandle(packet, len)) {
  50. return config;
  51. }
  52. }
  53. return NULL;
  54. }