periphery.pyi 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. from typing import overload
  2. from stdc import intptr
  3. class gpio_config:
  4. direction: int # (gpio_direction_t)
  5. edge: int # (gpio_edge_t)
  6. event_clock: int # (gpio_event_clock_t)
  7. debounce_us: int # (uint32_t)
  8. bias: int # (gpio_bias_t)
  9. drive: int # (gpio_drive_t)
  10. inverted: bool # (bool)
  11. label: str # (const char*)
  12. @overload
  13. def __init__(self): ...
  14. @overload
  15. def __init__(self, direction: int, edge: int, event_clock: int, debounce_us: int, bias: int, drive: int, inverted: bool, label: str): ...
  16. class periphery_version:
  17. major: int # (unsigned)
  18. minor: int # (unsigned)
  19. patch: int # (unsigned)
  20. commit_id: str # (const char*)
  21. @overload
  22. def __init__(self): ...
  23. @overload
  24. def __init__(self, major: int, minor: int, patch: int, commit_id: str): ...
  25. def gpio_new() -> intptr:
  26. """Wraps `gpio_t* gpio_new()`"""
  27. def gpio_open(gpio: intptr, path: str, line: int, direction: int, /) -> int:
  28. """Wraps `int gpio_open(gpio_t* gpio, const char* path, unsigned line, gpio_direction_t direction)`"""
  29. def gpio_open_name(gpio: intptr, path: str, name: str, direction: int, /) -> int:
  30. """Wraps `int gpio_open_name(gpio_t* gpio, const char* path, const char* name, gpio_direction_t direction)`"""
  31. def gpio_open_advanced(gpio: intptr, path: str, line: int, config: intptr, /) -> int:
  32. """Wraps `int gpio_open_advanced(gpio_t* gpio, const char* path, unsigned line, const gpio_config_t* config)`"""
  33. def gpio_open_name_advanced(gpio: intptr, path: str, name: str, config: intptr, /) -> int:
  34. """Wraps `int gpio_open_name_advanced(gpio_t* gpio, const char* path, const char* name, const gpio_config_t* config)`"""
  35. def gpio_open_sysfs(gpio: intptr, line: int, direction: int, /) -> int:
  36. """Wraps `int gpio_open_sysfs(gpio_t* gpio, unsigned line, gpio_direction_t direction)`"""
  37. def gpio_read(gpio: intptr, value: intptr, /) -> int:
  38. """Wraps `int gpio_read(gpio_t* gpio, bool* value)`"""
  39. def gpio_write(gpio: intptr, value: bool, /) -> int:
  40. """Wraps `int gpio_write(gpio_t* gpio, bool value)`"""
  41. def gpio_poll(gpio: intptr, timeout_ms: int, /) -> int:
  42. """Wraps `int gpio_poll(gpio_t* gpio, int timeout_ms)`"""
  43. def gpio_close(gpio: intptr, /) -> int:
  44. """Wraps `int gpio_close(gpio_t* gpio)`"""
  45. def gpio_free(gpio: intptr, /) -> None:
  46. """Wraps `void gpio_free(gpio_t* gpio)`"""
  47. def gpio_read_event(gpio: intptr, edge: intptr, timestamp: intptr, /) -> int:
  48. """Wraps `int gpio_read_event(gpio_t* gpio, gpio_edge_t* edge, uint64_t* timestamp)`"""
  49. def gpio_poll_multiple(gpios: intptr, count: int, timeout_ms: int, gpios_ready: intptr, /) -> int:
  50. """Wraps `int gpio_poll_multiple(gpio_t** gpios, size_t count, int timeout_ms, bool* gpios_ready)`"""
  51. def gpio_get_direction(gpio: intptr, direction: intptr, /) -> int:
  52. """Wraps `int gpio_get_direction(gpio_t* gpio, gpio_direction_t* direction)`"""
  53. def gpio_get_edge(gpio: intptr, edge: intptr, /) -> int:
  54. """Wraps `int gpio_get_edge(gpio_t* gpio, gpio_edge_t* edge)`"""
  55. def gpio_get_event_clock(gpio: intptr, event_clock: intptr, /) -> int:
  56. """Wraps `int gpio_get_event_clock(gpio_t* gpio, gpio_event_clock_t* event_clock)`"""
  57. def gpio_get_debounce_us(gpio: intptr, debounce_us: intptr, /) -> int:
  58. """Wraps `int gpio_get_debounce_us(gpio_t* gpio, uint32_t* debounce_us)`"""
  59. def gpio_get_bias(gpio: intptr, bias: intptr, /) -> int:
  60. """Wraps `int gpio_get_bias(gpio_t* gpio, gpio_bias_t* bias)`"""
  61. def gpio_get_drive(gpio: intptr, drive: intptr, /) -> int:
  62. """Wraps `int gpio_get_drive(gpio_t* gpio, gpio_drive_t* drive)`"""
  63. def gpio_get_inverted(gpio: intptr, inverted: intptr, /) -> int:
  64. """Wraps `int gpio_get_inverted(gpio_t* gpio, bool* inverted)`"""
  65. def gpio_set_direction(gpio: intptr, direction: int, /) -> int:
  66. """Wraps `int gpio_set_direction(gpio_t* gpio, gpio_direction_t direction)`"""
  67. def gpio_set_edge(gpio: intptr, edge: int, /) -> int:
  68. """Wraps `int gpio_set_edge(gpio_t* gpio, gpio_edge_t edge)`"""
  69. def gpio_set_event_clock(gpio: intptr, event_clock: int, /) -> int:
  70. """Wraps `int gpio_set_event_clock(gpio_t* gpio, gpio_event_clock_t event_clock)`"""
  71. def gpio_set_debounce_us(gpio: intptr, debounce_us: int, /) -> int:
  72. """Wraps `int gpio_set_debounce_us(gpio_t* gpio, uint32_t debounce_us)`"""
  73. def gpio_set_bias(gpio: intptr, bias: int, /) -> int:
  74. """Wraps `int gpio_set_bias(gpio_t* gpio, gpio_bias_t bias)`"""
  75. def gpio_set_drive(gpio: intptr, drive: int, /) -> int:
  76. """Wraps `int gpio_set_drive(gpio_t* gpio, gpio_drive_t drive)`"""
  77. def gpio_set_inverted(gpio: intptr, inverted: bool, /) -> int:
  78. """Wraps `int gpio_set_inverted(gpio_t* gpio, bool inverted)`"""
  79. def gpio_line(gpio: intptr, /) -> int:
  80. """Wraps `unsigned gpio_line(gpio_t* gpio)`"""
  81. def gpio_fd(gpio: intptr, /) -> int:
  82. """Wraps `int gpio_fd(gpio_t* gpio)`"""
  83. def gpio_name(gpio: intptr, str: intptr, len: int, /) -> int:
  84. """Wraps `int gpio_name(gpio_t* gpio, char* str, size_t len)`"""
  85. def gpio_label(gpio: intptr, str: intptr, len: int, /) -> int:
  86. """Wraps `int gpio_label(gpio_t* gpio, char* str, size_t len)`"""
  87. def gpio_chip_fd(gpio: intptr, /) -> int:
  88. """Wraps `int gpio_chip_fd(gpio_t* gpio)`"""
  89. def gpio_chip_name(gpio: intptr, str: intptr, len: int, /) -> int:
  90. """Wraps `int gpio_chip_name(gpio_t* gpio, char* str, size_t len)`"""
  91. def gpio_chip_label(gpio: intptr, str: intptr, len: int, /) -> int:
  92. """Wraps `int gpio_chip_label(gpio_t* gpio, char* str, size_t len)`"""
  93. def gpio_tostring(gpio: intptr, str: intptr, len: int, /) -> int:
  94. """Wraps `int gpio_tostring(gpio_t* gpio, char* str, size_t len)`"""
  95. def gpio_errno(gpio: intptr, /) -> int:
  96. """Wraps `int gpio_errno(gpio_t* gpio)`"""
  97. def gpio_errmsg(gpio: intptr, /) -> str:
  98. """Wraps `const char* gpio_errmsg(gpio_t* gpio)`"""
  99. def pwm_new() -> intptr:
  100. """Wraps `pwm_t* pwm_new()`"""
  101. def pwm_open(pwm: intptr, chip: int, channel: int, /) -> int:
  102. """Wraps `int pwm_open(pwm_t* pwm, unsigned chip, unsigned channel)`"""
  103. def pwm_enable(pwm: intptr, /) -> int:
  104. """Wraps `int pwm_enable(pwm_t* pwm)`"""
  105. def pwm_disable(pwm: intptr, /) -> int:
  106. """Wraps `int pwm_disable(pwm_t* pwm)`"""
  107. def pwm_close(pwm: intptr, /) -> int:
  108. """Wraps `int pwm_close(pwm_t* pwm)`"""
  109. def pwm_free(pwm: intptr, /) -> None:
  110. """Wraps `void pwm_free(pwm_t* pwm)`"""
  111. def pwm_get_enabled(pwm: intptr, enabled: intptr, /) -> int:
  112. """Wraps `int pwm_get_enabled(pwm_t* pwm, bool* enabled)`"""
  113. def pwm_get_period_ns(pwm: intptr, period_ns: intptr, /) -> int:
  114. """Wraps `int pwm_get_period_ns(pwm_t* pwm, uint64_t* period_ns)`"""
  115. def pwm_get_duty_cycle_ns(pwm: intptr, duty_cycle_ns: intptr, /) -> int:
  116. """Wraps `int pwm_get_duty_cycle_ns(pwm_t* pwm, uint64_t* duty_cycle_ns)`"""
  117. def pwm_get_period(pwm: intptr, period: intptr, /) -> int:
  118. """Wraps `int pwm_get_period(pwm_t* pwm, double* period)`"""
  119. def pwm_get_duty_cycle(pwm: intptr, duty_cycle: intptr, /) -> int:
  120. """Wraps `int pwm_get_duty_cycle(pwm_t* pwm, double* duty_cycle)`"""
  121. def pwm_get_frequency(pwm: intptr, frequency: intptr, /) -> int:
  122. """Wraps `int pwm_get_frequency(pwm_t* pwm, double* frequency)`"""
  123. def pwm_get_polarity(pwm: intptr, polarity: intptr, /) -> int:
  124. """Wraps `int pwm_get_polarity(pwm_t* pwm, pwm_polarity_t* polarity)`"""
  125. def pwm_set_enabled(pwm: intptr, enabled: bool, /) -> int:
  126. """Wraps `int pwm_set_enabled(pwm_t* pwm, bool enabled)`"""
  127. def pwm_set_period_ns(pwm: intptr, period_ns: int, /) -> int:
  128. """Wraps `int pwm_set_period_ns(pwm_t* pwm, uint64_t period_ns)`"""
  129. def pwm_set_duty_cycle_ns(pwm: intptr, duty_cycle_ns: int, /) -> int:
  130. """Wraps `int pwm_set_duty_cycle_ns(pwm_t* pwm, uint64_t duty_cycle_ns)`"""
  131. def pwm_set_period(pwm: intptr, period: float, /) -> int:
  132. """Wraps `int pwm_set_period(pwm_t* pwm, double period)`"""
  133. def pwm_set_duty_cycle(pwm: intptr, duty_cycle: float, /) -> int:
  134. """Wraps `int pwm_set_duty_cycle(pwm_t* pwm, double duty_cycle)`"""
  135. def pwm_set_frequency(pwm: intptr, frequency: float, /) -> int:
  136. """Wraps `int pwm_set_frequency(pwm_t* pwm, double frequency)`"""
  137. def pwm_set_polarity(pwm: intptr, polarity: int, /) -> int:
  138. """Wraps `int pwm_set_polarity(pwm_t* pwm, pwm_polarity_t polarity)`"""
  139. def pwm_chip(pwm: intptr, /) -> int:
  140. """Wraps `unsigned pwm_chip(pwm_t* pwm)`"""
  141. def pwm_channel(pwm: intptr, /) -> int:
  142. """Wraps `unsigned pwm_channel(pwm_t* pwm)`"""
  143. def pwm_tostring(pwm: intptr, str: intptr, len: int, /) -> int:
  144. """Wraps `int pwm_tostring(pwm_t* pwm, char* str, size_t len)`"""
  145. def pwm_errno(pwm: intptr, /) -> int:
  146. """Wraps `int pwm_errno(pwm_t* pwm)`"""
  147. def pwm_errmsg(pwm: intptr, /) -> str:
  148. """Wraps `const char* pwm_errmsg(pwm_t* pwm)`"""
  149. def periphery_version() -> str:
  150. """Wraps `const char* periphery_version()`"""
  151. def periphery_version_info() -> intptr:
  152. """Wraps `const periphery_version_t* periphery_version_info()`"""
  153. # aliases
  154. gpio_direction_t = int
  155. gpio_edge_t = int
  156. gpio_event_clock_t = int
  157. gpio_bias_t = int
  158. gpio_drive_t = int
  159. pwm_polarity_t = int
  160. # enums
  161. GPIO_ERROR_ARG: int
  162. GPIO_ERROR_OPEN: int
  163. GPIO_ERROR_NOT_FOUND: int
  164. GPIO_ERROR_QUERY: int
  165. GPIO_ERROR_CONFIGURE: int
  166. GPIO_ERROR_UNSUPPORTED: int
  167. GPIO_ERROR_INVALID_OPERATION: int
  168. GPIO_ERROR_IO: int
  169. GPIO_ERROR_CLOSE: int
  170. GPIO_DIR_IN: int
  171. GPIO_DIR_OUT: int
  172. GPIO_DIR_OUT_LOW: int
  173. GPIO_DIR_OUT_HIGH: int
  174. GPIO_EDGE_NONE: int
  175. GPIO_EDGE_RISING: int
  176. GPIO_EDGE_FALLING: int
  177. GPIO_EDGE_BOTH: int
  178. GPIO_EVENT_CLOCK_REALTIME: int
  179. GPIO_EVENT_CLOCK_MONOTONIC: int
  180. GPIO_EVENT_CLOCK_HTE: int
  181. GPIO_BIAS_DEFAULT: int
  182. GPIO_BIAS_PULL_UP: int
  183. GPIO_BIAS_PULL_DOWN: int
  184. GPIO_BIAS_DISABLE: int
  185. GPIO_DRIVE_DEFAULT: int
  186. GPIO_DRIVE_OPEN_DRAIN: int
  187. GPIO_DRIVE_OPEN_SOURCE: int
  188. PWM_ERROR_ARG: int
  189. PWM_ERROR_OPEN: int
  190. PWM_ERROR_QUERY: int
  191. PWM_ERROR_CONFIGURE: int
  192. PWM_ERROR_CLOSE: int
  193. PWM_POLARITY_NORMAL: int
  194. PWM_POLARITY_INVERSED: int