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
/* using this the code inside the if will run every PERIODIC_UPDATE_TIME ms
3736
-
assuming the function is called repeteadly in the loop() function */
3736
+
assuming the function is called repeatedly in the loop() function */
3737
3737
3738
3738
if (millis() - start > PERIODIC_UPDATE_TIME) {
3739
3739
start = millis();
@@ -3922,7 +3922,7 @@ void optaAnalogTask() {
3922
3922
static long int start = millis();
3923
3923
3924
3924
/* using this the code inside the if will run every PERIODIC_UPDATE_TIME ms
3925
-
assuming the function is called repeteadly in the loop() function */
3925
+
assuming the function is called repeatedly in the loop() function */
3926
3926
3927
3927
if (millis() - start > PERIODIC_UPDATE_TIME) {
3928
3928
start = millis();
@@ -4030,19 +4030,6 @@ exp.setPwm(ch, <period_us>, <pulse_us>); // the first argument is to define the
4030
4030
The following example will let you set a **PWM** signal on channel **P1**, increasing and decreasing its duty-cycle sequentially, this sketch is based on the built-in example found in **File > Examples > Arduino_Opta_Blueprint > Analog > PWM**:
@@ -4211,7 +4198,159 @@ The Opta™ Analog Expansions have **8 status LEDs** on the front panel. They ar
4211
4198
| LED 7 | 6 or OA_LED_7 |
4212
4199
| LED 8 | 7 or OA_LED_8 |
4213
4200
4201
+
To control a status LED use the built-in function `switchLedOn()` or `switchLedOff()` as shown below:
4202
+
4203
+
```arduino
4204
+
// Turn ON
4205
+
exp.switchLedOn(<LED>, <update>); // define the LED to control and set to true or false the update parameter
4206
+
exp.switchLedOff(<LED>, <update>); // define the LED to control and set to true or false the update parameter
4207
+
```
4208
+
If the `update` parameter is set to "false", then you will be setting the desired status of the LED but it won't be applied until you call `updateLeds()` function.
4209
+
4210
+
```arduino
4211
+
exp.switchLedOn(OA_LED_1, false); // set the desired status to the queue
4212
+
exp.updateLeds(); // apply the changes and update the current LED state
4213
+
```
4214
+
4215
+
The following example will let you control the status LEDs sequentially, this sketch can be found in **File > Examples > Arduino_Opta_Blueprint > Analog > LED**:
4216
+
4217
+
```arduino
4218
+
#include "OptaBlue.h"
4219
+
4220
+
#define PERIODIC_UPDATE_TIME 2 //actually not used (it's DELAY_LED that leads the timing)
Please take into account that `OptaController.update()` must be called cyclically to support the hot plug of new expansions. In other words, by calling the update() function cyclically, the controller will discover new expansions when they are plugged in while the controller is already running.
4333
+
4334
+
Thanks to this function, the action of plugging in a new expansion will cause the controller to start a completely new discovery process and a new I2C address assignment.
4335
+
4336
+
`OptaController.update()` function DOES NOT:
4337
+
* Check if an expansion has been removed and remove their objects
4338
+
* Update any data from or to the expansion
4339
+
4340
+
The expansion object in the example above is defined using the `OptaController.getExpansion(i);` function, as follows:
4341
+
4342
+
```arduino
4343
+
for(int i = 0; i < OptaController.getExpansionNum(); i++) { // check all the available expansion slots
The above method will check if there is an Ext A0602 expansion connected in the `i` index from the five admitted. This will ensure which expansion the read state belongs to.
4348
+
4349
+
The function `optaAnalogTask()` turns on sequentially the **LEDs** and turns them off again.
4350
+
4351
+
After the Opta™ controller is programmed with the example sketch, you can see the onboard LEDs blinking with a pattern and experience the following behavior:
4214
4352
4353
+

0 commit comments