| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #include <MiLightRemoteConfig.h>
- /**
- * IMPORTANT NOTE: These should be in the same order as MiLightRemoteType.
- */
- const MiLightRemoteConfig* MiLightRemoteConfig::ALL_REMOTES[] = {
- &FUT096Config, // rgbw
- &FUT091Config, // cct
- &FUT092Config, // rgb+cct
- &FUT098Config, // rgb
- &FUT089Config // 8-group rgb+cct (b8, fut089)
- };
- const MiLightRemoteConfig* MiLightRemoteConfig::fromType(const String& type) {
- if (type.equalsIgnoreCase("rgbw") || type.equalsIgnoreCase("fut096")) {
- return &FUT096Config;
- }
- if (type.equalsIgnoreCase("cct") || type.equalsIgnoreCase("fut091")) {
- return &FUT091Config;
- }
- if (type.equalsIgnoreCase("rgb_cct") || type.equalsIgnoreCase("fut092")) {
- return &FUT092Config;
- }
- if (type.equalsIgnoreCase("fut089")) {
- return &FUT089Config;
- }
- if (type.equalsIgnoreCase("rgb") || type.equalsIgnoreCase("fut098")) {
- return &FUT098Config;
- }
- Serial.println(F("ERROR - tried to fetch remote config for type"));
- return NULL;
- }
- const MiLightRemoteConfig* MiLightRemoteConfig::fromType(MiLightRemoteType type) {
- if (type == REMOTE_TYPE_UNKNOWN || type >= size(ALL_REMOTES)) {
- Serial.println(F("ERROR - tried to fetch remote config for unknown type"));
- return NULL;
- }
- return ALL_REMOTES[type];
- }
- const MiLightRemoteConfig* MiLightRemoteConfig::fromReceivedPacket(
- const MiLightRadioConfig& radioConfig,
- const uint8_t* packet,
- const size_t len
- ) {
- for (size_t i = 0; i < MiLightRemoteConfig::NUM_REMOTES; i++) {
- const MiLightRemoteConfig* config = MiLightRemoteConfig::ALL_REMOTES[i];
- if (&config->radioConfig == &radioConfig
- && config->packetFormatter->canHandle(packet, len)) {
- return config;
- }
- }
- // This can happen under normal circumstances, so not an error condition
- #ifdef DEBUG_PRINTF
- Serial.println(F("ERROR - tried to fetch remote config for unknown packet"));
- #endif
- return NULL;
- }
- const MiLightRemoteConfig FUT096Config( //rgbw
- new RgbwPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[0],
- REMOTE_TYPE_RGBW,
- "rgbw",
- 4
- );
- const MiLightRemoteConfig FUT091Config( //cct
- new CctPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[1],
- REMOTE_TYPE_CCT,
- "cct",
- 4
- );
- const MiLightRemoteConfig FUT092Config( //rgb+cct
- new RgbCctPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[2],
- REMOTE_TYPE_RGB_CCT,
- "rgb_cct",
- 4
- );
- const MiLightRemoteConfig FUT089Config( //rgb+cct B8 / FUT089
- new FUT089PacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[2],
- REMOTE_TYPE_FUT089,
- "fut089",
- 8
- );
- const MiLightRemoteConfig FUT098Config( //rgb
- new RgbPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[3],
- REMOTE_TYPE_RGB,
- "rgb",
- 0
- );
|