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

Expander_templates #567

Merged
merged 8 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/mcu_definitions/expander/Arduino_nano.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[board_pins nano_manufacturer]
mcu: nano
aliases:
MCU_TX1=PD1 , MCU_RX0=PD0 ,
MCU_D2=PD2 , MCU_D3=PD3 , MCU_D4=PD4 , MCU_D5=PD5 , MCU_D6=PD6 , MCU_D7=PD7 , MCU_D8=PB0 , MCU_D9=PB1 , MCU_D10=PB2 , MCU_D11=PB3 , MCU_D12=PB4 , MCU_D13=PB5 ,
MCU_A0=PC0 , MCU_A1=PC1 , MCU_A2=PC2 , MCU_A3=PC3 , MCU_A4=PC4 , MCU_A5=PC5 ,
20 changes: 20 additions & 0 deletions config/mcu_definitions/expander/STM32_Klipper_Expander.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[board_pins expander_manufacturer]
mcu: expander
aliases:
# Mosfets
MCU_M0=PA0 , MCU_M1=PA1 , MCU_M2=PA2 , MCU_M3=PA3 ,

# Thermistor
MCU_T0=PA6 , MCU_T1=PA5 ,

# Neopixel header
MCU_DATA=PB1 ,

# I2C Header
MCU_SLC=PF1 , MCU_SDA=PF0 ,

# GPIO
MCU_PA7=PA7 ,

# Onboard Led
MCU_LED=PA4 ,
32 changes: 30 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function install_mcu_templates {
fi
fi

# Finally see if the user use an MMU/ERCF board
# Next see if the user use an MMU/ERCF board
read < /dev/tty -rp "[CONFIG] Do you have an MMU/ERCF MCU and want to install a template? (y/N) " install_mmu_template
if [[ -z "$install_mmu_template" ]]; then
install_mmu_template="n"
Expand Down Expand Up @@ -240,8 +240,36 @@ function install_mcu_templates {
printf "[CONFIG] No MMU/ERCF template selected. Skip and continuing...\n\n"
fi
fi
}

# Finally see if the user use an expander board
read < /dev/tty -rp "[CONFIG] Do you have an expander board and want to install a template? (y/N) " install_expander_template
if [[ -z "$install_expander_template" ]]; then
install_expander_template="n"
fi
install_expander_template="${install_expander_template,,}"

# Check if the user wants to install an expander MCU template
if [[ "$install_expander_template" =~ ^(yes|y)$ ]]; then
file_list=()
while IFS= read -r -d '' file; do
file_list+=("$file")
done < <(find "${FRIX_CONFIG_PATH}/user_templates/mcu_defaults/expand" -maxdepth 1 -type f -print0)
echo "[CONFIG] Please select your expander MCU in the following list:"
for i in "${!file_list[@]}"; do
echo " $((i+1))) $(basename "${file_list[i]}")"
done

read < /dev/tty -p "[CONFIG] Template to install (or 0 to skip): " expander_template
if [[ "$expander_template" -gt 0 ]]; then
# If the user selected a file, copy its content into the mcu.cfg file
filename=$(basename "${file_list[$((expander_template-1))]}")
cat "${FRIX_CONFIG_PATH}/user_templates/mcu_defaults/expand/$filename" >> ${USER_CONFIG_PATH}/mcu.cfg
printf "[CONFIG] Template '$filename' inserted into your mcu.cfg user file\n\n"
else
printf "[CONFIG] No expander template selected. Skip and continuing...\n\n"
fi
fi
}

# Step 5: restarting Klipper
function restart_klipper {
Expand Down
32 changes: 32 additions & 0 deletions user_templates/mcu_defaults/expander/Arduino_nano.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#------------------------------------------------#
#### Adruino Nano ATmega328P board definition ####
#------------------------------------------------#

[mcu nano]
##--------------------------------------------------------------------
serial: /dev/serial/by-id/change-me-to-the-correct-mcu-path
restart_method: command
##--------------------------------------------------------------------

# For use with Arduino Nano with ATmega328P (8-bit AVR family)
# If you want to override the wiring of Arduino Nano board, keep in mind that this
# board is defined using the "nano" name. So you should use "pin: nano:PIN_NAME"
# in your own overrides.cfg files.
# You can rename here your PIN_NAME to be used in Klippain macros or in your own.

[include config/mcu_definitions/expander/Arduino_nano.cfg] # Do not remove this line
[board_pins nano_mcu]
mcu: nano
aliases:
# Digital I/O pins
NANO_TX1=MCU_TX1 , NANO_RX0=MCU_RX0 ,
NANO_D3=MCU_D3 , NANO_D5=MCU_D5 , NANO_D6=MCU_D6 , NANO_D9=MCU_D9 , NANO_D10_SS=MCU_D10 , NANO_D11_MOSI=MCU_D11 , # with PWM output for exemple for fans and output_pin devices or any others I/O devices
NANO_D2=MCU_D2 , NANO_D4=MCU_D4 , NANO_D7=MCU_D7 , NANO_D8=MCU_D8 , NANO_D12_MISO=MCU_D12 , NANO_D13_SCK=MCU_D13 , # without PWM for exemple for fans, heaters, servos, leds (Rem: D13 used for Inbuilt LED)

# Analog Input pins
NANO_A0=MCU_A0 , NANO_A1=MCU_A1 , NANO_A2=MCU_A2 , NANO_A3=MCU_A3 , NANO_A4_I2C=MCU_A4 , NANO_A5_I2C=MCU_A5 , # can be used (for exemple) for thermistors

# Status LED lights when klipper connects
[static_digital_output onboardANLED]
pins: nano:NANO_D13_SCK

31 changes: 31 additions & 0 deletions user_templates/mcu_defaults/expander/STM32_Klipper_Expander.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#-----------------------------------------------#
#### STM32 Klipper Expander board definition ####
#-----------------------------------------------#

[mcu expander]
##--------------------------------------------------------------------
serial: /dev/serial/by-id/change-me-to-the-correct-mcu-path
restart_method: command
##--------------------------------------------------------------------

# For use with https://github.com/VoronDesign/Voron-Hardware/tree/master/Klipper_Expander
# If you want to override the wiring of the STM32 Klipper Expander board, keep in mind that this
# board is defined using the "expand" name. So you should use "pin: expand:PIN_NAME"
# in your own overrides.cfg files.
# You can rename here your PIN_NAME to be used in Klippain macros or in your own.

[include config/mcu_definitions/expander/STM32_Klipper_Expander.cfg] # Do not remove this line
[board_pins expander_mcu]
mcu: expander
aliases:
EXP_FAN0=MCU_M0 , EXP_FAN1=MCU_M1 , EXP_FAN2=MCU_M2 , EXP_FAN3=MCU_M3 , # can be use for fans, Leds, Heaters ...
EXP_TEMP0=MCU_T0 , EXP_TEMP1=MCU_T1 , # for thermistor
EXP_NEOPIXEL=MCU_DATA ,
EXP_SLC=MCU_SLC , EXP_SDA=MCU_SDA , # for 3.3V displays or sensors
EXP_PA7=MCU_PA7 , # can be use for external mosfet, relay or a door open sensor
EXP_ONBOARDLED=MCU_LED , # onboard status led

# Status LED lights when klipper connects
[static_digital_output onboardKELED]
pins: !expander:EXP_ONBOARDLED