timer_8h_source.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.10"/>
  7. <title>CoffeePi: timer.h Source File</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="search/searchdata.js"></script>
  13. <script type="text/javascript" src="search/search.js"></script>
  14. <script type="text/javascript">
  15. $(document).ready(function() { init_search(); });
  16. </script>
  17. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  18. </head>
  19. <body>
  20. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  21. <div id="titlearea">
  22. <table cellspacing="0" cellpadding="0">
  23. <tbody>
  24. <tr style="height: 56px;">
  25. <td id="projectalign" style="padding-left: 0.5em;">
  26. <div id="projectname">CoffeePi
  27. </div>
  28. <div id="projectbrief">Coffee machine control for Raspberry Pi</div>
  29. </td>
  30. </tr>
  31. </tbody>
  32. </table>
  33. </div>
  34. <!-- end header part -->
  35. <!-- Generated by Doxygen 1.8.10 -->
  36. <script type="text/javascript">
  37. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  38. </script>
  39. <div id="navrow1" class="tabs">
  40. <ul class="tablist">
  41. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  42. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  43. <li class="current"><a href="files.html"><span>Files</span></a></li>
  44. <li>
  45. <div id="MSearchBox" class="MSearchBoxInactive">
  46. <span class="left">
  47. <img id="MSearchSelect" src="search/mag_sel.png"
  48. onmouseover="return searchBox.OnSearchSelectShow()"
  49. onmouseout="return searchBox.OnSearchSelectHide()"
  50. alt=""/>
  51. <input type="text" id="MSearchField" value="Search" accesskey="S"
  52. onfocus="searchBox.OnSearchFieldFocus(true)"
  53. onblur="searchBox.OnSearchFieldFocus(false)"
  54. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  55. </span><span class="right">
  56. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  57. </span>
  58. </div>
  59. </li>
  60. </ul>
  61. </div>
  62. <div id="navrow2" class="tabs2">
  63. <ul class="tablist">
  64. <li><a href="files.html"><span>File&#160;List</span></a></li>
  65. <li><a href="globals.html"><span>Globals</span></a></li>
  66. </ul>
  67. </div>
  68. </div><!-- top -->
  69. <!-- window showing the filter options -->
  70. <div id="MSearchSelectWindow"
  71. onmouseover="return searchBox.OnSearchSelectShow()"
  72. onmouseout="return searchBox.OnSearchSelectHide()"
  73. onkeydown="return searchBox.OnSearchSelectKey(event)">
  74. </div>
  75. <!-- iframe showing the search results (closed by default) -->
  76. <div id="MSearchResultsWindow">
  77. <iframe src="javascript:void(0)" frameborder="0"
  78. name="MSearchResults" id="MSearchResults">
  79. </iframe>
  80. </div>
  81. <div class="header">
  82. <div class="headertitle">
  83. <div class="title">timer.h</div> </div>
  84. </div><!--header-->
  85. <div class="contents">
  86. <a href="timer_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">/*</span></div>
  87. <div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment"> * timer.h</span></div>
  88. <div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment"> *</span></div>
  89. <div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment"> * Created on: Nov 9, 2015</span></div>
  90. <div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment"> * Author: Philipp Hinz</span></div>
  91. <div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment"> */</span></div>
  92. <div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;</div>
  93. <div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="preprocessor">#ifndef TIMER_H_</span></div>
  94. <div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="preprocessor">#define TIMER_H_</span></div>
  95. <div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;</div>
  96. <div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="classtimer.html"> 17</a></span>&#160;<span class="keyword">class </span><a class="code" href="classtimer.html">timer</a> {</div>
  97. <div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="keyword">public</span>:</div>
  98. <div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160; <a class="code" href="classtimer.html#a863dd9a194499a5ebbaf6937969916f2">timer</a>(<span class="keywordtype">void</span> (*handler)(<span class="keywordtype">void</span>));</div>
  99. <div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160; <a class="code" href="classtimer.html#a863dd9a194499a5ebbaf6937969916f2">timer</a>(<span class="keywordtype">void</span> *(*handler)(<span class="keywordtype">void</span> *));</div>
  100. <div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classtimer.html#a0a4b48605728320ce7a5a825e34e16f2">setDivider</a>(<span class="keywordtype">int</span> divider);</div>
  101. <div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160; <span class="keywordtype">int</span> <a class="code" href="classtimer.html#a3d5386a682a23df5c6a841ce8fc55bd4">getDivider</a>();</div>
  102. <div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classtimer.html#a7d9f6d9f98d51534be127d57f497b345">call</a>();</div>
  103. <div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classtimer.html#a9aa894a57748b2bdf3adce46f5736794">start</a>();</div>
  104. <div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classtimer.html#a3218d61649e284071544b17c8c915ecc">stop</a>();</div>
  105. <div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classtimer.html#abbb117c0ae32aa48df5df60328e224f9">isActive</a>();</div>
  106. <div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="classtimer.html#a296c5e65582e19eaf61ae0bffa4071dc"> 27</a></span>&#160; <a class="code" href="classtimer.html">timer</a> *<a class="code" href="classtimer.html#a296c5e65582e19eaf61ae0bffa4071dc">next</a>; </div>
  107. <div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="keyword">private</span>:</div>
  108. <div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; void (*handler)(void);</div>
  109. <div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; <span class="keywordtype">void</span> *(*thandler)(<span class="keywordtype">void</span> *);</div>
  110. <div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <span class="keywordtype">int</span> divider;</div>
  111. <div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <span class="keywordtype">int</span> <span class="keywordtype">id</span> = 0; </div>
  112. <div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <span class="keywordtype">bool</span> active;</div>
  113. <div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; <span class="keywordtype">bool</span> asThread; </div>
  114. <div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; pthread_t thread;</div>
  115. <div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;};</div>
  116. <div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160;</div>
  117. <div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8h.html#a9e737e3249388fb2e50d868bad69c688">initTimers</a>(<span class="keywordtype">void</span>);</div>
  118. <div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8h.html#a43ed436d8c1803ced3029a909320a841">stopTimers</a>(<span class="keywordtype">void</span>);</div>
  119. <div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="keywordtype">void</span> *<a class="code" href="timer_8h.html#ae9859727c0e51a70b4ff5f47d2527a77">nullThread</a>(<span class="keywordtype">void</span> *threadid);</div>
  120. <div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160;</div>
  121. <div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="timer_8h.html#ad6f1d374549d22100d676d5fcac0a7e5"> 42</a></span>&#160;<span class="preprocessor">#define SIG SIGRTMIN</span></div>
  122. <div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="timer_8h.html#af3ec03c16ee82e8578cfd8fd133d7a6f"> 43</a></span>&#160;<span class="preprocessor">#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)</span></div>
  123. <div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="timer_8h.html#a2694a39dfd1fa087ca6f9f391c91dae7"> 44</a></span>&#160;<span class="preprocessor">#define CLOCKID CLOCK_REALTIME</span></div>
  124. <div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160;</div>
  125. <div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* TIMER_H_ */</span><span class="preprocessor"></span></div>
  126. <div class="ttc" id="classtimer_html_a863dd9a194499a5ebbaf6937969916f2"><div class="ttname"><a href="classtimer.html#a863dd9a194499a5ebbaf6937969916f2">timer::timer</a></div><div class="ttdeci">timer(void(*handler)(void))</div><div class="ttdoc">Timer constructor Depending on the call of the constructor the handler will be called as thread or no...</div><div class="ttdef"><b>Definition:</b> timer.cpp:34</div></div>
  127. <div class="ttc" id="timer_8h_html_a9e737e3249388fb2e50d868bad69c688"><div class="ttname"><a href="timer_8h.html#a9e737e3249388fb2e50d868bad69c688">initTimers</a></div><div class="ttdeci">void initTimers(void)</div><div class="ttdoc">inits the system timer based on signals </div><div class="ttdef"><b>Definition:</b> timer.cpp:153</div></div>
  128. <div class="ttc" id="classtimer_html_a7d9f6d9f98d51534be127d57f497b345"><div class="ttname"><a href="classtimer.html#a7d9f6d9f98d51534be127d57f497b345">timer::call</a></div><div class="ttdeci">void call()</div><div class="ttdoc">Calls the timer handler if enabled. </div><div class="ttdef"><b>Definition:</b> timer.cpp:69</div></div>
  129. <div class="ttc" id="timer_8h_html_ae9859727c0e51a70b4ff5f47d2527a77"><div class="ttname"><a href="timer_8h.html#ae9859727c0e51a70b4ff5f47d2527a77">nullThread</a></div><div class="ttdeci">void * nullThread(void *threadid)</div><div class="ttdoc">This is a dummy thread. </div><div class="ttdef"><b>Definition:</b> timer.cpp:229</div></div>
  130. <div class="ttc" id="classtimer_html_a296c5e65582e19eaf61ae0bffa4071dc"><div class="ttname"><a href="classtimer.html#a296c5e65582e19eaf61ae0bffa4071dc">timer::next</a></div><div class="ttdeci">timer * next</div><div class="ttdoc">contains the pointer on the next timer element of the list </div><div class="ttdef"><b>Definition:</b> timer.h:27</div></div>
  131. <div class="ttc" id="classtimer_html_a9aa894a57748b2bdf3adce46f5736794"><div class="ttname"><a href="classtimer.html#a9aa894a57748b2bdf3adce46f5736794">timer::start</a></div><div class="ttdeci">void start()</div><div class="ttdoc">enables the timer </div><div class="ttdef"><b>Definition:</b> timer.cpp:93</div></div>
  132. <div class="ttc" id="timer_8h_html_a43ed436d8c1803ced3029a909320a841"><div class="ttname"><a href="timer_8h.html#a43ed436d8c1803ced3029a909320a841">stopTimers</a></div><div class="ttdeci">void stopTimers(void)</div><div class="ttdoc">Stops all existing timers. </div><div class="ttdef"><b>Definition:</b> timer.cpp:214</div></div>
  133. <div class="ttc" id="classtimer_html_abbb117c0ae32aa48df5df60328e224f9"><div class="ttname"><a href="classtimer.html#abbb117c0ae32aa48df5df60328e224f9">timer::isActive</a></div><div class="ttdeci">bool isActive()</div><div class="ttdoc">Returns the timers active state. </div><div class="ttdef"><b>Definition:</b> timer.cpp:128</div></div>
  134. <div class="ttc" id="classtimer_html_a0a4b48605728320ce7a5a825e34e16f2"><div class="ttname"><a href="classtimer.html#a0a4b48605728320ce7a5a825e34e16f2">timer::setDivider</a></div><div class="ttdeci">void setDivider(int divider)</div><div class="ttdoc">sets the divider for this timer (based on system timer) </div><div class="ttdef"><b>Definition:</b> timer.cpp:110</div></div>
  135. <div class="ttc" id="classtimer_html_a3d5386a682a23df5c6a841ce8fc55bd4"><div class="ttname"><a href="classtimer.html#a3d5386a682a23df5c6a841ce8fc55bd4">timer::getDivider</a></div><div class="ttdeci">int getDivider()</div><div class="ttdoc">reads the timer divider </div><div class="ttdef"><b>Definition:</b> timer.cpp:119</div></div>
  136. <div class="ttc" id="classtimer_html"><div class="ttname"><a href="classtimer.html">timer</a></div><div class="ttdoc">Timer Class This class allows the creation of multiple timers that are based by a divider on a single...</div><div class="ttdef"><b>Definition:</b> timer.h:17</div></div>
  137. <div class="ttc" id="classtimer_html_a3218d61649e284071544b17c8c915ecc"><div class="ttname"><a href="classtimer.html#a3218d61649e284071544b17c8c915ecc">timer::stop</a></div><div class="ttdeci">void stop()</div><div class="ttdoc">disables the timer </div><div class="ttdef"><b>Definition:</b> timer.cpp:101</div></div>
  138. </div><!-- fragment --></div><!-- contents -->
  139. <!-- start footer part -->
  140. <hr class="footer"/><address class="footer"><small>
  141. Generated by &#160;<a href="http://www.doxygen.org/index.html">
  142. <img class="footer" src="doxygen.png" alt="doxygen"/>
  143. </a> 1.8.10
  144. </small></address>
  145. </body>
  146. </html>