func main() { flag.Parse() if !utils.FileExists("/sys/bus/w1/devices/28-0000047ade8f") { ioutil.WriteFile("/sys/devices/bone_capemgr.9/slots", []byte("BB-W1:00A0"), 0666) } b, err := ioutil.ReadFile(*configPath) if err != nil { panic(err) } cfg := &gogadgets.Config{} err = json.Unmarshal(b, cfg) for _, config := range cfg.Gadgets { if config.Location == "mash tun" && config.Name == "valve" { gpio, err := gogadgets.NewGPIO(&config.Pin) if err == nil { cfg := &brewery.MashConfig{ TankRadius: *mashRadius, ValveRadius: *valveRadius, } dev, mashErr := brewgadgets.NewMash(cfg) mash := dev.(*brewgadgets.Mash) mash.HLTVolume = *hltVolume if mashErr == nil { brewgadgets.Calibrate(mash, gpio) } else { fmt.Println(mashErr) } } else { fmt.Println(err) } } } }
//gpio for the float switch at the top of my hlt. When //it is triggered I know how much water is in the container. func getPoller(cfg *BrewConfig) gogadgets.Poller { pin := &gogadgets.Pin{ Port: cfg.FloatSwitchPort, Pin: cfg.FloatSwitchPin, Direction: "in", Edge: "rising", } g, err := gogadgets.NewGPIO(pin) if err != nil { panic(err) } return g }