Update slider position from python variable

• RPi 3b+ via internet to online Blynk server
• iOS 14.2.1

  • Blynk Library version 0.2.6

Hi, I’m very new to Blynk. I’m making a remote control for a preamp that uses I2C to control many functions. Volume can be controlled by a rotary encoder (working fine) or the blynk slider (working fine). I want the blynk software to read the volume setting from the responsible microprocessor and set the position of the slider actuator to reflect the current volume.

Python library 0.2.6 needs better documentation - it shouldn’t be so hit-or-miss to get reads and writes working. What activates a register handler for virtual pins? How do I make the system respond to outside changes?

#___________Block 1 - works fine and blynk slider writes to chip via I2C  __________
# register handler for virtual pin V0 writing
@blynk.handle_event('write V0')
def write_virtual_pin_handler(pin, value):
#    print(WRITE_EVENT_PRINT_MSG.format(pin, value))
    print('slider value = {}', value)
        newvalue0 = (value[-1])
        volume = int(newvalue0)
        bus.write_byte_data(0x48, 0x17, volume) # volume register
    except IOError as err:
#_____Block 2 - has no effect on blynk pin V0 and slider is stationary while chip registers change __
# register handler for virtual pin V0 reading
@blynk.handle_event('read V0')
def read_virtual_pin_handler(pin):
    global volume
        newvolume = bus.read_byte_data(0x48, 0x17) # I2C read of DAC chip volume register
        if volume != newvolume: # if the volume has changed then
            volume = newvolume  # and reset 
            blynk.virtual_write(V0, volume)  
    except IOError as err:

I thought the latest Python library was 2.0.0


I appreciate your attention, Pete.

There are two library sources on GitHub. I chose the one that had more recent activity.

1.Are the two different?
2. If so, which is preferable?
3. Can a slider read a pin and move without being touched?
4. https://you.be/hZG_Ra7wfgU

I’m a C++ guy, so don’t know the differences between the two Python libraries I’m afraid.

A slider can be updated from the hardware side. In C++ this is done with a Blynk.virtualWrite(vPin) command.
It can also be forced to send its value to the server (and on to the hardware) via a Blynk.syncVirtual(vPin) command in C++. I assume that a similar command exists in Python.