-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSyncPWM.h
58 lines (51 loc) · 1.63 KB
/
SyncPWM.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* SyncPWM library.
*
* Copyright Jean-Luc Béchennec 2015. Based on a design of Pierre Molinaro
*
* This library allows to use a PWM which is synchronized with the same
* PWM of other Arduino.
*
* Currently on ATMega328 timer2 is used so the PWM output is on pin 3
*
* This software is distributed under the GNU Public Licence v2 (GPLv2)
*
* Please read the LICENCE file
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "Arduino.h"
class SyncPWM
{
static byte syncPWMState;
/*
* Program timer2 to start the PWM
*/
void startPWM();
public:
/*
* beginMasterClock starts the synchronization signal on pin 3
*/
void beginMasterClock();
/*
* begin starts the synchronized PWM on pin 3. By default, the PWM
* is initialized at 0. The argument gives the synchronization pin
* where the signal coming from the master is received
*/
void begin(const byte pin);
/*
* analogWrite changed the value of the PWM
*/
void analogWrite(byte value);
/*
* displayPortAddrAndMask displays the port address and the bit mask
* used for the sync input pin
*/
void displayPortAddrAndMask();
};