\hypertarget{photosensor_8h}{
\section{photosensor.h File Reference}
\label{photosensor_8h}\index{photosensor.h@{photosensor.h}}
}
{\tt \#include \char`\"{}t89c51cc02.h\char`\"{}}\par
{\tt \#include \char`\"{}datatypes.h\char`\"{}}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{photosensor_8h_2a0e20bede32e1ebb6e7688c581565ae}{PHOTOSENSOR\_\-OFF}~0x03
\item 
\#define \hyperlink{photosensor_8h_67fba92a933075592b76b05fe3793fd8}{Photosensor\_\-Power\-Off}()~P3=(P3 \& PHOTOSENSOR\_\-OFF)
\item 
\#define \hyperlink{photosensor_8h_02e0ccf2b02f51fc14ec77a65736e65e}{Photosensor\_\-select}(s)~\hyperlink{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{psensor}=s; P3=((P3 \& PHOTOSENSOR\_\-OFF)$|$\hyperlink{photosensor_8c_fbe3f2fbf1674532a7fa21c44d4a2b4f}{psensor\_\-select}\mbox{[}\hyperlink{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{psensor} \& 0x07\mbox{]})
\item 
\#define \hyperlink{photosensor_8h_8845753fdeb4000635f254b5feb235ed}{PHOTOSENSORS\_\-NR}~5
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{photosensor_8h_6cc5dda48129bf64144af2e9bc05a752}{Photosensor\_\-init} (void)
\begin{CompactList}\small\item\em initialize photosensor subsystem \item\end{CompactList}\item 
void \hyperlink{photosensor_8h_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_8h_210834aef834148028fad310515a624e}{Photosensor\_\-read} (\hyperlink{datatypes_8h_92076741b75a8c2bdc5c24049c253d9a}{BYTE})
\begin{CompactList}\small\item\em read the value of a single photosensor \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}


Definition in file \hyperlink{photosensor_8h-source}{photosensor.h}.

\subsection{Define Documentation}
\hypertarget{photosensor_8h_2a0e20bede32e1ebb6e7688c581565ae}{
\index{photosensor.h@{photosensor.h}!PHOTOSENSOR_OFF@{PHOTOSENSOR\_\-OFF}}
\index{PHOTOSENSOR_OFF@{PHOTOSENSOR\_\-OFF}!photosensor.h@{photosensor.h}}
\subsubsection[PHOTOSENSOR\_\-OFF]{\setlength{\rightskip}{0pt plus 5cm}\#define PHOTOSENSOR\_\-OFF~0x03}}
\label{photosensor_8h_2a0e20bede32e1ebb6e7688c581565ae}


bit mask used to turn off all photosensors 

Definition at line 7 of file photosensor.h.\hypertarget{photosensor_8h_67fba92a933075592b76b05fe3793fd8}{
\index{photosensor.h@{photosensor.h}!Photosensor_PowerOff@{Photosensor\_\-PowerOff}}
\index{Photosensor_PowerOff@{Photosensor\_\-PowerOff}!photosensor.h@{photosensor.h}}
\subsubsection[Photosensor\_\-PowerOff]{\setlength{\rightskip}{0pt plus 5cm}\#define Photosensor\_\-Power\-Off()~P3=(P3 \& PHOTOSENSOR\_\-OFF)}}
\label{photosensor_8h_67fba92a933075592b76b05fe3793fd8}


macro to turn off all photosensors 

Definition at line 9 of file photosensor.h.

Referenced by main(), Photosensor\_\-init(), Photosensor\_\-read(), and Photosensor\_\-toggle().\hypertarget{photosensor_8h_02e0ccf2b02f51fc14ec77a65736e65e}{
\index{photosensor.h@{photosensor.h}!Photosensor_select@{Photosensor\_\-select}}
\index{Photosensor_select@{Photosensor\_\-select}!photosensor.h@{photosensor.h}}
\subsubsection[Photosensor\_\-select]{\setlength{\rightskip}{0pt plus 5cm}\#define Photosensor\_\-select(s)~\hyperlink{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{psensor}=s; P3=((P3 \& PHOTOSENSOR\_\-OFF)$|$\hyperlink{photosensor_8c_fbe3f2fbf1674532a7fa21c44d4a2b4f}{psensor\_\-select}\mbox{[}\hyperlink{photosensor_8c_832b2d71c7cacb1b522b24653bbcf75b}{psensor} \& 0x07\mbox{]})}}
\label{photosensor_8h_02e0ccf2b02f51fc14ec77a65736e65e}


macro to activate a given photosensor 

Definition at line 11 of file photosensor.h.

Referenced by Photosensor\_\-read(), and Photosensor\_\-toggle().\hypertarget{photosensor_8h_8845753fdeb4000635f254b5feb235ed}{
\index{photosensor.h@{photosensor.h}!PHOTOSENSORS_NR@{PHOTOSENSORS\_\-NR}}
\index{PHOTOSENSORS_NR@{PHOTOSENSORS\_\-NR}!photosensor.h@{photosensor.h}}
\subsubsection[PHOTOSENSORS\_\-NR]{\setlength{\rightskip}{0pt plus 5cm}\#define PHOTOSENSORS\_\-NR~5}}
\label{photosensor_8h_8845753fdeb4000635f254b5feb235ed}


number of active photosensors 

Definition at line 13 of file photosensor.h.

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


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_8h_210834aef834148028fad310515a624e}{
\index{photosensor.h@{photosensor.h}!Photosensor_read@{Photosensor\_\-read}}
\index{Photosensor_read@{Photosensor\_\-read}!photosensor.h@{photosensor.h}}
\subsubsection[Photosensor\_\-read]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{datatypes_8h_89b917a7bdb582e19cbde98e817fa0b3}{WORD} Photosensor\_\-read (\hyperlink{datatypes_8h_92076741b75a8c2bdc5c24049c253d9a}{BYTE} {\em sensornr})}}
\label{photosensor_8h_210834aef834148028fad310515a624e}


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_8h_fa72506eb4acf4b63e847b4005418412}{
\index{photosensor.h@{photosensor.h}!Photosensor_toggle@{Photosensor\_\-toggle}}
\index{Photosensor_toggle@{Photosensor\_\-toggle}!photosensor.h@{photosensor.h}}
\subsubsection[Photosensor\_\-toggle]{\setlength{\rightskip}{0pt plus 5cm}void Photosensor\_\-toggle (void)}}
\label{photosensor_8h_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.