/** * <summary> * Changes the current load cell bridge excitation method. * <para> * Remember to call the <c>saveToFlash()</c> method of the module if the * modification must be kept. * </para> * <para> * </para> * </summary> * <param name="newval"> * a value among <c>YWeighScale.EXCITATION_OFF</c>, <c>YWeighScale.EXCITATION_DC</c> and * <c>YWeighScale.EXCITATION_AC</c> corresponding to the current load cell bridge excitation method * </param> * <para> * </para> * <returns> * <c>0</c> if the call succeeds. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public int set_excitation(int newval) { if (_func == null) { throw new YoctoApiProxyException("No WeighScale connected"); } if (newval == _Excitation_INVALID) { return(YAPI.SUCCESS); } // our enums start at 0 instead of the 'usual' -1 for invalid return(_func.set_excitation(newval - 1)); }
private async void onLoad(object sender, RoutedEventArgs e) { try { await YAPI.RegisterHub("usb"); sensor = YWeighScale.FirstWeighScale(); if (sensor == null) { await FatalError("No WeighScale connected"); } display = YDisplay.FirstDisplay(); if (display != null) { //clean up await display.resetAll(); // retreive the display size w = await display.get_displayWidth(); h = await display.get_displayHeight(); // reteive the first layer l0 = await display.get_displayLayer(0); l1 = await display.get_displayLayer(1); // display a text in the middle of the screen await l0.selectFont("Large.yfm"); } await sensor.set_excitation(YWeighScale.EXCITATION_AC); await YAPI.Sleep(3000); await sensor.tare(); unit = await sensor.get_unit(); await sensor.registerValueCallback(sensorValueChangeCallBack); } catch (YAPI_Exception ex) { await FatalError(ex.Message); } timer = new NonReentrantDispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 100); timer.TickTask = async() => { await dispatcherTimer_Tick(); }; timer.Start(); }