Skip to content

Commit c06206a

Browse files
authored
Merge pull request #37 from sparkfun/v16_Candidate
Merging v16_Candidate
2 parents 3340309 + 520f49a commit c06206a

29 files changed

+4826
-326
lines changed
161 KB
Binary file not shown.
159 KB
Binary file not shown.

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ If you'd like to contribute, start by searching through the [issues](https://git
77
If you decide to add a feature or support for a new sensor to OpenLog Artemis, please create a PR and follow these best practices:
88

99
* Change as little as possible. Do not sumbit a PR that changes 100 lines of whitespace. Break up into multiple PRs if necessary.
10-
* If you add a new feature document how it works in the PR.
10+
* If you add a new feature, please document how it works in the PR.
11+
* Please submit your PR using the [release-candidate branch](https://github.com/sparkfun/OpenLog_Artemis/tree/release_candidate). That way, we can merge and test your PR quickly without changing the _master_ branch
12+
13+
![Contributing.JPG](./img/Contributing.JPG)
1114

1215
## Style guide
1316

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 140 additions & 32 deletions
Large diffs are not rendered by default.

Firmware/OpenLog_Artemis/Sensors.ino

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
void getData()
33
{
44
measurementCount++;
5+
measurementTotal++;
56

67
char tempData[50];
78
outputData[0] = '\0'; //Clear string contents
@@ -110,8 +111,12 @@ void getData()
110111

111112
if (online.IMU)
112113
{
114+
//printDebug("getData: online.IMU = " + (String)online.IMU + "\r\n");
115+
113116
if (myICM.dataReady())
114117
{
118+
//printDebug("getData: myICM.dataReady = " + (String)myICM.dataReady() + "\r\n");
119+
115120
myICM.getAGMT(); //Update values
116121

117122
if (settings.logIMUAccel)
@@ -135,6 +140,10 @@ void getData()
135140
strcat(outputData, tempData);
136141
}
137142
}
143+
//else
144+
//{
145+
// printDebug("getData: myICM.dataReady = " + (String)myICM.dataReady() + "\r\n");
146+
//}
138147
}
139148

140149
//Append all external sensor data on linked list to outputData
@@ -164,11 +173,11 @@ void getData()
164173

165174
if (settings.printMeasurementCount)
166175
{
167-
sprintf(tempData, "%d,", measurementCount);
176+
sprintf(tempData, "%d,", measurementTotal);
168177
strcat(outputData, tempData);
169178
}
170179

171-
strcat(outputData, "\n");
180+
strcat(outputData, "\r\n");
172181

173182
totalCharactersPrinted += strlen(outputData);
174183
}
@@ -670,7 +679,7 @@ void gatherDeviceValues()
670679
}
671680
break;
672681
default:
673-
Serial.printf("printDeviceValue unknown device type: %s\n", getDeviceName(temp->deviceType));
682+
Serial.printf("printDeviceValue unknown device type: %s\r\n", getDeviceName(temp->deviceType));
674683
break;
675684
}
676685

@@ -981,7 +990,7 @@ void printHelperText(bool terminalOnly)
981990
}
982991
break;
983992
default:
984-
Serial.printf("\nprinterHelperText device not found: %d\n", temp->deviceType);
993+
Serial.printf("\nprinterHelperText device not found: %d\r\n", temp->deviceType);
985994
break;
986995
}
987996
}
@@ -994,12 +1003,13 @@ void printHelperText(bool terminalOnly)
9941003
if (settings.printMeasurementCount)
9951004
strcat(helperText, "count,");
9961005

997-
strcat(helperText, "\n");
1006+
strcat(helperText, "\r\n");
9981007

9991008
Serial.print(helperText);
10001009
if ((terminalOnly == false) && (settings.logData == true) && (online.microSD) && (settings.enableSD && online.microSD))
10011010
sensorDataFile.print(helperText);
10021011
}
1012+
10031013
//If certain devices are attached, we need to reduce the I2C max speed
10041014
void setMaxI2CSpeed()
10051015
{
@@ -1036,6 +1046,7 @@ void setMaxI2CSpeed()
10361046
qwiic.setClock(maxSpeed);
10371047
for (int i = 0; i < 100; i++) //Allow time for the speed to change
10381048
{
1049+
checkBattery();
10391050
delay(1);
10401051
}
10411052
}

