No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Helpers.cs 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Device.Gpio;
  3. namespace Iot.Device.Pigpio
  4. {
  5. internal static class Helpers
  6. {
  7. public static uint AsMode(this PinMode mode)
  8. {
  9. switch (mode)
  10. {
  11. case PinMode.Input: return PigpiodIf.PI_INPUT;
  12. case PinMode.InputPullUp: return PigpiodIf.PI_INPUT;
  13. case PinMode.InputPullDown: return PigpiodIf.PI_INPUT;
  14. case PinMode.Output: return PigpiodIf.PI_OUTPUT;
  15. default: throw new ArgumentException($"PinMode value of '{mode}' is not valid");
  16. }
  17. }
  18. public static uint AsPullUpDown(this PinMode mode)
  19. {
  20. switch (mode)
  21. {
  22. case PinMode.InputPullUp: return PigpiodIf.PI_PUD_UP;
  23. case PinMode.InputPullDown: return PigpiodIf.PI_PUD_DOWN;
  24. default: return PigpiodIf.PI_PUD_OFF;
  25. }
  26. }
  27. public static uint AsValue(this PinValue value)
  28. {
  29. return (uint)(int)value;
  30. }
  31. }
  32. }