\hypertarget{group__lowerlevelservomeths}{}\section{Methods}
\label{group__lowerlevelservomeths}\index{Methods@{Methods}}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{group__lowerlevelservomeths_ga687beb327e20f4d0541d1ac9e29c01c3}{Code\+Racer\+::servo\+\_\+settings} (uint8\+\_\+t pos\+\_\+center, uint8\+\_\+t pos\+\_\+left, uint8\+\_\+t pos\+\_\+right, uint8\+\_\+t sweep\+\_\+left\+\_\+pos, uint8\+\_\+t sweep\+\_\+right\+\_\+pos)
\begin{DoxyCompactList}\small\item\em Overwrites the default settings taken from header file by the parameters given to this method. \end{DoxyCompactList}\item 
void \hyperlink{group__lowerlevelservomeths_ga1e9afe1f27dfc9796b4c9b3dba245365}{Code\+Racer\+::servo\+\_\+sweep} ()
\begin{DoxyCompactList}\small\item\em Turns sweeping of the servo from left to right and back on. \end{DoxyCompactList}\item 
void \hyperlink{group__lowerlevelservomeths_gaac73bf99cf2d19f7b1987156aa842b74}{Code\+Racer\+::servo\+\_\+set\+\_\+to\+\_\+right} ()
\begin{DoxyCompactList}\small\item\em Drives the servo to the postion that is defined by \#servo\+\_\+right\+\_\+pos. \end{DoxyCompactList}\item 
void \hyperlink{group__lowerlevelservomeths_gaef7d1903b65a0a8ab4fafdc53080b07d}{Code\+Racer\+::servo\+\_\+set\+\_\+to\+\_\+left} ()
\begin{DoxyCompactList}\small\item\em Drives the servo to the postion that is defined by \#servo\+\_\+left\+\_\+pos. \end{DoxyCompactList}\item 
void \hyperlink{group__lowerlevelservomeths_gad1f28aa91079e88fc3093e3074edfb32}{Code\+Racer\+::servo\+\_\+set\+\_\+to\+\_\+center} ()
\begin{DoxyCompactList}\small\item\em Drives the servo to the postion that is defined by \#servo\+\_\+center\+\_\+pos. \end{DoxyCompactList}\item 
uint8\+\_\+t \hyperlink{group__lowerlevelservomeths_ga0149226288bff2290d52ed1cbd674edd}{Code\+Racer\+::servo\+\_\+set\+\_\+position\+\_\+wait} (uint8\+\_\+t position)
\begin{DoxyCompactList}\small\item\em Drive the servo to the postion given to this method. \end{DoxyCompactList}\item 
unsigned long \hyperlink{group__lowerlevelservomeths_gab8831340049de6dbddeda997745725e6}{Code\+Racer\+::servo\+\_\+set\+\_\+position} (uint8\+\_\+t position)
\begin{DoxyCompactList}\small\item\em Drive the servo to the postion given to this method. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}


\subsection{Function Documentation}
\mbox{\Hypertarget{group__lowerlevelservomeths_ga687beb327e20f4d0541d1ac9e29c01c3}\label{group__lowerlevelservomeths_ga687beb327e20f4d0541d1ac9e29c01c3}} 
\index{Methods@{Methods}!servo\+\_\+settings@{servo\+\_\+settings}}
\index{servo\+\_\+settings@{servo\+\_\+settings}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+settings()}{servo\_settings()}}
{\footnotesize\ttfamily void Code\+Racer\+::servo\+\_\+settings (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{pos\+\_\+center,  }\item[{uint8\+\_\+t}]{pos\+\_\+left,  }\item[{uint8\+\_\+t}]{pos\+\_\+right,  }\item[{uint8\+\_\+t}]{sweep\+\_\+left\+\_\+pos,  }\item[{uint8\+\_\+t}]{sweep\+\_\+right\+\_\+pos }\end{DoxyParamCaption})}



Overwrites the default settings taken from header file by the parameters given to this method. 


\begin{DoxyParams}{Parameters}
{\em pos\+\_\+center} & The postion at which the servo moves to straight forward. Default is 90. Allowed 10 $<$= pos\+\_\+center $<$= 170. \\
\hline
{\em pos\+\_\+left} & The postion at which the servo moves to the left. Default is 170. Allowed 10 $<$= pos\+\_\+center $<$= 170. \\
\hline
{\em pos\+\_\+right} & The postion at which the servo moves to the right. Default is 10. Allowed 10 $<$= pos\+\_\+center $<$= 170. \\
\hline
{\em sweep\+\_\+left\+\_\+pos} & If the servo is sweeping from left to the right -\/ this defines the most left postion. Default is 140. Allowed 10 $<$= pos\+\_\+center $<$= 170. \\
\hline
{\em sweep\+\_\+right\+\_\+pos} & If the servo is sweeping from left to the right -\/ this defines the most right postion. Default is 40. Allowed 10 $<$= pos\+\_\+center $<$= 170. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
nothing 
\end{DoxyReturn}


