Just an addition to @Tom's very nice answer. With these definitions, it is possible to parameterize the decorations using amplitude and segmengt length. Their result is stored in the TeX-dimensions \pgfdecorationsegmentamplitude and \pgfdecorationsegmentlength respectively. I also added an argument to the style defintions, which makes it possible to locally overwrite the default values.
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{kinematikz}
\pgfdeclaredecoration{lspr}{initial}
{
\state{initial}[width=\pgfdecorationsegmentlength]
{
\pgfpathmoveto{\pgfpoint{\pgfdecorationsegmentlength/3}{\pgfdecorationsegmentamplitude}}
\pgfpathlineto{\pgfpoint{\pgfdecorationsegmentlength/3*2}{-\pgfdecorationsegmentamplitude}}
}
\state{final}
{
\pgfpathmoveto{\pgfpointdecoratedpathlast}
}
}
\pgfdeclaredecoration{rspr}{initial}
{
\state{initial}[width=\pgfdecorationsegmentlength]
{
\pgfpathlineto{\pgfpoint{\pgfdecorationsegmentlength/3}{\pgfdecorationsegmentamplitude}}
\pgfpathmoveto{\pgfpoint{\pgfdecorationsegmentlength/3*2}{-\pgfdecorationsegmentamplitude}}
\pgfpathlineto{\pgfpoint{\pgfdecorationsegmentlength}{0pt}}
}
\state{final}
{
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\tikzset{
rspring/.style = {
thick,decorate,green!40!black,decoration={rspr, amplitude=12pt, segment length=12pt, #1}
},
lspring/.style = {
thick,decorate,green!40!black,decoration={lspr, amplitude=12pt, segment length=12pt, #1}
},
}
\begin{document}
\begin{tikzpicture}
\coordinate (P1) at (0,0);
\coordinate (P2) at (5,0);
\draw[lspring] (P1) -- (P2);
\pic (bar) at (P1) {link bar generic=P2/0};
\draw[rspring] (P1) -- (P2);
\begin{scope}[yshift=-1.2cm]
\coordinate (P3) at (0,0);
\coordinate (P4) at (5,0);
\draw[lspring={amplitude=14pt, segment length=17pt}] (P3) -- (P4);
\pic (bar) at (P3) {link bar generic=P4/0};
\draw[rspring={amplitude=14pt, segment length=17pt}] (P3) -- (P4);
\end{scope}
\end{tikzpicture}
\end{document}

I am once again amazed how easy and flexible TikZ/PGF is!
foreachloop and some computations. – SebGlav May 24 '22 at 11:52