Package rstem :: Module button :: Class Button
[hide private]
[frames] | no frames]

Class Button

source code

object --+
         |
        Button

A button from a GPIO port

Instance Methods [hide private]
 
__init__(self, port)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
is_pressed(self)
Returns: True if button is pressed
source code
 
was_clicked(self) source code
 
_verify_change_value(change) source code
 
call_on_change(self, event_callback, change='falling', bouncetime=300)
Calls given event_callback function when button changes state (example pressed).
source code
 
remove_call_on_change(self)
Removes the callback function set for this button.
source code
 
wait_for_change(self, change='falling')
Blocks until given change event happens
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, port)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • port (int) - GPIO number (BCM mode) that button is plugged into
Overrides: object.__init__

is_pressed(self)

source code 
Returns:
True if button is pressed

call_on_change(self, event_callback, change='falling', bouncetime=300)

source code 

Calls given event_callback function when button changes state (example pressed).

Parameters:
  • event_callback (function) - function to call when button changes state
  • change - type of event to watch for (either button.PRESSED, button.RELEASED, or button.BOTH)
  • bouncetime (int8) - msec to debounce button

Warning: Function must have the first argument be the port number

remove_call_on_change(self)

source code 

Removes the callback function set for this button. Does nothing if no callback function is set

wait_for_change(self, change='falling')

source code 

Blocks until given change event happens

Parameters:
  • change - type of event to watch for (either button.PRESSED, button.RELEASED, or button.BOTH)