Microsoft MakeCode

Circuit Playground Express on mobile devices

In trying to use a CPX as a USB HID device on an iPhone or iPad, I’m getting this error:
“CANNOT USE ACCESSORY
CPlay Express (app): This accessory requires too much power.”

I believe there is a USB report descriptor that can be set to a value that makes the phone/tablet happy, as I’ve had Circuit Playground Express running CircuitPython code in the past.

You can see the different reports on a Mac in System Report for a Circuit Playground Express running MakeCode vs. CircuitPython, on the MakeCode board there is a “Current Required (mA):500” line that may be causing the problem.

Running MakeCode:

CPlay Express (app):
Product ID:	0x2402
Vendor ID:	0x03eb  (Atmel Corporation)
Version:	42.02
Serial Number:	1318705658
Speed:	Up to 12 Mb/sec
Manufacturer:	CPlay Express (app)
Location ID:	0x14100000 / 10
Current Available (mA):	500
Current Required (mA):	500
Extra Operating Current (mA):0

Running CircuitPython:

CircuitPlayground Express:

 Product ID:0x8019
 Vendor ID:0x239a
 Version:1.00
 Serial Number:8E1438657525D4050213E25354D1E0FF
 Speed:Up to 12 Mb/sec
 Manufacturer:Adafruit Industries LLC
 Location ID:0x14100000 / 14
 Current Available (mA):500
 Extra Operating Current (mA):0

Update, this was fixed at one point before: https://github.com/microsoft/pxt-adafruit/issues/837 but seems broken now. I tried in release and Beta MakeCode.
Most recently:

Adafruit Circuit Playground Express version:  1.5.12
Microsoft MakeCode version:  5.28.24
codal-circuit-playground runtime version:  v2.0.1

Phone is iPhone X running iOS 13.2.3

Apple brand Lightning to USB adapter and a known good USB cable.

Code I’m running on the Circuit Playground Express:

input.buttonA.onEvent(ButtonEvent.Click, function () {
    keyboard.type("a")
})

The HID driver was contributed by Adafruit. Do you know who is the maintainer on the CircuitPython side? they might have a better idea of what’s going on.

I think this isn’t the HID driver, but the USB descriptor. Looks like it got changed back to 500mA here: https://github.com/lancaster-university/codal-core/commit/36dafe77219239c1397ece44ed37a7f6e6f50d5a – the 250 value there is multiplied by 2mA, so 500mA which is more than the iPhone or iPad want to provide.

@mmoskal do you know if this can be adjusted back to a level that mobile devices will allow?

Yes, though it would be probably better to do it on the pxt side, not codal side. I would think that CPX can consume more than 100mA at peak, but maybe we’ll just ignore this…

OK, cool. What needs to be done to set this on the pxt side vs. codal?

@mmoskal anything we can do to get this updated?

I should be able to look at that this week