V6RgbCctCommandHandler.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. case V2_MODE:
  35. client->updateMode(arg-1);
  36. break;
  37. default:
  38. return false;
  39. }
  40. return true;
  41. }