@@ -21,8 +21,7 @@ typealias Tick = StreamTicksResponse
21
21
abstract class Board (name : String ) : Component(SUBTYPE , named(name)) {
22
22
companion object {
23
23
@JvmField
24
- val SUBTYPE =
25
- Subtype (Subtype .NAMESPACE_RDK , Subtype .RESOURCE_TYPE_COMPONENT , " board" )
24
+ val SUBTYPE = Subtype (Subtype .NAMESPACE_RDK , Subtype .RESOURCE_TYPE_COMPONENT , " board" )
26
25
27
26
/* *
28
27
* Get the ResourceName of the component
@@ -51,94 +50,190 @@ abstract class Board(name: String) : Component(SUBTYPE, named(name)) {
51
50
* @param pin the name of the GPIO pin
52
51
* @param high when true, sets the pin to high. When false, sets the pin to low.
53
52
*/
54
- abstract fun setGpioState (pin : String , high : Boolean , extra : Optional <Struct >)
53
+ abstract fun setGpioState (pin : String , high : Boolean , extra : Struct )
54
+
55
+ /* *
56
+ * Set the high/low state of the given pin of a board.
57
+ * @param pin the name of the GPIO pin
58
+ * @param high when true, sets the pin to high. When false, sets the pin to low.
59
+ */
60
+ fun setGpioState (pin : String , high : Boolean ) {
61
+ return setGpioState(pin, high, Struct .getDefaultInstance())
62
+ }
55
63
56
64
/* *
57
65
* Get the high/low state of the given pin of a board.
58
66
* @param pin the name of the GPIO pin
59
67
* @return the state of the pin: true if high, false otherwise.
60
68
*/
61
- abstract fun getGpioState (pin : String , extra : Optional <Struct >): Boolean
69
+ abstract fun getGpioState (pin : String , extra : Struct ): Boolean
70
+
71
+ /* *
72
+ * Get the high/low state of the given pin of a board.
73
+ * @param pin the name of the GPIO pin
74
+ * @return the state of the pin: true if high, false otherwise.
75
+ */
76
+ fun getGpioState (pin : String ): Boolean {
77
+ return getGpioState(pin, Struct .getDefaultInstance())
78
+ }
79
+
80
+ /* *
81
+ * Set the duty cycle of the given pin of a board.
82
+ * @param pin the name of the GPIO pin
83
+ * @param dutyCyclePct the duty cycle percent
84
+ */
85
+ abstract fun setPwm (pin : String , dutyCyclePct : Double , extra : Struct )
62
86
63
87
/* *
64
88
* Set the duty cycle of the given pin of a board.
65
89
* @param pin the name of the GPIO pin
66
90
* @param dutyCyclePct the duty cycle percent
67
91
*/
68
- abstract fun setPwm (pin : String , dutyCyclePct : Double , extra : Optional <Struct >)
92
+ fun setPwm (pin : String , dutyCyclePct : Double ) {
93
+ return setPwm(pin, dutyCyclePct, Struct .getDefaultInstance())
94
+ }
95
+
96
+ /* *
97
+ * Get the duty cycle of the given pin of a board.
98
+ * @param pin the name of the pin
99
+ * @returns the duty cycle percent
100
+ */
101
+ abstract fun getPwm (pin : String , extra : Struct ): Double
69
102
70
103
/* *
71
104
* Get the duty cycle of the given pin of a board.
72
105
* @param pin the name of the pin
73
106
* @returns the duty cycle percent
74
107
*/
75
- abstract fun getPwm (pin : String , extra : Optional <Struct >): Double
108
+ fun getPwm (pin : String ): Double {
109
+ return getPwm(pin, Struct .getDefaultInstance())
110
+ }
76
111
77
112
/* *
78
113
* Set the PWM frequency of the given pin of a board.
79
114
* @param pin the name of the pin
80
115
* @param frequencyHz the frequency to set
81
116
*/
82
- abstract fun setPwmFrequency (pin : String , frequencyHz : Int , extra : Optional <Struct >)
117
+ abstract fun setPwmFrequency (pin : String , frequencyHz : Int , extra : Struct )
118
+
119
+ /* *
120
+ * Set the PWM frequency of the given pin of a board.
121
+ * @param pin the name of the pin
122
+ * @param frequencyHz the frequency to set
123
+ */
124
+ fun setPwmFrequency (pin : String , frequencyHz : Int ) {
125
+ return setPwmFrequency(pin, frequencyHz, Struct .getDefaultInstance())
126
+ }
127
+
128
+ /* *
129
+ * Get the PWM frequency of the given pin of a board.
130
+ * @param pin the name of the pin
131
+ * @returns the frequency of the pin in Hz
132
+ */
133
+ abstract fun getPwmFrequency (pin : String , extra : Struct ): Int
83
134
84
135
/* *
85
136
* Get the PWM frequency of the given pin of a board.
86
137
* @param pin the name of the pin
87
138
* @returns the frequency of the pin in Hz
88
139
*/
89
- abstract fun getPwmFrequency (pin : String , extra : Optional <Struct >): Int
140
+ fun getPwmFrequency (pin : String ): Int {
141
+ return getPwmFrequency(pin, Struct .getDefaultInstance())
142
+ }
90
143
91
144
/* *
92
145
* Write analog value to pin.
93
146
* @param pin the name of the pin
94
147
* @param value the value to set
95
148
*/
96
- abstract fun writeAnalog (pin : String , value : Int , extra : Optional <Struct >)
149
+ abstract fun writeAnalog (pin : String , value : Int , extra : Struct )
150
+
151
+ /* *
152
+ * Write analog value to pin.
153
+ * @param pin the name of the pin
154
+ * @param value the value to set
155
+ */
156
+ fun writeAnalog (pin : String , value : Int ) {
157
+ return writeAnalog(pin, value, Struct .getDefaultInstance())
158
+ }
97
159
98
160
/* *
99
161
* Read the current value of an analog reader of a board.
100
162
* @param analogReader the name of the analog reader
101
163
* @returns the current value of the analog reader
102
164
*/
103
- abstract fun getAnalogReaderValue (analogReader : String , extra : Optional <Struct >): Int
165
+ abstract fun getAnalogReaderValue (analogReader : String , extra : Struct ): Int
166
+
167
+ /* *
168
+ * Read the current value of an analog reader of a board.
169
+ * @param analogReader the name of the analog reader
170
+ * @returns the current value of the analog reader
171
+ */
172
+ fun getAnalogReaderValue (analogReader : String ): Int {
173
+ return getAnalogReaderValue(analogReader, Struct .getDefaultInstance())
174
+ }
175
+
176
+ /* *
177
+ * Return the current value of the interrupt which is based on the type of Interrupt.
178
+ * @param digitalInterrupt the name of the digital interrupt
179
+ * @returns the current value of the digital reader
180
+ */
181
+ abstract fun getDigitalInterruptValue (digitalInterrupt : String , extra : Struct ): Int
104
182
105
183
/* *
106
184
* Return the current value of the interrupt which is based on the type of Interrupt.
107
185
* @param digitalInterrupt the name of the digital interrupt
108
186
* @returns the current value of the digital reader
109
187
*/
110
- abstract fun getDigitalInterruptValue (
111
- digitalInterrupt : String ,
112
- extra : Optional <Struct >
113
- ): Int
188
+ fun getDigitalInterruptValue (digitalInterrupt : String ): Int {
189
+ return getDigitalInterruptValue(digitalInterrupt, Struct .getDefaultInstance())
190
+ }
114
191
115
192
/* *
116
193
* Stream digital interrupts ticks.
117
194
* @param interrupts the list of digital interrupts names from which to receive ticks
118
195
* @returns a [Stream] of [Tick] objects
119
196
*/
120
- abstract fun streamTicks (interrupts : List <String >, extra : Optional <Struct >): Iterator <Tick >
197
+ abstract fun streamTicks (interrupts : List <String >, extra : Struct ): Iterator <Tick >
198
+
199
+ /* *
200
+ * Stream digital interrupts ticks.
201
+ * @param interrupts the list of digital interrupts names from which to receive ticks
202
+ * @returns a [Stream] of [Tick] objects
203
+ */
204
+ fun streamTicks (interrupts : List <String >): Iterator <Tick > {
205
+ return streamTicks(interrupts, Struct .getDefaultInstance())
206
+ }
207
+
208
+ /* *
209
+ * Add a listener for the digital interrupts.
210
+ * @param interrupts the list of digital interrupts names from which to receive ticks
211
+ * @param tickQueue an object to receive values from the callback
212
+ */
213
+ abstract fun addCallbacks (interrupts : List <String >, tickQueue : Queue <Tick >, extra : Struct )
121
214
122
215
/* *
123
216
* Add a listener for the digital interrupts.
124
217
* @param interrupts the list of digital interrupts names from which to receive ticks
125
218
* @param tickQueue an object to receive values from the callback
126
219
*/
127
- abstract fun addCallbacks (
128
- interrupts : List <String >,
129
- tickQueue : Queue <Tick >,
130
- extra : Optional <Struct >
131
- )
220
+ fun addCallbacks (interrupts : List <String >, tickQueue : Queue <Tick >) {
221
+ return addCallbacks(interrupts, tickQueue, Struct .getDefaultInstance())
222
+ }
132
223
133
224
/* *
134
225
* Set the board to the indicated power mode.
135
226
* @param powerMode the power mode to set
136
227
* @param duration if provided, the board will exit the given power mode after this duration
137
228
*/
138
- abstract fun setPowerMode (
139
- powerMode : PowerMode ,
140
- duration : Duration ,
141
- extra : Optional <Struct >
142
- )
229
+ abstract fun setPowerMode (powerMode : PowerMode , duration : Duration , extra : Struct )
143
230
231
+ /* *
232
+ * Set the board to the indicated power mode.
233
+ * @param powerMode the power mode to set
234
+ * @param duration if provided, the board will exit the given power mode after this duration
235
+ */
236
+ fun setPowerMode (powerMode : PowerMode , duration : Duration ) {
237
+ return setPowerMode(powerMode, duration, Struct .getDefaultInstance())
238
+ }
144
239
}
0 commit comments