Example #1
0
    def post_init(self):
        self.devices = {}

        hid = HIDService()

        advertisement = ProvideServicesAdvertisement(hid)
        advertisement.appearance = BLE_APPEARANCE_HID_KEYBOARD
        scan_response = Advertisement()
        scan_response.complete_name = 'KMK Keyboard'

        ble = BLERadio()
        if not ble.connected:
            ble.start_advertising(advertisement, scan_response)
            while not ble.connected:
                pass

        for device in hid.devices:
            us = device.usage
            up = device.usage_page

            if up == HIDUsagePage.CONSUMER and us == HIDUsage.CONSUMER:
                self.devices[HIDReportTypes.CONSUMER] = device
                continue

            if up == HIDUsagePage.KEYBOARD and us == HIDUsage.KEYBOARD:
                self.devices[HIDReportTypes.KEYBOARD] = device
                continue

            if up == HIDUsagePage.MOUSE and us == HIDUsage.MOUSE:
                self.devices[HIDReportTypes.MOUSE] = device
                continue

            if up == HIDUsagePage.SYSCONTROL and us == HIDUsage.SYSCONTROL:
                self.devices[HIDReportTypes.SYSCONTROL] = device
                continue
Example #2
0
 def __init__(self, init_ui=True):
     self.ble = BLERadio()
     ui.display_qr(self.addr_suffix)
     self.nameservice = NameService()
     self.advertisement = ProvideServicesAdvertisement(self.nameservice)
     self.scan_response = Advertisement()
     self.scan_response.complete_name = "BADGE-{}".format(self.addr_suffix)
     self.ble.start_advertising(self.advertisement, self.scan_response)
Example #3
0
import adafruit_ble
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_ble.services.standard.device_info import DeviceInfoService


# Use default HID descriptor
hid = HIDService()
device_info = DeviceInfoService(
    software_revision=adafruit_ble.__version__, manufacturer="Adafruit Industries"
)
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()

ble = adafruit_ble.BLERadio()
if ble.connected:
    for c in ble.connections:
        c.disconnect()

print("advertising")
ble.start_advertising(advertisement, scan_response)

k = Keyboard(hid.devices)
kl = KeyboardLayoutUS(k)
while True:
    while not ble.connected:
        pass
    print("Start typing:")

#  time.monotonic() variable
clock = 0

#  variable for distance for proximity scrolling
distance = 245

#  setup for HID and BLE
hid = HIDService()

device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
                                manufacturer="Adafruit Industries")
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "CircuitPython HID"

ble = adafruit_ble.BLERadio()

if not ble.connected:
    print("advertising")
    ble.start_advertising(advertisement, scan_response)
else:
    print("already connected")
    print(ble.connections)

#  setup for mouse
mouse = Mouse(hid.devices)

while True:
Example #5
0
        map_pulse()
    elif animation_num == 2:
        ravening()
    elif animation_num == 3:
        infected()
    elif animation_num == 4:
        prophetsbane()
    elif animation_num == 5:
        vorpal()


#-------------------- Bluefruit setup
ble = BLERadio()
uart_service = UARTService()
advertisement = ProvideServicesAdvertisement(uart_service)
scan_response = Advertisement()
scan_response.complete_name = "Bad Ass Halo Energy Sword"

#-------------------- Audio setup
audio = AudioOut(board.A0)  # Speaker
wave_file = None


def play_wav(name, loop=False):
    """
    Play a WAV file in the 'sounds' directory.
    :param name: partial file name string, complete name will be built around
                 this, e.g. passing 'foo' will play file 'sounds/foo.wav'.
    :param loop: if True, sound will repeat indefinitely (until interrupted
                 by another sound).
    """
Example #6
0
            percentage = 0
        return percentage
    else:
        return 0
        
bleHID = bleHIDService()
batteryService = BatteryService()
 
device_info = DeviceInfoService(
                                software_revision=adafruit_ble.__version__,
                                manufacturer="Adafruit Industries",
                                hardware_revision="0.0.1",
                                )
advertisement = ProvideServicesAdvertisement(device_info, bleHID, batteryService)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "CP Keyboard"
 
ble = adafruit_ble.BLERadio()
ble.name = "CircuitPython Keyboard"
#ble._adapter.enabled = False

np = neopixel.NeoPixel(board.NEOPIXEL,1)

def disconnectAll():
    if ble.connected:
        for connection in ble.connections:
            connection.disconnect()


class BT(KeyObject):
Example #7
0
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.device_info import DeviceInfoService
from adafruit_ble.services.standard.hid import HIDService
from adafruit_hid.keyboard import Keyboard
from therefore.cc_device import ConsumerControl

from . import mesh

hid = HIDService()

device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
                                manufacturer="Adafruit Industries")
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "Therefore"

ble = adafruit_ble.BLERadio()


def get_keyboard():
    return Keyboard(hid.devices)


def get_consumer_control():
    return ConsumerControl(hid.devices)


def advertise():
    if not connected():
Example #8
0
    trellis.activate_key(i, NeoTrellis.EDGE_FALLING)
    # set all keys to trigger the blink callback
    trellis.callbacks[i] = send

    # cycle the LEDs on startup
    trellis.pixels[i] = GREEN
    time.sleep(0.05)

for i in range(KEYCOUNT):
    trellis.pixels[i] = BLUE

device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
                                manufacturer="Stonehippo")
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "ZoomKeys HID"

ble = adafruit_ble.BLERadio()
if not ble.connected:
    print("advertising")
    ble.start_advertising(advertisement, scan_response)
else:
    print("connected")
    print(ble.connections)

while True:
    while not ble.connected:
        pass
    print("Start typing:")