V6RgbCctCommandHandler.cpp 978 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <V6RgbCctCommandHandler.h>
  2. bool V6RgbCctCommandHandler::handleCommand(
  3. MiLightClient* client,
  4. uint16_t deviceId,
  5. uint8_t group,
  6. uint32_t command,
  7. uint32_t commandArg)
  8. {
  9. const uint8_t cmd = command & 0xFF;
  10. const uint8_t arg = commandArg >> 24;
  11. client->prepare(MilightRgbCctConfig, deviceId, group);
  12. switch (cmd) {
  13. case V2_STATUS:
  14. if (arg == 0x01) {
  15. client->updateStatus(ON);
  16. } else if (arg == 0x02) {
  17. client->updateStatus(OFF);
  18. } else if (arg == 0x05) {
  19. client->updateBrightness(0);
  20. }
  21. break;
  22. case V2_COLOR:
  23. client->updateColorRaw(arg);
  24. break;
  25. case V2_KELVIN:
  26. client->updateTemperature(arg);
  27. break;
  28. case V2_BRIGHTNESS:
  29. client->updateBrightness(arg);
  30. break;
  31. case V2_SATURATION:
  32. client->updateSaturation(100 - arg);
  33. break;
  34. default:
  35. return false;
  36. }
  37. return true;
  38. }