Skip to content

Commit beec911

Browse files
committed
Correctly use earlephilhower.varant if variant not given, ensure USB power macro is always there
1 parent 840e8c4 commit beec911

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/platformio-build.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,13 @@ def configure_usb_flags(cpp_defines):
148148
("USB_PID", usb_pid),
149149
("USB_MANUFACTURER", '\\"%s\\"' % usb_manufacturer),
150150
("USB_PRODUCT", '\\"%s\\"' % usb_product),
151-
("SERIALUSB_PID", usb_pid),
152-
("USBD_MAX_POWER_MA", 250)
151+
("SERIALUSB_PID", usb_pid)
153152
])
154153

154+
if "USBD_MAX_POWER_MA" not in env.Flatten(env.get("CPPDEFINES", [])):
155+
env.Append(CPPDEFINES=[("USBD_MAX_POWER_MA", 500)])
156+
print("Warning: Undefined USBD_MAX_OWER_MA, assuming 500mA")
157+
155158
# use vidtouse and pidtouse
156159
# for USB PID/VID autodetection
157160
hw_ids = board.get("build.hwids", [["0x2E8A", "0x00C0"]])
@@ -200,9 +203,9 @@ def configure_usb_flags(cpp_defines):
200203

201204
libs = []
202205

203-
variant = board.get("build.arduino.earlephilhower.variant", board.get("build.variant", None))
206+
variant = board.get("build.arduino.earlephilhower.variant", board.get("build.variant", ""))
204207

205-
if variant is not None:
208+
if variant != "":
206209
env.Append(CPPPATH=[
207210
os.path.join(FRAMEWORK_DIR, "variants", variant)
208211
])

0 commit comments

Comments
 (0)