示例#1
0
        public async Task TemperatureProbEventsDisplayTutorial()
        {
            bool shouldExit = false;
            bool tempChanged = true;
            Action<Modulo> changeLambda = (joy) => { tempChanged = true; };

            Port port = new Port();
            DisplayModulo display = new DisplayModulo();
            TemperatureProbe tempProbe = new TemperatureProbe();

            Assert.IsTrue(await port.Initialize(null));
            Assert.IsTrue(display.Initialize(port, null, (dsp, nt) => { shouldExit = true; }));
            Assert.IsTrue(tempProbe.Initialize(port, null, changeLambda));

            display.Clear();
            while (port.Loop())
            {
                if (tempChanged)
                {
                    display.SetCursor(0, 0);
                    display.Write("Temp C " + tempProbe.GetTemperatureCelsius() 
                        + "\r\ndeg F " + tempProbe.GetTemperatureFahrenheit());
                    display.Refresh();
                }
                if (shouldExit)
                {
                    break;
                }
            }
            display.Dispose();
            tempProbe.Dispose();
            port.Close();
        }
示例#2
0
        public async Task IRRemoteEventsDisplayTutorial()
        {
            bool shouldExit = false;
            bool stringChanged = false;
            String codeString = String.Empty;
            Action<IRRemote, sbyte, int, ushort[], int> dataReceivedCallback
                    = (rem, protocol, value, extdata, exlen) =>
                    {
                        codeString = String.Format("Protocol {0:X} {1:X} ex len {2}", protocol, value, exlen);
                        System.Diagnostics.Debug.WriteLine("String " + codeString);
                        stringChanged = true;
                    };
            Port port = new Port();
            DisplayModulo display = new DisplayModulo();
            IRRemote irRemote = new IRRemote();
            Assert.IsTrue(await port.Initialize(null));
            Assert.IsTrue(display.Initialize(port, null, (dsp, nt) => { shouldExit = true; }));
            Assert.IsTrue(irRemote.Initialize(port, null, dataReceivedCallback));

            display.Clear();
            while (port.Loop())
            {
                if (stringChanged)
                {
                    display.SetCursor(0, 0);
                    display.Write(codeString);
                    display.Refresh();
                    stringChanged = false;
                }
                if (shouldExit)
                {
                    break;
                }
            }
            display.Dispose();
            irRemote.Dispose();
            port.Close();
        }
示例#3
0
 private void draw_crosshairs(DisplayModulo display, int x, int y, bool selected)
 {
     float[] CROSSHAIR_COLOR = { 0.4f, 0.4f, 0.4f, 1.0f };//     # Gray
     float[] DOT_COLOR_DESELECTED = { 0.4f, 0.4f, 0.4f, 1.0f };//  # Gray
     float[] DOT_COLOR_SELECTED = { 1, 0, 0, 1 };//          # Red
     float[] TEXT_COLOR = { 0, 0.7f, 0, 1 };//               # Green
     int DOT_SIZE_SELECTED = 8;
     int DOT_SIZE_DESELECTED = 4;
     float[] dot_color;
     int dot_size;
     //# Draw crosshairs
     display.Clear();
     display.SetLineColor(CROSSHAIR_COLOR);
     //# Horizontal crosshair
     display.DrawRect(0, (byte)y, display.Width, 1);
     // # Vertical crosshair
     display.DrawRect((byte)x, 0, 1, display.Height);
     // # Dot
     if (selected)
     {
         dot_color = DOT_COLOR_SELECTED;
         dot_size = DOT_SIZE_SELECTED;
     }
     else
     {
         dot_color = DOT_COLOR_DESELECTED;
         dot_size = DOT_SIZE_DESELECTED;
     }
     display.SetFillColor(dot_color);
     display.DrawCircle((sbyte)x, (sbyte)y, (byte)dot_size);
     //# Coordinate value display
     display.SetTextColor(TEXT_COLOR);
     display.SetCursor(0, 0);
     display.Write(String.Format("x={0,2}\ny={1,2}", x, y));
     // # Update the display!
     display.Refresh();
 }