Exemple #1
0
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)
			}
		}
	}
}
Exemple #2
0
func (g *GPIO) Init() error {
	if !utils.FileExists(g.directionPath) {
		if err := g.writeValue(g.exportPath, g.export); err != nil {
			return err
		}
	}
	if g.activeLow == "1" {
		if err := g.writeValue(g.activeLowPath, g.activeLow); err != nil {
			return err
		}
	}
	if err := g.writeValue(g.directionPath, g.direction); err != nil {
		return err
	}
	if g.direction == "out" {
		if err := g.writeValue(g.valuePath, "0"); err != nil {
			return err
		}
	} else if g.edge != "" {
		if err := g.writeValue(g.edgePath, g.edge); err != nil {
			return err
		}
	}
	return nil
}
Exemple #3
0
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)
	}
	a := gogadgets.NewApp(configFlag)
	sleepTimes := map[string]time.Duration{
		"bed 1": 300 * time.Second,
		"bed 2": 300 * time.Second,
		"bed 3": 300 * time.Second,
	}
	g := &Greenhouse{sleepTimes: sleepTimes}
	a.AddGadget(g)
	a.Start()
}
Exemple #4
0
//I am too lazy to load the BB-W1 device tree overlay the right way, which would
//be to add it to uEnv.txt (which is a config file for u-boot).
func checkW1() {
	if !utils.FileExists("/sys/bus/w1/devices/28-0000047ade8f") {
		ioutil.WriteFile("/sys/devices/bone_capemgr.9/slots", []byte("BB-W1:00A0"), 0666)
	}
}