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
# 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: while not ble.connected:
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). """ global wave_file # pylint: disable=global-statement
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): def __init__(self, i):
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(): print("advertising")
# 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:") while ble.connected: