Quellcode durchsuchen

more generic radio

Chris Mullins vor 8 Jahren
Ursprung
Commit
c19e0cd39a

+ 35 - 0
lib/MiLight/MiLightButtons.h

@@ -0,0 +1,35 @@
+#ifndef _MILIGHT_BUTTONS
+#define _MILIGHT_BUTTONS 
+
+enum MiLightRgbwButton {
+  RGBW_ALL_ON            = 0x01,
+  RGBW_ALL_OFF           = 0x02,
+  RGBW_GROUP_1_ON        = 0x03,
+  RGBW_GROUP_1_OFF       = 0x04,
+  RGBW_GROUP_2_ON        = 0x05,
+  RGBW_GROUP_2_OFF       = 0x06,
+  RGBW_GROUP_3_ON        = 0x07,
+  RGBW_GROUP_3_OFF       = 0x08,
+  RGBW_GROUP_4_ON        = 0x09,
+  RGBW_GROUP_4_OFF       = 0x0A,
+  RGBW_SPEED_UP          = 0x0B, 
+  RGBW_SPEED_DOWN        = 0x0C, 
+  RGBW_DISCO_MODE        = 0x0D,
+  RGBW_BRIGHTNESS        = 0x0E,
+  RGBW_COLOR             = 0x0F,
+  RGBW_ALL_MAX_LEVEL     = 0x11,
+  RGBW_ALL_MIN_LEVEL     = 0x12,
+  
+  // These are the only mechanism (that I know of) to disable RGB and set the
+  // color to white.
+  RGBW_GROUP_1_MAX_LEVEL = 0x13,
+  RGBW_GROUP_1_MIN_LEVEL = 0x14,
+  RGBW_GROUP_2_MAX_LEVEL = 0x15,
+  RGBW_GROUP_2_MIN_LEVEL = 0x16,
+  RGBW_GROUP_3_MAX_LEVEL = 0x17,
+  RGBW_GROUP_3_MIN_LEVEL = 0x18,
+  RGBW_GROUP_4_MAX_LEVEL = 0x19,
+  RGBW_GROUP_4_MIN_LEVEL = 0x1A,
+};
+
+#endif

+ 73 - 40
lib/MiLight/MiLightClient.cpp

@@ -1,16 +1,29 @@
 #include <MiLightClient.h>
 
+MiLightRadio* MiLightClient::getRadio(const MiLightRadioType type) {
+  MiLightRadio* radio = NULL;
+  
+  if (type == RGBW) {
+    return rgbwRadio->getRadio();
+  } else if (type == CCT) {
+    return cctRadio->getRadio();
+  } 
+  
+  if (radio != NULL) {
+    radio->configure();
+  }
+  
+  return radio;
+}
+
 void MiLightClient::deserializePacket(const uint8_t rawPacket[], MiLightPacket& packet) {
   uint8_t ptr = 0;
   
   packet.deviceType = rawPacket[ptr++];
   packet.deviceId = (rawPacket[ptr++] << 8) | rawPacket[ptr++];
-  packet.color = rawPacket[ptr++];
-  
-  packet.brightness = rawPacket[ptr] >> 3;
-  packet.groupId = rawPacket[ptr++] & 0x07;
-  
-  packet.button = rawPacket[ptr++];
+  packet.b1 = rawPacket[ptr++];
+  packet.b2 = rawPacket[ptr++];
+  packet.b3 = rawPacket[ptr++];
   packet.sequenceNum = rawPacket[ptr++];
 }
 
@@ -23,9 +36,9 @@ void MiLightClient::serializePacket(uint8_t rawPacket[], const MiLightPacket& pa
   rawPacket[ptr++] = packet.deviceId >> 8;
   rawPacket[ptr++] = packet.deviceId & 0xFF;
   
-  rawPacket[ptr++] = packet.color;
-  rawPacket[ptr++] = (packet.brightness << 3) | (packet.groupId & 0x07);
-  rawPacket[ptr++] = packet.button;
+  rawPacket[ptr++] = packet.b1;
+  rawPacket[ptr++] = packet.b2;
+  rawPacket[ptr++] = packet.b3;
   rawPacket[ptr++] = packet.sequenceNum;
 }
 
@@ -33,20 +46,41 @@ uint8_t MiLightClient::nextSequenceNum() {
   return sequenceNum++;
 }
 
