@@ -18,6 +18,7 @@ To add new expansion to the BluePrint library is necessary to provide:
18
18
19
19
The FW and expansion class must be developed in a different folder/repository
20
20
and no changes or PR should be required in this Opta BluePrint library.
21
+ We suggest to create a separate library.
21
22
22
23
It is suggested that FW source files and the expansion class are put in the
23
24
same folder for simplicity reasons (this allows to share information between
@@ -45,7 +46,7 @@ So a good starting point to develop an expansion FW is the following folder
45
46
structure (suppose your expansion is called "NewExpansion")
46
47
47
48
```
48
- /rood_folder_of_new_expansion_library
49
+ /root_folder_of_new_expansion_library
49
50
|-firmware/NewExpansion/NewExpansion.ino
50
51
|-src/
51
52
|-OptaNewExpansion.h
@@ -66,25 +67,6 @@ Opta Controller is build.
66
67
** _ NOTE: in the following we suppose that the new expansion "name" is
67
68
"NewExpansion"_ **
68
69
69
- ## Performance request
70
- Each expansion performs Assign Address Process using a common class Module, which
71
- is contained in OptaBlueModule files (.h and .cpp).
72
- In particular the function Module::update() is responsible to change the I2C address
73
- of the expansion.
74
- When the expansion has not a valid address and it receives the command from the
75
- controller to set up the address, the change of the address (being performed in
76
- Module::update()) is done in the main loop of the function.
77
- So there is a delay between the time the expansion get the message (I2C interrupt) and
78
- the moment the espansion actually set the address (in the main loop).
79
- The actual set of the expansion, in other word, depends on how "fast" is the main
80
- loop, however the main controller waits for a certain time and then retry the
81
- process.
82
- The expansion must set the new address as fast as it can!
83
- This means that is is strongly suggested that the main loop of the expansion
84
- only runs when the address is valid, so that when not a valid address has been set up,
85
- it can react very quickly to the address set request.
86
-
87
-
88
70
### OptaNewExpansion class
89
71
90
72
The files OptaNewExpansion file .h and .cpp must contain the implementation
@@ -228,6 +210,35 @@ care of the message and you just need to return the same value.
228
210
Do not make any change to the ` expansion_type ` (an integer in the Module class).
229
211
This is set in Module class and must NOT be modified in any Custom expansion.
230
212
213
+ ### Performance request
214
+ Each expansion performs Assign Address Process using a common class Module, which
215
+ is contained in OptaBlueModule files (.h and .cpp).
216
+ The Module::begin() function performs the assign address process at the very
217
+ beginning, but the function Module::update() is responsible to change the I2C address
218
+ of the expansion when a new expansion is plugged in and the assign address process
219
+ is done a second time (this function has to be called in the NewExpansion::update()
220
+ function, see above).
221
+ In the latter case the change of the address (being performed in
222
+ Module::update()) is done in the main loop of the expansion.
223
+ So there is a delay between the time the expansion gets the message (I2C interrupt) and
224
+ the moment the espansion actually sets the address (in the main loop).
225
+ The actual set of the expansion, in other word, depends on how "fast" is the main
226
+ loop, however the main controller waits for a certain time and then retry the
227
+ process.
228
+ The expansion must set the new address as fast as it can in order to avoid retries
229
+ from the controller.
230
+ This means that is is strongly suggested that the main loop of the expansion (except for
231
+ the call to the Module::update() function) only runs when the address is valid,
232
+ so that when not a valid address has been set up, it can react very quickly to the
233
+ address set request.
234
+ A good way to understand if the expansion has a valid address is:
235
+ ```
236
+ if(wire_i2c_address <= OPTA_DEFAULT_SLAVE_I2C_ADDRESS ||
237
+ wire_i2c_address >= OPTA_CONTROLLER_FIRST_TEMPORARY_ADDRESS) {
238
+ // NO VALID ADDRESS ACQUIRED
239
+ }
240
+ ```
241
+
231
242
## OptaNewExpansionCfg.h
232
243
233
244
This is an optional configuration file that contains all the configuration
@@ -384,7 +395,7 @@ The I2C_TRANSACTION already takes cares of timeouts and will call the failed
384
395
communication callback if set.
385
396
386
397
** IMPORTANT**
387
- There are 3 operation the basic expansion class takes care which are common to
398
+ There are 3 operations the basic expansion class takes care which are common to
388
399
all classes (WRITE in flash, READ in flash, get FW version).
389
400
If you want to use these operation remember to call ` Expansion::execute(); ` in
390
401
your ` defaul ` case switch of execute. This will use the base ` execute() ` function
0 commit comments