| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include <MiLightRemoteConfig.h>
- const MiLightRemoteConfig* MiLightRemoteConfig::ALL_REMOTES[] = {
- &FUT096Config,
- &FUT091Config,
- &FUT092Config,
- &FUT089Config,
- &FUT098Config
- };
- 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;
- }
- return NULL;
- }
- const MiLightRemoteConfig* MiLightRemoteConfig::fromType(MiLightRemoteType type) {
- switch (type) {
- case REMOTE_TYPE_RGB:
- return &FUT096Config;
- case REMOTE_TYPE_CCT:
- return &FUT091Config;
- case REMOTE_TYPE_RGB_CCT:
- return &FUT092Config;
- case REMOTE_TYPE_FUT089:
- return &FUT089Config;
- default:
- return NULL;
- }
- }
- 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;
- }
- }
- return NULL;
- }
- const MiLightRemoteConfig FUT096Config( //rgbw
- new RgbwPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[0],
- REMOTE_TYPE_RGBW,
- "rgbw"
- );
- const MiLightRemoteConfig FUT091Config( //cct
- new CctPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[1],
- REMOTE_TYPE_CCT,
- "cct"
- );
- const MiLightRemoteConfig FUT092Config( //rgb+cct
- new RgbCctPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[2],
- REMOTE_TYPE_RGB_CCT,
- "rgb_cct"
- );
- const MiLightRemoteConfig FUT089Config( //rgb+cct B8 / FUT089
- new FUT089PacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[2],
- REMOTE_TYPE_FUT089,
- "fut089"
- );
- const MiLightRemoteConfig FUT098Config( //rgb
- new RgbPacketFormatter(),
- MiLightRadioConfig::ALL_CONFIGS[3],
- REMOTE_TYPE_RGB,
- "rgb"
- );
|