| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* SPDX-FileCopyrightText: 2023-2024 Bartosz Golaszewski <[email protected]> */ |
| 3 | |
| 4 | #ifndef __GPIODGLIB_LINE_SETTINGS_H__ |
| 5 | #define __GPIODGLIB_LINE_SETTINGS_H__ |
| 6 | |
| 7 | #if !defined(__INSIDE_GPIOD_GLIB_H__) && !defined(GPIODGLIB_COMPILATION) |
| 8 | #error "Only <gpiod-glib.h> can be included directly." |
| 9 | #endif |
| 10 | |
| 11 | #include <glib.h> |
| 12 | #include <glib-object.h> |
| 13 | |
| 14 | #include "line.h" |
| 15 | |
| 16 | G_BEGIN_DECLS |
| 17 | |
| 18 | G_DECLARE_FINAL_TYPE(GpiodglibLineSettings, gpiodglib_line_settings, |
| 19 | GPIODGLIB, LINE_SETTINGS, GObject); |
| 20 | |
| 21 | #define GPIODGLIB_LINE_SETTINGS_TYPE (gpiodglib_line_settings_get_type()) |
| 22 | #define GPIODGLIB_LINE_SETTINGS_OBJ(obj) \ |
| 23 | (G_TYPE_CHECK_INSTANCE_CAST((obj), GPIODGLIB_LINE_SETTINGS_TYPE, \ |
| 24 | GpiodglibLineSettings)) |
| 25 | |
| 26 | /** |
| 27 | * gpiodglib_line_settings_new: |
| 28 | * @first_prop: Name of the first property to set. |
| 29 | * |
| 30 | * Create a new line settings object. |
| 31 | * |
| 32 | * The constructor allows to set object's properties when it's first created |
| 33 | * instead of having to build an empty object and then call mutators separately. |
| 34 | * |
| 35 | * Currently supported properties are: `direction`, `edge-detection`, `bias`, |
| 36 | * `drive`, `debounce-period-us`, `active-low`, 'event-clock` and |
| 37 | * `output-value`. |
| 38 | * |
| 39 | * Returns: New #GpiodglibLineSettings. |
| 40 | */ |
| 41 | GpiodglibLineSettings * |
| 42 | gpiodglib_line_settings_new(const gchar *first_prop, ...); |
| 43 | |
| 44 | /** |
| 45 | * gpiodglib_line_settings_reset: |
| 46 | * @self: #GpiodglibLineSettings to manipulate. |
| 47 | * |
| 48 | * Reset the line settings object to its default values. |
| 49 | */ |
| 50 | void gpiodglib_line_settings_reset(GpiodglibLineSettings *self); |
| 51 | |
| 52 | /** |
| 53 | * gpiodglib_line_settings_set_direction: |
| 54 | * @self: #GpiodglibLineSettings to manipulate. |
| 55 | * @direction: New direction. |
| 56 | * |
| 57 | * Set direction. |
| 58 | */ |
| 59 | void gpiodglib_line_settings_set_direction(GpiodglibLineSettings *self, |
| 60 | GpiodglibLineDirection direction); |
| 61 | |
| 62 | /** |
| 63 | * gpiodglib_line_settings_get_direction: |
| 64 | * @self: #GpiodglibLineSettings to manipulate. |
| 65 | * |
| 66 | * Get direction. |
| 67 | * |
| 68 | * Returns: Current direction. |
| 69 | */ |
| 70 | GpiodglibLineDirection |
| 71 | gpiodglib_line_settings_get_direction(GpiodglibLineSettings *self); |
| 72 | |
| 73 | /** |
| 74 | * gpiodglib_line_settings_set_edge_detection: |
| 75 | * @self: #GpiodglibLineSettings to manipulate. |
| 76 | * @edge: New edge detection setting. |
| 77 | * |
| 78 | * Set edge detection. |
| 79 | */ |
| 80 | void gpiodglib_line_settings_set_edge_detection(GpiodglibLineSettings *self, |
| 81 | GpiodglibLineEdge edge); |
| 82 | |
| 83 | /** |
| 84 | * gpiodglib_line_settings_get_edge_detection: |
| 85 | * @self: #GpiodglibLineSettings to manipulate. |
| 86 | * |
| 87 | * Get edge detection. |
| 88 | * |
| 89 | * Returns: Current edge detection setting. |
| 90 | */ |
| 91 | GpiodglibLineEdge |
| 92 | gpiodglib_line_settings_get_edge_detection(GpiodglibLineSettings *self); |
| 93 | |
| 94 | /** |
| 95 | * gpiodglib_line_settings_set_bias: |
| 96 | * @self: #GpiodglibLineSettings to manipulate. |
| 97 | * @bias: New bias. |
| 98 | * |
| 99 | * Set bias. |
| 100 | */ |
| 101 | void gpiodglib_line_settings_set_bias(GpiodglibLineSettings *self, |
| 102 | GpiodglibLineBias bias); |
| 103 | |
| 104 | /** |
| 105 | * gpiodglib_line_settings_get_bias: |
| 106 | * @self: #GpiodglibLineSettings to manipulate. |
| 107 | * |
| 108 | * Get bias. |
| 109 | * |
| 110 | * Returns: Current bias setting. |
| 111 | */ |
| 112 | GpiodglibLineBias gpiodglib_line_settings_get_bias(GpiodglibLineSettings *self); |
| 113 | |
| 114 | /** |
| 115 | * gpiodglib_line_settings_set_drive: |
| 116 | * @self: #GpiodglibLineSettings to manipulate. |
| 117 | * @drive: New drive setting. |
| 118 | * |
| 119 | * Set drive. |
| 120 | */ |
| 121 | void gpiodglib_line_settings_set_drive(GpiodglibLineSettings *self, |
| 122 | GpiodglibLineDrive drive); |
| 123 | |
| 124 | /** |
| 125 | * gpiodglib_line_settings_get_drive: |
| 126 | * @self: #GpiodglibLineSettings to manipulate. |
| 127 | * |
| 128 | * Get drive. |
| 129 | * |
| 130 | * Returns: Current drive setting. |
| 131 | */ |
| 132 | GpiodglibLineDrive |
| 133 | gpiodglib_line_settings_get_drive(GpiodglibLineSettings *self); |
| 134 | |
| 135 | /** |
| 136 | * gpiodglib_line_settings_set_active_low: |
| 137 | * @self: #GpiodglibLineSettings to manipulate. |
| 138 | * @active_low: New active-low setting. |
| 139 | * |
| 140 | * Set active-low setting. |
| 141 | */ |
| 142 | void gpiodglib_line_settings_set_active_low(GpiodglibLineSettings *self, |
| 143 | gboolean active_low); |
| 144 | |
| 145 | /** |
| 146 | * gpiodglib_line_settings_get_active_low: |
| 147 | * @self: #GpiodglibLineSettings to manipulate. |
| 148 | * |
| 149 | * Get active-low setting. |
| 150 | * |
| 151 | * Returns: TRUE if active-low is enabled, FALSE otherwise. |
| 152 | */ |
| 153 | gboolean gpiodglib_line_settings_get_active_low(GpiodglibLineSettings *self); |
| 154 | |
| 155 | /** |
| 156 | * gpiodglib_line_settings_set_debounce_period_us: |
| 157 | * @self: #GpiodglibLineSettings to manipulate. |
| 158 | * @period: New debounce period in microseconds. |
| 159 | * |
| 160 | * Set debounce period. |
| 161 | */ |
| 162 | void gpiodglib_line_settings_set_debounce_period_us(GpiodglibLineSettings *self, |
| 163 | GTimeSpan period); |
| 164 | |
| 165 | /** |
| 166 | * gpiodglib_line_settings_get_debounce_period_us: |
| 167 | * @self: #GpiodglibLineSettings to manipulate. |
| 168 | * |
| 169 | * Get debounce period. |
| 170 | * |
| 171 | * Returns: Current debounce period in microseconds. |
| 172 | */ |
| 173 | GTimeSpan |
| 174 | gpiodglib_line_settings_get_debounce_period_us(GpiodglibLineSettings *self); |
| 175 | |
| 176 | /** |
| 177 | * gpiodglib_line_settings_set_event_clock: |
| 178 | * @self: #GpiodglibLineSettings to manipulate. |
| 179 | * @event_clock: New event clock. |
| 180 | * |
| 181 | * Set event clock. |
| 182 | */ |
| 183 | void gpiodglib_line_settings_set_event_clock(GpiodglibLineSettings *self, |
| 184 | GpiodglibLineClock event_clock); |
| 185 | |
| 186 | /** |
| 187 | * gpiodglib_line_settings_get_event_clock: |
| 188 | * @self: #GpiodglibLineSettings to manipulate. |
| 189 | * |
| 190 | * Get event clock setting. |
| 191 | * |
| 192 | * Returns: Current event clock setting. |
| 193 | */ |
| 194 | GpiodglibLineClock |
| 195 | gpiodglib_line_settings_get_event_clock(GpiodglibLineSettings *self); |
| 196 | |
| 197 | /** |
| 198 | * gpiodglib_line_settings_set_output_value: |
| 199 | * @self: #GpiodglibLineSettings to manipulate. |
| 200 | * @value: New output value. |
| 201 | * |
| 202 | * Set the output value. |
| 203 | */ |
| 204 | void gpiodglib_line_settings_set_output_value(GpiodglibLineSettings *self, |
| 205 | GpiodglibLineValue value); |
| 206 | |
| 207 | /** |
| 208 | * gpiodglib_line_settings_get_output_value: |
| 209 | * @self: #GpiodglibLineSettings to manipulate. |
| 210 | * |
| 211 | * Get the output value. |
| 212 | * |
| 213 | * Returns: Current output value. |
| 214 | */ |
| 215 | GpiodglibLineValue |
| 216 | gpiodglib_line_settings_get_output_value(GpiodglibLineSettings *self); |
| 217 | |
| 218 | G_END_DECLS |
| 219 | |
| 220 | #endif /* __GPIODGLIB_LINE_SETTINGS_H__ */ |