Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i think it can be use by PC game stream #35

Open
ghost opened this issue Jan 27, 2021 · 1 comment
Open

i think it can be use by PC game stream #35

ghost opened this issue Jan 27, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 27, 2021

捕获
just like this,if you can create a local website that display heartrate intime,it can be add to OBS,thank!

@nico202
Copy link

nico202 commented Feb 26, 2021

this is super easy with functions already available,

#! /usr/bin/python3
from miband import miband
from bluepy.btle import BTLEDisconnectError
from PIL import Image, ImageDraw


def make_image(text):
    image_size = (10, 10)
    image = Image.new('RGBA', image_size)
    # You can change fonts & draw the heart image here
    draw = ImageDraw.Draw(image)
    draw.text((0, 0), text, align="")
    return image


MAC = 'INSERT_MAC_HERE'
AUTH_KEY = bytes.fromhex('INSERT_KEY_HERE')

while True:
    try:
        band = miband(MAC, AUTH_KEY, debug=True)
        band.initialize()

        def callback(beats):
            make_image(str(beats)).save('beats.png')
        band.start_heart_rate_realtime(callback)
        band.disconnect()
        break
    except BTLEDisconnectError:
        print('connection to the MIBand failed. Trying out again')
        continue

this saves the image to a file named beats.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant