|
| 1 | +# OpenLog Artemis : How To Add A New Sensor |
| 2 | + |
| 3 | +These are _abbreviated_ instructions on how to add a new sensor to the OLA firmware. It's more of an aide-memoire really... Sorry about that. |
| 4 | + |
| 5 | +Caveat: this is _currently_ how a new sensor is added, for version v1.n of the OLA firmware using v1.2.n of the Apollo3 boards (the OLA code is compiled using the SparkFun RedBoard Artemis ATP (All The Pins) board). This will change, dramatically, when we upgrade to v2 of Apollo3 and integrate BLE support. |
| 6 | + |
| 7 | +## Release Candidate Branch |
| 8 | + |
| 9 | +First up, please target any commits at the _**release_candidate**_ branch, so they can be tested before being merged into the _master_ branch. |
| 10 | + |
| 11 | +- https://github.com/sparkfun/OpenLog_Artemis/tree/release_candidate |
| 12 | + |
| 13 | +## OpenLog_Artemis.ino |
| 14 | + |
| 15 | +- [Add the new sensor to the comments at the start of the file](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-7d096a133c17fd6db382abb9a3c6ea7b42ec505961876cecf404a55be5945347R71) |
| 16 | + |
| 17 | +- [#include the library .h file remembering to include the library manager helper link](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-7d096a133c17fd6db382abb9a3c6ea7b42ec505961876cecf404a55be5945347R203) |
| 18 | + |
| 19 | +## Sensors.ino |
| 20 | + |
| 21 | +### gatherDeviceValues |
| 22 | + |
| 23 | +- This is where the sensor readings are actually read. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-fba25af49a58a7a24fb75cb34321e25dd4a94a9d3515ac051fcaa4502e444f7fR725-R798) |
| 24 | + |
| 25 | +### printHelperText |
| 26 | + |
| 27 | +- [Add helper text for the sensor readings](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-fba25af49a58a7a24fb75cb34321e25dd4a94a9d3515ac051fcaa4502e444f7fR1132-R1165) |
| 28 | + |
| 29 | +## autoDetect.ino |
| 30 | + |
| 31 | +### addDevice |
| 32 | + |
| 33 | +- This code is called to add the discovered device to the linked list of active devices. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR234-R239). The class name comes from the library. The config struct is defined in settings.h. |
| 34 | + |
| 35 | +### beginQwiicDevices |
| 36 | + |
| 37 | +- This is the code that is called to start (begin) the device. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR453-R461) |
| 38 | + |
| 39 | +### configureDevice |
| 40 | + |
| 41 | +- If the sensor needs to be configured before use, that gets done here. [Add a case for the new sensor, even if it doesn't need to be configured.](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR705-R707) |
| 42 | + |
| 43 | +### getConfigFunctionPtr |
| 44 | + |
| 45 | +- [Add a pointer to the sensor menu function (defined in menuAttachedDevices.ino)](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR795-R797) |
| 46 | + |
| 47 | +### swap |
| 48 | + |
| 49 | +- [Add the device's I2C address(es) here - just for reference (we don't use these #defines any longer)](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR929) |
| 50 | + |
| 51 | +### testDevice |
| 52 | + |
| 53 | +- This is the code used to detect the sensor. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR987-R994). Provide some indication of how robust the detection is. Confidence would be high if the .begin writes and reads unique data to/from the sensor. Confidence is low if .begin only uses the standard _isConnected_ I2C address test. |
| 54 | + |
| 55 | +### getDeviceName |
| 56 | + |
| 57 | +- This is where the sensor name is defined as text. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR1423-R1425) |
| 58 | + |
| 59 | +## menuAttachedDevices.ino |
| 60 | + |
| 61 | +### menuAttachedDevices |
| 62 | + |
| 63 | +- This is the code which lists all the attached devices as a menu. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-6174875faf8039f2627c16aaf48e4db57f5a2c8c883061ac97202d74e9a46ef8R309-R311) |
| 64 | + |
| 65 | +### menuConfigure_ |
| 66 | + |
| 67 | +- [Add a new menuConfigure_ for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-6174875faf8039f2627c16aaf48e4db57f5a2c8c883061ac97202d74e9a46ef8R2026-R2133) |
| 68 | +- Boolean settings are simple to toggle. [Make them exclusive if you need to](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-6174875faf8039f2627c16aaf48e4db57f5a2c8c883061ac97202d74e9a46ef8R1942-R1948) |
| 69 | +- _int64_t_ values are requested using _getNumber_ (defined in support.ino) |
| 70 | +- _double_ values are requested using _getDouble_ (defined in support.ino) |
| 71 | + |
| 72 | +## nvm.ino |
| 73 | + |
| 74 | +### recordDeviceSettingsToFile |
| 75 | + |
| 76 | +- This function gets called to write the device settings to file. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-629ae89c3c660583493d544d3a7902728f4a8eefb65800c3acb64aea37d5d88dR611-R629). Include all of the sensor settings. |
| 77 | + |
| 78 | +### parseDeviceLine |
| 79 | + |
| 80 | +- This function gets called when the device settings are read back from file. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-629ae89c3c660583493d544d3a7902728f4a8eefb65800c3acb64aea37d5d88dR1116-R1150) |
| 81 | + |
| 82 | +## settings.h |
| 83 | + |
| 84 | +### enum |
| 85 | + |
| 86 | +- [Add the device to the enumerated sensors](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-c853eddd04f78093fed5ec20b822c3c224bfa5f268738ce4c479b45667f86fe9R25). Insert the new one above _DEVICE_TOTAL_DEVICES_ |
| 87 | + |
| 88 | +### settings struct |
| 89 | + |
| 90 | +- [Add a settings struct for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-c853eddd04f78093fed5ec20b822c3c224bfa5f268738ce4c479b45667f86fe9R265-R281). Include both _log_ and _powerOnDelayMillis_ |
0 commit comments