Beispiel #1
0
 public bool Initialize(Port port, 
                        ushort? deviceId = null,
                        Action<IRRemote,sbyte,int, ushort[],int> drc = null)
 {
     dataReceivedCallback = drc;
     return base.Initialize(port, "co.modulo.ir", deviceId);
 }
Beispiel #2
0
 public bool Initialize(Port port,
                        ushort? deviceId = null,
                        Action<MotorDriver> psitionReachedCallback = null,
                        Action<MotorDriver> fultChangedCallback = null)
 {
     positionReachedCallback = psitionReachedCallback;
     faultChangedCallback = fultChangedCallback;
     return base.Initialize(port, "co.modulo.motor", deviceId);
 }
 public bool Initialize(Port port,
                        ushort? deviceId = null,
                        Action<TemperatureProbe> tempCallback = null)
 {
     if (base.Initialize(port, "co.modulo.tempprobe", deviceId))
     {
         temperatureChangedCallback = tempCallback;
         return true;
     }
     return false;
 }
Beispiel #4
0
 public bool Initialize(Port port, 
                        ushort? deviceId = null,
                        Action<Modulo> btnPressCallback = null,
                        Action<Modulo> btnReleaseCallback = null,
                        Action<Modulo> psnChangeCallback = null)
 {
     base.Initialize(port, "co.modulo.knob", deviceId);
     buttonState = false;
     position = 0;
     buttonPressCallback = btnPressCallback;
     buttonReleaseCallback = btnReleaseCallback;
     positionChangeCallback = psnChangeCallback;
     return true;
 }
 public bool Initialize(Port port, 
                        ushort? deviceId = null,
                        Action<Modulo,int> pressCallback = null,
                        Action<Modulo,int> releaseCallback = null)
 {
     if (base.Initialize(port, "co.modulo.display", deviceId))
     {
         Width = 96;
         Height = 64;
         buttonPressCallback = pressCallback;
         buttonReleaseCallback = releaseCallback;
         return true;
     }
     return false;
 }
Beispiel #6
0
        public async Task KnobDisplayTutorial()
        {
            Port port = new Port();
            Assert.IsTrue(await port.Initialize(null));
            DisplayModulo display = new DisplayModulo();
            Assert.IsTrue(display.Initialize(port));
            Knob knob = new Knob();
            bool buttonRelease = false;
            bool posChange = false;

            Assert.IsTrue(knob.Initialize(port,
                    null,
                    null,
                    (knb) =>
                    {
                        buttonRelease = true;
                    },
                    (knb) =>
                    {
                        posChange = true;
                    }
                    ));
            while (port.Loop())
            {
                if (buttonRelease)
                {
                    display.Clear();
                    display.Write("knob done");
                    display.Refresh();
                    break;
                }
                if (posChange)
                {
                    int angle = knob.GetAngle();
                    display.Clear();
                    display.SetTextColor(1, 0, 0);
                    knob.SetColor(angle * 255 / 360.0f, angle * 255 / 360.0f, angle * 255 / 260.0f);
                    display.Write("knob angle " + angle);
                    display.Refresh();
                    posChange = false;
                }

            }
            display.Dispose();
            knob.Dispose();
            port.Close();
        }
Beispiel #7
0
        public async Task DisplayEventsTutorial()
        {
            Port port = new Port();
            Assert.IsTrue(await port.Initialize(null));
            DisplayModulo display = new DisplayModulo();
            Action<Modulo, int> resetLambda = (dsplay, btn) =>
            {
                display.Clear();
                display.SetTextColor(1, 1, 1);
                display.Write("Press Button");
                display.Refresh();
            };
            Assert.IsTrue(display.Initialize(port, null,
                (dsply, btn) =>
                {
                    display.Clear();
                    switch (btn)
                    {
                        case 0:
                            display.SetTextColor(1, 0, 0);
                            break;
                        case 1:
                            display.SetTextColor(0, 1, 0);
                            break;
                        case 2:
                            display.SetTextColor(0, 0, 1);
                            display.ShouldExit = true;
                            break;
                        default:
                            break;
                    }
                    display.Write(" Button " + btn);
                    display.Refresh();
                },
                (dsplay, btn) =>
                {
                    resetLambda(display, btn);
                }
                ));

            resetLambda(display, 0);

            port.RunForever();
            display.Dispose();
            port.Close();
        }
Beispiel #8
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();
        }
Beispiel #9
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();
        }
Beispiel #10
0
        public async Task JoyStickEventsDisplayTutorial()
        {
            bool shouldExit = false;
            bool joyStickChanged = true;
            Action<Modulo> changeLambda = (joy) => { joyStickChanged = true; };

            Port port = new Port();
            DisplayModulo display = new DisplayModulo();
            Joystick joystick = new Joystick();

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

            byte max_x = (byte)(display.Width - 1);
            byte max_y = (byte)(display.Height - 1);
            while (port.Loop())
            {
                if (joyStickChanged)
                {
                    joyStickChanged = false;
                    int screen_x = (int)(max_x / 2.0f - max_x / 2.0f * joystick.GetHPos());
                    int screen_y = (int)(max_y / 2.0f - max_y / 2.0f * joystick.GetVPos());
                    draw_crosshairs(display, screen_x, screen_y, joystick.GetButtonState());
                }
                if (shouldExit)
                {
                    break;
                }
            }
            display.Dispose();
            joystick.Dispose();
            port.Close();
        }