Definition at line 510 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
511 \{
512     servo\_center\_pos = pos\_center;
513     servo\_left\_pos = pos\_left;
514     servo\_right\_pos = pos\_right;
515     servo\_sweep\_left\_pos = sweep\_left\_pos;
516     servo\_sweep\_right\_pos = sweep\_right\_pos;
517 \}
\end{DoxyCode}
\mbox{\Hypertarget{group__lowerlevelservomeths_ga1e9afe1f27dfc9796b4c9b3dba245365}\label{group__lowerlevelservomeths_ga1e9afe1f27dfc9796b4c9b3dba245365}} 
\index{Methods@{Methods}!servo\+\_\+sweep@{servo\+\_\+sweep}}
\index{servo\+\_\+sweep@{servo\+\_\+sweep}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+sweep()}{servo\_sweep()}}
{\footnotesize\ttfamily void Code\+Racer\+::servo\+\_\+sweep (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Turns sweeping of the servo from left to right and back on. 

The sweeping range is defind by \#servo\+\_\+sweep\+\_\+left\+\_\+pos and \#servo\+\_\+sweep\+\_\+right\+\_\+pos attributes. Both can be set by either servo\+\_\+settings() or as public members. Every time servo\+\_\+sweep() is called the servo is driven by 5 steps until either \#servo\+\_\+sweep\+\_\+left\+\_\+pos or \#servo\+\_\+sweep\+\_\+right\+\_\+pos is reached. Then it will turn the direction and step to the other side every time this method is called. \begin{DoxyReturn}{Returns}
nothing 
\end{DoxyReturn}


Definition at line 526 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
527 \{
528     uint8\_t position;
529     \_servo\_sweep = \textcolor{keyword}{true};
530     \textcolor{keywordflow}{if} (millis() - \_servo\_position\_set\_at\_ms > SERVO\_SWEEP\_MS) \{
531         position = \_servo\_position + \_servo\_sweep\_step;
532         \textcolor{comment}{//sprintf(\_debugmsg,"[%s] current position=%ld newpostion=%ld", \_\_func\_\_, \_servo\_position,
       position);}
533         \textcolor{keywordflow}{if} ((position >= servo\_sweep\_left\_pos) || (position >= SERVO\_MAX\_POSITION)) \{
534             position = servo\_sweep\_left\_pos;
535             \_servo\_sweep\_step = SERVO\_SWEEP\_TO\_RIGHT\_STEP;
536         \}
537         \textcolor{keywordflow}{if} ((position <= servo\_sweep\_right\_pos) || (position <= SERVO\_MIN\_POSITION)) \{
538             position = servo\_sweep\_right\_pos;
539             \_servo\_sweep\_step = SERVO\_SWEEP\_TO\_LEFT\_STEP;
540         \}
541         \_servo\_set\_position(position);
542     \}
543 \}
\end{DoxyCode}
\mbox{\Hypertarget{group__lowerlevelservomeths_gaac73bf99cf2d19f7b1987156aa842b74}\label{group__lowerlevelservomeths_gaac73bf99cf2d19f7b1987156aa842b74}} 
\index{Methods@{Methods}!servo\+\_\+set\+\_\+to\+\_\+right@{servo\+\_\+set\+\_\+to\+\_\+right}}
\index{servo\+\_\+set\+\_\+to\+\_\+right@{servo\+\_\+set\+\_\+to\+\_\+right}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+set\+\_\+to\+\_\+right()}{servo\_set\_to\_right()}}
{\footnotesize\ttfamily void Code\+Racer\+::servo\+\_\+set\+\_\+to\+\_\+right (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Drives the servo to the postion that is defined by \#servo\+\_\+right\+\_\+pos. 

\begin{DoxyReturn}{Returns}
nothing 
\end{DoxyReturn}


Definition at line 548 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
549 \{
550     servo\_set\_position\_wait(servo\_right\_pos);
551 \}
\end{DoxyCode}
\mbox{\Hypertarget{group__lowerlevelservomeths_gaef7d1903b65a0a8ab4fafdc53080b07d}\label{group__lowerlevelservomeths_gaef7d1903b65a0a8ab4fafdc53080b07d}} 
\index{Methods@{Methods}!servo\+\_\+set\+\_\+to\+\_\+left@{servo\+\_\+set\+\_\+to\+\_\+left}}
\index{servo\+\_\+set\+\_\+to\+\_\+left@{servo\+\_\+set\+\_\+to\+\_\+left}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+set\+\_\+to\+\_\+left()}{servo\_set\_to\_left()}}
{\footnotesize\ttfamily void Code\+Racer\+::servo\+\_\+set\+\_\+to\+\_\+left (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Drives the servo to the postion that is defined by \#servo\+\_\+left\+\_\+pos. 

\begin{DoxyReturn}{Returns}
nothing 
\end{DoxyReturn}


Definition at line 556 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
557 \{
558     servo\_set\_position\_wait(servo\_left\_pos);
559 \}
\end{DoxyCode}
\mbox{\Hypertarget{group__lowerlevelservomeths_gad1f28aa91079e88fc3093e3074edfb32}\label{group__lowerlevelservomeths_gad1f28aa91079e88fc3093e3074edfb32}} 
\index{Methods@{Methods}!servo\+\_\+set\+\_\+to\+\_\+center@{servo\+\_\+set\+\_\+to\+\_\+center}}
\index{servo\+\_\+set\+\_\+to\+\_\+center@{servo\+\_\+set\+\_\+to\+\_\+center}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+set\+\_\+to\+\_\+center()}{servo\_set\_to\_center()}}
{\footnotesize\ttfamily void Code\+Racer\+::servo\+\_\+set\+\_\+to\+\_\+center (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Drives the servo to the postion that is defined by \#servo\+\_\+center\+\_\+pos. 

\begin{DoxyReturn}{Returns}
nothing 
\end{DoxyReturn}


Definition at line 564 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
565 \{
566     servo\_set\_position\_wait(servo\_center\_pos);
567 \}
\end{DoxyCode}
\mbox{\Hypertarget{group__lowerlevelservomeths_ga0149226288bff2290d52ed1cbd674edd}\label{group__lowerlevelservomeths_ga0149226288bff2290d52ed1cbd674edd}} 
\index{Methods@{Methods}!servo\+\_\+set\+\_\+position\+\_\+wait@{servo\+\_\+set\+\_\+position\+\_\+wait}}
\index{servo\+\_\+set\+\_\+position\+\_\+wait@{servo\+\_\+set\+\_\+position\+\_\+wait}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+set\+\_\+position\+\_\+wait()}{servo\_set\_position\_wait()}}
{\footnotesize\ttfamily uint8\+\_\+t Code\+Racer\+::servo\+\_\+set\+\_\+position\+\_\+wait (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{position }\end{DoxyParamCaption})}



Drive the servo to the postion given to this method. 

The method will wait until the servo has reached its new position. 
\begin{DoxyParams}{Parameters}
{\em position} & Position the servo will be drived to. Allowed are values 10$<$=postion$<$=170. 10 is at the right hand side, 170 at the left hand side. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The new servo position 
\end{DoxyReturn}


Definition at line 575 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
576 \{
577     \_servo\_sweep = \textcolor{keyword}{false};
578     \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} wait\_time\_ms = \_servo\_set\_position(position);
579     delay(wait\_time\_ms);
580     \textcolor{keywordflow}{return}(\_servo\_position);
581 \}
\end{DoxyCode}
\mbox{\Hypertarget{group__lowerlevelservomeths_gab8831340049de6dbddeda997745725e6}\label{group__lowerlevelservomeths_gab8831340049de6dbddeda997745725e6}} 
\index{Methods@{Methods}!servo\+\_\+set\+\_\+position@{servo\+\_\+set\+\_\+position}}
\index{servo\+\_\+set\+\_\+position@{servo\+\_\+set\+\_\+position}!Methods@{Methods}}
\subsubsection{\texorpdfstring{servo\+\_\+set\+\_\+position()}{servo\_set\_position()}}
{\footnotesize\ttfamily unsigned long Code\+Racer\+::servo\+\_\+set\+\_\+position (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{position }\end{DoxyParamCaption})}



Drive the servo to the postion given to this method. 

The method will not wait until the servo has reached its new position. 
\begin{DoxyParams}{Parameters}
{\em position} & Position the servo will be drived to. Allowed are values 10$<$=postion$<$=170. 10 is at the right hand side, 170 at the left hand side. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The time in ms the servo will need to reach the new position 
\end{DoxyReturn}


Definition at line 589 of file Code\+Racer.\+cpp.


\begin{DoxyCode}
590 \{
591     \_servo\_sweep = \textcolor{keyword}{false};
592     \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} wait\_time\_ms = \_servo\_set\_position(position);
593     \textcolor{keywordflow}{return}(wait\_time\_ms);
594 \}
\end{DoxyCode}
