예제 #1
0
파일: device.go 프로젝트: zdebeer99/zhome
func (this *FirmataDevice) RegisterChannel(is string, address string, chType string) {
	pin, err := se.StrToByte(address)
	if err != nil {
		err = fmt.Errorf("ChannelSetup Invalid address '%s'. address must be a pin number.", err)
		log.Println(err)
		return
	}
	mode, err := pinMode(chType)
	if err != nil {
		err = fmt.Errorf("ChannelSetup Invalid Pin Mode '%s'.", err)
		log.Println(err)
		return
	}
	ptype, err := pinType(chType)
	if err != nil {
		err = fmt.Errorf("ChannelSetup Invalid Pin Type '%s'.", err)
		log.Println(err)
		return
	}
	this.pins[address] = pinInfo{address, chType, pin, mode, ptype}
	if this.OK() {
		log.Println("SetPinMode", pin, mode)
		this.board.SetPinMode(pin, mode)
	}
	return
}
예제 #2
0
파일: device.go 프로젝트: zdebeer99/zhome
func (this *ZIOBoardDevice) RegisterChannel(id string, address string, chType string) {
	pin, err := se.StrToByte(address)
	if err != nil {
		err = fmt.Errorf("ZIOBoard '%s' ChannelSetup Invalid address '%s'. address must be a pin number. %s", id, address, err)
		log.Println(err)
		return
	}
	mode, err := pinMode(chType)
	if err != nil {
		err = fmt.Errorf("ZIOBoard '%s' ChannelSetup Invalid Pin Mode '%s'. %s", id, chType, err)
		log.Println(err)
		return
	}
	ptype, err := pinType(chType)
	if err != nil {
		err = fmt.Errorf("ZIOBoard '%s' ChannelSetup Invalid Pin Type '%s'. %s", id, chType, err)
		log.Println(err)
		return
	}
	this.pins[address] = pinInfo{id, address, chType, pin, mode, ptype, false}
	return
}