Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pin_concept.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 15.11.2013 01:16:15 CET
3 // File: pin_concept.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 __PIN_CONCEPT_HEADER
12 #define __PIN_CONCEPT_HEADER
13 
14 #include "../ustd/ard_assert.hpp"
15 
16 namespace tool {
17  template<uint8_t pin>
18  class intern {
19  public:
20  void mode(uint8_t const & pm) {
21  pinMode(pin, pm);
22  }
23  void write(bool const & state) {
24  digitalWrite(pin, state);
25  }
26  bool read() {
27  return digitalRead(pin);
28  }
29  void tone(uint16_t const & note, uint16_t const & dur) {
30  ::tone(pin, note, dur);
31  }
32  void tone(uint16_t const & note) {
33  ::tone(pin, note);
34  }
35  void no_tone() {
36  ::noTone(pin);
37  }
38  private:
39 
40  };
41 
42  class fake {
43  public:
44  void mode(uint8_t const & pm) {
45  }
46  void write(bool const & state) {
47  ASSERT_MSG(false, "don't use write of the fake pin")
48  }
49  bool read() {
50  ASSERT_MSG(false, "don't use read of the fake pin")
51  return false;
52  }
53  private:
54 
55  };
56 
57 
58 }//end namespace tool
59 
60 //------------------- some abbreviations -------------------
81 
82 #endif //__PIN_CONCEPT_HEADER
void tone(uint16_t const &note)
Definition: pin_concept.hpp:32
Definition: pin_concept.hpp:18
tool::intern< A4 > DA4
Definition: pin_concept.hpp:79
tool::intern< 6 > D6
Definition: pin_concept.hpp:67
tool::intern< 11 > D11
Definition: pin_concept.hpp:72
void mode(uint8_t const &pm)
Definition: pin_concept.hpp:20
tool::intern< A3 > DA3
Definition: pin_concept.hpp:78
tool::intern< 4 > D4
Definition: pin_concept.hpp:65
tool::intern< 2 > D2
Definition: pin_concept.hpp:63
tool::intern< 8 > D8
Definition: pin_concept.hpp:69
void mode(uint8_t const &pm)
Definition: pin_concept.hpp:44
#define digitalRead(x)
Definition: fast_io.hpp:60
tool::intern< 12 > D12
Definition: pin_concept.hpp:73
#define ASSERT_MSG(exp, msg)
Definition: ard_assert.hpp:34
tool::intern< 5 > D5
Definition: pin_concept.hpp:66
tool::intern< 0 > D0
Definition: pin_concept.hpp:61
void no_tone()
Definition: pin_concept.hpp:35
void write(bool const &state)
Definition: pin_concept.hpp:46
void write(bool const &state)
Definition: pin_concept.hpp:23
tool::intern< 7 > D7
Definition: pin_concept.hpp:68
tool::intern< 13 > D13
Definition: pin_concept.hpp:74
tool::intern< 1 > D1
Definition: pin_concept.hpp:62
bool read()
Definition: pin_concept.hpp:49
tool::intern< A5 > DA5
Definition: pin_concept.hpp:80
tool::intern< A1 > DA1
Definition: pin_concept.hpp:76
tool::intern< 3 > D3
Definition: pin_concept.hpp:64
void tone(uint16_t const &note, uint16_t const &dur)
Definition: pin_concept.hpp:29
bool read()
Definition: pin_concept.hpp:26
Definition: pin_concept.hpp:42
tool::intern< A2 > DA2
Definition: pin_concept.hpp:77
tool::intern< A0 > DA0
Definition: pin_concept.hpp:75
tool::intern< 9 > D9
Definition: pin_concept.hpp:70
tool::intern< 10 > D10
Definition: pin_concept.hpp:71
#define digitalWrite(x, y)
Definition: fast_io.hpp:59