コード例 #1
0
        public GpioWatcher(PinConfigration pinConfigration)
        {
            config  = pinConfigration;
            watcher = new FileSystemWatcher();

            // watcher configration.
            watcher.Path         = $"/sys/class/gpio/gpio{config.PinNumber}/";
            watcher.NotifyFilter = NotifyFilters.LastWrite;
            watcher.Changed     += (o, e) =>
            {
                Console.WriteLine($"{DateTime.Now} : watcher :{e.Name}");
                switch (e.Name)
                {
                case "value":
                    OnValueChanged();
                    break;

                case "direction":
                    OnDirectionChanged();
                    break;
                }
            };

            watcher.EnableRaisingEvents = true;
        }
コード例 #2
0
        public GpioController(PinConfigration pinConfigration)
        {
            config = pinConfigration;

            Open();
            Direction = config.Output;
        }