Firmware/OpenLog_Artemis/autoDetect.ino

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ bool addDevice(deviceType_e deviceType, uint8_t address, uint8_t muxAddress, uin
226226
}
227227
break;
228228
default:
229-
Serial.printf("addDevice Device type not found: %d\n", deviceType);
229+
Serial.printf("addDevice Device type not found: %d\r\n", deviceType);
230230
break;
231231
}
232232

@@ -252,12 +252,16 @@ bool beginQwiicDevices()
252252
{
253253
bool everythingStarted = true;
254254

255+
waitForQwiicBusPowerDelay(); // Wait while the qwiic devices power up - if required
256+
257+
qwiicPowerOnDelayMillis = settings.qwiicBusPowerUpDelayMs; // Set qwiicPowerOnDelayMillis to the _minimum_ defined by settings.qwiicBusPowerUpDelayMs. It will be increased if required.
258+
255259
//Step through the list
256260
node *temp = head;
257261

258262
if (temp == NULL)
259263
{
260-
Serial.println(F("beginQwiicDevices: No devices detected"));
264+
printDebug(F("beginQwiicDevices: No devices detected\r\n"));
261265
return (true);
262266
}
263267

@@ -277,20 +281,24 @@ bool beginQwiicDevices()
277281
case DEVICE_MULTIPLEXER:
278282
{
279283
QWIICMUX *tempDevice = (QWIICMUX *)temp->classPtr;
284+
struct_multiplexer *nodeSetting = (struct_multiplexer *)temp->configPtr; //Create a local pointer that points to same spot as node does
285+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
280286
temp->online = tempDevice->begin(temp->address, qwiic); //Address, Wire port
281287
}
282288
break;
283289
case DEVICE_LOADCELL_NAU7802:
284290
{
285291
NAU7802 *tempDevice = (NAU7802 *)temp->classPtr;
286292
struct_NAU7802 *nodeSetting = (struct_NAU7802 *)temp->configPtr; //Create a local pointer that points to same spot as node does
293+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
287294
temp->online = tempDevice->begin(qwiic); //Wire port
288295
}
289296
break;
290297
case DEVICE_DISTANCE_VL53L1X:
291298
{
292299
SFEVL53L1X *tempDevice = (SFEVL53L1X *)temp->classPtr;
293300
struct_VL53L1X *nodeSetting = (struct_VL53L1X *)temp->configPtr; //Create a local pointer that points to same spot as node does
301+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
294302
if (tempDevice->begin() == 0) //Returns 0 if init was successful. Wire port passed in constructor.
295303
temp->online = true;
296304
}
@@ -300,6 +308,7 @@ bool beginQwiicDevices()
300308
qwiic.setPullups(0); //Disable pullups for u-blox comms.
301309
SFE_UBLOX_GPS *tempDevice = (SFE_UBLOX_GPS *)temp->classPtr;
302310
struct_uBlox *nodeSetting = (struct_uBlox *)temp->configPtr; //Create a local pointer that points to same spot as node does
311+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
303312
temp->online = tempDevice->begin(qwiic, temp->address); //Wire port, Address
304313
qwiic.setPullups(settings.qwiicBusPullUps); //Re-enable pullups.
305314
}
@@ -308,86 +317,113 @@ bool beginQwiicDevices()
308317
{
309318
VCNL4040 *tempDevice = (VCNL4040 *)temp->classPtr;
310319
struct_VCNL4040 *nodeSetting = (struct_VCNL4040 *)temp->configPtr; //Create a local pointer that points to same spot as node does
320+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
311321
temp->online = tempDevice->begin(qwiic); //Wire port
312322
}
313323
break;
314324
case DEVICE_TEMPERATURE_TMP117:
315325
{
316326
TMP117 *tempDevice = (TMP117 *)temp->classPtr;
327+
struct_TMP117 *nodeSetting = (struct_TMP117 *)temp->configPtr; //Create a local pointer that points to same spot as node does
328+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
317329
temp->online = tempDevice->begin(temp->address, qwiic); //Address, Wire port
318330
}
319331
break;
320332
case DEVICE_PRESSURE_LPS25HB:
321333
{
322334
LPS25HB *tempDevice = (LPS25HB *)temp->classPtr;
335+
struct_LPS25HB *nodeSetting = (struct_LPS25HB *)temp->configPtr; //Create a local pointer that points to same spot as node does
336+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
323337
temp->online = tempDevice->begin(qwiic, temp->address); //Wire port, Address
324338
}
325339
break;
326340
case DEVICE_PRESSURE_MS5637:
327341
{
328342
MS5637 *tempDevice = (MS5637 *)temp->classPtr;
343+
struct_MS5637 *nodeSetting = (struct_MS5637 *)temp->configPtr; //Create a local pointer that points to same spot as node does
344+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
329345
temp->online = tempDevice->begin(qwiic); //Wire port
330346
}
331347
break;
332348
case DEVICE_PHT_BME280:
333349
{
334350
BME280 *tempDevice = (BME280 *)temp->classPtr;
351+
struct_BME280 *nodeSetting = (struct_BME280 *)temp->configPtr; //Create a local pointer that points to same spot as node does
352+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
335353
tempDevice->setI2CAddress(temp->address);
336354
temp->online = tempDevice->beginI2C(qwiic); //Wire port
337355
}
338356
break;
339357
case DEVICE_UV_VEML6075:
340358
{
341359
VEML6075 *tempDevice = (VEML6075 *)temp->classPtr;
360+
struct_VEML6075 *nodeSetting = (struct_VEML6075 *)temp->configPtr; //Create a local pointer that points to same spot as node does
361+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
342362
temp->online = tempDevice->begin(qwiic); //Wire port
343363
}
344364
break;
345365
case DEVICE_VOC_CCS811:
346366
{
347367
CCS811 *tempDevice = (CCS811 *)temp->classPtr;
368+
struct_CCS811 *nodeSetting = (struct_CCS811 *)temp->configPtr; //Create a local pointer that points to same spot as node does
369+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
348370
temp->online = tempDevice->begin(qwiic); //Wire port
349371
}
350372
break;
351373
case DEVICE_VOC_SGP30:
352374
{
353375
SGP30 *tempDevice = (SGP30 *)temp->classPtr;
376+
struct_SGP30 *nodeSetting = (struct_SGP30 *)temp->configPtr; //Create a local pointer that points to same spot as node does
377+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
354378
temp->online = tempDevice->begin(qwiic); //Wire port
355379
}
356380
break;
357381
case DEVICE_CO2_SCD30:
358382
{
359383
SCD30 *tempDevice = (SCD30 *)temp->classPtr;
384+
struct_SCD30 *nodeSetting = (struct_SCD30 *)temp->configPtr; //Create a local pointer that points to same spot as node does
385+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
360386
temp->online = tempDevice->begin(qwiic); //Wire port
361387
}
362388
break;
363389
case DEVICE_PHT_MS8607:
364390
{
365391
MS8607 *tempDevice = (MS8607 *)temp->classPtr;
392+
struct_MS8607 *nodeSetting = (struct_MS8607 *)temp->configPtr; //Create a local pointer that points to same spot as node does
393+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
366394
temp->online = tempDevice->begin(qwiic); //Wire port
367395
}
368396
break;
369397
case DEVICE_TEMPERATURE_MCP9600:
370398
{
371399
MCP9600 *tempDevice = (MCP9600 *)temp->classPtr;
400+
struct_MCP9600 *nodeSetting = (struct_MCP9600 *)temp->configPtr; //Create a local pointer that points to same spot as node does
401+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
372402
temp->online = tempDevice->begin(temp->address, qwiic); //Address, Wire port
373403
}
374404
break;
375405
case DEVICE_HUMIDITY_AHT20:
376406
{
377407
AHT20 *tempDevice = (AHT20 *)temp->classPtr;
408+
struct_AHT20 *nodeSetting = (struct_AHT20 *)temp->configPtr; //Create a local pointer that points to same spot as node does
409+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
378410
temp->online = tempDevice->begin(qwiic); //Wire port
379411
}
380412
break;
381413
case DEVICE_HUMIDITY_SHTC3:
382414
{
383415
SHTC3 *tempDevice = (SHTC3 *)temp->classPtr;
416+
struct_SHTC3 *nodeSetting = (struct_SHTC3 *)temp->configPtr; //Create a local pointer that points to same spot as node does
417+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
384418
if (tempDevice->begin(qwiic) == 0) //Wire port. Returns 0 on success.
385419
temp->online = true;
386420
}
387421
break;
388422
case DEVICE_ADC_ADS122C04:
389423
{
390424
SFE_ADS122C04 *tempDevice = (SFE_ADS122C04 *)temp->classPtr;
425+
struct_ADS122C04 *nodeSetting = (struct_ADS122C04 *)temp->configPtr; //Create a local pointer that points to same spot as node does
426+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
391427
if (tempDevice->begin(temp->address, qwiic) == true) //Address, Wire port. Returns true on success.
392428
temp->online = true;
393429
}
@@ -423,7 +459,7 @@ void printOnlineDevice()
423459

