vshymanskyy / blynk-library-python

Blynk library for Python. Works with Python 2, Python 3, MicroPython.

Home Page:https://blynk.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide virtual pin number to callback function

chrissv opened this issue · comments

Currently the callbacks for each pin must be declared individually and uniquely:

@blynk.VIRTUAL_READ(2)
def v2_read_handler():
    print "This is V2 handler"
@blynk.VIRTUAL_READ(3)
def v3_read_handler():
    print "This is V3 handler"

But there are cases where I want to call a common function, passing in the pin. Something like this (not real code, but the concept):

@blynk.VIRTUAL_READ(2)
def v2_read_handler():
    common_handler(pin)
@blynk.VIRTUAL_READ(3)
def v3_read_handler():
    common_handler(pin)

def common_handler(pin):
    print "This is V{} handler" % pin

This issue is to provide some mechanism to make the pin number available to the callback function.

Implemented. Please check the latest master, examples directory.
Waiting for the feedback!