RestService.cpp
/**
 * API GET, POST method to configure brightness on the LED controller.
 */
API GET, POST method to configure brightness on the LED controller.
API GET POST method to configure brightness on the LED controller .
static void _handle_brightness(void){
  String message = "";
  bool set = false;
  int cmd = 0;
  if(server.method() == HTTP_POST){ 
    String brightness = server.arg("brightness");
    if(brightness != ""){
      if(brightness == "up"){
        state.brightness = brightness;
        set = true;
        cmd = LED_BRIGHTNESS_UP;
      }else if(brightness == "down"){
        state.brightness = brightness;
        set = true;
        cmd = LED_BRIGHTNESS_DOWN;
      }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"
          "Brightness 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"
          "   up     | Shifts LED brightness up a step  \n"
          "   down   | Shifts LED brightness down a step\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 += "brightness: " + state.brightness;
    }
  }
  server.send(200, "text/plain", message);
  state.uri = server.uri();
  if(set){
    led_send_value(cmd);
    state.raw = cmd;
  }
}
static void _handle_brightness ( void ) { String message = " " ; bool set = false ; int cmd = 0 ; if ( server . method ( ) == HTTP_POST ) { String brightness = server . arg ( " " ) ; if ( brightness != " " ) { if ( brightness == " " ) { state . brightness = brightness ; set = true ; cmd = LED_BRIGHTNESS_UP ; } else if ( brightness == " " ) { state . brightness = brightness ; set = true ; cmd = LED_BRIGHTNESS_DOWN ; } 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 " ; } else { message += " " + state . brightness ; } } server . send ( 200 , " " , message ) ; state . uri = server . uri ( ) ; if ( set ) { led_send_value ( cmd ) ; state . raw = cmd ; } }
API GET, POST method to configure brightness on the LED controller.
API GET POST method to configure brightness on the LED controller .
// update brightness // report brightness adjust mechanism // Transmit over IR LED