-bool MiLightClient::available() {
+bool MiLightClient::available(const MiLightRadioType radioType) {
+  MiLightRadio* radio = getRadio(radioType);
+  radio->begin();
+  
+  if (radio == NULL) {
+    return false;
+  }
+  
   return radio->available();
 }
 
-void MiLightClient::read(MiLightPacket& packet) {
+void MiLightClient::read(const MiLightRadioType radioType, MiLightPacket& packet) {
+  MiLightRadio* radio = getRadio(radioType);
+  
+  if (radio == NULL) {
+    return;
+  }
+  
   uint8_t packetBytes[MILIGHT_PACKET_LENGTH];
   size_t length;
   radio->read(packetBytes, length);
   deserializePacket(packetBytes, packet);
 }
 
-void MiLightClient::write(MiLightPacket& packet, const unsigned int resendCount) {
+void MiLightClient::write(const MiLightRadioType radioType, 
+  MiLightPacket& packet, 
+  const unsigned int resendCount) {
+    
   uint8_t packetBytes[MILIGHT_PACKET_LENGTH];
   serializePacket(packetBytes, packet);
+  MiLightRadio* radio = getRadio(radioType);
+  
+  if (radio == NULL) {
+    return;
+  }
   
   for (int i = 0; i < resendCount; i++) {
     radio->write(packetBytes, MILIGHT_PACKET_LENGTH);
@@ -54,36 +88,26 @@ void MiLightClient::write(MiLightPacket& packet, const unsigned int resendCount)
 }
 
 
-void MiLightClient::write(
+void MiLightClient::writeRgbw(
   const uint16_t deviceId,
   const uint8_t color,
   const uint8_t brightness,
   const uint8_t groupId,
-  const MiLightButton button) {
-    
-  // Expect an input value in [0, 100]. Map it down to [0, 25].
-  const uint8_t adjustedBrightness = round(brightness * (25 / 100.0));
-  
-  // The actual protocol uses a bizarre range where min is 16, max is 23:
-  // [16, 15, ..., 0, 31, ..., 23]
-  const uint8_t packetBrightnessValue = (
-    ((31 - adjustedBrightness) + 17) % 32
-  );
+  const uint8_t button) {
   
   MiLightPacket packet;
-  packet.deviceType = MiLightDeviceType::RGBW;
+  packet.deviceType = RGBW;;
   packet.deviceId = deviceId;
-  packet.color = color;
-  packet.brightness = packetBrightnessValue;
-  packet.groupId = groupId;
-  packet.button = button;
+  packet.b1 = color;
+  packet.b2 = (brightness << 3) | (groupId & 0x07);
+  packet.b3 = button;
   packet.sequenceNum = nextSequenceNum();
   
-  write(packet);
+  write(RGBW, packet);
 }
     
 void MiLightClient::updateColorRaw(const uint16_t deviceId, const uint8_t groupId, const uint16_t color) {
-  write(deviceId, color, 0, groupId, COLOR);
+  writeRgbw(deviceId, color, 0, groupId, RGBW_COLOR);
 }
 
 void MiLightClient::updateHue(const uint16_t deviceId, const uint8_t groupId, const uint16_t hue) {
@@ -92,21 +116,30 @@ void MiLightClient::updateHue(const uint16_t deviceId, const uint8_t groupId, co
   const int16_t remappedColor = (hue + 40) % 360;
   const uint8_t adjustedColor = round(remappedColor * (255 / 360.0));
   
-  write(deviceId, adjustedColor, 0, groupId, COLOR);
+  writeRgbw(deviceId, adjustedColor, 0, groupId, RGBW_COLOR);
 }
 
 void MiLightClient::updateBrightness(const uint16_t deviceId, const uint8_t groupId, const uint8_t brightness) {
-  write(deviceId, 0, brightness, groupId, BRIGHTNESS);
+  // Expect an input value in [0, 100]. Map it down to [0, 25].
+  const uint8_t adjustedBrightness = round(brightness * (25 / 100.0));
+  
+  // The actual protocol uses a bizarre range where min is 16, max is 23:
+  // [16, 15, ..., 0, 31, ..., 23]
+  const uint8_t packetBrightnessValue = (
+    ((31 - adjustedBrightness) + 17) % 32
+  );
+  
+  writeRgbw(deviceId, 0, packetBrightnessValue, groupId, RGBW_BRIGHTNESS);
 }
 
 void MiLightClient::updateStatus(const uint16_t deviceId, const uint8_t groupId, MiLightStatus status) {
-  uint8_t button = MiLightButton::GROUP_1_ON + ((groupId - 1)*2) + status;
-  write(deviceId, 0, 0, groupId, static_cast<MiLightButton>(button));
+  uint8_t button = RGBW_GROUP_1_ON + ((groupId - 1)*2) + status;
+  writeRgbw(deviceId, 0, 0, groupId, button);
 }
 
 void MiLightClient::updateColorWhite(const uint16_t deviceId, const uint8_t groupId) {
-  uint8_t button = MiLightButton::GROUP_1_MAX_LEVEL + ((groupId - 1)*2);
-  pressButton(deviceId, groupId, static_cast<MiLightButton>(button));
+  uint8_t button = RGBW_GROUP_1_MAX_LEVEL + ((groupId - 1)*2);
+  pressButton(deviceId, groupId, button);
 }
 
 void MiLightClient::pair(const uint16_t deviceId, const uint8_t groupId) {
@@ -119,14 +152,14 @@ void MiLightClient::unpair(const uint16_t deviceId, const uint8_t groupId) {
   updateColorWhite(deviceId, groupId);
 }
     
-void MiLightClient::pressButton(const uint16_t deviceId, const uint8_t groupId, MiLightButton button) {
-  write(deviceId, 0, 0, groupId, button);
+void MiLightClient::pressButton(const uint16_t deviceId, const uint8_t groupId, const uint8_t button) {
+  writeRgbw(deviceId, 0, 0, groupId, button);
 }
 
 void MiLightClient::allOn(const uint16_t deviceId) {
-  write(deviceId, 0, 0, 0, ALL_ON);
+  writeRgbw(deviceId, 0, 0, 0, RGBW_ALL_ON);
 }
 
 void MiLightClient::allOff(const uint16_t deviceId) {
-  write(deviceId, 0, 0, 0, ALL_OFF);
+  writeRgbw(deviceId, 0, 0, 0, RGBW_ALL_OFF);
 }

+ 59 - 63
lib/MiLight/MiLightClient.h

@@ -2,46 +2,16 @@
 #include <MiLightRadio.h>
 #include <PL1167_nRF24.h>
 #include <RF24.h>
+#include <MiLightButtons.h>
 
 #ifndef _MILIGHTCLIENT_H
 #define _MILIGHTCLIENT_H
 
 #define MILIGHT_PACKET_LENGTH 7
 
-enum MiLightDeviceType {
-  WHITE = 0xB0,
-  RGBW = 0xB8
-};
-
-enum MiLightButton {
-  ALL_ON            = 0x01,
-  ALL_OFF           = 0x02,
-  GROUP_1_ON        = 0x03,
-  GROUP_1_OFF       = 0x04,
-  GROUP_2_ON        = 0x05,
-  GROUP_2_OFF       = 0x06,
-  GROUP_3_ON        = 0x07,
-  GROUP_3_OFF       = 0x08,
-  GROUP_4_ON        = 0x09,
-  GROUP_4_OFF       = 0x0A,
-  SPEED_UP          = 0x0B, 
-  SPEED_DOWN        = 0x0C, 
-  DISCO_MODE        = 0x0D,
-  BRIGHTNESS        = 0x0E,
-  COLOR             = 0x0F,
-  ALL_MAX_LEVEL     = 0x11,
-  ALL_MIN_LEVEL     = 0x12,
-  
-  // These are the only mechanism (that I know of) to disable RGB and set the
-  // color to white.
-  GROUP_1_MAX_LEVEL = 0x13,
-  GROUP_1_MIN_LEVEL = 0x14,
-  GROUP_2_MAX_LEVEL = 0x15,
-  GROUP_2_MIN_LEVEL = 0x16,
-  GROUP_3_MAX_LEVEL = 0x17,
-  GROUP_3_MIN_LEVEL = 0x18,
-  GROUP_4_MAX_LEVEL = 0x19,
-  GROUP_4_MIN_LEVEL = 0x1A,
+enum MiLightRadioType {
+  RGBW  = 0xB8,
+  CCT   = 0x5A
 };
 
 enum MiLightStatus { ON = 0, OFF = 1 };
@@ -49,67 +19,93 @@ enum MiLightStatus { ON = 0, OFF = 1 };
 struct MiLightPacket {
   uint8_t deviceType;
   uint16_t deviceId;
-  uint8_t color;
-  uint8_t brightness;
-  uint8_t groupId;
-  uint8_t button;
+  uint8_t b1;
+  uint8_t b2;
+  uint8_t b3;
   uint8_t sequenceNum;
 };
 
+class MiLightRadioStack {
+public:
+  MiLightRadioStack(RF24& rf, const MiLightRadioConfig& config) {
+    nrf = new PL1167_nRF24(rf);
+    radio = new MiLightRadio(*nrf, config);
+  }
+  
+  ~MiLightRadioStack() {
+    delete radio;
+    delete nrf;
+  }
+  
+  inline MiLightRadio* getRadio() {
+    return this->radio;
+  }
+  
+private:
+  PL1167_nRF24 *nrf;
+  MiLightRadio *radio;
+};
+
 class MiLightClient {
   public:
-    MiLightClient(uint8_t cePin, uint8_t csnPin, MiLightRadioConfig& config) :
-      sequenceNum(0) {
-      rf = new RF24(cePin, csnPin);
-      prf = new PL1167_nRF24(*rf);
-      radio = new MiLightRadio(*prf, config);
+    MiLightClient(uint8_t cePin, uint8_t csnPin)
+    : sequenceNum(0),
+      rf(RF24(cePin, csnPin))
+    {
+      rgbwRadio = new MiLightRadioStack(rf, MilightRgbwConfig);
+      cctRadio = new MiLightRadioStack(rf, MilightCctConfig);
     }
     
     ~MiLightClient() {
-      delete rf;
-      delete prf;
-      delete radio;
+      delete rgbwRadio;
+      delete cctRadio;
     }
     
     void begin() {
-      radio->begin();
+      rgbwRadio->getRadio()->begin();
+      cctRadio->getRadio()->begin();
     }
     
-    bool available();
-    void read(MiLightPacket& packet);
-    void write(MiLightPacket& packet, const unsigned int resendCount = 50);
+    bool available(const MiLightRadioType radioType);
+    void read(const MiLightRadioType radioType, MiLightPacket& packet);
+    void write(const MiLightRadioType radioType, MiLightPacket& packet, const unsigned int resendCount = 50);
     
-    void write(
+    void writeRgbw(
       const uint16_t deviceId,
       const uint8_t color,
       const uint8_t brightness,
       const uint8_t groupId,
-      const MiLightButton button
+      const uint8_t button
     );
     
-    void updateColorRaw(const uint16_t deviceId, const uint8_t groupId, const uint16_t color);
-    
-    void updateHue(const uint16_t deviceId, const uint8_t groupId, const uint16_t hue);
-    void updateBrightness(const uint16_t deviceId, const uint8_t groupId, const uint8_t brightness);
+    // Common methods
     void updateStatus(const uint16_t deviceId, const uint8_t groupId, MiLightStatus status);
-    void updateColorWhite(const uint16_t deviceId, const uint8_t groupId);
     void pair(const uint16_t deviceId, const uint8_t groupId);
     void unpair(const uint16_t deviceId, const uint8_t groupId);
-    
     void allOn(const uint16_t deviceId);
     void allOff(const uint16_t deviceId);
+    void pressButton(const uint16_t deviceId, const uint8_t groupId, uint8_t button);
     
-    void pressButton(const uint16_t deviceId, const uint8_t groupId, MiLightButton button);
+    // RGBW methods
+    void updateHue(const uint16_t deviceId, const uint8_t groupId, const uint16_t hue);
+    void updateBrightness(const uint16_t deviceId, const uint8_t groupId, const uint8_t brightness);
+    void updateColorWhite(const uint16_t deviceId, const uint8_t groupId);
+    void updateColorRaw(const uint16_t deviceId, const uint8_t groupId, const uint16_t color);
+
+    // CCT methods
+    void updateColorTemperature(const uint8_t colorTemperature);
+    
+    MiLightRadio* getRadio(const MiLightRadioType type);
     
     static void deserializePacket(const uint8_t rawPacket[], MiLightPacket& packet);
     static void serializePacket(uint8_t rawPacket[], const MiLightPacket& packet);
     
   private:
-    RF24 *rf;
-    PL1167_nRF24 *prf;
-    MiLightRadio* radio;
-    uint8_t sequenceNum;
+    RF24 rf;
+    MiLightRadioStack* rgbwRadio;
+    MiLightRadioStack* cctRadio;
     
+    uint8_t sequenceNum;
     uint8_t nextSequenceNum();
 };
 

+ 18 - 10
lib/MiLight/MiLightRadio.cpp

@@ -9,7 +9,7 @@
 
 #define PACKET_ID(packet) ( ((packet[1] & 0xF0)<<24) | (packet[2]<<16) | (packet[3]<<8) | (packet[7]) )
 
-MiLightRadio::MiLightRadio(AbstractPL1167 &pl1167, MiLightRadioConfig& config)
+MiLightRadio::MiLightRadio(AbstractPL1167 &pl1167, const MiLightRadioConfig& config)
   : _pl1167(pl1167), config(config) {
   _waiting = false;
 }
@@ -20,8 +20,19 @@ int MiLightRadio::begin()
   if (retval < 0) {
     return retval;
   }
+  
+  retval = configure();
+  if (retval < 0) {
+    return retval;
+  }
 
-  retval = _pl1167.setCRC(true);
+  available();
+
+  return 0;
+}
+
+int MiLightRadio::configure() {
+  int retval = _pl1167.setCRC(true);
   if (retval < 0) {
     return retval;
   }
@@ -36,8 +47,6 @@ int MiLightRadio::begin()
     return retval;
   }
 
-  // retval = _pl1167.setSyncword(0x147A, 0x258B);
-  // retval = _pl1167.setSyncword(0x050A, 0x55AA);
   retval = _pl1167.setSyncword(config.syncword0, config.syncword3);
   if (retval < 0) {
     return retval;
@@ -47,29 +56,26 @@ int MiLightRadio::begin()
   if (retval < 0) {
     return retval;
   }
-
-  available();
-
+  
   return 0;
 }
 
 bool MiLightRadio::available()
 {
+  configure();
+  
   if (_waiting) {
     return true;
   }
   
   if (_pl1167.receive(config.channels[0]) > 0) {
-  Serial.println(1);
     size_t packet_length = sizeof(_packet);
     if (_pl1167.readFIFO(_packet, packet_length) < 0) {
       return false;
     }
-  Serial.println(2);
     if (packet_length == 0 || packet_length != _packet[0] + 1U) {
       return false;
     }
-  Serial.println(3);
 
     uint32_t packet_id = PACKET_ID(_packet);
     if (packet_id == _prev_packet_id) {
@@ -115,6 +121,8 @@ int MiLightRadio::write(uint8_t frame[], size_t frame_length)
   if (frame_length > sizeof(_out_packet) - 1) {
     return -1;
   }
+  
+  configure();
 
   memcpy(_out_packet + 1, frame, frame_length);
   _out_packet[0] = frame_length;

+ 2 - 1
lib/MiLight/MiLightRadio.h

@@ -21,7 +21,7 @@
 
 class MiLightRadio {
   public:
-    MiLightRadio(AbstractPL1167 &pl1167, MiLightRadioConfig& config);
+    MiLightRadio(AbstractPL1167 &pl1167, const MiLightRadioConfig& config);
     
     int begin();
     bool available();
@@ -29,6 +29,7 @@ class MiLightRadio {
     int dupesReceived();
     int write(uint8_t frame[], size_t frame_length);
     int resend();
+    int configure();
   private:
     AbstractPL1167 &_pl1167;
     const MiLightRadioConfig& config;

+ 5 - 5
lib/MiLight/MiLightUdpServer.cpp

@@ -61,15 +61,15 @@ void MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
         break;
         
       case UDP_DISCO_MODE:
-        pressButton(this->lastGroup, DISCO_MODE);
+        pressButton(this->lastGroup, RGBW_DISCO_MODE);
         break;
         
       case UDP_SPEED_DOWN:
-        pressButton(this->lastGroup, SPEED_DOWN);
+        pressButton(this->lastGroup, RGBW_SPEED_DOWN);
         break;
         
       case UDP_SPEED_UP:
-        pressButton(this->lastGroup, SPEED_UP);
+        pressButton(this->lastGroup, RGBW_SPEED_UP);
         break;
         
       case UDP_BRIGHTNESS:
@@ -88,6 +88,6 @@ void MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
   }
 }
 
-void MiLightUdpServer::pressButton(uint8_t group, MiLightButton button) {
-  client->write(deviceId, 0, 0, group, button);
+void MiLightUdpServer::pressButton(uint8_t group, uint8_t button) {
+  client->writeRgbw(deviceId, 0, 0, group, button);
 }  

+ 1 - 1
lib/MiLight/MiLightUdpServer.h

@@ -54,7 +54,7 @@ protected:
   char packetBuffer[MILIGHT_PACKET_BUFFER_SIZE];
   
   void handleCommand(uint8_t command, uint8_t commandArg);
-  void pressButton(uint8_t group, MiLightButton button);
+  void pressButton(uint8_t group, uint8_t button);
 };
 
 #endif

+ 9 - 6
platformio.ini

@@ -8,13 +8,16 @@
 ; Please visit documentation for the other options and examples
 ; http://docs.platformio.org/page/projectconf.html
 
-[env:nodemcuv2]
-platform = espressif8266
-board = nodemcuv2
-framework = arduino
-lib_deps = 
-  RF24
+[common]
+lib_deps_builtin = 
   SPI
+lib_deps_external = 
+  RF24
   WiFiManager
   ArduinoJson
   Vector
+
+[env:nodemcuv2]
+platform = espressif8266
+board = nodemcuv2
+framework = arduino

+ 17 - 9
src/main.cpp

@@ -86,26 +86,34 @@ void handleUpdateGroup(const UrlTokenBindings* urlBindings) {
 }
 
 void handleListenGateway() {
-  while (!milightClient->available()) {
+  uint8_t readType = 0;
+  
+  while (readType == 0) {
     if (!server->clientConnected()) {
       return;
     }
     
+    if (milightClient->available(RGBW)) {
+      readType = RGBW;
+    } else if (milightClient->available(CCT)) {
+      readType = CCT;
+    }
+    
     yield();
   }
   
   MiLightPacket packet;
-  milightClient->read(packet);
+  milightClient->read(static_cast<MiLightRadioType>(readType), packet);
   
   String response = "Packet received (";
   response += String(sizeof(packet)) + " bytes)";
   response += ":\n";
+  response += "Type         : " + String(readType) + "\n";
   response += "Request type : " + String(packet.deviceType, HEX) + "\n";
   response += "Device ID    : " + String(packet.deviceId, HEX) + "\n";
-  response += "Color        : " + String(packet.color, HEX) + "\n";
-  response += "Brightness   : " + String(packet.brightness, HEX) + "\n";
-  response += "Group ID     : " + String(packet.groupId, HEX) + "\n";
-  response += "Button       : " + String(packet.button, HEX) + "\n";
+  response += "B1           : " + String(packet.b1, HEX) + "\n";
+  response += "B2           : " + String(packet.b2, HEX) + "\n";
+  response += "B3           : " + String(packet.b3, HEX) + "\n";
   response += "Sequence Num : " + String(packet.sequenceNum, HEX) + "\n";
   response += "\n\n";
   
@@ -186,7 +194,7 @@ void initMilightUdpServers() {
   }
 }
 
-void initMilightClients() {
+void initMilightClient() {
   if (milightClient) {
     delete milightClient;
   }
@@ -203,7 +211,7 @@ void handleUpdateSettings() {
   if (parsedSettings.success()) {
     settings.patch(parsedSettings);
     settings.save();
-    initMilightClients();
+    initMilightClient();
     initMilightUdpServers();
     
     if (server->authenticationRequired() && !settings.hasAuthSettings()) {
@@ -223,7 +231,7 @@ void setup() {
   wifiManager.autoConnect();
   SPIFFS.begin();
   Settings::load(settings);
-  initMilightClients();
+  initMilightClient();
   initMilightUdpServers();
   
   server->on("/", HTTP_GET, handleServeFile(WEB_INDEX_FILENAME, "text/html"));

+ 1 - 1
web/index.html

@@ -100,7 +100,7 @@
     
     var updateGroup = _.throttle(
       function(params) {
-        params.mode = currentMode();
+        params.mode = getCurrentMode();
         
         $.ajax(
           activeUrl(),