A button class that reports precisely when it is pressed. More...
Public Member Functions | |
| def | press (self, timer) |
| Recognizes the button has been pressed and records it. More... | |
| def | __init__ (self, callback=None, epoch=None) |
| Create a Button object. More... | |
| def | REPORT (self, message) |
| Schedule a debug message to be reported with a time stamp. More... | |
| def | disable (self, Timer trigger=None) |
| Disable the button and runs the callback function specified upon Button creation. More... | |
| def | enable (self) |
| Enable the button after having been disabled. | |
| def | trigger (self, int irq_src) |
| Collect and report a button action. More... | |
| def | press (self, int irq_src=None) |
| Recognizes the button has been pressed and updates the time. More... | |
| def | release (self, int irq_src=None) |
| Recognizes the button press has finished. More... | |
| def | __init__ (self, falling_callback=None, rising_callback=None, epoch=None) |
| Create a Button object. More... | |
Public Attributes | |
| pressed_counts | |
| The time when this button is pressed. | |
| epoch | |
| Compare all timed events to this time (button zero). More... | |
| callback | |
| A function to return to when the button is pressed. More... | |
| triggered | |
| The last edge that was encountered on the button The default state is that the button has not been pressed (i.e. More... | |
| time_pressed | |
| Last time the button was pressed #. | |
| time_released | |
| Last time the button was released #. | |
| interrupt | |
| Interrupt for button detection and timeout handling #. | |
A button class that reports precisely when it is pressed.
A Button class that reports rising and falling edges.
Subclasses the Pin object from pyb. Responds upon the falling edge (push) of the user button.
This button class extends the pyb.Pin class, so can be treated as a Pin. On creation the button can be given callback functions to call on rising and calling edges. It can also be easily enabled and disabled.
| def Button.Button.__init__ | ( | self, | |
callback = None, |
|||
epoch = None |
|||
| ) |
| def Button.Button.__init__ | ( | self, | |
falling_callback = None, |
|||
rising_callback = None, |
|||
epoch = None |
|||
| ) |
Create a Button object.
| falling_callback | A function to optionally be called when a falling edge is detected |
| rising_callback | A function to optionally be called when a rising edge is detected |
| epoch | A global zero time to which all other time readings are compared. If not provided, the button will create its own. |
| def Button.Button.disable | ( | self, | |
| Timer | trigger = None |
||
| ) |
Disable the button and runs the callback function specified upon Button creation.
| trigger | The timer that disabled the button (if supplied) |
| def Button.Button.press | ( | self, | |
| int | irq_src = None |
||
| ) |
Recognizes the button has been pressed and updates the time.
Sets time_pressed and, if applicable, schedules a callback function with the triggered time.
| irq_src | The interrupt request source line number (required as an interrupt callback). |
| def Button.Button.press | ( | self, | |
| timer | |||
| ) |
Recognizes the button has been pressed and records it.
If applicable, the Button's callback function is also called.
| timer | The timer which triggered this interrupt. |
| def Button.Button.release | ( | self, | |
| int | irq_src = None |
||
| ) |
Recognizes the button press has finished.
Updates the sequence with the type of press.
Sets time_released and, if applicable, schedules a callback function with the triggered time.
| irq_src | The interrupt request source line number (required as an interrupt callback). |
| def Button.Button.REPORT | ( | self, | |
| message | |||
| ) |
Schedule a debug message to be reported with a time stamp.
| message | The message to be reported. |
| def Button.Button.trigger | ( | self, | |
| int | irq_src | ||
| ) |
Collect and report a button action.
Currently the debug functionality in unstable within interrupts, so it has been disabled.
| irq_src | The interrupt request source line number (required as an interrupt callback). |
| Button.Button.callback |
A function to return to when the button is pressed.
Callback functions to return to when the button is pressed or released #.
| Button.Button.epoch |
Compare all timed events to this time (button zero).
#
| Button.Button.triggered |
The last edge that was encountered on the button The default state is that the button has not been pressed (i.e.
previous edge was RISING).