AskSin++
PhaseCut.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin++
3 // 2017-03-29 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 // 2019-01-11 scuba82: highly inspired by https://github.com/blackhack/ArduLibraries/tree/master/DimmerOne
5 //- -----------------------------------------------------------------------------------------------------------------------
6 
7 #ifndef _PHASECUT_h
8 #define _PHASECUT_h
9 
10 #ifndef PHASECUTMODE
11 #define PHASECUTMODE 0
12 #endif
13 
14 #ifndef ZEROPIN
15 #define ZEROPIN 2
16 #endif
17 
18 #include "Arduino.h"
19 //#include "Debug.h"
20 
21 namespace as {
22  class PhaseCut
23  {
24  public:
25  PhaseCut();
26 
27  void init(uint8_t output_pin);
28 
29  bool Start();
30  bool Stop();
31  bool isrunning();
32 
33  bool SetDimValue(double value);
34 
35  double GetDimValue() { return _timer; }
36 
37  // Do not call this!
38  void ZeroCrossEvent();
39  void CmpAEvent();
40  void Fire();
41 
42  private:
43  void SetTimer();
44 
45  uint8_t ZERO_CROSS_PIN;
46  uint8_t OUTPUT_PIN;
47  double _timer;
48 
49  bool _valid_zero_crossing;
50  bool isInit;
51  bool running;
52  };
53 
54  void ZeroCrossEventCaller();
55 
56  extern PhaseCut phaseCut;
57 }
58 #endif
as::PhaseCut
Definition: PhaseCut.h:23