Hi guys,
How can I interpret incoming data from a
BLYNK_WRITE(V1)
{
value = param.asInt();
}
Can I only have these?
param.asInt();
param.asFloat();
param.asDouble();
param.asStr();
or can I have for examples param.asBool();??
Hi guys,
How can I interpret incoming data from a
BLYNK_WRITE(V1)
{
value = param.asInt();
}
Can I only have these?
param.asInt();
param.asFloat();
param.asDouble();
param.asStr();
or can I have for examples param.asBool();??
You can also get the RAW data from the param buffer:
param.getBuffer()
param.getLength()
Don’t need that as this will do the same thing…
BLYNK_WRITE(V0){ // Button Widget with set range of 0-1
if (param.asInt()) {
Blynk.virtualWrite(V1, "TRUE");} // Display Widget output if param 1
else {
Blynk.virtualWrite(V1, "FALSE");} // Display Widget output if param 0
}
Thank you.
Can you please explain what’s the purpose of getting RAW data?
I open this post because I am trying to reduce the memory used by global variables.
If I declare a global variable as follow
bool value = FALSE;
and then call
BLYNK_WRITE(V1)
{
value = param.asInt();
}
value will occupy memory as integer or boolean?
As a boolean since you declared it as such.
1 will evaluate to true, 0 to false.
To do this could use #define instead of variables
You write code like this
#define SomeVariable 5
void someFunc()
{
Serial.println(SomeVariable);
}
Then when you hit compile, the ide will replace all occurrences of the text ‘SomeVariable’ with the actual value, thereby reducing variable memory usage. So the code sent to your mcu will actually look like this
void someFunc()
{
Serial.println(5);
}
It simply does a search and replace
Thank you very much I have reduced the sketch size by 15%