Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        /// <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);
        }