示例#1
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();
        }
示例#2
0
 /**
  * <summary>
  *   Hides the layer.
  * <para>
  *   The state of the layer is preserved but the layer is not displayed
  *   on the screen until the next call to <c>unhide()</c>. Hiding the layer can positively
  *   affect the drawing speed, since it postpones the rendering until all operations are
  *   completed (double-buffering).
  * </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 hide()
 {
     return(_objptr.hide());
 }