#!/usr/bin/env bash
#
# Build tests for STM32H743VI_btt
# Ender-5 Plus with SKR V3.0 (STM32H7)
#

# exit on first failure
set -e

#
# Build with the default configurations
#
restore_configs
use_example_configs "Creality/Ender-5 Plus/BigTreeTech SKR 3"
opt_set DEFAULT_MAX_FEEDRATE '{ 6250, 6250, 15, 5375 }'
exec_test $1 $2 "Creality Ender-5 Plus with BigTreeTech SKR 3" "$3"


#
# SKR 3 EZ default
#
restore_configs
opt_set MOTHERBOARD BOARD_BTT_SKR_V3_0_EZ SERIAL_PORT -1
exec_test $1 $2 "BigTreeTech SKR 3 EZ | Default Configuration" "$3"

#
# SKR 3 EZ with MMU2
#
restore_configs
opt_set MOTHERBOARD BOARD_BTT_SKR_V3_0_EZ SERIAL_PORT -1 \
        BAUDRATE 115200 X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 \
        Z_DRIVER_TYPE TMC2209 Z2_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 \
        EXTRUDERS 5 MMU_MODEL PRUSA_MMU2 HEATER_0_MAXTEMP 305 \
        BED_MAXTEMP 125 HOTEND_OVERSHOOT 5 INVERT_X_DIR true \
        INVERT_E0_DIR true X_BED_SIZE 235 Y_BED_SIZE 225 Z_MAX_POS 240 \
        GRID_MAX_POINTS_X 5 E0_AUTO_FAN_PIN FAN1_PIN \
        BLTOUCH_HS_MODE true BLTOUCH_HS_EXTRA_CLEARANCE 0 \
        Z_STEPPER_ALIGN_XY '{{10,110},{200,110}}' \
        Z_STEPPER_ALIGN_ITERATIONS 10 DEFAULT_STEPPER_TIMEOUT_SEC 0 \
        SLOWDOWN_DIVISOR 16 SDCARD_CONNECTION ONBOARD BLOCK_BUFFER_SIZE 64 \
        CHOPPER_TIMING CHOPPER_DEFAULT_24V MMU_SERIAL_PORT 2
opt_enable PIDTEMPBED ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION \
        USE_PROBE_FOR_Z_HOMING BLTOUCH FILAMENT_RUNOUT_SENSOR \
        AUTO_BED_LEVELING_BILINEAR RESTORE_LEVELING_AFTER_G28 \
        EXTRAPOLATE_BEYOND_GRID LCD_BED_LEVELING MESH_EDIT_MENU Z_SAFE_HOMING \
        EEPROM_SETTINGS EEPROM_AUTO_INIT NOZZLE_PARK_FEATURE SDSUPPORT \
        SPEAKER CR10_STOCKDISPLAY QUICK_HOME BLTOUCH_FORCE_SW_MODE \
        Z_STEPPER_AUTO_ALIGN INPUT_SHAPING_X INPUT_SHAPING_Y SHAPING_MENU \
        ADAPTIVE_STEP_SMOOTHING LCD_INFO_MENU STATUS_MESSAGE_SCROLLING \
        SET_PROGRESS_MANUALLY M73_REPORT SHOW_REMAINING_TIME \
        PRINT_PROGRESS_SHOW_DECIMALS AUTO_REPORT_SD_STATUS USE_BIG_EDIT_FONT \
        BABYSTEPPING BABYSTEP_WITHOUT_HOMING BABYSTEP_ALWAYS_AVAILABLE \
        DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL LIN_ADVANCE \
        BEZIER_CURVE_SUPPORT EMERGENCY_PARSER ADVANCED_PAUSE_FEATURE \
        TMC_DEBUG HOST_ACTION_COMMANDS HOST_PAUSE_M76 HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS \
        MMU_DEBUG
opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FILAMENT_LOAD_UNLOAD_GCODES PARK_HEAD_ON_PAUSE
exec_test $1 $2 "BigTreeTech SKR 3 EZ | MMU2" "$3"

#
# SKR 3 EZ with MMU3
#
restore_configs
opt_set MOTHERBOARD BOARD_BTT_SKR_V3_0_EZ SERIAL_PORT -1 \
        BAUDRATE 115200 X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 \
        Z_DRIVER_TYPE TMC2209 Z2_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 \
        EXTRUDERS 5 MMU_MODEL PRUSA_MMU3 HEATER_0_MAXTEMP 305 \
        BED_MAXTEMP 125 HOTEND_OVERSHOOT 5 INVERT_X_DIR true \
        INVERT_E0_DIR true X_BED_SIZE 235 Y_BED_SIZE 225 Z_MAX_POS 240 \
        GRID_MAX_POINTS_X 5 E0_AUTO_FAN_PIN FAN1_PIN \
        BLTOUCH_HS_MODE true BLTOUCH_HS_EXTRA_CLEARANCE 0 \
        Z_STEPPER_ALIGN_XY '{{10,110},{200,110}}' \
        Z_STEPPER_ALIGN_ITERATIONS 10 DEFAULT_STEPPER_TIMEOUT_SEC 0 \
        SLOWDOWN_DIVISOR 16 SDCARD_CONNECTION ONBOARD BLOCK_BUFFER_SIZE 64 \
        CHOPPER_TIMING CHOPPER_DEFAULT_24V MMU_SERIAL_PORT 2
opt_enable PIDTEMPBED ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION \
        USE_PROBE_FOR_Z_HOMING BLTOUCH FILAMENT_RUNOUT_SENSOR \
        AUTO_BED_LEVELING_BILINEAR RESTORE_LEVELING_AFTER_G28 \
        EXTRAPOLATE_BEYOND_GRID LCD_BED_LEVELING MESH_EDIT_MENU Z_SAFE_HOMING \
        EEPROM_SETTINGS EEPROM_AUTO_INIT NOZZLE_PARK_FEATURE SDSUPPORT \
        SPEAKER CR10_STOCKDISPLAY QUICK_HOME BLTOUCH_FORCE_SW_MODE \
        Z_STEPPER_AUTO_ALIGN INPUT_SHAPING_X INPUT_SHAPING_Y SHAPING_MENU \
        ADAPTIVE_STEP_SMOOTHING LCD_INFO_MENU STATUS_MESSAGE_SCROLLING \
        SET_PROGRESS_MANUALLY M73_REPORT SHOW_REMAINING_TIME \
        PRINT_PROGRESS_SHOW_DECIMALS AUTO_REPORT_SD_STATUS USE_BIG_EDIT_FONT \
        BABYSTEPPING BABYSTEP_WITHOUT_HOMING BABYSTEP_ALWAYS_AVAILABLE \
        DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL LIN_ADVANCE \
        BEZIER_CURVE_SUPPORT EMERGENCY_PARSER ADVANCED_PAUSE_FEATURE \
        TMC_DEBUG HOST_ACTION_COMMANDS HOST_PAUSE_M76 HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS \
        MMU_MENUS MMU3_SPOOL_JOIN_CONSUMES_ALL_FILAMENT MMU_DEBUG
opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FILAMENT_LOAD_UNLOAD_GCODES PARK_HEAD_ON_PAUSE
exec_test $1 $2 "BigTreeTech SKR 3 EZ | MMU3" "$3"
