示例#1
0
func CloseDoor() {
	config.Local_elev.Door_open = false
	hardware.SetDoorOpenLamp(0)
	dir := ChooseNewDirection()
	config.Local_elev.Is_idle = (dir == config.DIR_STOP)
	config.Local_elev.Direction = dir
	hardware.SetMotorDirection(dir)
}
示例#2
0
func OpenDoor(ch_open <-chan bool) {
	const duration = 2 * time.Second
	timer := time.NewTimer(0)
	timer.Stop()
	for {
		time.Sleep(100 * time.Millisecond)
		select {
		case <-ch_open:
			timer.Reset(duration)
			config.Local_elev.Door_open = true
			hardware.SetDoorOpenLamp(1)
		case <-timer.C:
			timer.Stop()
			CloseDoor()
		}
	}
}