424460
if (temp == NULL)
425461
{
426-
Serial.println(F("printOnlineDevice: No devices detected"));
462+
printDebug(F("printOnlineDevice: No devices detected"));
427463
return;
428464
}
429465

@@ -433,23 +469,23 @@ void printOnlineDevice()
433469
if (temp->online)
434470
{
435471
if (temp->muxAddress == 0)
436-
sprintf(sensorOnlineText, "%s online at address 0x%02X\n", getDeviceName(temp->deviceType), temp->address);
472+
sprintf(sensorOnlineText, "%s online at address 0x%02X\r\n", getDeviceName(temp->deviceType), temp->address);
437473
else
438-
sprintf(sensorOnlineText, "%s online at address 0x%02X.0x%02X.%d\n", getDeviceName(temp->deviceType), temp->address, temp->muxAddress, temp->portNumber);
474+
sprintf(sensorOnlineText, "%s online at address 0x%02X.0x%02X.%d\r\n", getDeviceName(temp->deviceType), temp->address, temp->muxAddress, temp->portNumber);
439475

440476
deviceCount++;
441477
}
442478
else
443479
{
444-
sprintf(sensorOnlineText, "%s failed to respond\n", getDeviceName(temp->deviceType));
480+
sprintf(sensorOnlineText, "%s failed to respond\r\n", getDeviceName(temp->deviceType));
445481
}
446482
Serial.print(sensorOnlineText);
447483

