Digital pin widget

Even works with API…

http://10.10.3.13:8080/5fb55413762b400cbb979111b630b9af/update/V128?value=hia

image

1 Like

Device selector reduces repeated widgets.

1 Like

My bad. I was looking at BLYNK_WRITE(pin) where pin <= 127. I don’t see a restriction with Blynk.virtualWrite. It seems to pass whatever value you specify. If the server accepts values greater than 127, you should be good.

    template <typename... Args>
    void virtualWrite(int pin, Args... values) {
        char mem[BLYNK_MAX_SENDBYTES];
        BlynkParam cmd(mem, 0, sizeof(mem));
        cmd.add("vw");
        cmd.add(pin);
        cmd.add_multi(values...);
        static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE, 0, cmd.getBuffer(), cmd.getLength()-1);
    }
1 Like

What are you trying to do? Receive a value on the device from the server using the BLYNK_WRITE macro (which involves one and only one parameter … pin)? Or send a value from the device to the server?

to write a value to label widget on v128

Blynk.virtualWrite(128, "nok");

Right?

2 Likes

ooopss, I’m tired :smile:

It works with iOS.

yes and it works well with android now !
thank you so much !
tomorow I will use 128 pins more :smile:
maybe we need 512 ? :thinking:

1 Like

It just won’t work in the other direction. For example, you can assign a Text Input widget to V128, but don’t expect BLYNK_WRITE(128) to be invoked. And don’t specify a Refresh Interval of anything other than PUSH. BLYNK_READ(128) won’t work either.

How are you using 128 virtual pins? Are you associating groups of pins with devices? Are all of the virtual pins tied to widgets?

1 Like

All the virtual pins tied to widgets .
I use two devices and bridge widgets.

I wonder if there’s a reason they haven’t extended BLYNK_READ and BLYNK_WRITE? It seems odd that you can assign pins 128 - 255 to widgets in the Blynk app, but BLYNK_READ and BLYNK_WRITE don’t accept pins 128 - 255. Maybe I’m looking at the wrong library. I’m looking at the master branch,

We could always extend BLYNK_READ and BLYNK_WRITE ourselves, but then we need to maintain the local copy.

1 Like

Yes I dono too.
I have to swap some Vpins below 127 to 128 and above.
So I’ll save vpins for blynk_read

I confirmed that V128 assigned to a Text Input widget is invoked on the device. It invokes GetWriteHandler, however, there’s no BlynkWidgetWrite128 widget write handler. Consequently, GetWriteHandler returns NULL and the thread dies. But the infrastructure is certainly there to support it.

WidgetWriteHandler GetWriteHandler(uint8_t pin)
{
    if (pin >= BLYNK_COUNT_OF(BlynkWriteHandlerVector))
        return NULL;
#ifdef BLYNK_HAS_PROGMEM
    return (WidgetWriteHandler)pgm_read_word(&BlynkWriteHandlerVector[pin]);
#else
    return BlynkWriteHandlerVector[pin];
#endif
}
1 Like

Yeah I think so too.

You use this “From App to Device” function method for any pin over 127… Single function for all, but with switch case logic to distinguish individual pins as needed.

1 Like

That’ll certainly work. Is that the plan? They don’t intend to extend the BLYNK_WRITE macro?

And BLYNK_READ_DEFAULT(). I’ll be darn. @Blynk_Coeur, you don’t need to reassign any of your pins.

As referenced in that topic, it would apparently just increase the memory usage of the library for the minority of need… so probably not, at least with this current version of Blynk. Who knows what 2.0 will look like.