Skip to main content

Brilliant Monocle Driver

brilliant-monocle-driver is a simple Python library that uses Bleak to connect to and control a Brilliant Labs Monocle display device.

Install

pip install brilliant-monocle-driver

Usage examples

Display battery and then blank screen

import asyncio
from brilliant_monocle_driver import Monocle

def callback(channel, text_in):
  """
  Callback to handle incoming text from the Monocle.
  """
  print(text_in)

# Simple MicroPython command that prints battery level for five seconds
# and then blanks the screen
COMMAND = """
import display
import device
import time
from brilliant_monocle_driver import Monocle

def show_battery(count):
  batLvl = str(device.battery_level())
  display.fill(0x000066)
  display.text("bat: {} {}".format(batLvl, count), 5, 5, 0xffffff)
  display.show()

count = 0
while (count < 5):
  show_battery(count)
  time.sleep(1)
  count += 1

display.fill(0x000000)
display.show()

print("Done")

"""

async def execute():
    mono = Monocle(callback)
    async with mono:
        await mono.send(COMMAND)

asyncio.run(execute())

Receive touch events

import asyncio
from brilliant_monocle_driver import Monocle

def a_touch():
    print("A touch!")

def b_touch():
    print("B touch!")

async def execute():
    mono = Monocle()
    async with mono:
        await mono.install_touch_events()
        mono.set_a_touch_callback(a_touch)
        mono.set_b_touch_callback(b_touch)
        await asyncio.sleep(30000)

asyncio.run(execute())

Details

brilliant-monocle-driver attaches to a Monocle via the UART characteristics exposed over BLE in Monocle's default firmware, as specified in the Monocle documentation. Once connection is established, commands can be sent directly to the Monocle as MicroPython. The driver avoids MTU overflow and does some convenience / correction massaging (sending Ctrl-C to stop any running command and wrapping the incoming command in Ctrl-A | Ctrl-D to avoid interference from the REPL's echo and auto-formatting convenience behaviors).

Metadata

Release files for brilliant-monocle-driver 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brilliant-monocle-driver 0.1.3
File Size Uploaded Provenance Actions
brilliant-monocle-driver-0.1.3.tar.gz 6.3 kB Without provenance Details for brilliant-monocle-driver-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brilliant-monocle-driver 0.1.3
File Interpreter ABI Platform Actions
brilliant_monocle_driver-0.1.3-py3-none-any.whl Python 3 none any Details for brilliant_monocle_driver-0.1.3-py3-none-any.whl

Total release size: 13.4 kB

Release files / brilliant-monocle-driver-0.1.3.tar.gz

Download URL brilliant-monocle-driver-0.1.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cda6261cd24d896820ab764a02ca2c603a9cdad930cd9037989073ba7dace516
BLAKE2b-256 checksum
How to use checksums
05e35b295b81c0e5fa5c7a6785b71000dab4acd1f014c9ed13cd862a1ff45fe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / brilliant_monocle_driver-0.1.3-py3-none-any.whl

Download URL brilliant_monocle_driver-0.1.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b8fd210fdb33d35fd19e4839fcb0459d8802e6db33a7575009919abb8b41bf9
BLAKE2b-256 checksum
How to use checksums
ae5019eb4dac188b5b25eb0b94ac3af2d42a5f56544120b9e66e62865d6ef3be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Security for brilliant-monocle-driver 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page