forked from GiorgioAresu/FanController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFanController.h
44 lines (40 loc) · 1.02 KB
/
FanController.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
/*
FanController.h - Library to control up to six fans.
Created by Giorgio Aresu, November 13, 2016.
Edited by LukeV1, April 15, 2019.
Released into the public domain.
*/
#ifndef FanController_h
#define FanController_h
#define LIBCALL_ENABLEINTERRUPT
#include "Arduino.h"
#include "EnableInterrupt.h"
class FanController
{
public:
FanController(byte sensorPin, unsigned int sensorThreshold, byte pwmPin = 0);
void begin();
unsigned int getSpeed();
void setDutyCycle(byte dutyCycle);
byte getDutyCycle();
private:
static FanController *_instances[6];
byte _sensorPin;
byte _sensorThreshold;
byte _pwmPin;
byte _pwmDutyCycle;
byte _instance;
unsigned int _lastReading;
volatile unsigned int _halfRevs;
unsigned long _lastMillis;
void _trigger();
void _attachInterrupt();
static void _triggerCaller(byte instance);
static void _triggerExt0();
static void _triggerExt1();
static void _triggerExt2();
static void _triggerExt3();
static void _triggerExt4();
static void _triggerExt5();
};
#endif