blob: b27795ab69657aac80652d880346cac3a4225a58 (
plain)
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
|
#include "shift.h"
#include "consts.h"
unsigned char shift_state[2] = {0};
void update_shift_state() {
for(int i = 0; i < 2; i++)
shift(shift_state[i]);
}
void shift(unsigned char data) {
#ifdef DEBUG
Serial.print("Sending data to shift register: ");
Serial.println(data, BIN);
#endif
// pull down latch
digitalWrite(PINOUT_LCK, LOW);
for(int i = 0; i < 8; i++) {
bool bit = (data & 1 << i) > 0;
// schrijf bit en pulse serial clock
digitalWrite(PINOUT_SER, bit);
digitalWrite(PINOUT_SCK, HIGH);
delayMicroseconds(CONFIG_SRSER_DELAY);
digitalWrite(PINOUT_SCK, LOW);
}
// pull up latch
digitalWrite(PINOUT_LCK, HIGH);
}
|