1- declare module " node-libgpiod" {
2- /**
1+ declare module ' node-libgpiod' {
2+ /**
33 * Chip instances represent GPIO chips (each with a fixed number of
44 * GPIO lines) on the Linux host. The number of GPIO chips depends on
55 * the hardware available.
66 */
7- declare class Chip {
8- /**
7+ declare class Chip {
8+ /**
99 * Constructs a new Chip instance by its chip number.
1010 *
1111 * @param chipNumber the number of the GPIO chip
1212 * @throws error if the chip cannot be opened
1313 */
14- constructor ( chipNumber : number ) ;
15-
16- /**
14+ constructor ( chipNumber : number ) ;
15+
16+ /**
1717 * Constructs a new Chip instance by its device name or full device path.
1818 *
1919 * @param deviceNameOrPath the device name or full device path of the GPIO chip
2020 * @throws error if the chip cannot be opened
2121 */
22- constructor ( deviceNameOrPath : string ) ;
23-
24- /**
22+ constructor ( deviceNameOrPath : string ) ;
23+
24+ /**
2525 * Returns the number of GPIO lines available (reserved or not) on the GPIO chip.
2626 */
27- getNumberOfLines ( ) : number
28-
29- /**
27+ getNumberOfLines ( ) : number ;
28+
29+ /**
3030 * Returns the GPIO chip name as represented by the kernel.
3131 */
32- getChipName ( ) : string
33-
34- /**
32+ getChipName ( ) : string ;
33+
34+ /**
3535 * Returns the GPIO chip label as represented by the kernel.
3636 */
37- getChipLabel ( ) : string
38- }
39-
40- /**
37+ getChipLabel ( ) : string ;
38+ }
39+
40+ /**
4141 * Line instances represent direct access to a specific GPIO line on
4242 * the Linux host. Those lines can be reserved as input or output.
4343 */
44- declare class Line {
45-
46- /**
44+ declare class Line {
45+ /**
4746 * Constructs a new Line instance for the given chip and line offset.
4847 *
4948 * @param chip the parent gpio chip
5049 * @param offset the line offset
5150 * @throws error if the line cannot be opened
5251 */
53- constructor ( chip : Chip , offset : number ) ;
54-
55- /**
52+ constructor ( chip : Chip , offset : number ) ;
53+
54+ /**
5655 * Returns the line offset of this Line instance for the assigned GPIO chip.
5756 *
5857 * @throws error if the line offset cannot be read
5958 */
60- getLineOffset ( ) : number ;
61-
62- /**
59+ getLineOffset ( ) : number ;
60+
61+ /**
6362 * Returns the line name as represented by the kernel. The name is either a
6463 * valid string, or undefined if not set.
6564 *
6665 * @throws error if the line name cannot be read
6766 */
68- getLineName ( ) : string | undefined ;
69-
70- /**
67+ getLineName ( ) : string | undefined ;
68+
69+ /**
7170 * Returns the line consumer as represented by the kernel. This consumer is
7271 * either a valid string, or undefined if not set.
7372 *
7473 * @throws error if the line consumer cannot be read
7574 */
76- getLineConsumer ( ) : string | undefined ;
77-
78- /**
75+ getLineConsumer ( ) : string | undefined ;
76+
77+ /**
7978 * Returns the state value of the line as off (0) or on (1).
8079 * @throws error if the line is not reserved
8180 */
82- getValue ( ) : 0 | 1 ;
83-
84- /**
81+ getValue ( ) : 0 | 1 ;
82+
83+ /**
8584 * Sets the state of the line to either on or off. Setting the same state as
8685 * current, nothing happens.
8786 *
8887 * @param value the new state of the output line (0 = off, 1 = on)
8988 * @throws error if the line is not reserved as an output
9089 */
91- setValue ( value : 0 | 1 ) : void ;
92-
93- /**
90+ setValue ( value : 0 | 1 ) : void ;
91+
92+ /**
9493 * Releases a previously created reservation. If the line is not reserved at
9594 * the time of calling this method, nothing happens.
9695 */
97- release ( ) : void ;
98-
99- /**
96+ release ( ) : void ;
97+
98+ /**
10099 * Reserves the current line as an output. It is possible to pass a defaultValue,
101100 * which defines the base state of the line (off or on). If not given, the default
102101 * state is off.
@@ -107,19 +106,19 @@ declare module "node-libgpiod" {
107106 * @param consumer an optional consumer name to assign to the reservation
108107 * @throws error if the line is already reserved
109108 */
110- requestOutputMode ( defaultValue ?: 0 | 1 , consumer ?: string ) : void ;
111-
112- /**
109+ requestOutputMode ( defaultValue ?: 0 | 1 , consumer ?: string ) : void ;
110+
111+ /**
113112 * Reserves the current line as an input.
114113 *
115114 * A consumer name can be given to assign a name to the reservation.
116115 *
117116 * @param consumer an optional consumer name to assign to the reservation
118117 * @throws error if the line is already reserved
119118 */
120- requestInputMode ( consumer ?: string ) : void ;
119+ requestInputMode ( consumer ?: string ) : void ;
121120
122- /**
121+ /**
123122 * Reserves the current line as an input with Flags.
124123 *
125124 * A consumer name can be given to assign a name to the reservation.
@@ -128,28 +127,27 @@ declare module "node-libgpiod" {
128127 * @param flags GPIOD_LINE_REQUEST_FLAG_xxxx as defined in gpiod.h
129128 * @throws error if the line is already reserved
130129 */
131- requestInputModeFlags ( consumer ?: string , flags ?: number ) : void ;
132- }
133-
130+ requestInputModeFlags ( consumer ?: string , flags ?: number ) : void ;
131+ }
134132
135- /**
133+ /**
136134 * LineFlags
137- * Those flags where introduced in libgpiod 1.5 and allows to fine tune how
135+ * Those flags where introduced in libgpiod 1.5 and allows to fine tune how
138136 * line should behave.
139137 */
140- declare interface LineFlags {
141- GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN : 1 ;
142- GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE : 2 ;
143- GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 4 ;
144- GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE : 8 ;
145- GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN : 16 ;
146- GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP : 32 ;
147- }
148-
149- /**
138+ declare type LineFlags = {
139+ GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN : 1 ;
140+ GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE : 2 ;
141+ GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 4 ;
142+ GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE : 8 ;
143+ GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN : 16 ;
144+ GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP : 32 ;
145+ } ;
146+
147+ /**
150148 * Returns true if the libgpiod functionality is available in
151149 * the current execution environment, otherwise false (for example
152150 * in non-Linux development environments).
153151 */
154- declare function available ( ) : boolean ;
152+ declare function available ( ) : boolean ;
155153}
0 commit comments