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
""" | |
Simple Linux Python BLE central device communicate with micro:bit | |
""" | |
from time import sleep | |
import pydbus | |
from gi.repository import GLib | |
DEVICE_ADDR = 'DE:82:35:E7:CE:BE' # micro:bit address | |
BTN_A_STATE = 'E95DDA90-251D-470A-A062-FA1922DFA9A8' |
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
from collections import deque | |
correct_values = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, | |
987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, | |
75025, 121393, 196418, 317811] | |
def get_item(request): | |
fib_seq = deque([0, 1], 2) | |
if request < 2: |
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
#!/usr/bin/env python | |
from bluedot import BlueDot | |
import colorsys | |
import time | |
import blinkt | |
def move(pos): | |
# print("The Blue Dot x={} y={} d={} a={}".format(pos.x, pos.y, pos.distance, pos.angle)) | |
h=((pos.angle+180) % 360) / 360 |
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
sudo apt-get install bluetooth bluez-tools | |
sudo apt-get install build-essential autoconf glib2.0 libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev | |
sudo apt-get install rsync python-dbus python3-dbus python-dbusmock python3-dbusmock | |
sudo pip3 install Sphinx | |
sudo pip3 install sphinx_rtd_theme | |
sudo pip3 install pycodestyle |
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
#!/usr/bin/env python3 | |
import dbus | |
import dbus.mainloop.glib | |
from gi.repository import GLib | |
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | |
mainloop = GLib.MainLoop() | |
def interfaces_added(path, interfaces): |
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
from time import sleep | |
from mote import Mote | |
from bluezero import constants | |
from bluezero import tools | |
from bluezero import adapter | |
from bluezero import device | |
from bluezero.GATT import Characteristic | |
display_on = False |