/** * <summary> * Adapts the load cell signal bias (stored in the corresponding genericSensor) * so that the current signal corresponds to a zero weight. * <para> * Remember to call the * <c>saveToFlash()</c> method of the module if the modification must be kept. * </para> * <para> * </para> * </summary> * <returns> * <c>0</c> if the call succeeds. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public virtual int tare() { if (_func == null) { throw new YoctoApiProxyException("No WeighScale connected"); } return(_func.tare()); }
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(); }