Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
analog.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 08.07.2013 21:21:42 EDT
3 // File: analog.hpp
4 
5 /* This program is free software. It comes without any warranty, to
6  * the extent permitted by applicable law. You can redistribute it
7  * and/or modify it under the terms of the Do What The Fuck You Want
8  * To Public License, Version 2, as published by Sam Hocevar. See
9  * http://www.wtfpl.net/ or COPYING for more details. */
10 
11 #ifndef __ANALOG_HEADER
12 #define __ANALOG_HEADER
13 
14 #include <Arduino.h>
15 
16 #include <ustd/filter.hpp>
17 
18 namespace tool {
19  template<uint8_t pin, unsigned N = 4, unsigned W = 1>
20  class analog_class {
21  typedef int16_t value_type;
22  public:
24  for(unsigned i = 0; i < 2*N; ++i) {
25  update(); //warm up
26  }
27  }
28  operator value_type() const {
29  return f;
30  }
31  void update() {
32  f << analogRead(pin);
33  }
34  bool intervall(value_type const & low, value_type const & high) {
35  if(f > low and f < high)
36  return true;
37  return false;
38  }
39  private:
41  };
42 }//end namespace tool
43 
44 #endif //__ANALOG_HEADER
Definition: analog.hpp:20
Definition: tags.hpp:18
typename realization< T, tag0, typename realization< T, tag1, typename realization< T, tag2, typename realization< T, tag3, typename realization< T, tag4, typename realization< T, tag5, typename realization< T, tag6, typename realization< T, tag7, typename realization< T, tag8, typename realization< T, tag9, typename realization< T, end_tag, void >::type >::type >::type >::type >::type >::type >::type >::type >::type >::type >::type filter
Definition: filter.hpp:53
bool intervall(value_type const &low, value_type const &high)
Definition: analog.hpp:34
void update()
Definition: analog.hpp:31
analog_class()
Definition: analog.hpp:23