-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the case where a PiJuice isn't present
- Loading branch information
1 parent
5718266
commit dc8f024
Showing
8 changed files
with
166 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
| ||
namespace PiJuiceSharp | ||
{ | ||
/// <summary> | ||
/// A placeholder implementation of <see cref="IPiJuiceStatus"/> that returns default values for when no PiJuice | ||
/// interface is present at all. | ||
/// </summary> | ||
public sealed class AbsentPiJuiceStatus : IPiJuiceStatus | ||
{ | ||
public void Dispose() | ||
{ | ||
} | ||
|
||
public float GetBatteryCurrent() | ||
{ | ||
return 0F; | ||
} | ||
|
||
public int GetBatteryTemperature() | ||
{ | ||
return 0; | ||
} | ||
|
||
public float GetBatteryVoltage() | ||
{ | ||
return 0F; | ||
} | ||
|
||
public int GetChargeLevel() | ||
{ | ||
return 0; | ||
} | ||
|
||
public Dictionary<string, object> GetFaultStatus() | ||
{ | ||
return new(); | ||
} | ||
|
||
public float GetGpioCurrent() | ||
{ | ||
return 0F; | ||
} | ||
|
||
public float GetGpioVoltage() | ||
{ | ||
return 0F; | ||
} | ||
|
||
public LedBlinkState GetLedBlinkState(Led led) | ||
{ | ||
return new(); | ||
} | ||
|
||
public Color GetLedState(Led led) | ||
{ | ||
return new(); | ||
} | ||
|
||
public StatusInfo GetStatus() | ||
{ | ||
return new StatusInfo(false, false, BatteryStatus.NoPiJuice, PowerInputStatus.NotPresent, PowerInputStatus.NotPresent); | ||
} | ||
|
||
public void SetLedBlinkState(Led led, LedBlinkState state) | ||
{ | ||
} | ||
|
||
public void SetLedState(Led led, Color color) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
| ||
namespace PiJuiceSharp | ||
{ | ||
public interface IPiJuiceStatus : IDisposable | ||
{ | ||
float GetBatteryCurrent(); | ||
int GetBatteryTemperature(); | ||
float GetBatteryVoltage(); | ||
int GetChargeLevel(); | ||
Dictionary<string, object> GetFaultStatus(); | ||
float GetGpioCurrent(); | ||
float GetGpioVoltage(); | ||
LedBlinkState GetLedBlinkState(Led led); | ||
Color GetLedState(Led led); | ||
StatusInfo GetStatus(); | ||
void SetLedBlinkState(Led led, LedBlinkState state); | ||
void SetLedState(Led led, Color color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters