Advertisement
GyroGearloose

Speed slider extension

Feb 28th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.55 KB | None | 0 0
  1. // Extension for SPEED slider
  2.  
  3. //changed FUNCTIONxxxON into F_xxx to save space in the char buffer
  4.  
  5. //in definitions:
  6.  
  7. int SPEED          =       120;
  8. int new_SPEED      =       120;
  9.  
  10.  
  11.  ///////////////////////////////////////////////////////////////////////////////
  12.  // output parameters to serial, you may connect e.g. an Arduino and react on it
  13.  ///////////////////////////////////////////////////////////////////////////////
  14.     if(sParam.length()>0)
  15.   { // output parameters
  16.     int iEqu=sParam.indexOf("=");
  17.     if(iEqu>=0)
  18.     {  // is there a message?
  19.       sCmd = sParam.substring(iEqu+1,sParam.length());
  20. //      Serial.print("We are in output Parameters, value is: ");
  21.  
  22.       int iEqu_bright=sParam.indexOf("200");
  23.       if (iEqu_bright>=0)
  24.        {
  25.         sCmd = sParam.substring(iEqu+1,sParam.length());         // BRIGHTNESS
  26.       Serial.println(sCmd);
  27.       char carray[4];                                // values 0..255 = 3 digits; array = digits + 1
  28.       sCmd.toCharArray(carray, sizeof(carray));      // convert char to the array
  29.       new_BRIGHTNESS = atoi(carray);                 // atoi() converts an ascii character array to an integer
  30.       if (new_BRIGHTNESS == 0) {new_BRIGHTNESS = BRIGHTNESS; }
  31.       BRIGHTNESS = new_BRIGHTNESS;
  32.          FastLED.setBrightness(new_BRIGHTNESS);
  33.       Serial.print("new Brightness: ");
  34.       Serial.println(new_BRIGHTNESS);
  35.     }
  36.  
  37.  // space for RGB (300, 400, 500)
  38.  
  39.        int iEqu_speed=sParam.indexOf("600=");
  40.       if (iEqu_speed>=0)
  41.        {
  42.       sCmd = sParam.substring(iEqu+1,sParam.length());           // speed
  43. //      Serial.print("We are in SPEED, value is: ");
  44.       Serial.println(sCmd);
  45.       char carray[4];                                // values 0..255 = 3 digits; array = digits + 1
  46.       sCmd.toCharArray(carray, sizeof(carray));      // convert char to the array
  47.       new_SPEED = atoi(carray);                      // atoi() converts an ascii character array to an integer
  48.       if (new_SPEED == 0) {new_SPEED = SPEED; }      // if something else is selected (no change in brightness)
  49.       SPEED = new_SPEED;                
  50.       FRAMES_PER_SECOND = SPEED;
  51. //     FastLED.setMaxRefreshRate(new_SPEED);         // thought this would work  :(
  52.  
  53.  
  54.       Serial.print("new FPS: ");
  55.       Serial.println(SPEED);
  56. //      Serial.print("refresh: ");
  57. //      Serial.println(1000/new_SPEED);
  58.  
  59.        }
  60.  
  61.     } // end is there a message?
  62.   }   // end output Parameters  
  63.  
  64.  
  65.   ///////////////////////////
  66.   // format the html response
  67.   ///////////////////////////
  68.  
  69.  
  70.  
  71. //  under brightness slider:
  72.  
  73. sResponse += "</p>";
  74. sResponse += "<form action=\"?sCmd\" >";    // ?sCmd forced the '?' at the right spot  
  75. sResponse += "<input type=\"submit\" value=\"SET\">";
  76. sResponse += "&nbsp;&nbsp <font color=yellow><b>SPEED ";  // perhaps we can show here the current value
  77. sResponse += round(new_SPEED /2);    // this is just a scale depending on the max value; round for better readability
  78. sResponse += " %";
  79. sResponse += "<BR>";
  80. sResponse += "<input style=\"width:250px; height:50px\" type=\"range\" name=\"=F_600\" id=\"cmd\" value=\"";   // '=' in front of F__200 forced the = at the right spot
  81. sResponse += SPEED;
  82. sResponse += "\" min=20 max=400 step=20 onchange=\"showValue(points)\" />";
  83. sResponse += "</font></b>";
  84. sResponse += "</form>";
  85. sResponse += "<p>";
  86. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  87.  
  88.       if(sCmd.indexOf("F_200=250")>=0) { }
  89. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  90. //under F200_values
  91.       if(sCmd.indexOf("F_600=20")>=0)  {  }  
  92.       if(sCmd.indexOf("F_600=40")>=0)  {  }
  93.       if(sCmd.indexOf("F_600=60")>=0)  {  }
  94.       if(sCmd.indexOf("F_600=80")>=0)  {  }
  95.       if(sCmd.indexOf("F_600=100")>=0) {  }
  96.       if(sCmd.indexOf("F_600=120")>=0) {  }
  97.       if(sCmd.indexOf("F_600=140")>=0) {  }
  98.       if(sCmd.indexOf("F_600=160")>=0) {  }
  99.       if(sCmd.indexOf("F_600=180")>=0) {  }
  100.       if(sCmd.indexOf("F_600=200")>=0) {  }
  101.       if(sCmd.indexOf("F_600=220")>=0) {  }
  102.       if(sCmd.indexOf("F_600=240")>=0) {  }
  103.       if(sCmd.indexOf("F_600=260")>=0) {  }
  104.       if(sCmd.indexOf("F_600=280")>=0) {  }
  105.       if(sCmd.indexOf("F_600=300")>=0) {  }
  106.       if(sCmd.indexOf("F_600=320")>=0) {  }
  107.       if(sCmd.indexOf("F_600=340")>=0) {  }
  108.       if(sCmd.indexOf("F_600=360")>=0) {  }
  109.       if(sCmd.indexOf("F_600=380")>=0) {  }
  110.       if(sCmd.indexOf("F_600=400")>=0) {  }
  111.  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement