-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcc-controller.go
77 lines (62 loc) · 1.34 KB
/
rcc-controller.go
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
package main
import (
"fmt"
"os"
"time"
"github.com/fatih/color"
"github.com/stianeikeland/go-rpio"
)
var (
// Use mcu pin 10, corresponds to physical pin 19 on the pi
blinkPin = rpio.Pin(4)
rccPin = rpio.Pin(3)
//pulseLength = 300
)
// InitRCC adds type and callback to types map.
func InitRCC() {
AddDeviceType("RCCSimple", RCCCommandHandler)
}
// RCCCommandHandler handles command string for RCCSimple Type devices.
func RCCCommandHandler(data *GenericCommand) {
if Debug {
fmt.Println("Processing RCCSimple Command", data)
}
}
func testRCCSend() {
if err := rpio.Open(); err != nil {
fmt.Println(err)
os.Exit(1)
}
defer rpio.Close()
rccPin.Output()
testCode := [13]int{1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0}
// Toggle pin 20 times
for x := 0; x < len(testCode); x++ {
state := testCode[x]
if state == 1 {
color.Green("High: ", state)
rccPin.High()
} else {
color.Green("Low: ", state)
rccPin.Low()
}
time.Sleep(300)
}
}
func testGPIO() {
// Open and map memory to access gpio, check for errors
if err := rpio.Open(); err != nil {
fmt.Println(err)
os.Exit(1)
}
// Unmap gpio memory when done
defer rpio.Close()
// Set pin to output mode
blinkPin.Output()
// Toggle pin 20 times
for x := 0; x < 20; x++ {
color.Green("Blinking...")
blinkPin.Toggle()
time.Sleep(time.Second / 5)
}
}