forked from ukBaz/python-bluezero
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bit:commander extension to microbit (ukBaz#166)
4tronix is creating a new game controller style add-on for the microbit. This adds support for that functionality. This also adds better support for microbit IO Pin Service This also adds better support for async/eventloop
- Loading branch information
Showing
14 changed files
with
447 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Main eventloop import | ||
from gi.repository import GLib | ||
|
||
import logging | ||
try: # Python 2.7+ | ||
from logging import NullHandler | ||
except ImportError: | ||
class NullHandler(logging.Handler): | ||
def emit(self, record): | ||
pass | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.WARNING) | ||
logger.addHandler(NullHandler()) | ||
|
||
|
||
class EventLoop: | ||
# def generic_error_cb(self, error): | ||
# """Generic Error Callback function.""" | ||
# logger.error('D-Bus call failed: ' + str(error)) | ||
# self.mainloop.quit() | ||
|
||
# def __new__(cls): | ||
# return object.__new__(cls) | ||
|
||
def __init__(self): | ||
self.mainloop = GLib.MainLoop() | ||
|
||
# @property | ||
# def run(self): | ||
# return self.mainloop.is_running() | ||
# | ||
# @run.setter | ||
# def run(self, state): | ||
# if state: | ||
# self.mainloop.run() | ||
# else: | ||
# self.mainloop.quit() | ||
def run(self): | ||
self.mainloop.run() | ||
|
||
def quit(self): | ||
self.mainloop.quit() | ||
|
||
def is_running(self): | ||
self.mainloop.is_running() | ||
|
||
def add_timer(self, time, callback): | ||
GLib.timeout_add(time, callback) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.