【问题标题】:Using Gpio on Raspberry Pi 4 B with uno-platform在具有 uno 平台的 Raspberry Pi 4 B 上使用 Gpio
【发布时间】:2021-08-16 03:17:23
【问题描述】:

我真的希望我不是唯一一个遇到这个问题的人 (我删除了我之前的问题,因为它似乎有点误导,所以这是我的第二次尝试)

我尝试通过 Uno 应用使用 Rasbpery pi 4b GPIO 引脚:

我的设置:

我之前用 consol APP 试过,效果很好:

控制台APP代码:

using System;
using System.Device.Gpio;


namespace ConsoleApp1
{
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Startet");


        int pin = 17;
        GpioController controller = new GpioController();
        controller.OpenPin(pin, PinMode.Output);


        Console.WriteLine("Enter to Turn HIGH");
        Console.Read();

        Console.WriteLine("is HIGH");
        controller.Write(pin, PinValue.High);


        Console.WriteLine("Enter to Turn LOW");
        Console.Read();

        Console.WriteLine("is LOW");
        controller.Write(pin, PinValue.Low);




    }
}
}

上面的代码运行良好。现在我在 UNO 的尝试:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

using System.Device.Gpio;

namespace App1
{

public sealed partial class MainPage : Page
   
{
    
    public MainPage()
    {
        this.InitializeComponent();
    }

    bool SwitchOnOffReminder;


    private void Test_Click(object sender, RoutedEventArgs e)
    {
    
        int pin = 17;
        GpioController controller = new GpioController();
        controller.OpenPin(pin, PinMode.Output);
        



        Ausgabe.Text = "Meldung\n";
        Ausgabe.Text = Ausgabe.Text + controller.GetPinMode(pin).ToString();

        if (SwitchOnOffReminder== false)
        {
            SwitchOnOffReminder= true;
            Ausgabe.Text = Ausgabe.Text + "Pin HIGH";
            controller.Write(pin, PinValue.High);


        }
        else
        {
            SwitchOnOffReminder= false;
            Ausgabe.Text = Ausgabe.Text + "Pin LOW";
            controller.Write(pin, PinValue.Low);

        }

    }
}
}

结果:它不起作用,Raspberry 控制台显示: Uno.UI.Runtime.skia.GtkCoreWindowsExtension[0] Gtk 不支持指针捕获发布"

有人可以帮我吗?

【问题讨论】:

  • 您将哪个 nuget 包添加到您的应用程序中?如果是System.Device.Gpio,您可能会遇到此问题:github.com/unoplatform/uno/issues/3813。另外,Ausgabe.Text 是否在点击时被更改?
  • @JérômeLaban 是的,正是我需要的!!!!谢谢你

标签: c# raspberry-pi4 uno-platform pigpio


【解决方案1】:

正如@JérômeLaban 在评论中回答的那样:

您可以在这里找到解决方案: github.com/unoplatform/uno/issues/3813

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-11
    相关资源
    最近更新 更多