[Tex/LaTex] New switches in circuitikz (no, nc)

circuitikz

I need different switches than the ones inside circuitikz. I have already drawed them with just some lines but I would like to use them like the other standard components in circuitikz. I only found some tutorials that adds a few lines to an existing component like an resistor but I have no idea how to add a complete new part. Maybe some of you is able to do that?

Here is my working minimal example:

\documentclass{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage[european]{circuitikz}

\begin{document}

\begin{circuitikz}

% Normally Open Switch
\draw[thick] (0,0) --++(0,0.5)--++(-0.4,1) coordinate (sw)
($(sw)+(0.4,0)$) --++(0,0.5);

% Normally Closed Switch
\draw[thick] (3,0) --++(0,0.5)--++(0.4,1) coordinate (sw)
($(sw)+(-0.4,-0.4)$) --++(0,0.9) 
($(sw)+(-0.4,-0.4)$) --++(0.4,0);

\end{circuitikz}

\end{document}

The result:

This is how it looks like

I would like to get the same result with this:

\documentclass{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage[european]{circuitikz}

\begin{document}

\begin{circuitikz}

% Normally Open Switch
\draw (0,0) to[nos] (0,2);

% Normally Closed Switch
\draw (3,0) to[ncs] (3,2);

\end{circuitikz}

\end{document}

Thank you!

Best Answer

I used the same height, width and depth parameters for the Offner and Schliesser.

\documentclass[border=5pt]{standalone}

%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
%\usepackage[ngerman]{babel}

\usepackage[european]{circuitikz}

\makeatletter
\ctikzset{bipoles/offner/height/.initial=.35}
\ctikzset{bipoles/offner/width/.initial=.5}
\ctikzset{bipoles/offner/depth/.initial=.1}

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/offner/depth}}{nos}{\ctikzvalof{bipoles/offner/height}}{\ctikzvalof{bipoles/offner/width}}{
            \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
            \pgfusepath{draw}
}
\def\nospath#1{\pgf@circ@bipole@path{nos}{#1}}
\compattikzset{nos/.style = {\circuitikzbasekey, /tikz/to path=\nospath, l=#1}}

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/offner/height}}{ncs}{\ctikzvalof{bipoles/offner/depth}}{\ctikzvalof{bipoles/offner/width}}{
            \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@down}}
            \pgfusepath{draw}
      \pgfsetlinewidth{\pgfstartlinewidth}
      \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
      \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
      \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@down}}
      \pgfusepath{draw}
}
\def\ncspath#1{\pgf@circ@bipole@path{ncs}{#1}}
\compattikzset{ncs/.style = {\circuitikzbasekey, /tikz/to path=\ncspath, l=#1}}
\makeatother

\begin{document}

\begin{circuitikz}

% Normally Open Switch
\draw (0,0) to[nos] (0,2);

% Normally Closed Switch
\draw (3,0) to[ncs] (3,2);

\end{circuitikz}

\end{document}

demo