-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFanSpeed.h
executable file
·76 lines (63 loc) · 1.34 KB
/
FanSpeed.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
FanSpeed.h - Library for reading fan speed.
Created by Andrey Rublev, November 10, 2010.
*/
#ifndef FanSpeed_h
#define FanSpeed_h
#include "WProgram.h"
typedef void (*FANCB)(uint8_t);
class FanSpeedBase
{
public:
virtual void process();
volatile unsigned long counter;
void reset();
protected:
void init(int pin, bool useInternalResistor);
int _pin;
};
class FanSpeed: public FanSpeedBase
{
public:
FanSpeed(int pin, bool useInternalResistor = true);
void process();
private:
uint8_t pulseState;
uint8_t prevPulseState;
uint8_t bit;
};
class FanSpeedInt: public FanSpeedBase
{
public:
FanSpeedInt(int pin, bool useInternalResistor = true);
void process();
};
/**
FanSpeedMultiD - for reading fan speed from ports 0-7
*/
class FanSpeedMultiD
{
public:
FanSpeedMultiD(uint8_t pins, uint8_t states, FANCB cb);
void process();
protected:
FANCB callback;
uint8_t state;
uint8_t prevState;
uint8_t bits;
};
/**
FanSpeedMultiB - for reading fan speed from ports 8-13
*/
class FanSpeedMultiB
{
public:
FanSpeedMultiB(uint8_t pins, uint8_t states, FANCB cb);
void process();
protected:
FANCB callback;
uint8_t state;
uint8_t prevState;
uint8_t bits;
};
#endif