You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Arduino/libraries/SX1509/readme.md
+31-16Lines changed: 31 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,8 @@ These functions work much like the Arduino *digitalWrite* and *pinMode* function
59
59
60
60
For an example sketch using these functions, check out the [sx1509_digitalReadWrite example](https://github.com/sparkfun/SX1509_IO-Expander/tree/master/Arduino/libraries/SX1509/examples/sx1509_digitalReadWrite).
61
61
62
-
**pinDir(byte pin, byte inOut)**: Pin direction (INPUT/OUTPUT) control
62
+
### pinDir(byte pin, byte inOut)
63
+
Pin direction (INPUT/OUTPUT) control
63
64
64
65
Input:
65
66
@@ -70,7 +71,8 @@ Examples:<br>
70
71
`` sx1509.pinDir(1, INPUT); // Set SX1509 pin 1 as an input ``<br>
71
72
`` sx1509.pinDir(15, OUTPUT); // Set SX1509 pin 15 as an output``
72
73
73
-
**writePin(byte pin, byte highLow)**: Writes a pin to either high or low if it's configured as an OUTPUT. If the pin is configured as an INPUT, this method will activate either the PULL-UP or PULL-DOWN resistor (HIGH or LOW respectively).
74
+
### writePin(byte pin, byte highLow)
75
+
Writes a pin to either high or low if it's configured as an OUTPUT. If the pin is configured as an INPUT, this method will activate either the PULL-UP or PULL-DOWN resistor (HIGH or LOW respectively).
74
76
75
77
Input:
76
78
@@ -81,7 +83,8 @@ Examples:<br>
81
83
``sx1509.writePin(1, HIGH); // If pin 1 is an INPUT, this activates a pull-up resistor ``<br>
82
84
``sx1509.writePin(15, LOW); // If pin 15 is an OUTPUT, this writes the pin LOW``
83
85
84
-
**readPin(byte pin)**: Reads the digital value (HIGH/LOW) of a pin. The pin should be configured as an INPUT.
86
+
### readPin(byte pin)
87
+
Reads the digital value (HIGH/LOW) of a pin. The pin should be configured as an INPUT.
85
88
86
89
Input:
87
90
@@ -102,7 +105,8 @@ For an example sketch using these functions, check out the [sx1509_ledDriver exa
102
105
103
106
Here's the functions available to do some LED driving:
104
107
105
-
**ledDriverInit(byte pin, byte freq, bool log)**: Initializes LED driving on a pin. This function must be called if you want to use the pwm or blink functions on that pin.
108
+
### ledDriverInit(byte pin, byte freq, bool log)
109
+
Initializes LED driving on a pin. This function must be called if you want to use the pwm or blink functions on that pin.
106
110
107
111
Inputs:
108
112
@@ -121,7 +125,8 @@ Examples:<br>
121
125
``sx1509.ledDriverInit(14); // Enables LED driving on pin 14, defaults to no clock divider and linear intensity.``
122
126
123
127
124
-
**pwm(byte pin, byte iOn)**: This function can be used to control the intensity of an output pin connected to an LED.
128
+
### pwm(byte pin, byte iOn)
129
+
This function can be used to control the intensity of an output pin connected to an LED.
125
130
126
131
Inputs:
127
132
@@ -133,7 +138,8 @@ Example:<br>
133
138
``sx1509.pwm(0, 127); // Sets LED on pin 0 to medium intensity ``<br>
134
139
``sx1509.pwm(14, 255); // Sets LED on pin 14 to 100% on``
135
140
136
-
**blink(byte pin, byte tOn, byte tOff, byte offIntensity, byte tRise, byte tFall)**: Controls both the **blink and breathe** functionality on LED pins.
**readKeyData()**: Returns a 16-bit value containing the status of the keypad engine.
213
+
### readKeyData()
214
+
Returns a 16-bit value containing the status of the keypad engine.
207
215
208
216
Output: A 16-bit value is returned. The lower 8 bits represent the up-to 8 rows, while the MSB represents the up-to 8 columns. Bit-values of 1 indicate a button in that row or column is being pressed. As such, at least two bits should be set.
209
217
@@ -221,7 +229,8 @@ Want to make use of the SX1509's interrupt output? Want an interrupt generated w
221
229
222
230
For an example sketch using the SX1509's interrupt functionality check out the [sx1509_interruptDebounce example](https://github.com/sparkfun/SX1509_IO-Expander/tree/master/Arduino/libraries/SX1509/examples/sx1509_interruptDebounce).
223
231
224
-
**enableInterrupt(byte pin, byte riseFall)**: This function sets up an interrupt on a pin. Interrupts can occur on all SX1509 pins, and can be generated on rising, falling, or both.
232
+
### enableInterrupt(byte pin, byte riseFall)
233
+
This function sets up an interrupt on a pin. Interrupts can occur on all SX1509 pins, and can be generated on rising, falling, or both.
225
234
226
235
Inputs:
227
236
@@ -233,7 +242,8 @@ Inputs:
233
242
234
243
This function does not set up a pin as an input, or configure its pull-up/down resistors!
235
244
236
-
**interruptSource(void)**: Returns an unsigned int representing which pin caused an interrupt.
245
+
### interruptSource(void)
246
+
Returns an unsigned int representing which pin caused an interrupt.
237
247
238
248
Output: 16-bit value, with a single bit set representing the pin(s) that generated an interrupt. E.g. a return value of 0x0104 would mean pins 8 and 3 (bits 8 and 3) have generated an interrupt.
239
249
@@ -245,7 +255,8 @@ Getting some jitter in the SX1509 inputs? Need to add debounce to your keypad sc
245
255
246
256
For an example sketch using the SX1509's debounce functionality check out the [sx1509_interruptDebounce example](https://github.com/sparkfun/SX1509_IO-Expander/tree/master/Arduino/libraries/SX1509/examples/sx1509_interruptDebounce).
247
257
248
-
**debounceConfig(byte configValue)**: This method configures the debounce time of every input.
258
+
### debounceConfig(byte configValue)
259
+
This method configures the debounce time of every input.
249
260
250
261
Input:
251
262
@@ -261,7 +272,8 @@ Input:
261
272
262
273
fOSC is set with the configClock function. It defaults to 2MHz.
263
274
264
-
**debounceEnable(byte pin)**: This method enables debounce on SX1509 input pin.
275
+
### debounceEnable(byte pin)
276
+
This method enables debounce on SX1509 input pin.
265
277
266
278
Input:
267
279
@@ -275,13 +287,15 @@ Need to **reset** the SX1509 (hardware or software)? Want to **configure the clo
275
287
276
288
These functions are all interspersed through many of the library examples sketches.
277
289
278
-
**reset(bool hardware)**: This function resets the SX1509 - either a hardware reset or software. A hardware reset (hardware parameter = 1) pulls the reset line low, pausing, then pulling the reset line high. A software reset writes a 0x12 then 0x34 to the REG_RESET as outlined in the datasheet.
290
+
### reset(bool hardware)
291
+
This function resets the SX1509 - either a hardware reset or software. A hardware reset (hardware parameter = 1) pulls the reset line low, pausing, then pulling the reset line high. A software reset writes a 0x12 then 0x34 to the REG_RESET as outlined in the datasheet.
279
292
280
293
Input:
281
294
282
295
**hardware*: 0 executes a software reset, 1 executes a hardware reset.
283
296
284
-
**configClock(byte oscSource, byte oscPinFunction, byte oscFreqOut, byte oscDivider)**: This function configures the oscillator source/speed and the clock, which is used to drive LEDs and time debounces.
This function configures the oscillator source/speed and the clock, which is used to drive LEDs and time debounces.
285
299
286
300
Inputs:
287
301
@@ -298,7 +312,8 @@ Inputs:
298
312
* ClkX = fOSC / (2^(RegMisc[6:4] -1))
299
313
* This value defaults to 1.
300
314
301
-
**sync()**: Resets the PWM/Blink/Fade counters, syncing any blinking LEDs. Bit 2 of REG_MISC is set, which alters the functionality of the nReset pin. The nReset pin is toggled low->high, which should reset all LED counters. Bit 2 of REG_MISC is again cleared, returning nReset pin to POR functionality.
315
+
### sync()
316
+
Resets the PWM/Blink/Fade counters, syncing any blinking LEDs. Bit 2 of REG_MISC is set, which alters the functionality of the nReset pin. The nReset pin is toggled low->high, which should reset all LED counters. Bit 2 of REG_MISC is again cleared, returning nReset pin to POR functionality.
302
317
303
318
No inputs or outputs. Just does.
304
319
@@ -310,4 +325,4 @@ If you do make use of the library, or if you find places for improvement, I'd lo
0 commit comments