func (i *InterfaceKit) initInterfaceKit(h C.CPhidgetInterfaceKitHandle) error { var err error runtime.SetFinalizer(i, func(i *InterfaceKit) { i.cleanupInterfaceKit() }) i.ifkHandle = h if err = i.initPhidget(C.CPhidgetHandle(h)); err != nil { return err } i.inputChanged = make(chan InterfaceKitChange, channelSize) i.outputChanged = make(chan InterfaceKitChange, channelSize) i.sensorChanged = make(chan InterfaceKitChange, channelSize) i.InputChanged = i.inputChanged i.OutputChanged = i.outputChanged i.SensorChanged = i.sensorChanged if i.onInputChangedHandler, err = i.setOnChangeHandler(i.inputChanged, inputChanged); err != nil { return err } if i.onOutputChangedHandler, err = i.setOnChangeHandler(i.outputChanged, outputChanged); err != nil { return err } if i.onSensorChangedHandler, err = i.setOnChangeHandler(i.sensorChanged, sensorChanged); err != nil { return err } return nil }
func (i *IR) initIR(h C.CPhidgetIRHandle) error { runtime.SetFinalizer(i, func(i *IR) { i.cleanupIR() }) i.irHandle = h if err := i.initPhidget(C.CPhidgetHandle(h)); err != nil { return nil } i.code = make(chan IRCode, channelSize) i.learn = make(chan IRLearn, channelSize) i.rawData = make(chan IRRawData, channelSize) i.Code = i.code i.Learn = i.learn i.RawData = i.rawData if err := i.setOnCodeHandler(); err != nil { return err } if err := i.setOnLearnHandler(); err != nil { return err } if err := i.setOnRawDataHandler(); err != nil { return err } return nil }