Esempio n. 1
0
        /// <summary>
        /// Get basic PiJuice status information
        /// </summary>
        /// <returns>PiJuice status</returns>
        public Status GetStatus()
        {
            Status status = new Status();

            var response = _piJuice.ReadCommand(PiJuiceCommand.Status, 1);

            status.IsFault              = (response[0] & 0x01) == 0x01;
            status.IsButton             = (response[0] & 0x02) == 0x02;
            status.Battery              = (BatteryState)(response[0] >> 2 & 0x03);
            status.PowerInput           = (PowerInState)(response[0] >> 4 & 0x03);
            status.PowerInput5VoltInput = (PowerInState)(response[0] >> 6 & 0x03);

            return(status);
        }
Esempio n. 2
0
 /// <summary>
 /// Get basic PiJuice status information
 /// </summary>
 /// <returns>PiJuice status</returns>
 public Status GetStatus()
 {
     byte[] response = _piJuice.ReadCommand(PiJuiceCommand.Status, 1);
     return(new Status(
                (response[0] & 0x01) == 0x01,
                (response[0] & 0x02) == 0x02,
                (BatteryState)(response[0] >> 2 & 0x03),
                (PowerInState)(response[0] >> 4 & 0x03),
                (PowerInState)(response[0] >> 6 & 0x03)));
 }
Esempio n. 3
0
 /// <summary>
 /// Get battery profile
 /// </summary>
 /// <returns>Battery profile</returns>
 public BatteryProfile GetBatteryProfile()
 {
     byte[] response = _piJuice.ReadCommand(PiJuiceCommand.BatteryProfile, 14);
     return(new BatteryProfile(
                new ElectricCharge(BinaryPrimitives.ReadInt16LittleEndian(response), ElectricChargeUnit.MilliampereHour),
                new ElectricCurrent(response[2] * 75 + 550, ElectricCurrentUnit.Milliampere),
                new ElectricCurrent(response[3] * 50 + 50, ElectricCurrentUnit.Milliampere),
                new ElectricPotential(response[4] * 20 + 3500, ElectricPotentialUnit.Millivolt),
                new ElectricPotential(response[5] * 20, ElectricPotentialUnit.Millivolt),
                new Temperature(response[6], TemperatureUnit.DegreeCelsius),
                new Temperature(response[7], TemperatureUnit.DegreeCelsius),
                new Temperature(response[8], TemperatureUnit.DegreeCelsius),
                new Temperature(response[9], TemperatureUnit.DegreeCelsius),
                (response[11] << 8) | response[10],
                new ElectricResistance(((response[13] << 8) | response[12]) * 10, ElectricResistanceUnit.Ohm)));
 }
Esempio n. 4
0
 /// <summary>
 /// Get battery profile
 /// </summary>
 /// <returns>Battery profile</returns>
 public BatteryProfile GetBatteryProfile()
 {
     byte[] response = _piJuice.ReadCommand(PiJuiceCommand.BatteryProfile, 14);
     return(new BatteryProfile(
                ElectricCharge.FromMilliampereHours(BinaryPrimitives.ReadInt16LittleEndian(response)),
                ElectricCurrent.FromMilliamperes(response[2] * 75 + 550),
                ElectricCurrent.FromMilliamperes(response[3] * 50 + 50),
                ElectricPotential.FromMillivolts(response[4] * 20 + 3500),
                ElectricPotential.FromMillivolts(response[5] * 20),
                Temperature.FromDegreesCelsius(response[6]),
                Temperature.FromDegreesCelsius(response[7]),
                Temperature.FromDegreesCelsius(response[8]),
                Temperature.FromDegreesCelsius(response[9]),
                (response[11] << 8) | response[10],
                ElectricResistance.FromOhms(((response[13] << 8) | response[12]) * 10)));
 }
Esempio n. 5
0
        /// <summary>
        /// Get battery profile
        /// </summary>
        /// <returns>Battery profile</returns>
        public BatteryProfile GetBatteryProfile()
        {
            var batteryProfile = new BatteryProfile();

            var response = _piJuice.ReadCommand(PiJuiceCommand.BatteryProfile, 14);

            batteryProfile.Capacity           = new ElectricCharge(BinaryPrimitives.ReadInt16LittleEndian(response), ElectricChargeUnit.MilliampereHour);
            batteryProfile.ChargeCurrent      = new ElectricCurrent(response[2] * 75 + 550, ElectricCurrentUnit.Milliampere);
            batteryProfile.TerminationCurrent = new ElectricCurrent(response[3] * 50 + 50, ElectricCurrentUnit.Milliampere);
            batteryProfile.RegulationVoltage  = new ElectricPotential(response[4] * 20 + 3500, ElectricPotentialUnit.Millivolt);
            batteryProfile.CutOffVoltage      = new ElectricPotential(response[5] * 20, ElectricPotentialUnit.Millivolt);
            batteryProfile.TemperatureCold    = new Temperature(response[6], TemperatureUnit.DegreeCelsius);
            batteryProfile.TemperatureCool    = new Temperature(response[7], TemperatureUnit.DegreeCelsius);
            batteryProfile.TemperatureWarm    = new Temperature(response[8], TemperatureUnit.DegreeCelsius);
            batteryProfile.TemperatureHot     = new Temperature(response[9], TemperatureUnit.DegreeCelsius);
            batteryProfile.NegativeTemperatureCoefficientB          = (response[11] << 8) | response[10];
            batteryProfile.NegativeTemperatureCoefficientResistance = new ElectricResistance(((response[13] << 8) | response[12]) * 10, ElectricResistanceUnit.Ohm);

            return(batteryProfile);
        }