BTT belter

This commit is contained in:
2026-01-22 22:28:52 +01:00
parent fa3cd23ec5
commit 3252d53c55
2 changed files with 46 additions and 1 deletions

View File

@@ -2,6 +2,9 @@
My collection of useful shell scripts. My collection of useful shell scripts.
### belter_tension_calculator.sh
script to calculate the tension with the readings from [BigTreeTech belter tool](https://bttwiki.com/belter.html) in mm, formula from the xlsx on their [git](https://github.com/bigtreetech/Belter-belt-tension-Tool).
### randint.sh ### randint.sh
usage: randint \<positive integer\> usage: randint \<positive integer\>
print in the terminal a random integer x with $` 0 \leq x \leq \$1`$ print in the terminal a random integer x with $` 0 \leq x \leq \$1`$

42
belter_tension_calculator.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
if ! [[ "$1" =~ ^-?[0-9](\.[0-9]+)?+$ ]]; then
echo "Usage: $0 <Belter display value (mm)>"
exit 1
fi
echo "Belter display value: $1mm"
tension=$(awk -v x="$1" 'BEGIN {
if (x < 0) x = -x
printf "%.3f", 7.673640167 * x - 33.7167364
}')
echo "Belt tension: $tension N"
echo ""
ESC=$'\033'
GREEN="${ESC}[32m"
RED="${ESC}[31m"
RESET="${ESC}[0m"
check_range() {
local label="$1"
local min="$2"
local max="$3"
awk -v t="$tension" -v min="$min" -v max="$max" \
-v label="$label" -v G="$GREEN" -v R="$RED" -v Z="$RESET" '
BEGIN {
if (t >= min && t <= max)
printf "%s 🟩 %s[%.1f, %.1f] N%s\n", label, G, min, max, Z
else
printf "%s 🟥 %s[%.1f, %.1f] N%s\n", label, R, min, max, Z
}'
}
echo "Reference tensions:"
check_range "Voron A/B belts :" 7.8 15
check_range "Voron 2.4 Z belts :" 20.4 25.8
check_range "V350/250 belts :" 12 20
check_range "GT2 belts :" 20 30