<!-- iframe showing the search results (closed by default) -->
<divid="MSearchResultsWindow">
<iframesrc="javascript:void(0)"frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<divclass="header">
<divclass="summary">
<ahref="#func-members">Functions</a></div>
<divclass="headertitle">
<divclass="title">Methods<divclass="ingroups"><aclass="el"href="../../da/daf/group__lowerlevelus.html">Lower level ultra sonic methods and getters</a></div></div></div>
<trclass="memdesc:ga5f034198a28b069478c454c63dbfa225"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <ahref="#ga5f034198a28b069478c454c63dbfa225">More...</a><br/></td></tr>
<trclass="memdesc:gaa01602a576fd57609bc7e08f8ef32e58"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <ahref="#gaa01602a576fd57609bc7e08f8ef32e58">More...</a><br/></td></tr>
<trclass="memitem:gafdd5c75d7a8e7b7c993e512ee93dde9a"><tdclass="memItemLeft"align="right"valign="top">unsigned long </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d6/dfc/group__lowerlevelusmeths.html#gafdd5c75d7a8e7b7c993e512ee93dde9a">CodeRacer::usonic_measure_cm</a> (unsigned long max_echo_run_time_us)</td></tr>
<trclass="memdesc:gafdd5c75d7a8e7b7c993e512ee93dde9a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <ahref="#gafdd5c75d7a8e7b7c993e512ee93dde9a">More...</a><br/></td></tr>
<trclass="memitem:ga1f3401ef472cb11997e7dc98ef3e2424"><tdclass="memItemLeft"align="right"valign="top">unsigned long </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d6/dfc/group__lowerlevelusmeths.html#ga1f3401ef472cb11997e7dc98ef3e2424">CodeRacer::usonic_measure_us</a> (unsigned long max_echo_run_time_us)</td></tr>
<trclass="memdesc:ga1f3401ef472cb11997e7dc98ef3e2424"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <ahref="#ga1f3401ef472cb11997e7dc98ef3e2424">More...</a><br/></td></tr>
<trclass="memdesc:ga0c00edbbf4a3169613c9ea84d6e7dc13"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <ahref="#ga0c00edbbf4a3169613c9ea84d6e7dc13">More...</a><br/></td></tr>
<trclass="memdesc:gad4309b6da17085575fb0c55559e240b8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <ahref="#gad4309b6da17085575fb0c55559e240b8">More...</a><br/></td></tr>
<trclass="memitem:gab413551ea8a67e1b60eda1671029b645"><tdclass="memItemLeft"align="right"valign="top">unsigned long </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d6/dfc/group__lowerlevelusmeths.html#gab413551ea8a67e1b60eda1671029b645">CodeRacer::usonic_measure_single_shot_cm</a> (unsigned long max_echo_run_time_us)</td></tr>
<trclass="memdesc:gab413551ea8a67e1b60eda1671029b645"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <ahref="#gab413551ea8a67e1b60eda1671029b645">More...</a><br/></td></tr>
<trclass="memitem:ga1b5b43372082f5daeee47410a09a590c"><tdclass="memItemLeft"align="right"valign="top">unsigned long </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d6/dfc/group__lowerlevelusmeths.html#ga1b5b43372082f5daeee47410a09a590c">CodeRacer::usonic_measure_single_shot_us</a> (unsigned long max_echo_run_time_us)</td></tr>
<trclass="memdesc:ga1b5b43372082f5daeee47410a09a590c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <ahref="#ga1b5b43372082f5daeee47410a09a590c">More...</a><br/></td></tr>
<tdclass="memname">unsigned long CodeRacer::usonic_measure_cm </td>
<td>(</td>
<tdclass="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><divclass="memdoc">
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
<p>This is the medium one out of 3 measurements. The maximum measured distance is about 100cm and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dlclass="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00672">672</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00673"></a><spanclass="lineno"> 673</span> {</div><divclass="line"><aname="l00674"></a><spanclass="lineno"> 674</span> <spanclass="keywordflow">return</span>(usonic_measure_cm(US_MAX_ECHO_TIME_US));</div><divclass="line"><aname="l00675"></a><spanclass="lineno"> 675</span> }</div></div><!-- fragment -->
<tdclass="memname">unsigned long CodeRacer::usonic_measure_us </td>
<td>(</td>
<tdclass="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><divclass="memdoc">
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
<p>This is the medium one out of 3 measurements. The maximum measured distance is about 6000 microseconds and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dlclass="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00682">682</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00683"></a><spanclass="lineno"> 683</span>  {</div><divclass="line"><aname="l00684"></a><spanclass="lineno"> 684</span> <spanclass="keywordflow">return</span>(usonic_measure_us(US_MAX_ECHO_TIME_US));</div><divclass="line"><aname="l00685"></a><spanclass="lineno"> 685</span>  }</div></div><!-- fragment -->
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
<p>This is the medium one out of 3 measurements. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time and by that the maximum of distance that can be measured. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00694">694</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00695"></a><spanclass="lineno"> 695</span> {</div><divclass="line"><aname="l00696"></a><spanclass="lineno"> 696</span> <spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span> echo_runtime_us = usonic_measure_us(max_echo_run_time_us);</div><divclass="line"><aname="l00697"></a><spanclass="lineno"> 697</span> <spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span> distance_cm = echo_runtime_us * 0.0172;</div><divclass="line"><aname="l00698"></a><spanclass="lineno"> 698</span> <spanclass="comment">//Serial.print("MEASURE_DISTANCE. Distance in cm is: ");</span></div><divclass="line"><aname="l00699"></a><spanclass="lineno"> 699</span> <spanclass="comment">//Serial.println(distance_cm);</span></div><divclass="line"><aname="l00700"></a><spanclass="lineno"> 700</span>  _usonic_distance_cm = distance_cm;</div><divclass="line"><aname="l00701"></a><spanclass="lineno"> 701</span> <spanclass="keywordflow">return</span>(distance_cm);</div><divclass="line"><aname="l00702"></a><spanclass="lineno"> 702</span> }</div></div><!-- fragment -->
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
<p>This is the medium one out of 3 measurements. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time in microseconds and by that the maximum of distance that can be measured. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00711">711</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00712"></a><spanclass="lineno"> 712</span> {</div><divclass="line"><aname="l00713"></a><spanclass="lineno"> 713</span> <spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span> echo_runtime_us[3] = { 0,0,0 };</div><divclass="line"><aname="l00714"></a><spanclass="lineno"> 714</span>  uint8_t measnr = 0;</div><divclass="line"><aname="l00715"></a><spanclass="lineno"> 715</span> </div><divclass="line"><aname="l00716"></a><spanclass="lineno"> 716</span> <spanclass="keywordflow">do</span> {</div><divclass="line"><aname="l00717"></a><spanclass="lineno"> 717</span>  echo_runtime_us[measnr] = usonic_measure_single_shot_us(max_echo_run_time_us);</div><divclass="line"><aname="l00718"></a><spanclass="lineno"> 718</span> <spanclass="keywordflow">if</span> (echo_runtime_us[measnr] > 200) {</div><divclass="line"><aname="l00719"></a><spanclass="lineno"> 719</span>  measnr++;</div><divclass="line"><aname="l00720"></a><spanclass="lineno"> 720</span>  }</div><divclass="line"><aname="l00721"></a><spanclass="lineno"> 721</span>  } <spanclass="keywordflow">while</span> (measnr < 3);</div><divclass="line"><aname="l00722"></a><spanclass="lineno"> 722</span> </div><divclass="line"><aname="l00723"></a><spanclass="lineno"> 723</span> <spanclass="comment">// we will take the medium out of 3 values ... </span></div><divclass="line"><aname="l00724"></a><spanclass="lineno"> 724</span> <spanclass="keywordflow">if</span> (echo_runtime_us[0] > echo_runtime_us[1]) { std::swap(echo_runtime_us[0], echo_runtime_us[1]); }</div><divclass="line"><aname="l00725"></a><spanclass="lineno"> 725</span> <spanclass="keywordflow">if</span> (echo_runtime_us[1] > echo_runtime_us[2]) { std::swap(echo_runtime_us[1], echo_runtime_us[2]); }</div><divclass="line"><aname="l00726"></a><spanclass="lineno"> 726</span> <spanclass="keywordflow">if</span> (echo_runtime_us[0] > echo_runtime_us[1]) { std::swap(echo_runtime_us[0], echo_runtime_us[1]); }</div><divclass="line"><aname="l00727"></a><spanclass="lineno"> 727</span> </div><divclass="line"><aname="l00728"></a><spanclass="lineno"> 728</span> <spanclass="comment">//Serial.print("MEASURE_DISTANCE_US. Echo runtime in us is: ");</span></div><divclass="line"><aname="l00729"></a><spanclass="lineno"> 729</span> <spanclass="comment">//Serial.println(echo_runtime_us[1]);</span></div><divclass="line"><aname="l00730"></a><spanclass="lineno"> 730</span> </div><divclass="line"><aname="l00731"></a><spanclass="lineno"> 731</span> <spanclass="comment">// if the stop at minimal distance is enabeled - check for minimal distance is reached</span></div><divclass="line"><aname="l00732"></a><spanclass="lineno"> 732</span> <spanclass="keywordflow">if</span> (<spanclass="keyword">true</span> == _coderacer_stop_at_distance_enabled) {</div><divclass="line"><aname="l00733"></a><spanclass="lineno"> 733</span> <spanclass="keywordflow">if</span> (echo_runtime_us[1] <= _usonic_stop_distance_us) {</div><divclass="line"><aname="l00734"></a><spanclass="lineno"> 734</span>  _coderacer_stopped_at_min_distance = <spanclass="keyword">true</span>;</div><divclass="line"><aname="l00735"></a><spanclass="lineno"> 735</span>  stop_driving();</div><divclass="line"><aname="l00736"></a><spanclass="lineno"> 736</span>  _coderacer_stop_at_distance_enabled = <spanclass="keyword">false</span>;</div><divclass="line"><aname="l00737"></a><spanclass="lineno"> 737</span>  }</div><divclass="line"><aname="l00738"></a><spanclass="lineno"> 738</span>  }</div><divclass="line"><aname="l00739"></a><spanclass="lineno"> 739</span>  _usonic_distance_us = echo_runtime_us[1];</div><divclass="line"><aname
<tdclass="memname">unsigned long CodeRacer::usonic_measure_single_shot_cm </td>
<td>(</td>
<tdclass="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><divclass="memdoc">
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
<p>This is a one shot measurement. The maximum measured distance is about 6000 microseconds and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dlclass="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00748">748</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00749"></a><spanclass="lineno"> 749</span> {</div><divclass="line"><aname="l00750"></a><spanclass="lineno"> 750</span> <spanclass="keywordflow">return</span>(usonic_measure_single_shot_cm(US_MAX_ECHO_TIME_US));</div><divclass="line"><aname="l00751"></a><spanclass="lineno"> 751</span> }</div></div><!-- fragment -->
<tdclass="memname">unsigned long CodeRacer::usonic_measure_single_shot_us </td>
<td>(</td>
<tdclass="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><divclass="memdoc">
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
<p>This is a one shot measurement. The maximum measured distance is about 6000 microseconds and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dlclass="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00758">758</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00759"></a><spanclass="lineno"> 759</span> {</div><divclass="line"><aname="l00760"></a><spanclass="lineno"> 760</span> <spanclass="keywordflow">return</span>(usonic_measure_single_shot_us(US_MAX_ECHO_TIME_US));</div><divclass="line"><aname="l00761"></a><spanclass="lineno"> 761</span> }</div></div><!-- fragment -->
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
<p>This is a one shot measurement. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time in microseconds and by that the maximum of distance that can be measured. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00770">770</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00771"></a><spanclass="lineno"> 771</span> {</div><divclass="line"><aname="l00772"></a><spanclass="lineno"> 772</span> <spanclass="comment">// convert into cm ... 344m/sec is the speed of noise - thus 34400cm/sec ... or 34,400cm/milisec ... or 0,0344cm/microsec</span></div><divclass="line"><aname="l00773"></a><spanclass="lineno"> 773</span> <spanclass="comment">// the echo has to go the distance twice - forth and back - so the duration has to be the half of the measured one</span></div><divclass="line"><aname="l00774"></a><spanclass="lineno"> 774</span> <spanclass="comment">// distance_cm = echo_duration/2 * 0,0344 or distance_cm = echo_duration/2 / 29,1 or distance_cm = echo_duration * 0,0172</span></div><divclass="line"><aname="l00775"></a><spanclass="lineno"> 775</span> <spanclass="comment">// distance_cm = (echo_duration/2) / 29.1;</span></div><divclass="line"><aname="l00776"></a><spanclass="lineno"> 776</span> <spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span> echo_runtime_us = usonic_measure_single_shot_us(max_echo_run_time_us);</div><divclass="line"><aname="l00777"></a><spanclass="lineno"> 777</span> <spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span> distance_cm = echo_runtime_us * 0.0172;</div><divclass="line"><aname="l00778"></a><spanclass="lineno"> 778</span> <spanclass="comment">//Serial.print("MEASURE_DISTANCE. Distance in cm is: ");</span></div><divclass="line"><aname="l00779"></a><spanclass="lineno"> 779</span> <spanclass="comment">//Serial.println(distance_cm);</span></div><divclass="line"><aname="l00780"></a><spanclass="lineno"> 780</span>  _usonic_distance_cm = distance_cm;</div><divclass="line"><aname="l00781"></a><spanclass="lineno"> 781</span> <spanclass="keywordflow">return</span>(distance_cm);</div><divclass="line"><aname="l00782"></a><spanclass="lineno"> 782</span> }</div></div><!-- fragment -->
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
<p>This is a one shot measurement. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time in microseconds and by that the maximum of distance that can be measured. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html#l00791">791</a> of file <aclass="el"href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
<divclass="fragment"><divclass="line"><aname="l00792"></a><spanclass="lineno"> 792</span>  {</div><divclass="line"><aname="l00793"></a><spanclass="lineno"> 793</span> <spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span> echo_runtime_us;</div><divclass="line"><aname="l00794"></a><spanclass="lineno"> 794</span> <spanclass="comment">// start measurement - send a short pulse "HIGH" to the TRIG pin of the ultrasonic sensor</span></div><divclass="line"><aname="l00795"></a><spanclass="lineno"> 795</span>  pinMode(_us_echo_pin, OUTPUT);</div><divclass="line"><aname="l00796"></a><spanclass="lineno"> 796</span>  pinMode(_us_echo_pin, INPUT);</div><divclass="line"><aname="l00797"></a><spanclass="lineno"> 797</span>  digitalWrite(_us_trigger_pin, LOW);</div><divclass="line"><aname="l00798"></a><spanclass="lineno"> 798</span>  delayMicroseconds(2);</div><divclass="line"><aname="l00799"></a><spanclass="lineno"> 799</span>  digitalWrite(_us_trigger_pin, HIGH);</div><divclass="line"><aname="l00800"></a><spanclass="lineno"> 800</span>  delayMicroseconds(10);</div><divclass="line"><aname="l00801"></a><spanclass="lineno"> 801</span>  digitalWrite(_us_trigger_pin, LOW);</div><divclass="line"><aname="l00802"></a><spanclass="lineno"> 802</span> <spanclass="comment">// measure runtime in microseconds until the ECHO pin aof the sensor goes HIGH</span></div><divclass="line"><aname="l00803"></a><spanclass="lineno"> 803</span>  echo_runtime_us = pulseInLong(_us_echo_pin, HIGH, max_echo_run_time_us);</div><divclass="line"><aname="l00804"></a><spanclass="lineno"> 804</span> <spanclass="keywordflow">if</span> (echo_runtime_us == 0) {</div><divclass="line"><aname="l00805"></a><spanclass="lineno"> 805</span>  echo_runtime_us = max_echo_run_time_us; <spanclass="comment">// US_MAX_ECHO_TIME_US;</span></div><divclass="line"><aname="l00806"></a><spanclass="lineno"> 806</span>  }</div><divclass="line"><aname="l00807"></a><spanclass="lineno"> 807</span> <spanclass="comment">//Serial.print("MEASURE_DISTANCE_US. Echo runtime in us is: ");</span></div><divclass="line"><aname="l00808"></a><spanclass="lineno"> 808</span> <spanclass="comment">//Serial.println(echo_runtime_us);</span></div><divclass="line"><aname="l00809"></a><spanclass="lineno"> 809</span>  _usonic_distance_us = echo_runtime_us;</div><divclass="line"><aname="l00810"></a><spanclass="lineno"> 810</span> <spanclass="keywordflow">return</span>(echo_runtime_us);</div><divclass="line"><aname="l00811"></a><spanclass="lineno"> 811</span>  }</div></div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->