Setting ZeRGBa value from hardware

Hi,

I’m using ZeRGBa widget in set up on V0 virtual pin (merged output). On hardware (ESP8266) I’m trying to set some value to the ZeRGBa widget, like this:

Blynk.virtualWrite(V0, redValue, greenValue, blueValue);

Is that the right way to do it? Can it be done?

Thanks,
Kristijan

No worries, thanks for letting me know.
Will there be support for multiple widgets controlling the same pin? For example, controlling RGB values using zeRGBa and sliders? Syncing from hardware works (for sliders, not zeRGBa), but doing it in the mobile app would much be better.

@kristijan @Pavel meant that it doesn’t work on iOS. However it works on Android.

I think this is possible. Did you tried that? I can say for sure this 100% possible for SPLIT mode. However I never tried it by myself for MERGE mode. It should work. If no - this is a bug. @kristijan please let us know if that doesn’t work for you.

@Dmitriy I’ve tried the code I’ve put in my first post, but unfortunately it doesn’t work. The selector circle in zeRGBa widget moves a little (maybe a few pixels) on the first update, and then doesn’t move at all after that. I’m using android and ESP8266 if it matters.

I’ve done the same thing in reverse (syncing value set by zeRGBa to sliders) and that works as expected.
Haven’t tried SPLIT mode. Is it possible for two widgets to use the same virtual pin?

@kristijan please show your code. I checked - it works for me.

No.

Here’s the code:

int redValue = 0;
int greenValue = 0;
int blueValue = 0;

BLYNK_WRITE(V0)
{   
  redValue = param[0].asInt();
  greenValue = param[1].asInt();
  blueValue = param[2].asInt();

  analogWrite(RED_PIN, redValue);
  analogWrite(GREEN_PIN, greenValue);
  analogWrite(BLUE_PIN, blueValue);

  Blynk.virtualWrite(V1, redValue);
  Blynk.virtualWrite(V2, greenValue);
  Blynk.virtualWrite(V3, blueValue);
}

BLYNK_WRITE(V1)
{
  redValue = param.asInt();

  analogWrite(RED_PIN, redValue);
  Blynk.virtualWrite(V0, redValue, greenValue, blueValue);
}

BLYNK_WRITE(V2)
{
  greenValue = param.asInt();

  analogWrite(GREEN_PIN, greenValue);
  Blynk.virtualWrite(V0, redValue, greenValue, blueValue);
}

BLYNK_WRITE(V3)
{
  blueValue = param.asInt();

  analogWrite(BLUE_PIN, blueValue);
  Blynk.virtualWrite(V0, redValue, greenValue, blueValue);
}

V0 is virtual pin used by zeRGBa. V1, V2 and V3 are used by separate sliders. All sliders and zeRGBa are configured to use values 0-1023.

@kristijan hello again. Please check latest 1.12.1 version. Your issue should be fixed there. Let me know if not.

@Dmitriy Sorry for the late response. Works fine with default ranges (0-255), but when scaled to 0-1023 values over 255 start from 0 (like it’s doing x % 255).

@Dmitriy Will this be implemented for iOS?

It should in latest iOS version.

Hey, I tried this on my NodeMCU with scaled values (0-1023).

Blynk.virtualWrite(V1, currentRed, currentGreen, currentBlue);

This works for me.

Thank you and @Dmitriy . Your post helped me with this.