% schulmathematik bundle: package schulma-physik
% Version 1.7
% 16. April 2025
\ProvidesExplPackage{schulma-physik}{2025-04-16}{1.7}{Befehle für die Schulphysik}

\newif \ifschulma@physik@circuitikz % keine expl3-Syntax möglich, da von circuits.ee.IEC nicht unterstützt

\DeclareOption {circuitikz}
  {
    \schulma@physik@circuitikztrue
  }

\ProcessOptions \relax

\RequirePackage {siunitx}
\RequirePackage {tikz}

\sisetup { locale = DE , uncertainty-mode = separate }

\NewDocumentCommand \Massstab {m m m m}
  {
    \ensuremath
      {
        \qty {#1} {#2}
        \; \widehat {=} \;
        \qty {#3} {#4}
      }
  }

\NewDocumentCommand \tqty {m m}
  {
    \ensuremath
      {
        \group_begin:
        \textstyle
        \qty [ per-mode = fraction ] {#1} {#2}
        \group_end:
      }
  }

\cs_new_eq:NN \tSI \tqty

\NewDocumentCommand \tunit {m}
  {
    \ensuremath
      {
        \group_begin:
        \textstyle
        \unit [ per-mode = fraction ] {#1}
        \group_end:
      }
  }

\cs_new_eq:NN \tsi \tunit

\NewDocumentCommand \Beschl {m}
  {
    \tqty {#1} { \m \per \square \s }
  }

\NewDocumentCommand \Erdb { }
  {
    \tqty {9,81} { \m \per \square \s }
  }

\NewDocumentCommand \Ortsf { }
  {
    \tqty {9,81} { \N \per \kg }
  }

\NewDocumentCommand \Elem { }
  {
    \qty {1,60e-19} {\coulomb}
  }

\NewDocumentCommand \Elekm { }
  {
    \qty {9,11e-31} {\kg}
  }

\NewDocumentCommand \Lichtg { }
  {
    \qty {3,00e8} { \m \per \s }
  }

\NewDocumentCommand \Planck { }
  {
    \qty {6,63e-34} { \J \s }
  }

\NewDocumentCommand \EFK { }
  {
    \qty {8,85e-12} { \A \s \per \V \per \m }
  }

\NewDocumentCommand \MFK {s}
  {
    \IfBooleanTF {#1}
      {
        \qty {1,26e-6} { \V \s \per \A \per \m }
      }
      {
        \ensuremath
          {
            4 \,
            \cs_if_exist_use:N \symup
            \pi
            \cdot
            \qty [ print-unity-mantissa = false ] {e-7} { \V \s \per \A \per \m }
          }
      }
  }

\dim_const:Nn \c_schulma_physik_messschieber_l_skala_dim {15.2cm}
\dim_const:Nn \c_schulma_physik_messschieber_b_skala_dim {15mm}
\dim_const:Nn \c_schulma_physik_messschieber_l_schieber_dim {4cm}
\dim_const:Nn \c_schulma_physik_messschieber_b_schieber_dim {17mm}
\dim_const:Nn \c_schulma_physik_messschieber_l_fenster_dim {25mm}
\dim_const:Nn \c_schulma_physik_messschieber_b_fenster_dim {1cm}
\dim_const:Nn \c_schulma_physik_messschieber_randabstand_dim {1mm}

\bool_new:N \l_schulma_physik_messschieber_cm_bool
\bool_new:N \l_schulma_physik_messschieber_inch_bool

\msg_new:nnn {schulma-physik} {falsche Option}
  {
    #1~ist~keine~gültige~Option~für~einen~Messschieber.
  }

\NewDocumentCommand \Messschieber {om}
  {
    \IfValueTF {#1}
      {
        \str_case:nnF {#1}
          {
            {cm} {
                   \bool_set_true:N \l_schulma_physik_messschieber_cm_bool
                   \bool_set_false:N \l_schulma_physik_messschieber_inch_bool
                 }
            {inch} {
                     \bool_set_false:N \l_schulma_physik_messschieber_cm_bool
                     \bool_set_true:N \l_schulma_physik_messschieber_inch_bool
                   }
            {cm+inch} {
                        \bool_set_true:N \l_schulma_physik_messschieber_cm_bool
                        \bool_set_true:N \l_schulma_physik_messschieber_inch_bool
                      }
          }
          {
            \msg_warning:nnn {schulma-physik} {falsche Option} {#1}
          }
      }
      {
        \bool_set_true:N \l_schulma_physik_messschieber_cm_bool
        \bool_set_false:N \l_schulma_physik_messschieber_inch_bool
      }

    \begin {tikzpicture} [ font = \sffamily ]
    % Hauptskala
    \draw ( -1.6cm , 0 )
      -- ++ ( \c_schulma_physik_messschieber_l_skala_dim , 0 )
      \bool_if:NT \l_schulma_physik_messschieber_cm_bool { node [ above~left ] { \small cm } }
      -- ++ ( 0 , \c_schulma_physik_messschieber_b_skala_dim )
      \bool_if:NT \l_schulma_physik_messschieber_inch_bool { node [ below~left ] { \small inch } }
      -- ++ ( - \c_schulma_physik_messschieber_l_skala_dim , 0)
      -- cycle ;
    \bool_if:NT \l_schulma_physik_messschieber_cm_bool
      {
        \int_step_inline:nnn {0} {120}
          {
            \int_set:Nn \l_tmpa_int { \int_mod:nn {##1} {10} }
            \int_compare:nNnTF {\l_tmpa_int} = {0}
              {
                \draw ( ##1*1mm , \c_schulma_physik_messschieber_randabstand_dim ) -- ++ ( 0, 6.5mm )
                  node [ left = -2pt , yshift = -2.5pt ] { \footnotesize \int_eval:n {##1/10} } ;
              }
              {
                \int_compare:nNnTF {\l_tmpa_int} = {5}
                  {
                    \draw ( ##1*1mm , \c_schulma_physik_messschieber_randabstand_dim ) -- ++ ( 0 , 5.25mm );
                  }
                  {
                    \draw ( ##1*1mm , \c_schulma_physik_messschieber_randabstand_dim ) -- ++ ( 0 , 4mm );
                  }
              }
          }
      }
    \bool_if:NT \l_schulma_physik_messschieber_inch_bool
      {
        \int_step_inline:nnn {0} {80}
          {
            \int_set:Nn \l_tmpa_int { \int_mod:nn {##1} {16} }
            \int_compare:nNnTF {\l_tmpa_int} = {0}
              {
                \draw ( ##1*0.0625in , \c_schulma_physik_messschieber_b_skala_dim - \c_schulma_physik_messschieber_randabstand_dim ) -- ++ (0,-6mm)
                  node [ left = -2pt , yshift = 3pt ] { \footnotesize \int_eval:n {##1/16} } ;
              }
              {
                \int_compare:nNnTF {\l_tmpa_int} = {8}
                  {
                    \draw (##1*0.0625in , \c_schulma_physik_messschieber_b_skala_dim - \c_schulma_physik_messschieber_randabstand_dim ) -- ++ (0,-5mm) ;
                  }
                  {
                    \int_if_even:nTF {##1}
                      {
                        \draw ( ##1*0.0625in , \c_schulma_physik_messschieber_b_skala_dim - \c_schulma_physik_messschieber_randabstand_dim ) -- ++ (0,-4mm) ;
                      }
                      {
                        \draw ( ##1*0.0625in , \c_schulma_physik_messschieber_b_skala_dim - \c_schulma_physik_messschieber_randabstand_dim ) -- ++ (0,-3mm) ;
                      }
                  }
              }
          }
      }
    % Schieber
    \draw [ fill = white , even~odd~rule ]
      ( #2cm - 0.5 * \c_schulma_physik_messschieber_l_schieber_dim + 4.5mm ,
        -0.5 * \c_schulma_physik_messschieber_b_schieber_dim + 0.5 * \c_schulma_physik_messschieber_b_skala_dim )
      rectangle ++ ( \c_schulma_physik_messschieber_l_schieber_dim , \c_schulma_physik_messschieber_b_schieber_dim )
      { [rounded~corners = 0.5 * \c_schulma_physik_messschieber_b_fenster_dim ]
        ( #2cm - 0.5 * \c_schulma_physik_messschieber_l_fenster_dim + 4.5mm ,
          0.5 \c_schulma_physik_messschieber_b_skala_dim - 0.5 \c_schulma_physik_messschieber_b_fenster_dim )
        rectangle ++ ( \c_schulma_physik_messschieber_l_fenster_dim , \c_schulma_physik_messschieber_b_fenster_dim ) } ;
    % Noniusskala
    \bool_if:NT \l_schulma_physik_messschieber_cm_bool
      {
        \int_step_inline:nnn {0} {10}
          {
            \int_set:Nn \l_tmpa_int { \int_mod:nn {##1} {10} }
            \int_compare:nNnTF {\l_tmpa_int} = {0}
              {
                \draw ( #2cm + ##1 * 0.9mm , 0.5 \c_schulma_physik_messschieber_b_skala_dim - 0.5 \c_schulma_physik_messschieber_b_fenster_dim )
                  -- ++ ( 0 , -1.6mm ) ;
              }
              {
                \int_compare:nNnTF {\l_tmpa_int} = {5}
                  {
                    \draw ( #2cm + ##1 * 0.9mm , 0.5 \c_schulma_physik_messschieber_b_skala_dim - 0.5 \c_schulma_physik_messschieber_b_fenster_dim )
                      -- ++ ( 0 , -1.3mm ) ;
                  }
                  {
                    \draw ( #2cm + ##1 * 0.9mm , 0.5 \c_schulma_physik_messschieber_b_skala_dim - 0.5 \c_schulma_physik_messschieber_b_fenster_dim )
                      -- ++ ( 0 , -1mm ) ;
                  }
              }
          }
      }
    \bool_if:NT \l_schulma_physik_messschieber_inch_bool
      {
        \int_step_inline:nnn {0} {8}
          {
            \int_set:Nn \l_tmpa_int { \int_mod:nn {##1} {4} }
            \int_compare:nNnTF {\l_tmpa_int} = {0}
              {
                \draw ( #2cm + ##1 * 0.0546875in , 0.5 * \c_schulma_physik_messschieber_b_skala_dim + 0.5 * \c_schulma_physik_messschieber_b_fenster_dim )
                  -- ++ ( 0 , 1.6mm ) ;
              }
              {
                \int_compare:nNnTF {\l_tmpa_int} = {2}
                  {
                    \draw ( #2cm + ##1 * 0.0546875in , 0.5 * \c_schulma_physik_messschieber_b_skala_dim + 0.5 * \c_schulma_physik_messschieber_b_fenster_dim )
                      -- ++ ( 0 , 1.3mm ) ;
                  }
                  {
                    \draw ( #2cm + ##1 * 0.0546875in , 0.5 * \c_schulma_physik_messschieber_b_skala_dim + 0.5 * \c_schulma_physik_messschieber_b_fenster_dim )
                      -- ++ ( 0 , 1mm ) ;
                  }
              }
          }
      }
    \end{tikzpicture}
  }

\dim_new:N \l_schulma_physik_messschraube_massstab_dim
\dim_set:Nn \l_schulma_physik_messschraube_massstab_dim {2mm}
\dim_new:N \l_schulma_physik_messschraube_skalenstrich_y_dim
\dim_new:N \l_schulma_physik_messschraube_skalenstrich_deltay_dim
\int_new:N \l_schulma_physik_messschraube_skalenbeschriftung_int
\fp_new:N \l_schulma_physik_messschraube_hundertstelbruchteile_fp

\NewDocumentCommand \Messschraube {m}
  {
    % nach: dexteritas, https://tex.stackexchange.com/questions/472876/how-to-draw-micrometer-scale-using-tikz
    \begin{tikzpicture} [ font = \sffamily ]
    % horizontale Skala
    \draw [semithick] (0,0) -- ( #1 * \l_schulma_physik_messschraube_massstab_dim , 0 ) ;
    \int_step_inline:nnn {0} { \fp_to_int:n {#1} + 2 }
      {
        \int_compare:nNnTF { \int_mod:nn {##1} {5} } = {0}
          {
            \draw [thick] ( ##1 * \l_schulma_physik_messschraube_massstab_dim , -0.5 ) -- ++ (0,0.65) node [above] { \small ##1 } ;
          }
          {
            \draw ( ##1 * \l_schulma_physik_messschraube_massstab_dim , 0) -- ++ (0,-0.5) ;
          }
      }
    \node [ above~right ] at (-5mm,-1cm) {\small mm} ;
    % drehbare Skala
    \fp_set:Nn \l_schulma_physik_messschraube_hundertstelbruchteile_fp { #1 * 100 - \fp_to_int:n { #1 * 100} }
    \fill [white] ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1cm ) -- ++ (8mm,5mm) -- ++ (0,-3cm) -- ++ (-8mm,5mm) -- cycle ;
    \draw [thin] ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1 ) -- ++ (0,-2cm) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1cm ) -- ++ (8mm,5mm) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , -1cm ) -- ++ (8mm,-5mm) ;
    \int_step_inline:nnn {-17} {17}
      {
        \int_set:Nn \l_schulma_physik_messschraube_skalenbeschriftung_int
          {
            \int_mod:nn { \fp_to_int:n { #1 * 100 } + ##1 } {100}
          }
        \dim_set:Nn \l_schulma_physik_messschraube_skalenstrich_y_dim
          {
            \fp_eval:n { ( ##1 - \l_schulma_physik_messschraube_hundertstelbruchteile_fp ) / 18 } cm
          }
        \int_compare:nNnTF { \int_mod:nn {\l_schulma_physik_messschraube_skalenbeschriftung_int} {5} } = {0}
          {
            % langer Strich mit Zahl
            \dim_set:Nn \l_schulma_physik_messschraube_skalenstrich_deltay_dim { 4.375mm * ##1/18 }
            \int_compare:nNnTF {\l_schulma_physik_messschraube_skalenbeschriftung_int} < {10}
              {
                \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , \l_schulma_physik_messschraube_skalenstrich_y_dim )
                  -- ++ ( 7mm , \l_schulma_physik_messschraube_skalenstrich_deltay_dim )
                  node [right] { \footnotesize 0 \int_to_arabic:n {\l_schulma_physik_messschraube_skalenbeschriftung_int} } ;
              }
              {
                \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , \l_schulma_physik_messschraube_skalenstrich_y_dim )
                  -- ++ ( 7mm , \l_schulma_physik_messschraube_skalenstrich_deltay_dim )
                  node [right] { \footnotesize \int_to_arabic:n {\l_schulma_physik_messschraube_skalenbeschriftung_int} } ;
              }
          }
          {
            % kurzer Strich
            \dim_set:Nn \l_schulma_physik_messschraube_skalenstrich_deltay_dim { 2.5mm * ##1/18 }
            \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , \l_schulma_physik_messschraube_skalenstrich_y_dim )
              -- ++ ( 4mm , \l_schulma_physik_messschraube_skalenstrich_deltay_dim ) ;
          }
       }
    % oberer und unterer Rand
    \draw (-5mm,1cm) -- ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1cm ) ;
    \draw (-5mm,-1cm) -- ( #1 * \l_schulma_physik_messschraube_massstab_dim , -1cm ) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim + 8mm, 1.5cm ) -- ++ (2cm,0) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim + 8mm, -1.5cm ) -- ++ (2cm,0) ;
    % geschwungene Linien links und rechts
    \draw (-5mm,-1cm) to [ out=130 , in=-130 ] (-5mm,0) to [ out=130 , in=-130 ] (-5mm,1cm) ;
    \draw [very~thin] (-5mm,0) to [ out=50 , in=-50 ] (-5mm,1cm) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim + 2.8cm , 1.5cm ) to [ out=-50 , in=50 ] ++ (0,-1.5cm) to [ out=-50 , in=50 ] ++ (0,-1.5cm) ;
    \draw [very~thin] ( #1 * \l_schulma_physik_messschraube_massstab_dim + 2.8cm , 0 ) to [ out=130 , in=-130 ] ++ (0,1.5cm) ;
    \end{tikzpicture}
  }

\dim_new:N \l_schulma_physik_kraftmesser_breite_skala_dim
\dim_set:Nn \l_schulma_physik_kraftmesser_breite_skala_dim {1cm}
\dim_new:N \l_schulma_physik_kraftmesser_laenge_skala_dim
\dim_set:Nn \l_schulma_physik_kraftmesser_laenge_skala_dim {9cm}
\dim_new:N \l_schulma_physik_kraftmesser_breite_huelse_dim
\dim_set:Nn \l_schulma_physik_kraftmesser_breite_huelse_dim {1.1cm}
\dim_new:N \l_schulma_physik_kraftmesser_laenge_huelse_dim
\dim_set:Nn \l_schulma_physik_kraftmesser_laenge_huelse_dim {3cm}
\dim_new:N \l_schulma_physik_kraftmesser_offset_huelse_dim
\dim_set:Nn \l_schulma_physik_kraftmesser_offset_huelse_dim {0.5pt}


\NewDocumentCommand \Kraftmesser {mm}
  {
    \begin{tikzpicture} [ font = { \sffamily \bfseries \footnotesize } ]
    % Haken
    \draw [ very~thick ] ( 0 , -#1/#2 * \l_schulma_physik_kraftmesser_laenge_skala_dim ) -- ++ (0,-6mm) arc [ start~angle = 90 , end~angle = 380 , radius = 2mm ] ;
    % ausziehbare Skala
    \int_step_inline:nn { \fp_eval:n { round ( 10*#1/#2 + 1 ) } }
      {
        \int_if_even:nTF {##1}
          {
            \str_set:Nn \l_tmpa_str {red}
          }
          {
            \str_set:Nn \l_tmpa_str {white}
          }

        \draw [ fill = \l_tmpa_str ]
          ( -0.5 * \l_schulma_physik_kraftmesser_breite_skala_dim , \fp_to_decimal:n { -#1/#2 + (##1-1)/10 } * \l_schulma_physik_kraftmesser_laenge_skala_dim )
          to [ out = -20 , in = 200 ] node [above] { \int_compare:nNnT {##1} = {1} {N} }
          ++ ( \l_schulma_physik_kraftmesser_breite_skala_dim , 0 )
          -- ++ ( 0, 0.1 * \l_schulma_physik_kraftmesser_laenge_skala_dim )
          to [ out = 200 , in = -20 ]
          node [ below , inner~sep = 2pt ] { \num [ mode = text , reset-text-family = false , reset-text-series = false ] { \fp_to_decimal:n {##1/10*#2} } }
          ++ ( -\l_schulma_physik_kraftmesser_breite_skala_dim , 0 ) -- cycle ;
      }
    % Überstand der Skala
    \draw [ fill = white ] ( -0.5 * \l_schulma_physik_kraftmesser_breite_skala_dim , -#1/#2 * \l_schulma_physik_kraftmesser_laenge_skala_dim - 1.5mm )
      to [ out = -20 , in = 200 ] ++ ( \l_schulma_physik_kraftmesser_breite_skala_dim , 0 ) -- ++ (0,1.5mm)
      to [ out = 200 , in = -20 ] ++ ( -\l_schulma_physik_kraftmesser_breite_skala_dim , 0 ) -- cycle ;
    % mittlere Striche
    \begin {scope}
    \clip ( 0.25 \l_schulma_physik_kraftmesser_breite_skala_dim , 0 )
      rectangle ( 0.5 \l_schulma_physik_kraftmesser_breite_skala_dim , -#1/#2 * \l_schulma_physik_kraftmesser_laenge_skala_dim ) ;
    \int_step_inline:nn { \fp_eval:n { ceil ( 100*#1/#2 ) } }
      {
        \int_compare:nNnT { \int_mod:nn {##1} {10} } = {5}
          {
            \draw ( -0.5 \l_schulma_physik_kraftmesser_breite_skala_dim , \fp_to_decimal:n { -#1/#2 + ##1/100 } * \l_schulma_physik_kraftmesser_laenge_skala_dim )
              to [ out = -20 , in = 200 ] ++ ( \l_schulma_physik_kraftmesser_breite_skala_dim , 0 ) ;
          }
      }
    \end {scope}
    % kleine Striche
    \begin {scope}
    \clip ( 0.35 \l_schulma_physik_kraftmesser_breite_skala_dim , 0 )
      rectangle ( 0.5 \l_schulma_physik_kraftmesser_breite_skala_dim , -#1/#2 * \l_schulma_physik_kraftmesser_laenge_skala_dim ) ;
    \int_step_inline:nn { \fp_eval:n { ceil ( 100*#1/#2 ) } }
      {
        \int_compare:nNnT { \int_mod:nn {##1} {5} } > {0}
          {
            \draw ( -0.5 \l_schulma_physik_kraftmesser_breite_skala_dim , \fp_to_decimal:n { -#1/#2 + ##1/100 } * \l_schulma_physik_kraftmesser_laenge_skala_dim )
              to [ out = -20 , in = 200 ] ++ ( \l_schulma_physik_kraftmesser_breite_skala_dim , 0 ) ;
          }
      }
    \end {scope}
    % Hülse
    \draw [ fill = cyan ] ( -0.5 * \l_schulma_physik_kraftmesser_breite_huelse_dim , \l_schulma_physik_kraftmesser_offset_huelse_dim )
      -- ++ ( 0 , \l_schulma_physik_kraftmesser_laenge_huelse_dim )
      to [ out = -20 , in = 200 ] ++ ( 0.5 * \l_schulma_physik_kraftmesser_breite_huelse_dim , 0 )
      to [ out = 20 , in = 160 ] ++ ( 0.5 * \l_schulma_physik_kraftmesser_breite_huelse_dim , 0 ) -- ++ ( 0 , -\l_schulma_physik_kraftmesser_laenge_huelse_dim )
      to [ out = 200 , in = -20 ] cycle ;
    \draw [ fill = cyan!60 ]
      ( -0.5 * \l_schulma_physik_kraftmesser_breite_huelse_dim , \l_schulma_physik_kraftmesser_laenge_huelse_dim + \l_schulma_physik_kraftmesser_offset_huelse_dim )
      to [ out = 20 , in = 160 ] ++ ( 0.5 \l_schulma_physik_kraftmesser_breite_huelse_dim , 0 )
      to [ out = 200 , in = -20 ] cycle ;
    \end{tikzpicture}
  }


\dim_const:Nn \c_schulma_physik_multimeter_zeigerlaenge_dim {3.4cm}
\dim_const:Nn \c_schulma_physik_multimeter_skalenradius_dim {2.9cm}
\dim_const:Nn \c_schulma_physik_multimeter_breite_dim {5cm}
\dim_const:Nn \c_schulma_physik_multimeter_hoehe_dim {4cm}
\dim_new:N \l_schulma_physik_multimeter_skalenbeschriftung_dim
\fp_const:Nn \c_schulma_physik_multimeter_sektorwinkel_fp {80}

\NewDocumentCommand \Multimeter {mmm}
  {
    \begin {tikzpicture} [ font = { \sffamily \footnotesize } ]
    % äußere Skala bis 10
    \dim_set:Nn \l_tmpa_dim { \c_schulma_physik_multimeter_skalenradius_dim + 1mm }
    \dim_set:Nn \l_schulma_physik_multimeter_skalenbeschriftung_dim { \c_schulma_physik_multimeter_skalenradius_dim + 5mm }
    \int_step_inline:nnn {0} {50}
      {
        \fp_set:Nn \l_tmpa_fp { 90 + (0.5 - ##1/50) * \c_schulma_physik_multimeter_sektorwinkel_fp }
        \int_compare:nNnTF { \int_mod:nn {##1} {5} } = {0}
          {
            \dim_set:Nn \l_tmpb_dim { \c_schulma_physik_multimeter_skalenradius_dim + 3mm }
            \draw ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpa_dim ) -- ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpb_dim ) ;
            \int_compare:nNnT { \int_mod:nn {##1} {10} } = {0}
              {
                \node at ( \fp_use:N \l_tmpa_fp \c_colon_str \l_schulma_physik_multimeter_skalenbeschriftung_dim ) { \int_eval:n {2*##1/10} } ;
              }
          }
          {
            \dim_set:Nn \l_tmpb_dim { \c_schulma_physik_multimeter_skalenradius_dim + 2mm }
            \draw ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpa_dim ) -- ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpb_dim ) ;
          }
      }
    % innere Skala bis 3
    \dim_set:Nn \l_tmpa_dim { \c_schulma_physik_multimeter_skalenradius_dim - 1mm }
    \dim_set:Nn \l_schulma_physik_multimeter_skalenbeschriftung_dim { \c_schulma_physik_multimeter_skalenradius_dim - 5mm }
    \int_step_inline:nnn {0} {30}
      {
        \fp_set:Nn \l_tmpa_fp { 90 + (0.5 - ##1/30) * \c_schulma_physik_multimeter_sektorwinkel_fp }
        \int_compare:nNnTF { \int_mod:nn {##1} {5} } = {0}
          {
            \dim_set:Nn \l_tmpb_dim { \c_schulma_physik_multimeter_skalenradius_dim - 3mm }
            \draw ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpa_dim ) -- ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpb_dim ) ;
            \int_compare:nNnT { \int_mod:nn {##1} {10} } = {0}
              {
                \node at ( \fp_use:N \l_tmpa_fp \c_colon_str \l_schulma_physik_multimeter_skalenbeschriftung_dim ) { \int_eval:n {##1/10} } ;
              }
          }
          {
            \dim_set:Nn \l_tmpb_dim { \c_schulma_physik_multimeter_skalenradius_dim - 2mm }
            \draw ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpa_dim ) -- ( \fp_use:N \l_tmpa_fp \c_colon_str \l_tmpb_dim ) ;
          }
      }
    % Zeiger
    \fp_set:Nn \l_tmpa_fp { 90 + (0.5 - #1/#2) * \c_schulma_physik_multimeter_sektorwinkel_fp }
    \fill (0,0) circle [ radius = 2.5pt ] ;
    \draw [semithick] (0,0) -- ( \fp_use:N \l_tmpa_fp \c_colon_str \dim_use:N \c_schulma_physik_multimeter_zeigerlaenge_dim ) ;
    % Rahmen
    \draw ( -0.5 * \c_schulma_physik_multimeter_breite_dim , -3mm ) -- ++ ( \c_schulma_physik_multimeter_breite_dim , 0 )
      node [above~left] { \normalsize \qty [ mode = text , reset-text-family = false ] {#2} {#3} }
      -- ++ ( 0 , \c_schulma_physik_multimeter_hoehe_dim ) -- ++ ( - \c_schulma_physik_multimeter_breite_dim , 0 )
      -- ++ ( 0 , - \c_schulma_physik_multimeter_hoehe_dim ) ;
    \end{tikzpicture}
  }

\ExplSyntaxOff

\ifschulma@physik@circuitikz
  \RequirePackage{circuitikz}
  \ctikzset{resistor=european,inductor=american}
\else
  \usetikzlibrary{circuits.ee.IEC}

  \pgfdeclareshape{doppelbuchse}
    {%
      \inheritsavedanchors[from=rectangle ee]%
      \inheritanchor[from=rectangle ee]{center}%
      \inheritanchor[from=rectangle ee]{north}%
      \inheritanchor[from=rectangle ee]{south}%
      \inheritanchor[from=rectangle ee]{east}%
      \inheritanchor[from=rectangle ee]{west}%
      \inheritanchor[from=rectangle ee]{north east}%
      \inheritanchor[from=rectangle ee]{north west}%
      \inheritanchor[from=rectangle ee]{south east}%
      \inheritanchor[from=rectangle ee]{south west}%
      \inheritanchor[from=rectangle ee]{input}%
      \inheritanchor[from=rectangle ee]{output}%
      \inheritanchorborder[from=rectangle ee]%
      \backgroundpath{
        \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}%
        \pgf@xa=\pgf@x \pgf@ya=\pgf@y
        \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}}%
        \pgf@xb=\pgf@x \pgf@yb=\pgf@y
        \pgfutil@tempdima=\pgf@yb%
        \advance\pgfutil@tempdima by -\pgf@ya%
        \pgfutil@tempdima=0.5\pgfutil@tempdima%
        \advance\pgf@xa by \pgfutil@tempdima%
        \advance\pgf@xb by -\pgfutil@tempdima%
        {\pgfpathcircle{\pgfqpoint{\pgf@xa}{0pt}}{\pgfutil@tempdima}}
        {\pgfpathcircle{\pgfqpoint{\pgf@xb}{0pt}}{\pgfutil@tempdima}}
      }%
    }

  \tikzset
    {
      bulb IEC graphic/.style=
        {
          circuit symbol lines,
          circuit symbol size=width 1.9 height 1.9,
          shape=generic circle IEC,
          /pgf/generic circle IEC/before background=
            {
              \pgfpathmoveto{\pgfpointpolar{-135}{1pt}}
              \pgfpathlineto{\pgfpointpolar{45}{1pt}}
              \pgfpathmoveto{\pgfpointpolar{-45}{1pt}}
              \pgfpathlineto{\pgfpointpolar{135}{1pt}}
              \pgfusepathqstroke
            },
          transform shape,
        },
      capacitor IEC graphic/.style=
        {
          circuit symbol lines,
          circuit symbol size=width 0.8 height 2.4,
          transform shape,
          shape=capacitor IEC,
        },
      amperemeter graphic/.style=
        {
          circuit symbol open,
          circuit symbol size=width 2 height 2,
          transform shape,
          shape=generic circle IEC,
          info=center:{\sffamily A}
        },
      voltmeter graphic/.style=
        {
          circuit symbol open,
          circuit symbol size=width 2 height 2,
          transform shape,
          shape=generic circle IEC,
          info=center:{\sffamily V}
        },
      circuit declare symbol=messgeraet,
      set messgeraet graphic=
        {
          circuit symbol open,
          circuit symbol size=width 2 height 2,
          transform shape,
          shape=generic circle IEC,
          /pgf/generic circle IEC/before background=
            {
              \draw[annotation arrow,->] (0.58pt,-0.58pt)--(-0.58pt,0.58pt);
            }
        },
      circuit declare symbol=spannungsquelle,
      set spannungsquelle graphic=
        {
          circuit symbol open,
          circuit symbol size=width 2.4 height 0.5,
          transform shape,
          shape=doppelbuchse,
          outer sep=0pt
        },
    }
\fi
