-
-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify split_common significantly #4772
Conversation
Both master and slave run the standard keyboard_task main loop now.
Simplify some of the preprocessor mess by using common function names.
Also, the changes are causing this issue: And this: |
Yes, I've changed the semantics significantly and wanted to highlight which existing builds using CUSTOM_MATRIX need to be updated so we can discuss how best to do it. Looks like miniaxe has a raw pin-per-key scan, that can easily move into split_common. @ka2hiro And handwired/xealous appears to have an old version of the matrix code, and can probably be converted to just use the standard implementation? @alex-ong |
with regards to my matrix code - it is indeed an older version that i've tweaked a whole bunch to make it faster. |
For boards with more pins than sense--sorry, switches.
Gllad I tested this out fiirst..... IIt's not fuunctioioning correctlllyy. IIt's innteerruping keeystrokes on nthe slavee half, whhich cauuses them too be dououble seent, or more. Nnoote, I usee colemak, annd all of theese errors are onn the slave half. Edit: |
There shouldn't be any difference in the sending code (it only moved about a bit), but the main loop is completely different. My initial guess is that some stuff is being run on the slave that should only happen on master. Matrix_scan() is calling matrix_scan_quantum() for both sides, which is probably completely wrong, and as mentioned earlier there's a bunch of options in keyboard_task that are outside the is_keyboard_master check. Lets see what happens if I revert the matrix_scan_quantum change and reinstate the matrix_scan_slave_user mechanism instead. |
Testing out the changes again, and this appears to be a lot better. The issue has gone away. So that's a plus! :) |
a37c4b2
to
5d584dc
Compare
Well, I don't like that the Xealous keyboard is broken because of these changes. But I'm not sure there is a simple way to fix it (other than turning split common off, copying the files over, and just using the old code.... But that may be fine, honestly. Though, I don't have any i2c based boards to test on, either. Just serial. @nooges @That-Canadian and @mtei, do these changes look good to you? |
I'm working towards getting xealous going, which is why I've just refactored the debounce stuff a bit. |
Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes
d90a74e
to
279e24d
Compare
This should complete the split_common changes, although I still need to convert xealous to use it. |
Documentation is added, and I've merged it with master. (sorry, I had to revert that recent change to CUSTOM_MATRIX, it directly conflicted and really wasn't better the other way...) |
@pelrun For example, drivers/avr/ssd1306.c uses the I2C interface to communicate with the OLED display and requires split_common/i2c.c (or other i2c.c) to operate the I2C interface. But it seems that your change to common_features.mk assumes the I2C interface for master-slave communication only. |
SPLIT_TRANSPORT is specifically intended to exclude files when they would actively cause a problem (e.g. on ARM where neither is compatible.) So it's up to the keyboard to not explicitly exclude a feature it actually requires. If it's unset, then it behaves just like the original build and includes both drivers (so all existing split keyboards build without modification - the travis CI pass should be enough to prove that.) Anyway, other code shouldn't be using split_common/i2c.c - how would they work on a non-split keyboard that doesn't include that file at all? |
ideally, we should be using |
Basically I agree. But can we do it right now? I think that it is better to gradually improve. |
It's trivially easy to update the i2c code to use the global driver, but this is already a hefty PR and it'll never land if I keep adding things to it. |
I do not know why SPLIT_TRANSPORT is necessary. QUANTUM_LIB_SRC works well, I think that it is not necessary to replace with SPLIT_TRANSPORT.
It behaves not like the original build. |
Example:
The current common_features.mk of the master branch uses QUANTUM_LIB_SRC. So I tried using QUANTUM_LIB_SRC by changing common_features.mk on your branch.
Summary:
|
I've fixed the problem with QUANTUM_LIB_SRC, now that I understand how it's affecting the linking. It doesn't remove the need for SPLIT_TRANSPORT, which now is like CUSTOM_MATRIX and only allows disabling the current comms code right now, but will select other standard implementations when they're available. |
The following functions in quantum/matrix.c and quantum/split_common/matrix.c have the
I think that this 'inline` keyword should be remove. |
Indentation of |
It is better to copy the code of |
It may be worth adding a comment on those lines, so that it's clearer why they're handled this way. |
Is this ready to go, as is? It looks like it works fine, as I'm using it locally, without issue. |
There are no code changes left, just those minor niggling formatting/comment issues, which can easily go into the next PR. |
...or they can go into this one because it hasn't been merged yet 💃 |
d7ec226
to
9db5a3f
Compare
I tried this split_common PR codes with Patched Helix(i2c with OLED). I only used it for a short time, but it seemed to be working well. |
* upstream/master: (390 commits) [Keyboard] handwired/ortho60 Configurator update, readme update, and rules tidy (qmk#4877) Fix Encoder documentation (qmk#4861) TKC1800 refactor and Configurator visual fixes (qmk#4870) Fixed the build break of helix/rev1:OLED_sample caused by PR qmk#4462. (qmk#4874) Add cursor keys to top layer (qmk#4876) [Keyboard] Fix bootloader size for v60_type_r (qmk#4873) Flip definitions of macOS brightness alias Grammatical fixes for GPIO Control doc (qmk#4869) handwired/ortho5x13: layout macro refactor Add new brightness aliases to keycodes_basic.md [Keyboard] update VENDOR_ID, PRODUCT_ID, and DEVICE_VER for Duck boards (qmk#4612) Add Planck rev1 and rev2, clean up rev3-5 config.h Allows Terminal to use ModTap/LayerTap keys (qmk#4586) Defined IS_(HOST_)LED_ON/OFF() and improved LED documentation (qmk#4853) MacOS Brightness Alias (qmk#4836) [Keymap] added custom led effect keymap.c (qmk#4856) Simplify split_common Code significantly (qmk#4772) Add documentation and fix formating (qmk#4860) [Keymap] Adding bdk keymap for ergobox_ez (qmk#4850) 40percent.club Luddite: Configurator update (qmk#4859) ...
* Eliminate separate slave loop Both master and slave run the standard keyboard_task main loop now. * Refactor i2c/serial specific code Simplify some of the preprocessor mess by using common function names. * Fix missing #endif * Move direct pin mapping support from miniaxe to split_common For boards with more pins than sense--sorry, switches. * Reordering and reformatting only * Don't run matrix_scan_quantum on slave side * Clean up the offset/slaveOffset calculations * Cut undebounced matrix size in half * Refactor debouncing * Minor fixups * Split split_common transport and debounce code into their own files Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes * Refactor debounce for non-split keyboards too * Update handwired/xealous to build using new split_common * Fix debounce breaking basic test * Dodgy method to allow a split kb to only include one of i2c/serial SPLIT_TRANSPORT = serial or SPLIT_TRANSPORT = i2c will include only that driver code in the binary. SPLIT_TRANSPORT = custom (or anything else) will include neither, the keyboard must supply it's own code if SPLIT_TRANSPORT is not defined then the original behaviour (include both avr i2c and serial code) is maintained. This could be better but it would require explicitly updating all the existing split keyboards. * Enable LTO to get lets_split/sockets under the line * Add docs for SPLIT_TRANSPORT, CUSTOM_MATRIX, CUSTOM_DEBOUNCE * Remove avr-specific sei() from split matrix_setup Not needed now that slave doesn't have a separate main loop. Both sides (on avr) call sei() in lufa's main() after exiting keyboard_setup(). * Fix QUANTUM_LIB_SRC references and simplify SPLIT_TRANSPORT. * Add comments and fix formatting.
Description
Time to throw a cat amongst the pigeons and make some changes that might (well probably will) break something.
Split_common no longer has a separate main loop for the slave, it reuses the keyboard_task main loop like ergodox infinity. This eliminates a lot of the code and makes it a bit easier to reason about. It also means that the slave will behave slightly differently depending on what flags are enabled - many of the options lie outside the is_keyboard_master gate in keyboard_task, and I expect that will have to change as they're tested.
The master/slave transport stuff has also been slighly refactored - instead of i2c_* and serial_* functions and a bunch of ifdefs to change the calling code, it's all been renamed generically, so there's no transport-specific ifdefs in the guts of the matrix code.
Types of changes
Checklist: