From 3252d53c5574ba261d44abbff10ddc1c7f024c35 Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Thu, 22 Jan 2026 22:28:52 +0100 Subject: [PATCH] BTT belter --- README.md | 5 ++++- belter_tension_calculator.sh | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 belter_tension_calculator.sh diff --git a/README.md b/README.md index 6a7caaa..28e72dc 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ 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 usage: randint \ print in the terminal a random integer x with $` 0 \leq x \leq \$1`$ @@ -42,4 +45,4 @@ Automatically toggle DNS leak protection for wireguard connections with nftables Adds tcp/udp rules to block outgoing traffic to dns port (53) if the outgoing interface isn't the wireguard connection. It assumes wireguard connection names start with "wg-" - You can check for DNS leaks with [this website](https://www.dnsleaktest.com/) \ No newline at end of file + You can check for DNS leaks with [this website](https://www.dnsleaktest.com/) diff --git a/belter_tension_calculator.sh b/belter_tension_calculator.sh new file mode 100755 index 0000000..72c3fa1 --- /dev/null +++ b/belter_tension_calculator.sh @@ -0,0 +1,42 @@ +#!/bin/bash +if ! [[ "$1" =~ ^-?[0-9](\.[0-9]+)?+$ ]]; then + echo "Usage: $0 " + 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 +