Giter VIP home page Giter VIP logo

Comments (1)

nico202 avatar nico202 commented on August 25, 2024 3

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

from miband4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.