コード例 #1
0
ファイル: SoftPwm.cs プロジェクト: jessejjohnson/iot-devices
        /// <summary>
        /// Initializes a new <see cref="SoftPwm"/> instance.
        /// </summary>
        public SoftPwm()
        {
            // Get GPIO
            gpioController = GpioController.GetDefault();

            // Make sure we have it
            if (gpioController == null) { throw new DeviceNotFoundException("GPIO"); }

            // How many pins
            pinCount = gpioController.PinCount;

            // Create pin lookup
            pins = new Dictionary<int, SoftPwmPin>(pinCount);

            // Create
            stopwatch = new Stopwatch();

            // Defaults
            actualFrequency = MIN_FREQUENCY;
            ticksPerSecond = Stopwatch.Frequency;

            // Create the updater. Default to 0 seconds between updates, meaning run as fast as possible.
            // IMPORTANT: Do not use Scheduler.Default, create a new Scheduler.
            // This puts us in parallel priority with other sensors and allows
            // us to run on a separate core if available.
            updater = new ScheduledUpdater(scheduleOptions: new ScheduleOptions(0), scheduler: new Scheduler());
            updater.SetUpdateAction(Update);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new <see cref="AnalogSensor"/> instance.
        /// </summary>
        public AnalogSensor()
        {
            // Create updater
            updater = new ScheduledUpdater(new ScheduleOptions(reportInterval: 100));
            updater.SetUpdateAction(Update);
            updater.Starting += (s, e) => EnsureInitialized();

            // Create events
            readingChangedEvent = new ObservableEvent<IAnalogSensor, AnalogSensorReadingChangedEventArgs>(updater);
        }
コード例 #3
0
ファイル: SS944.cs プロジェクト: jessejjohnson/iot-devices
        /// <summary>
        /// Initializes a new <see cref="SS944"/> instance.
        /// </summary>
        public SS944()
        {
            // Create updater
            updater = new ScheduledUpdater(new ScheduleOptions(reportInterval: 100));
            updater.SetUpdateAction(Update);
            updater.Starting += (s, e) => EnsureInitialized();

            // Create events
            readingChangedEvent = new ObservableEvent<IThumbstick, ThumbstickReadingChangedEventArgs>(updater);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new <see cref="GraphicsDisplayPanel"/> instance.
        /// </summary>
        public GraphicsDisplayPanel()
        {
            // Theme
            this.DefaultStyleKey = typeof(GraphicsDisplayPanel);

            // Create the updater. Default to 1 second between updates.
            // IMPORTANT: Do not use Scheduler.Default, create a new Scheduler.
            // This puts us in parallel priority with other sensors and allows 
            // us to run on a separate core if available.
            updater = new ScheduledUpdater(scheduleOptions: new ScheduleOptions(1000), scheduler: new Scheduler());
            updater.SetAsyncUpdateAction(RenderAsyncAction);
        }
コード例 #5
0
ファイル: SoftPwm.cs プロジェクト: jessejjohnson/iot-devices
 public void Dispose()
 {
     if (updater != null)
     {
         updater.Dispose();
         updater = null;
     }
     // Dispose each pin
     lock(pins)
     {
         for (int i = pinCount - 1; i >= 0; i--)
         {
             if (pins.ContainsKey(i))
             {
                 pins[i].Pin.Dispose();
                 pins.Remove(i);
             }
         }
     }
     pins = null;
 }
コード例 #6
0
        public void Dispose()
        {
            if (updater != null)
            {
                updater.Dispose();
                updater = null;
            }

            if (adcChannel != null)
            {
                adcChannel.Dispose();
                adcChannel = null;
            }

            isInitialized = false;
        }
コード例 #7
0
ファイル: SS944.cs プロジェクト: jessejjohnson/iot-devices
 public void Dispose()
 {
     if (updater != null)
     {
         updater.Dispose();
         updater = null;
     }
     if (buttonPin != null)
     {
         buttonPin.Dispose();
         buttonPin = null;
     }
     if (xChannel != null)
     {
         xChannel.Dispose();
         xChannel = null;
     }
     if (yChannel != null)
     {
         yChannel.Dispose();
         yChannel = null;
     }
     isInitialized = false;
 }