예제 #1
0
        private async Task UpdateDisplay(string value)
        {
            double dval = Convert.ToDouble(value);
            string txt  = String.Format("{0:F2} {1}", dval, unit);

            CurVal.Text = txt;
            if (display != null)
            {
                long start = DateTime.Now.Ticks;
                try {
                    await l0.clear();

                    await l0.drawText(w - 1, h / 2, YDisplayLayer.ALIGN.CENTER_RIGHT, txt);

                    await display.swapLayerContent(0, 1);
                } catch (YAPI_Exception ex) {
                    await FatalError(ex.Message);
                }

                long stop  = DateTime.Now.Ticks;
                long delta = (stop - start) / 1000;
                if (delta > 50)
                {
                    Debug.WriteLine("screen update took {0}ms", delta);
                }
            }
        }
예제 #2
0
 public void DisplayFull(double currentspeed, double currentdistance, double currentduration, double maxspeed, double avgspeed, string speedUnit, string timeUnit, string distanceUnit)
 {
     if (_display.isOnline())
     {
         _bgLayer.clear();
         _bgLayer.selectGrayPen(0);
         _bgLayer.drawBar(0, 0, _w, _h);
         _bgLayer.selectGrayPen(255);
         _bgLayer.selectFont("Small.yfm");
         _bgLayer.drawText(1, 1 * _h / 5, YDisplayLayer.ALIGN.CENTER_LEFT, String.Format("speed={0:0.0}{1}", currentspeed, speedUnit));
         _bgLayer.drawText(1, 2 * _h / 5, YDisplayLayer.ALIGN.CENTER_LEFT, String.Format("(max={0:0.0}{2} avg={1:0.0}{2})", maxspeed, avgspeed, speedUnit));
         _bgLayer.drawText(1, 3 * _h / 5, YDisplayLayer.ALIGN.CENTER_LEFT, String.Format("distance = {0:0.0}{1}", currentdistance, distanceUnit));
         _bgLayer.drawText(1, 4 * _h / 5, YDisplayLayer.ALIGN.CENTER_LEFT, String.Format("Time = {0:0.0}{1}", currentduration, timeUnit));
         RePaint();
     }
 }
예제 #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();
        }
예제 #4
0
 /**
  * <summary>
  *   Erases the whole content of the layer (makes it fully transparent).
  * <para>
  *   This method does not change any other attribute of the layer.
  *   To reinitialize the layer attributes to defaults settings, use the method
  *   <c>reset()</c> instead.
  * </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 clear()
 {
     return(_objptr.clear());
 }