Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            _thread = new Thread(() =>
            {
                while (!_close)
                {
                    byte gp_value = _gpio.ReadGpioVal();
                    bool trigger  = FormatGPIOOutVal(gp_value);
                    if (trigger)
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            gp66_out.Text = "1";
                            Out_Click(null, null);
                        }));
                    }
                    else
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            gp66_out.Text = "0";
                            Out_Click(null, null);
                        }));
                    }
                    SpinWait.SpinUntil(() => _close, 10);
                }
            });

            Loaded       += MainWindow_Loaded;
            this.Closing += Gpio_Closing;
            Init();
        }
        private void InitGpioModeAndVal()
        {
            byte gp_mode = GPIO.ReadGpioMode();

            FormatGPIOModeVal(gp_mode);
            string str_mode = Utils.BinaryStrToHexStr(Utils.ByteToBinaryStr(gp_mode));

            mode_val.Text = str_mode;

            byte gp_value = GPIO.ReadGpioVal();

            FormatGPIOOutVal(gp_value);
            string str_val = Utils.BinaryStrToHexStr(Utils.ByteToBinaryStr(gp_value));

            out_val.Text = str_val;
        }