Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions adafruit_ble_magic_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

"""

try:
from typing import Optional
except ImportError:
pass

from adafruit_ble.services import Service
from adafruit_ble.uuid import VendorUUID
from adafruit_ble.characteristics import Characteristic
Expand All @@ -28,20 +33,20 @@ class MagicLightService(Service):
uuid=VendorUUID("0000ffe9-0000-1000-8000-00805f9b34fb"), max_length=7
)

def __init__(self, service=None):
def __init__(self, service: Optional["MagicLightService"] = None) -> None:
super().__init__(service=service)
self._color = 0xFFFFFF
self._buf = bytearray(7)
self._buf[0] = 0x56
self._buf[6] = 0xAA
self._brightness = 1.0

def __getitem__(self, index):
def __getitem__(self, index: int) -> int:
if index > 0:
raise IndexError()
return self._color

def __setitem__(self, index, value):
def __setitem__(self, index: int, value: int) -> None:
if index > 0:
raise IndexError()
if isinstance(value, int):
Expand Down