\hypertarget{photosensor_8c}{
\section{photosensor.c File Reference}
\label{photosensor_8c}\index{photosensor.c@{photosensor.c}}
}
{\tt \#include \char`\"{}t89c51cc02.h\char`\"{}}\par
{\tt \#include \char`\"{}datatypes.h\char`\"{}}\par
{\tt \#include \char`\"{}photosensor.h\char`\"{}}\par
{\tt \#include \char`\"{}adc.h\char`\"{}}\par
{\tt \#include \char`\"{}sharp.h\char`\"{}}\par
{\tt \#include $<$stdlib.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{photosensor_8c_9fae1e927b2ded0859692ab5bbd9d0eb}{Photosensor\_\-init} ()
\begin{CompactList}\small\item\em initialize photosensor subsystem \item\end{CompactList}\item 
void \hyperlink{photosensor_8c_fa72506eb4acf4b63e847b4005418412}{Photosensor\_\-toggle} (void)
\begin{CompactList}\small\item\em toggles LED of selected photosensor \item\end{CompactList}\item 
\hyperlink{datatypes_8h_89b917a7bdb582e19cbde98e817fa0b3}{WORD} \hyperlink{photosensor_8c_e04a12a7101a68caddca577045f804df}{Photosensor\_\-read} (\hyperlink{datatypes_8h_92076741b75a8c2bdc5c24049c253d9a}{BYTE} sensornr)
\begin{CompactList}\small\item\em read the value of a single photosensor \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
\hyperlink{datatypes_8h_92076741b75a8c2bdc5c24049c253d9a}{BYTE} \hyperlink{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{psensor}
\item 
const char \hyperlink{photosensor_8c_fbe3f2fbf1674532a7fa21c44d4a2b4f}{psensor\_\-select} \mbox{[}$\,$\mbox{]} = \{0,0x08,0x10,0x20,0x40,0x80,0,0\}
\end{CompactItemize}


\subsection{Detailed Description}


Definition in file \hyperlink{photosensor_8c-source}{photosensor.c}.

\subsection{Function Documentation}
\hypertarget{photosensor_8c_9fae1e927b2ded0859692ab5bbd9d0eb}{
\index{photosensor.c@{photosensor.c}!Photosensor_init@{Photosensor\_\-init}}
\index{Photosensor_init@{Photosensor\_\-init}!photosensor.c@{photosensor.c}}
\subsubsection[Photosensor\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void Photosensor\_\-init (void)}}
\label{photosensor_8c_9fae1e927b2ded0859692ab5bbd9d0eb}


initialize photosensor subsystem 

The photosensors are turned off by default. 

Definition at line 31 of file photosensor.c.

References Photosensor\_\-Power\-Off, and psensor.

Referenced by main().\hypertarget{photosensor_8c_e04a12a7101a68caddca577045f804df}{
\index{photosensor.c@{photosensor.c}!Photosensor_read@{Photosensor\_\-read}}
\index{Photosensor_read@{Photosensor\_\-read}!photosensor.c@{photosensor.c}}
\subsubsection[Photosensor\_\-read]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{datatypes_8h_89b917a7bdb582e19cbde98e817fa0b3}{WORD} Photosensor\_\-read (\hyperlink{datatypes_8h_92076741b75a8c2bdc5c24049c253d9a}{BYTE} {\em sensornr})}}
\label{photosensor_8c_e04a12a7101a68caddca577045f804df}


read the value of a single photosensor 

The given sensor is activated first and than sampled with a simple differential scheme. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sensornr}]number of photo sensor to read \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]voltage value of given sensor \end{Desc}


Definition at line 79 of file photosensor.c.

References ADC(), Photosensor\_\-Power\-Off, Photosensor\_\-select, and SHARP\_\-PWRCTL.

Referenced by main().\hypertarget{photosensor_8c_fa72506eb4acf4b63e847b4005418412}{
\index{photosensor.c@{photosensor.c}!Photosensor_toggle@{Photosensor\_\-toggle}}
\index{Photosensor_toggle@{Photosensor\_\-toggle}!photosensor.c@{photosensor.c}}
\subsubsection[Photosensor\_\-toggle]{\setlength{\rightskip}{0pt plus 5cm}void Photosensor\_\-toggle (void)}}
\label{photosensor_8c_fa72506eb4acf4b63e847b4005418412}


toggles LED of selected photosensor 

The photosensor is selected with the \hyperlink{photosensor_8h_02e0ccf2b02f51fc14ec77a65736e65e}{Photosensor\_\-select} function.\par
 Invalid sensor numbers will turn off all photosensors. 

Definition at line 44 of file photosensor.c.

References Photosensor\_\-Power\-Off, Photosensor\_\-select, and psensor.

\subsection{Variable Documentation}
\hypertarget{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{
\index{photosensor.c@{photosensor.c}!psensor@{psensor}}
\index{psensor@{psensor}!photosensor.c@{photosensor.c}}
\subsubsection[psensor]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{datatypes_8h_92076741b75a8c2bdc5c24049c253d9a}{BYTE} \hyperlink{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{psensor}}}
\label{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}


stores number of active photosensor 

Definition at line 21 of file photosensor.c.

Referenced by Photosensor\_\-init(), and Photosensor\_\-toggle().\hypertarget{photosensor_8c_fbe3f2fbf1674532a7fa21c44d4a2b4f}{
\index{photosensor.c@{photosensor.c}!psensor_select@{psensor\_\-select}}
\index{psensor_select@{psensor\_\-select}!photosensor.c@{photosensor.c}}
\subsubsection[psensor\_\-select]{\setlength{\rightskip}{0pt plus 5cm}const char \hyperlink{photosensor_8c_fbe3f2fbf1674532a7fa21c44d4a2b4f}{psensor\_\-select}\mbox{[}$\,$\mbox{]} = \{0,0x08,0x10,0x20,0x40,0x80,0,0\}}}
\label{photosensor_8c_fbe3f2fbf1674532a7fa21c44d4a2b4f}


bit masks to activate 1 of 5 photo sensors 

Definition at line 24 of file photosensor.c.