Ejemplo n.º 1
0
 protected override void functionArrival()
 {
     base.functionArrival();
     _displayWidth  = _func.get_displayWidth();
     _displayHeight = _func.get_displayHeight();
     _displayType   = _func.get_displayType() + 1;
     _layerWidth    = _func.get_layerWidth();
     _layerHeight   = _func.get_layerHeight();
     _layerCount    = _func.get_layerCount();
 }
Ejemplo n.º 2
0
        public HamsterScreen(string hwid, bool useImperial)
        {
            if (hwid == "")
            {
                _display = YDisplay.FirstDisplay();
                if (_display == null)
                {
                    throw new Exception("No Yocto-Display connected");
                }
            }
            else
            {
                _display = YDisplay.FindDisplay(hwid);
                if (!_display.isOnline())
                {
                    throw new Exception("No Yocto-Display named " + hwid + "found");
                }
            }

            _useImperial = useImperial;
            _display.resetAll();
            _w       = _display.get_displayWidth();
            _h       = _display.get_displayHeight();
            _fgLayer = _display.get_displayLayer(2);
            _bgLayer = _display.get_displayLayer(1);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Console dotNET Application 0.1.0");
            Console.WriteLine("--------------------------------");
            Console.WriteLine("");

            Console.WriteLine("Using Yoctopuce lib " + YAPI.GetAPIVersion());
            string errsmg = "";

            if (YAPI.RegisterHub("usb", ref errsmg) != YAPI.SUCCESS)
            {
                Console.WriteLine("Unable to register the USB port :" + errsmg);
                return;
            }

            YSensor sensor = YSensor.FirstSensor();

            if (sensor == null)
            {
                Console.WriteLine("No Yoctopuce sensor find on USB.");
                return;
            }

            YDisplay display = YDisplay.FirstDisplay();

            if (display == null)
            {
                Console.WriteLine("No Yoctopuce display find on USB.");
                return;
            }

            // display clean up
            display.resetAll();

            YDisplayLayer l1 = display.get_displayLayer(1);

            l1.hide();    // L1 is hidden, l2 stay visible
            int w = display.get_displayWidth();
            int h = display.get_displayHeight();


            while (sensor.isOnline() && display.isOnline())
            {
                string value = sensor.get_currentValue() + " " + sensor.get_unit();
                string name  = sensor.get_friendlyName();
                // display a text in the middle of the screen
                l1.clear();
                l1.selectFont("Large.yfm");
                l1.drawText(w / 2, h / 2, YDisplayLayer.ALIGN.CENTER, value);
                l1.selectFont("Small.yfm");
                l1.drawText(w - 1, h - 1, YDisplayLayer.ALIGN.BOTTOM_RIGHT, name);
                display.swapLayerContent(0, 1);
                Console.WriteLine(name + " ->" + value);
                YAPI.Sleep(500, ref errsmg);
            }
            YAPI.FreeAPI();
        }
Ejemplo n.º 4
0
        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();
        }