RestService.cpp
/**
 * API GET, POST method to set controller into a special function mode.
 */
API GET, POST method to set controller into a special function mode.
API GET POST method to set controller into a special function mode .
static void _handle_functions(void){
  String message = "";
  bool set = false;
  int cmd = 0;
  if(server.method() == HTTP_POST){ 
    String function = server.arg("function");
    if(function != ""){
      if(function == "flash"){
        state.function = function;
        set = true;
        cmd = LED_FLASH_CMD;
      }else if(function == "strobe"){
        state.function = function;
        set = true;
        cmd = LED_STROBE_CMD;
      }else if(function == "fade"){
        state.function = function;
        set = true;
        cmd = LED_FADE_CMD;
      }else if(function == "smooth"){
        state.function = function;
        set = true;
        cmd = LED_SMOOTH_CMD;
      }else{
        message += "error: argument does not match expected";
      }
    }else{
      message += "error: argument expected";
    }
    if(set){
      message += "success";
    }
  }else{ 
    if(server.arg("documentation") == "true"){
      message += "IR Controlled LED Strip Web Service\n\n"
          "Function command expects POST request with a single arguement. "
          "The contents of this argument will be a string enumeration from "
          "table below.\n\n"
          "   String | Behavior\n"
          "   -------|--------------------------------------------\n"
          "   flash  | Flash a subset of preselected colors (Note)\n"
          "   strobe | Strobe last static color selected (Note)   \n"
          "   fade   | Fade last static color selected (Note)     \n"
          "   smooth | Smooth last static color selected (Note)   \n"
          "\n"
          "Special functions have a unique property depending if one send the"
          " command after it is already in the selected mode. The following lists"
          " describes this behavior.\n"
          "  - Pressing Flash once does same action as smooth\n"
          "  - Pressing Flash twice strobes between color transitions of flash 1.\n"
          "  - Pressing Strobe once strobes currently displayed color\n"
          "  - Pressing Strobe twice smoothly changes brightness of static color.\n"
          "  - Pressing fade once fades between all colors\n"
          "  - Pressing fade twice fades only an rgb single cycling them.\n"
          "  - Pressing smooth once transitions between all colors abruptly.\n"
          "  - Pressing smooth twice flashes only an rgb single cycling them.\n"
          "\n"
          "When running a special function the brightness adjustment will alter"
          "the transition speed of the current function.\n"
          "  - During Flash increases/decreases transition speed (9 ticks)\n"
          "  - During Strobe increases/decreases transition speed (9 ticks)\n"
          "  - During Fade increases/decreases transition speed (9 ticks)\n"
          "  - During Smooth increases/decreases transition speed (9 ticks)\n";
    }else{
      message += "function: " + state.function;
    }
  }
  server.send(200, "text/plain", message);
  state.uri = server.uri();
  if(set){
    led_send_value(cmd);
    state.raw = cmd;
  }
}
static void _handle_functions ( void ) { String message = " " ; bool set = false ; int cmd = 0 ; if ( server . method ( ) == HTTP_POST ) { String function = server . arg ( " " ) ; if ( function != " " ) { if ( function == " " ) { state . function = function ; set = true ; cmd = LED_FLASH_CMD ; } else if ( function == " " ) { state . function = function ; set = true ; cmd = LED_STROBE_CMD ; } else if ( function == " " ) { state . function = function ; set = true ; cmd = LED_FADE_CMD ; } else if ( function == " " ) { state . function = function ; set = true ; cmd = LED_SMOOTH_CMD ; } else { message += " " ; } } else { message += " " ; } if ( set ) { message += " " ; } } else { if ( server . arg ( " " ) == " " ) { message += " \n \n " " " " " " \n \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " " " " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " " " \n " " \n " " \n " " \n " " \n " ; } else { message += " " + state . function ; } } server . send ( 200 , " " , message ) ; state . uri = server . uri ( ) ; if ( set ) { led_send_value ( cmd ) ; state . raw = cmd ; } }
API GET, POST method to set controller into a special function mode.
API GET POST method to set controller into a special function mode .
// update function state // report function information // Transmit over IR LED