448484
temp = temp->next;
449485
}
450486

451487
if (settings.printDebugMessages == true)
452-
Serial.printf("Device count: %d\n", deviceCount);
488+
Serial.printf("Device count: %d\r\n", deviceCount);
453489
}
454490

455491
//Given the node number, apply the node's configuration settings to the device
@@ -633,7 +669,7 @@ void configureDevice(node * temp)
633669
}
634670
break;
635671
default:
636-
Serial.printf("configureDevice: Unknown device type %d: %s\n", deviceType, getDeviceName((deviceType_e)deviceType));
672+
Serial.printf("configureDevice: Unknown device type %d: %s\r\n", deviceType, getDeviceName((deviceType_e)deviceType));
637673
break;
638674
}
639675
}
@@ -1154,14 +1190,14 @@ deviceType_e testDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumb
11541190
default:
11551191
{
11561192
if (muxAddress == 0)
1157-
Serial.printf("Unknown device at address (0x%02X)\n", i2cAddress);
1193+
Serial.printf("Unknown device at address (0x%02X)\r\n", i2cAddress);
11581194
else
1159-
Serial.printf("Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\n", i2cAddress, muxAddress, portNumber);
1195+
Serial.printf("Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\r\n", i2cAddress, muxAddress, portNumber);
11601196
return DEVICE_UNKNOWN_DEVICE;
11611197
}
11621198
break;
11631199
}
1164-
Serial.printf("Known I2C address but device failed identification at address 0x%02X\n", i2cAddress);
1200+
Serial.printf("Known I2C address but device failed identification at address 0x%02X\r\n", i2cAddress);
11651201
return DEVICE_UNKNOWN_DEVICE;
11661202
}
11671203

@@ -1191,9 +1227,9 @@ deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portN
11911227
default:
11921228
{
11931229
if (muxAddress == 0)
1194-
Serial.printf("Unknown device at address (0x%02X)\n", i2cAddress);
1230+
Serial.printf("Unknown device at address (0x%02X)\r\n", i2cAddress);
11951231
else
1196-
Serial.printf("Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\n", i2cAddress, muxAddress, portNumber);
1232+
Serial.printf("Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\r\n", i2cAddress, muxAddress, portNumber);
11971233
return DEVICE_UNKNOWN_DEVICE;
11981234
}
11991235
break;

0 commit comments

Comments
 (0)