Represents an analog sensor reading.
Inheritance: ISensorReading
Example #1
0
 /// <summary>
 /// Initializes a new <see cref="AnalogSensorReadingChangedEventArgs"/>
 /// </summary>
 /// <param name="reading">
 /// The current reading.
 /// </param>
 public AnalogSensorReadingChangedEventArgs(AnalogSensorReading reading)
 {
     if (reading == null)
     {
         throw new ArgumentNullException(nameof(reading));
     }
     this.Reading = reading;
 }
Example #2
0
        private void EnsureInitialized()
        {
            if (isInitialized) { return; }

            // Validate
            if (adcChannel == null) { throw new MissingIoException(nameof(AdcChannel)); }

            // Create default reading
            currentReading = new AnalogSensorReading(0, 0);

            // Done
            isInitialized = true;
        }
Example #3
0
        private void Update()
        {
            // Read X and Y values
            var val = adcChannel.ReadValue();
            var ratio = adcChannel.ReadRatio(); // TODO: Support customized value scaling

            // Update current value
            lock (currentReading)
            {
                currentReading = new AnalogSensorReading(val, ratio);
            }

            // Notify
            readingChangedEvent.Raise(this, new AnalogSensorReadingChangedEventArgs(currentReading));
        }
 /// <summary>
 /// Initializes a new <see cref="AnalogSensorReadingChangedEventArgs"/>
 /// </summary>
 /// <param name="reading">
 /// The current reading.
 /// </param>
 public AnalogSensorReadingChangedEventArgs(AnalogSensorReading reading)
 {
     if (reading == null) throw new ArgumentNullException("reading");
     this.Reading = reading;
 }