Ejemplo n.º 1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "XYZ"  # Change XYZ to the UID of your Rotary Encoder Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rotary_encoder import BrickletRotaryEncoder

if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    re = BrickletRotaryEncoder(UID, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    # Get current count without reset
    count = re.get_count(False)
    print("Count: " + str(count))

    raw_input("Press key to exit\n")  # Use input() in Python 3
    ipcon.disconnect()
Ejemplo n.º 2
0
HOST = "localhost"
PORT = 4223
UID = "XYZ"  # Change XYZ to the UID of your Rotary Encoder Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rotary_encoder import BrickletRotaryEncoder


# Callback function for count callback
def cb_count(count):
    print("Count: " + str(count))


if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    re = BrickletRotaryEncoder(UID, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    # Register count callback to function cb_count
    re.register_callback(re.CALLBACK_COUNT, cb_count)

    # Set period for count callback to 0.05s (50ms)
    # Note: The count callback is only called every 0.05 seconds
    #       if the count has changed since the last call!
    re.set_count_callback_period(50)

    raw_input("Press key to exit\n")  # Use input() in Python 3
    ipcon.disconnect()
Ejemplo n.º 3
0
 def create_instance(self, uid, ipcon):
     return BrickletRotaryEncoder(uid, ipcon)
HOST = "localhost"
PORT = 4223
UID = "XYZ"  # Change XYZ to the UID of your Rotary Encoder Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rotary_encoder import BrickletRotaryEncoder

# Callback function for count callback
def cb_count(count):
    print("Count: " + str(count))


if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    re = BrickletRotaryEncoder(UID, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    # Register count callback to function cb_count
    re.register_callback(re.CALLBACK_COUNT, cb_count)

    # Set period for count callback to 0.05s (50ms)
    # Note: The count callback is only called every 0.05 seconds
    #       if the count has changed since the last call!
    re.set_count_callback_period(50)

    raw_input("Press key to exit\n")  # Use input() in Python 3
    ipcon.disconnect()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "XYZ" # Change XYZ to the UID of your Rotary Encoder Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rotary_encoder import BrickletRotaryEncoder

if __name__ == "__main__":
    ipcon = IPConnection() # Create IP connection
    re = BrickletRotaryEncoder(UID, ipcon) # Create device object

    ipcon.connect(HOST, PORT) # Connect to brickd
    # Don't use device before ipcon is connected

    # Get current count without reset
    count = re.get_count(False)
    print("Count: " + str(count))

    raw_input("Press key to exit\n") # Use input() in Python 3
    ipcon.disconnect()