Skip to content
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

Framework Laptop 16 Keyboards #1

Draft
wants to merge 537 commits into
base: master
Choose a base branch
from
Draft

Framework Laptop 16 Keyboards #1

wants to merge 537 commits into from

Conversation

JohnAZoidberg
Copy link
Member

@JohnAZoidberg JohnAZoidberg commented Dec 16, 2022

Building:

qmk compile -kb framework/ansi -km default
qmk compile -kb framework/iso -km default
qmk compile -kb framework/jis -km default
qmk compile -kb framework/numpad -km default
qmk compile -kb framework/gridpad -km default

Other commands:

# Flash firmware (device must be in bootloader mode)
qmk flash -kb framework/ansi -km default

# Render layout with labels
qmk info -kb framework/ansi -km default -m

# Render layout matrix information
qmk info -kb framework/ansi -km default -m

# Show console output of connected QMK devices
qmk console

Resources:

Tasks

  • Make sure it works on our board, not just RasperryPi Pico
    • Change 16MB flash size to 1MB. No need
    • Make sure GPIOs are properly mapped. Pretty sure it's fine. Need to undefine PICO_FL16
  • USB VID and PID (tested)
  • Signal BOOT_DONE
  • Reading key input via ADC
    • Implement logic
    • Make sure the matrix ligns up with the actual electrical matrix
    • Implement actually reading from ADC
  • Single-zone PWM backlight
    • Test that it works
  • Capslock/Numlock LED
    • Test that it works
  • Enable RGB backlight with IS31FL3743A (see docs/feature_rgb_matrix.md)
    • Map LED positions. TODO: Probably needs some adjustment still
    • Fix numpad RGB mapping
    • Pull SDB(GP29) low to put IS31FL3743A into low power mode
    • Make sure mapping from keycode to LED is correct
    • Make sure mapping of LEDs IS31FL3743A matrix is correct
    • Make sure mapping of LEDs to absolute coordinates is correct
    • Make sure it's persisted. Currently it emulated EEPROM in the last 64K of flash. See: platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h.
  • Try debugging
    • Using HID console (Works with qmk console)
    • Using debugger
  • Split variants
    • Layouts
      • ANSI (78 keys)
      • ISO (79 keys)
      • JIS (83 keys)
      • Numpad (21 keys)
      • Gridpad (23 keys)
    • Fix key position and sizes in info.json
  • Enable VIA support
    • Add configs for each layout
      • ANSI
      • ISO
      • JIS
      • Numpad
      • Gridpad
    • Enable VIA in config.
  • Special Media Keys
  • Support FN lock
  • Support firmware update via software only, without mechanical intervention. This would be used in the factory for flashing the firmware.
  • Figure out a way to put the serial number, which won't be overridden by reflashing QMK
  • Remove mouse report
  • Move spacebar LED to the middle

@JohnAZoidberg
Copy link
Member Author

Fixed the build and made sure that GH Actions also tests that.

@JohnAZoidberg
Copy link
Member Author

JohnAZoidberg commented Dec 20, 2022

image
Debugging via print and uprintf console works

keyboards/lotus/config.h Outdated Show resolved Hide resolved
keyboards/lotus/keymaps/default/keymap.c Outdated Show resolved Hide resolved
keyboards/lotus/keymaps/default/keymap.c Outdated Show resolved Hide resolved
keyboards/lotus/matrix.c Outdated Show resolved Hide resolved
keyboards/lotus/matrix.c Outdated Show resolved Hide resolved
keyboards/lotus/matrix.c Outdated Show resolved Hide resolved
keyboards/lotus/matrix.c Outdated Show resolved Hide resolved
@JohnAZoidberg
Copy link
Member Author

Firmware sizes currently:

