Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text value display
#6
Hi, 
you don't need to convert you integer or float values to Strings.

You have add code only here, it is very simple:

Code:
String text1="";  //Declare some variable for the text.  On Virtuino use the pin V32
String text2="";  // V33
String text3="";  // V34

//============================================================== onCommandReceived
//==============================================================
/* This function is called every time Virtuino app sends a request to server to change a Pin value
* The 'variableType' can be a character like V, T, O  V=Virtual pin  T=Text Pin    O=PWM Pin
* The 'variableIndex' is the pin number index of Virtuino app
* The 'valueAsText' is the value that has sent from the app   */
void onReceived(char variableType, uint8_t variableIndex, String valueAsText){     
    if (variableType=='V'){
        float value = valueAsText.toFloat();        // convert the value to float. The valueAsText have to be numerical
        if (variableIndex<V_memory_count) V[variableIndex]=value;              // copy the received value to arduino V memory array
        else if (variableIndex==32) text1=valueAsText;  // V32 -> Text
        else if (variableIndex==33) text2=valueAsText;  // V33 -> Text
        // else if (variableIndex==34) text3=valueAsText; // V34 ->Text
    }
     
    }
}

//==============================================================
/* This function is called every time Virtuino app requests to read a pin value*/
String onRequested(char variableType, uint8_t variableIndex){     
    if (variableType=='V') {
    if (variableIndex<V_memory_count) return  String(V[variableIndex]);   // return the value of the arduino V memory array
    else if (variableIndex==32) return text1;  // V32 -> Text
        else if (variableIndex==33) return text2;  // V33 -> Text
        // else if (variableIndex==34) return text3; // V34 ->Text
  }
   
  return "";
}
Reply


Messages In This Thread
Text value display - by Ulbi79 - 07-07-2022, 07:43 AM
RE: Text value display - by iliaslamprou - 07-11-2022, 10:40 PM
RE: Text value display - by Ulbi79 - 07-12-2022, 12:51 PM
RE: Text value display - by iliaslamprou - 07-13-2022, 12:29 AM
RE: Text value display - by Ulbi79 - 07-13-2022, 05:16 PM
RE: Text value display - by iliaslamprou - 07-13-2022, 11:55 PM
RE: Text value display - by Ulbi79 - 07-14-2022, 06:54 AM
RE: Text value display - by iliaslamprou - 07-14-2022, 09:04 PM
RE: Text value display - by Ulbi79 - 07-15-2022, 07:44 AM
RE: Text value display - by iliaslamprou - 07-15-2022, 07:41 PM
RE: Text value display - by krzycho - 12-28-2022, 01:21 PM
RE: Text value display - by iliaslamprou - 12-29-2022, 09:25 PM
RE: Text value display - by krzycho - 12-30-2022, 10:06 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)