-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOutputs.pde
More file actions
84 lines (68 loc) · 2.66 KB
/
Outputs.pde
File metadata and controls
84 lines (68 loc) · 2.66 KB
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
77
78
79
80
81
82
83
84
/*
Copyright (C) 2009, 2010 Matt Reba, Jeremiah Dillingham
This file is part of BrewTroller.
BrewTroller is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BrewTroller is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BrewTroller. If not, see <http://www.gnu.org/licenses/>.
BrewTroller - Open Source Brewing Computer
Software Lead: Matt Reba (matt_AT_brewtroller_DOT_com)
Hardware Lead: Jeremiah Dillingham (jeremiah_AT_brewtroller_DOT_com)
Documentation, Forums and more information available at http://www.brewtroller.com
*/
#include "HWProfile.h"
void pinInit() {
#ifdef OUTPUT_GPIO
{
byte gpioPinNums[OUT_GPIO_COUNT] = OUT_GPIO_PINS;
for (byte i = 0; i < OUT_GPIO_COUNT; i++) gpioPin[i].setup(gpioPinNums[i], OUTPUT);
}
#endif
#ifdef OUTPUT_MUX
muxLatchPin.setup(MUX_LATCH_PIN, OUTPUT);
muxDataPin.setup(MUX_DATA_PIN, OUTPUT);
muxClockPin.setup(MUX_CLOCK_PIN, OUTPUT);
muxENPin.setup(MUX_ENABLE_PIN, OUTPUT);
#if MUX_ENABLE_LOGIC == 0
muxENPin.set();
#endif
setMUX(0);
#endif
#ifdef HEARTBEAT
hbPin.setup(HEARTBEAT_PIN, OUTPUT);
#endif
}
#ifdef OUTPUT_MUX
void setMUX(unsigned long bits) {
vlvBits = bits;
//MUX Valve Code
//ground latchPin and hold low for as long as you are transmitting
muxLatchPin.clear();
//clear everything out just in case to prepare shift register for bit shifting
muxDataPin.clear();
muxClockPin.clear();
//for each bit in the long myDataOut
for (byte i = 0; i < 32; i++) {
muxClockPin.clear();
//create bitmask to grab the bit associated with our counter i and set data pin accordingly (NOTE: 32 - i causes bits to be sent most significant to least significant)
if ( vlvBits & ((unsigned long)1<<(31 - i)) ) muxDataPin.set(); else muxDataPin.clear();
//register shifts bits on upstroke of clock pin
muxClockPin.set();
//zero the data pin after shift to prevent bleed through
muxDataPin.clear();
}
//stop shifting
muxClockPin.clear();
muxLatchPin.set();
delayMicroseconds(10);
muxLatchPin.clear();
//Enable outputs
muxENPin.set(MUX_ENABLE_LOGIC);
}
#endif