コード例 #1
0
ファイル: main.go プロジェクト: opendoor-labs/gong
func resetAllChannels(d *pca9685.PCA9685) error {
	for i := 0; i < 16; i++ {
		setting := servoMin
		if i == bellChannels["resale_contract"] {
			if isNewHardware() {
				setting = chimeMaxNew
			} else {
				setting = chimeMax
			}
		} else if isNewHardware() {
			setting = servoMinNew
		}
		if err := d.SetPwm(i, 0, setting); err != nil {
			return err
		}
	}
	return nil
}
コード例 #2
0
ファイル: main.go プロジェクト: opendoor-labs/gong
func ringBellNew(d *pca9685.PCA9685, chanID int) {
	if err := d.Wake(); err != nil {
		log.Fatal("waking: ", err)
	}
	time.Sleep(100 * time.Millisecond)
	if err := d.SetPwm(chanID, 0, servoMaxNew); err != nil {
		log.Fatal("setting to max: ", err)
	}
	time.Sleep(450 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, servoMinNew); err != nil {
		log.Fatal("setting to min: ", err)
	}
	time.Sleep(400 * time.Millisecond)
	if err := d.Sleep(); err != nil {
		log.Fatal("sleeping: ", err)
	}
}
コード例 #3
0
ファイル: main.go プロジェクト: opendoor-labs/gong
func ringChimeNew(d *pca9685.PCA9685, chanID int) {
	if err := d.Wake(); err != nil {
		log.Fatal("waking: ", err)
	}
	time.Sleep(100 * time.Millisecond)
	if err := d.SetPwm(chanID, 0, chimeMinNew); err != nil {
		log.Fatal("setting to min: ", err)
	}
	time.Sleep(100 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, chimeMaxNew); err != nil {
		log.Fatal("setting to middle: ", err)
	}
	time.Sleep(500 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, chimeMinNew); err != nil {
		log.Fatal("setting to min 2: ", err)
	}
	time.Sleep(100 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, chimeMaxNew); err != nil {
		log.Fatal("setting to max: ", err)
	}
	time.Sleep(400 * time.Millisecond)

	if err := d.Sleep(); err != nil {
		log.Fatal("sleeping: ", err)
	}
}
コード例 #4
0
ファイル: main.go プロジェクト: opendoor-labs/gong
func ringChime(d *pca9685.PCA9685, chanID int) {
	if isNewHardware() {
		ringChimeNew(d, chanID)
		return
	}

	if err := d.Wake(); err != nil {
		log.Fatal("waking: ", err)
	}
	time.Sleep(100 * time.Millisecond)
	if err := d.SetPwm(chanID, 0, chimeMin); err != nil {
		log.Fatal("setting to min: ", err)
	}
	time.Sleep(120 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, (chimeMin+2*chimeMax)/3); err != nil {
		log.Fatal("setting to middle: ", err)
	}
	time.Sleep(500 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, chimeMin); err != nil {
		log.Fatal("setting to min 2: ", err)
	}
	time.Sleep(120 * time.Millisecond)

	if err := d.SetPwm(chanID, 0, chimeMax); err != nil {
		log.Fatal("setting to max: ", err)
	}
	time.Sleep(400 * time.Millisecond)

	if err := d.Sleep(); err != nil {
		log.Fatal("sleeping: ", err)
	}
}