RestService.cpp
/**
 * API GET, POST call to set raw byte data directly on the controller.
 */
API GET, POST call to set raw byte data directly on the controller.
API GET POST call to set raw byte data directly on the controller .
static void _handle_raw(void){
  String message = "";
  bool set = false;
  int cmd = 0;
  if(server.method() == HTTP_POST){ 
    String raw = server.arg("raw");
    if(raw != ""){
      cmd = raw.toInt();
      if(cmd >= 0 && cmd < 256){
        set = true;
        message += "success";
      }else{
        message += "error: invalid argument type";
      }
    }else{
      message += "error: argument expected";
    }
  }else{ 
    if(server.arg("documentation") == "true"){
      message += "IR Controlled LED Strip Web Service\n\n"
          "Raw command expects POST request with a single arguement. "
          "The contents of this argument will be a byte code from "
          "table below.\n\n"
          "    Hex Value | Name\n"
          "    ----------|----------------\n"
          "    x04       | Brightness-Down\n"
          "    x05       | Brightness-Up\n"
          "    x06       | Off\n"
          "    x07       | On\n"
          "    x08       | ~Green\n"
          "    x09       | ~Red\n"
          "    x0A       | ~Blue\n"
          "    x0B       | ~White\n"
          "    x0C       | ~Pea Green\n"
          "    x0D       | ~Orange\n"
          "    x0E       | ~Dark Orchid\n"
          "    x0F       | Flash Function\n"
          "    x10       | ~Cyan\n"
          "    x11       | ~Dark Yellow\n"
          "    x12       | ~Magenta\n"
          "    x13       | Fade Function\n"
          "    x14       | ~Light Blue\n"
          "    x15       | ~Yellow\n"
          "    x16       | ~Pink\n"
          "    x17       | Strobe Function\n"
          "    x18       | ~Sky Blue\n"
          "    x19       | ~Light Yellow\n"
          "    x1A       | ~Purple\n"
          "    x1B       | Smooth Function\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"
          "Brightness adjustment is measured in ticks. To move from brightest"
          " to least will take 9 ticks.\n"
          "\n"
          "Brightness adjustment will act as expected for static colors. However "
          "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 += "raw: " + state.raw;
    }
  }
  server.send(200, "text/plain", message);
  state.uri = server.uri();
  if(set){
    led_send_value(cmd);
    state.raw = cmd;
  }
}
static void _handle_raw ( void ) { String message = " " ; bool set = false ; int cmd = 0 ; if ( server . method ( ) == HTTP_POST ) { String raw = server . arg ( " " ) ; if ( raw != " " ) { cmd = raw . toInt ( ) ; if ( cmd >= 0 && cmd < 256 ) { set = true ; message += " " ; } else { message += " " ; } } else { 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 " " \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 . raw ; } } server . send ( 200 , " " , message ) ; state . uri = server . uri ( ) ; if ( set ) { led_send_value ( cmd ) ; state . raw = cmd ; } }
API GET, POST call to set raw byte data directly on the controller.
API GET POST call to set raw byte data directly on the controller .
// transmit raw // report raw codes // Transmit over IR LED