Esempio n. 1
0
 /// <summary>
 /// Returns an int value from 0 to 255 (included).
 /// </summary>
 /// <param name="InputPin">The Input pin on the PCF8591 to read analog value from</param>
 /// <returns>int</returns>
 public int ReadI2CAnalog(PCF8591_AnalogPin InputPin)
 {
     try
     {
         byte[] b = new byte[2];
         sensor.WriteRead(new byte[] { (byte)InputPin }, b);
         return(b[1]);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(-1);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Returns an double value from 0 to 1.
 /// </summary>
 /// <param name="InputPin">The Input pin on the PCF8591 to read analog value from</param>
 /// <returns>double</returns>
 public double ReadI2CAnalog_AsDouble_2Decimal(PCF8591_AnalogPin InputPin)
 {
     return(Math.Round(ReadI2CAnalog_AsDouble(InputPin) * 100) / 100);
 }
Esempio n. 3
0
 /// <summary>
 /// Returns an double value from 0 to 1.
 /// </summary>
 /// <param name="InputPin">The Input pin on the PCF8591 to read analog value from</param>
 /// <returns>double</returns>
 public double ReadI2CAnalog_AsDouble(PCF8591_AnalogPin InputPin)
 {
     return(ReadI2CAnalog(InputPin) / 255d);
 }
Esempio n. 4
0
 /// <summary>
 /// Returns an int value from 0 to 255 (included).
 /// </summary>
 /// <param name="InputPin">The Input pin on the PCF8591 to read analog value from</param>
 /// <returns></returns>
 public int ReadI2CAnalog(PCF8591_AnalogPin InputPin)
 {
     byte[] b = new byte[2];
     device.WriteRead(new byte[] { (byte)InputPin }, b);
     return(b[1]);
 }