forked from bracci/Qlockthree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShiftRegister.h
50 lines (40 loc) · 1.06 KB
/
ShiftRegister.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
/**
* ShiftRegister
* Mit der ShiftRegister-Klasse wird das Ausgeben der Bitmuster auf die
* 74HC595-Shift-Register gekapselt.
*
* @mc Arduino/RBBB
* @autor Christian Aschoff / caschoff _AT_ mac _DOT_ com
* @version 1.7
* @created 24.2.2011
*/
#ifndef SHIFTREGISTER_H
#define SHIFTREGISTER_H
#include "Arduino.h"
class ShiftRegister {
public:
ShiftRegister(byte dataPin, byte clockPin, byte latchPin);
void shiftOut(word data);
void shiftOutABit(boolean bitIsSet);
void prepareShiftregisterWrite();
void finishShiftregisterWrite();
private:
// slow version
byte _dataPin;
byte _clockPin;
byte _latchPin;
// fast version
uint8_t _dataBit;
uint8_t _dataPort;
volatile uint8_t *_dataOut;
uint8_t _clockBit;
uint8_t _clockPort;
volatile uint8_t *_clockOut;
uint8_t _latchBit;
uint8_t _latchPort;
volatile uint8_t *_latchOut;
void fastDigitalWriteToData(uint8_t val);
void fastDigitalWriteToClock(uint8_t val);
void fastDigitalWriteToLatch(uint8_t val);
};
#endif