Selaa lähdekoodia

RGB_CCT: handle mode, mode speed up/down in packet update handler

Chris Mullins 8 vuotta sitten
vanhempi
commit
4d94c3d71c
2 muutettua tiedostoa jossa 11 lisäystä ja 3 poistoa
  1. 10 2
      lib/MiLight/RgbCctPacketFormatter.cpp
  2. 1 1
      platformio.ini

+ 10 - 2
lib/MiLight/RgbCctPacketFormatter.cpp

@@ -124,8 +124,11 @@ void RgbCctPacketFormatter::parsePacket(const uint8_t *packet, JsonObject& resul
   uint8_t arg = packetCopy[RGB_CCT_ARGUMENT_INDEX];
 
   if (command == RGB_CCT_ON) {
-    // Group is not reliably encoded in group byte. Extract from arg byte
-    if (arg < 5) {
+    if (arg == RGB_CCT_MODE_SPEED_DOWN) {
+      result["command"] = "mode_speed_down";
+    } else if (arg == RGB_CCT_MODE_SPEED_UP) {
+      result["command"] = "mode_speed_up";
+    } else if (arg < 5) { // Group is not reliably encoded in group byte. Extract from arg byte
       result["state"] = "ON";
       result["group_id"] = arg;
     } else {
@@ -158,6 +161,11 @@ void RgbCctPacketFormatter::parsePacket(const uint8_t *packet, JsonObject& resul
     result["brightness"] = Units::rescale<uint8_t, uint8_t>(level, 255, 100);
   } else if (command == RGB_CCT_SATURATION) {
     result["saturation"] = constrain(arg - RGB_CCT_SATURATION_OFFSET, 0, 100);
+  } else if (command == RGB_CCT_MODE) {
+    result["mode"] = arg;
+  } else {
+    result["button_id"] = command;
+    result["argument"] = arg;
   }
 
   if (! result.containsKey("state")) {

+ 1 - 1
platformio.ini

@@ -18,7 +18,7 @@ lib_deps_external =
   ArduinoJson
   PubSubClient
   https://github.com/ratkins/RGBConverter
-build_flags = !python .get_version.py
+build_flags = !python .get_version.py -DMQTT_MAX_PACKET_SIZE=200
 # -D MQTT_DEBUG
 # -D MILIGHT_UDP_DEBUG
 # -D DEBUG_PRINTF