> ls -lh .build/*uf2
-rw-rw-r-- 1 zoid zoid 98K Jan  5 17:47 .build/lotus_ansi_default.uf2
-rw-rw-r-- 1 zoid zoid 95K Jan  5 18:15 .build/lotus_gridpad_default.uf2
-rw-rw-r-- 1 zoid zoid 85K Jan  5 18:14 .build/lotus_iso_default.uf2
-rw-rw-r-- 1 zoid zoid 85K Jan  5 18:15 .build/lotus_jis_default.uf2
-rw-rw-r-- 1 zoid zoid 84K Jan  5 18:15 .build/lotus_numpad_default.uf2

Much of that is UF2 overhead. The last byte in the .hex file is 0xC244 (49732), so the FW is roughly 50K big.

@JohnAZoidberg
Copy link
Member Author

JohnAZoidberg commented Jan 7, 2023

Testing while twisting potentiometer to provide ADC voltage, set the threshold at 3V:

Framework Computer Inc:Lotus Keyboard:1: Col 10 - Row 5 - State: 0, Voltage: 3.11                                                                                                             
Framework Computer Inc:Lotus Keyboard:1: 5 ms (200 Hz)                                                                                                                                        
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.88                                                                                                                                   
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 3.9                                                                                                                                     
Framework Computer Inc:Lotus Keyboard:1: Col 10 - Row 6 - State: 0, Voltage: 3.09                                                                                                              
Framework Computer Inc:Lotus Keyboard:1: 6 ms (166 Hz)                                                                                                                                        
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.88                                                                                                                                   
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 3.5                                                                                                                                     
Framework Computer Inc:Lotus Keyboard:1: Col 10 - Row 7 - State: 0, Voltage: 3.05                                                                                                              
Framework Computer Inc:Lotus Keyboard:1: 5 ms (200 Hz)                                                                                                                                        
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.64                                                                                                                                   
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 3.2                                                                                                                                     
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 0 - State: 0, Voltage: 3.09                                                                                                              
Framework Computer Inc:Lotus Keyboard:1: 6 ms (166 Hz)                                                                                                                                        
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.88                                                                                                                                   
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 2.98                                                                                                                                    
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 1 - State: 1, Voltage: 2.98                                                                                                             
Framework Computer Inc:Lotus Keyboard:1: 5 ms (200 Hz)                                                                                                                                        
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.64                                                                                                                                   
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 2.96                                                                                                                                    
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 2 - State: 1, Voltage: 2.96                                                                                                             
Framework Computer Inc:Lotus Keyboard:1: 5 ms (200 Hz)                                                                                                                                        
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.64                                    
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 2.92                                     
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 3 - State: 1, Voltage: 2.92              
Framework Computer Inc:Lotus Keyboard:1: 6 ms (166 Hz)                                         
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.64                                    
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 2.87                                     
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 4 - State: 1, Voltage: 2.87              
Framework Computer Inc:Lotus Keyboard:1: 5 ms (200 Hz)                                         
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.88                                    
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 2.83                                     
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 5 - State: 1, Voltage: 2.83              
Framework Computer Inc:Lotus Keyboard:1: 6 ms (166 Hz)                                         
Framework Computer Inc:Lotus Keyboard:1: Temperature: 19.88                                    
Framework Computer Inc:Lotus Keyboard:1: ADC Voltage: 2.80                                     
Framework Computer Inc:Lotus Keyboard:1: Col 11 - Row 6 - State: 1, Voltage: 2.80              

@JohnAZoidberg JohnAZoidberg requested a review from kiram9 January 7, 2023 13:54
@JohnAZoidberg
Copy link
Member Author

Works out of the box with a raspberry pi pico.
Does not drive the column GPIOs because GP29 is not present on the pico, which we need to use for SDB to enable the RGB controller.
I remapped that to GP22 for now.
Will have to undefine PICO_LOTUS when we do a build for the factory next week.

@JohnAZoidberg
Copy link
Member Author

JohnAZoidberg commented Jan 7, 2023

Printing many times per cycle on the console slows QMK down A LOT! Will have to measure latency without logging every matrix scan.

@JohnAZoidberg
Copy link
Member Author

Current ANSI FW size:

Without LTO: 61924
With LTO: 49668

mux_select_row(row);

// Wait for column select to settle and propagate to ADC
wait_us(30);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably way too high. With 30us we get only 100Hz scanrate because the inner loop is executed 16*8=3840 times.
To get 1000Hz scan rate we need to keep the scan under 1000us.

@kiram9 can you help me figure out an estimate?
I'm not quite sure what many of the words on the datasheets mean.
MUX: http://www.sg-micro.com/uploads/soft/20220512/1652340158.pdf
Pico datasheet says: "Capturing a sample takes 96 clock cycles (96 × 1/48MHz) = 2μs per sample (500ksps)." But currently I'm using the function that sleeps until the interrupt wakes it up when the measurement is done.

*/
static void read_adc(void) {
// Need to sleep a bit, otherwise we seem to get stuck
wait_us(5);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be fine now actually, changed some other code and probably don't need this anymore.

@JohnAZoidberg JohnAZoidberg removed the request for review from kiram9 February 8, 2023 06:47
Signed-off-by: Daniel Schaefer <dhs@frame.work>
If the backlight brightness was changed and the keyboard unplugged and
replugged, the lights would stay off. They should come back to the
previous value, which will happen automatically but the code would
override.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Factory mode enables layer 2 which has a regular keycode mapped to every
key. This way the factory can easily test whether the keys are working
or not.
It can either be disabled again or it'll turn of itself when the
keyboard resets.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Our schematic uses these custom names but they just map to the
per-controller names.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Previous URLs are not set up yet.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
@pdalpra
Copy link

pdalpra commented Feb 20, 2024

@JohnAZoidberg Sorry to hijack this PR but is it the current best source to build a custom firmware (=> not using VIA's web UI) ?

@Blue-Sauce
Copy link

@JohnAZoidberg Sorry to hijack this PR but is it the current best source to build a custom firmware (=> not using VIA's web UI) ?

v0.2.9 is the latest version. You can find it here
https://github.com/FrameworkComputer/qmk_firmware/tree/v0.2.9/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.