josefadamcik / SofleKeyboard

A split keyboard based on Lily58, Crkbd and Helix keyboards
https://josefadamcik.github.io/SofleKeyboard/
Other
1.88k stars 284 forks source link

Help: UART connection with Sofle Choc and KB2040 #134

Closed alecharp closed 2 years ago

alecharp commented 2 years ago

Kind of issue? Bug / Assembly / Software / HELP!

It's kind of all 4..

Which Board? Choc

Not ordered from keyhive, directly ordered the PCB at JLCPCB with the gerber files on the repository.

Which Board Revision? Choc = 2.1

What steps have you taken

Not a led issue

What is the issue?

I'm using two KB2040 from Adafruit and trying to have KMK (with circuitpython). I don't think this is related to the firmware but to the board. The pins to to UART Rx cannot be used to do Tx (I'm a noob in electronics, sorry), or it seems from https://github.com/adafruit/circuitpython/issues/4502.

This would means that the fact the LED are connected to the Tx (D0) and the Data to the Rx (D1) is problematic. For the right half, the lines should / needs to be inverted. What do you think?

Also, the current pcb is made to work in one direction. Did I understood that correctly? Does this means that the two half cannot sync up? Meaning a layer toogle change on the left side couldn't trigger a layer change on the right?

If the LED line was connected to another pin, we could have Rx/Tx pins linked to the TRRS connector and have the firmware handle the Tx/Rx cross connection. Did I understand that correctly as well?

KB2040 pinout: https://cdn-learn.adafruit.com/assets/assets/000/106/984/original/adafruit_products_Adafruit_KB2040_Pinout.png?1638564074

What you expected:

Nothing really. I mostly have questions and would like to know if I can "fix" the PCB I have, or if I have to spend time on changing the PCB design and order new ones.

alecharp commented 2 years ago

Side note, my point on the Tx/Rx is also based on https://github.com/KMKfw/kmk_firmware/issues/198#issue-872977177.

brianlow commented 2 years ago

This is cool. I think the RP2040 might become a really popular keyboard controller. Some first thoughts:

For the right half, the lines should / needs to be inverted

I don't think so if the controllers are installed in the holes with the outline around them. If so the controllers will be wired identically

brianlow commented 2 years ago

Also, the current pcb is made to work in one direction. Did I understood that correctly? Does this means that the two half cannot sync up?

With ProMicros the two halves work independently and then cooperate using the TRRS cable. So changing the layer with a keypress on the left will also change the layer on the right half

brianlow commented 2 years ago

I've read the RP2040 has a feature called programmable I/O so I think most pins can be configured to control the LEDs

alecharp commented 2 years ago

I don't think so if the controllers are installed in the holes with the outline around them. If so the controllers will be wired identically

yes, the D1 is connected to the other half D1. But in CircuitPython, I cannot create a UART connection with busio.UART(tx=board.RX, rx=None). The code won't load.

In the end, it's probably a problem of CircuitPython and not Sofle design. I'll more testing.

brianlow commented 2 years ago

So is the problem the LEDs are not lighting up?

If it helps: on the right side of the board the first LED (on the back of the PCB) will be connected to the top right pin of the RP2040 when looking at the top side of the board. I think this is pin D-. Could be wrong though, looking at the PCB layout is always a bit of a mind twister and don't have time to confirm with multimeter.

Could the first LED be dead by any chance? Perhaps try replacing it.

alecharp commented 2 years ago

no the leds, are completely fine. The problem is that when I try to setup the split module of KMK or even trying to create a busio.UART object on the board, I have an invalid pin with busio.UART(tx=board.RX, rx=None).

All I could find was https://github.com/adafruit/circuitpython/issues/4502 which let me thing that maybe the two Tx and Rx pins would need to be linked to the TRRS connector and with https://github.com/KMKfw/kmk_firmware/issues/198 it would "solve" the problem.

But again, I'm a electronic beginner (at best) so :shrug:

alecharp commented 2 years ago

Based on https://github.com/adafruit/circuitpython/issues/5953 response, we can close this.

Even if it would be best to have the Tx/Rx pins to cross, it possible to get around that. I just need to work on KMK split module to use pio and not the board UART.

brianlow commented 2 years ago

Good luck, let us know if you solve it!

alecharp commented 2 years ago

as I'm not good in electronic, and I mostly code in Java, not Python even less CircuitPython, that will be a challenge.

netgmx commented 2 years ago

I'm working on the redox keyboard drived by two pi pico, here is what I found:

left side (usb) self._uart = busio.UART(rx=self.data_pin)

right side self._uart = busio.UART(tx=self.data_pin2)

not nicest solution and now that I know what is going on I can design some logic around it, hope it helps someone

Tonasz commented 2 years ago

I accidentally found this issue as it was linked to KMK repository. I got some news which could interest you @alecharp: