Exemplo n.º 1
0
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)
	}
}
Exemplo n.º 2
0
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)
	}
}
Exemplo n.º 3
0
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)
	}
}