JanLunge / pog

A Kmk firmware flashing and configuration tool
https://pog.heaper.de/
MIT License
326 stars 20 forks source link

Pog KMK does not run on boards without VBus sense #11

Closed bgkendall closed 4 months ago

bgkendall commented 4 months ago

When using a controller board that does not define a VBUS_SENSE pin (many boards lack a built-in VBus detection circuit), Pog’s KMK will fail with the following error:

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
starting keyboard G33 (01HZ8WB406YBNHA9K16MZK2EK7)
Traceback (most recent call last):
  File "code.py", line 3, in <module>
  File "pog.py", line 112, in <module>
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'VBUS_SENSE'

Removing the following line from pog.json will fix the issue:

    "vbusPin": "VBUS_SENSE",

but it is added back whenever the Pog configuration is saved.

parallacks commented 4 months ago

This could be related to the task:

check if the controller you use even has the pin you specified.

I'd love to take this issue to start contributing to the project.

Jan, let me know if you'd like to have this as a separate option for users or if you like it to be handled automatically via the checking functionality.

JanLunge commented 4 months ago

I think it would be the esdiest to only eval the vbus pin in the pog.py template if the split side detection is set to vbus

vbusPin = None
if config.get('vbusPin') and config.get('splitSide') === 'vbus':
    vbusPin = eval("board." + config['vbusPin'])

In the src/pythontemplates/pog.ts Would be really cool to check id the pin is available before eval as well so pog never crashes even with wrong settings but that isnt done for the other pins either.

parallacks commented 4 months ago

Yeah after looking through the code a bit last night I realized that would probably be the easiest path forward. Ok cool. I can take care of that if you'd like.

JanLunge commented 4 months ago

@parallacks that would be really nice, thank you for the support

bgkendall commented 4 months ago

I should note that the previous log was using an Adafruit KB2040. With a Waveshare RP2040-Zero I get a different error on the same line:

Adafruit CircuitPython 9.0.5 on 2024-05-22; Waveshare RP2040-Zero with rp2040
>>> import board
>>> print(dir(board))
['__class__', '__name__', 'A0', 'A1', 'A2', 'A3', 'GP0', 'GP1', 'GP10', 'GP11', 'GP12', 'GP13', 'GP14', 'GP15', 'GP16', 'GP17', 'GP18', 'GP19', 'GP2', 'GP20', 'GP21', 'GP22', 'GP23', 'GP24', 'GP25', 'GP26', 'GP26_A0', 'GP27', 'GP27_A1', 'GP28', 'GP28_A2', 'GP29', 'GP29_A3', 'GP3', 'GP4', 'GP5', 'GP6', 'GP7', 'GP8', 'GP9', 'NEOPIXEL', 'RX', 'TX', 'UART', '__dict__', 'board_id']
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
starting keyboard Test0 (01HZB68CW01TNREE1WMWDPZ8N9)
Traceback (most recent call last):
  File "code.py", line 3, in <module>
  File "pog.py", line 112, in <module>
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'board'