Exemple #1
0
func New(id string, Connection string) *FirmataDevice {
	dev := &FirmataDevice{
		id,
		Connection,
		nil,
		make(map[string]pinInfo),
		se.NewStatus(),
	}
	var err error
	log.Println("Initialze Firmata")
	dev.board, err = firmata.NewClient(Connection, 57600)
	if err != nil {
		dev.status.SetError(fmt.Errorf("Arduino Firmata.New() Connection '%s' Failed. Error: %s", Connection, err))
		log.Println("Arduino Firmata Board Error", err)
	} else {
		go dev.eventHandler()
		log.Println("Arduino Firmata")
	}
	log.Println("Firmata Loaded! Done")
	log.Println("-----------------------")
	log.Println("Testing DHT22")
	dev.board.SetPinMode(8, firmata.DHT22)
	dev.board.ReadDHT22(8)
	log.Println("-----------------------")
	return dev
}
Exemple #2
0
func New(id string, connection string) *QwikSwitchDevice {
	return &QwikSwitchDevice{
		id,
		connection,
		nil,
		se.NewStatus(),
		false,
		make(map[string]string),
	}
}
Exemple #3
0
func New(id string, connection string) *ZIOBoardDevice {
	dev := &ZIOBoardDevice{
		id,
		connection,
		nil,
		make(map[string]pinInfo),
		se.NewStatus(),
		0,
	}
	dev.status.SetErrorStr("initilizing device.")
	dev.board = NewZIOBoard(connection)
	return dev
}