The deltaco_TB_298 module

Autogenerated API documentation for deltaco_TB_298

Driver with line reader for the Deltaco TB-298 Keypad

PyExpLabSys.drivers.deltaco_TB_298.detect_keypad_device()[source]

Return the input device path of the Deltaco TB-298 Keypad

Iterates over all devices in /dev/input/event?? and looks for one that has the Deltaco Keypad vendor and product id and has a “1” key

Returns:The Keypad device path
Return type:str
class PyExpLabSys.drivers.deltaco_TB_298.MaxSizeQueue(maxsize=0)[source]

Bases: queue.Queue

MaxSizeQueue: A subclassed queue.Queue object that pops the first item if raising a queue.Full exception when adding an item. Otherwise the queue will block until an item is removed from the queue.

put(item)[source]

Put an item into the queue.

If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until a free slot is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Full exception if no free slot was available within that time. Otherwise (‘block’ is false), put an item on the queue if a free slot is immediately available, else raise the Full exception (‘timeout’ is ignored in that case).

class PyExpLabSys.drivers.deltaco_TB_298.ThreadedKeypad(device_path, line_chars='0123456789', max_queue_sizes=None)[source]

Bases: threading.Thread

Threaded keypad reader

line_queue

Queue of enter separated lines entered

Type:MaxSizeQueue
event_queue

Queue of key pad events

Type:MaxSizeQueue
key_pressed_queue

Queue of pressed keys (only one entry will be added if the key is held down)

Type:MaxSizeQueue
device

The input device

Type:evdev.InputDevice
__init__(device_path, line_chars='0123456789', max_queue_sizes=None)[source]

Instantiate local variables

Holds 3 non-blocking queues that record inputs. If a queue is full, the first item is popped and the newest item is put in the end of the queue. When starting a function in a program that makes use of another queue, make sure to flush the queue before the main loop so you get the newest value first. Alternatively, if you want to keep an unused queue for history purposes, you may want to increase the max_queue_size of that queue.

Parameters:
  • device_path (str) – Path of the inpu device to use e.g: ‘/dev/input/event0’
  • line_chars (str) – String of accepted characters in a line. Default value is ‘0123456789’
  • max_queue_sizes – Dict used to overwrite the default max queue size of 1024 elements. The keys are ‘line’, ‘event’ and ‘key_pressed’ and the values are positive ints (0 is infinite).
run()[source]

Main run method

handle_event(event)[source]

Handle an event

stop()[source]

Stop the thread and put deltaco_TP_298.STOP in queues

PyExpLabSys.drivers.deltaco_TB_298.module_demo()[source]

Simple module demo