A year or so ago I put together an experimental branch with some example configs reorganized so that there is a “board_pins” section at the top of the file. This topic is for discussing that potential change to the Klipper example configs.
For example - the top of the generic-rambo.cfg file:
# Add human-readable names for pins on "rambo" style boards
[board_pins rambo]
aliases:
# Stepper motor pins
X_STEP=PC0, X_DIR=PL1, X_ENABLE=PA7,
Y_STEP=PC1, Y_DIR=PL0, Y_ENABLE=PA6,
Z_STEP=PC2, Z_DIR=PL2, Z_ENABLE=PA5,
E_STEP=PC3, E_DIR=PL6, E_ENABLE=PA4,
E1_STEP=PC4, E1_DIR=PL7, E1_ENABLE=PA3,
# Endstop pins
X_MIN=PB6, X_MAX=PA2, Y_MIN=PB5, Y_MAX=PA1, Z_MIN=PB4, Z_MAX=PC7,
# Heater and fan pins
E_HEATER=PH6, E_THERMISTOR=PF0,
E1_HEATER=PH4, E1_THERMISTOR=PF1,
BED_HEATER=PE5, BED_THERMISTOR=PF2,
RAMBO_FAN0=PH5, RAMBO_FAN1=PH3,
# Rambo board specific pins
RAMBO_LED=PB7,
RAMBO_DIGIPOT_CS=PD7,
RAMBO_X_MS1=PG1, RAMBO_X_MS2=PG0,
RAMBO_Y_MS1=PK7, RAMBO_Y_MS2=PG2,
RAMBO_Z_MS1=PK6, RAMBO_Z_MS2=PK5,
RAMBO_E_MS1=PK3, RAMBO_E_MS2=PK4,
RAMBO_E1_MS1=PK1, RAMBO_E1_MS2=PK2,
# EXP1 header pins (see sample-lcd.cfg file for common LCD displays)
EXP1_1=PE6, EXP1_3=PG3, EXP1_5=PJ2, EXP1_7=PJ7, EXP1_9=<GND>,
EXP1_2=PE2, EXP1_4=PG4, EXP1_6=PJ3, EXP1_8=PJ4, EXP1_10=<5V>,
# EXP2 header
EXP2_1=PB3, EXP2_3=PJ5, EXP2_5=PJ6, EXP2_7=PD4, EXP2_9=<GND>,
EXP2_2=PB1, EXP2_4=PB0, EXP2_6=PB2, EXP2_8=PE7, EXP2_10=PH2
# Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "spi"
The code with this change is at https://github.com/KevinOConnor/klipper-dev/tree/work-pins-20201222.
I do think doing this could improve the example configs. However, it didn’t seem that there was much of a preference one way or another on this change, so it has never moved forward. The advantage of defining the aliases is that it can make the pin assignments later in the config a little more transparent to users and it can make it a little easier to define all the pins in one area when translating a schematic. A possible disadvantage is that it introduces some complexity and may make the config less transparent.
There was a previous discussion on this topic at https://github.com/Klipper3d/klipper/pull/3671.
-Kevin