new version 0_2_2 from stuttgart
This commit is contained in:
parent
0514952897
commit
c1b71e9829
32 changed files with 1049 additions and 501 deletions
|
@ -152,19 +152,17 @@ int NTPClient::getSeconds() {
|
|||
return (this->getEpochTime() % 60);
|
||||
}
|
||||
|
||||
String NTPClient::getFormattedTime(unsigned long secs) {
|
||||
void NTPClient::getFormattedTime(char *formatted_time, unsigned long secs) {
|
||||
unsigned long rawTime = secs ? secs : this->getEpochTime();
|
||||
unsigned int hours = (rawTime % 86400L) / 3600;
|
||||
unsigned int minutes = (rawTime % 3600) / 60;
|
||||
unsigned int seconds = rawTime % 60;
|
||||
|
||||
char formatted_time[9];
|
||||
snprintf(formatted_time, sizeof(formatted_time), "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
return String(formatted_time);
|
||||
snprintf(formatted_time, 9, "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
// Based on https://github.com/PaulStoffregen/Time/blob/master/Time.cpp
|
||||
String NTPClient::getFormattedDate(unsigned long secs) {
|
||||
void NTPClient::getFormattedDate(char *formatted_date, unsigned long secs) {
|
||||
unsigned long rawTime = (secs ? secs : this->getEpochTime()) / 86400L; // in days
|
||||
unsigned long days = 0, year = 1970;
|
||||
uint8_t month;
|
||||
|
@ -187,11 +185,9 @@ String NTPClient::getFormattedDate(unsigned long secs) {
|
|||
month++; // jan is month 1
|
||||
rawTime++; // first day is day 1
|
||||
|
||||
char formatted_date[23];
|
||||
snprintf(formatted_date, sizeof(formatted_date), "%4lu-%02d-%02lu %s%+03d",
|
||||
year, month, rawTime, this->getFormattedTime(secs).c_str(), this->_timeOffset / 3600);
|
||||
|
||||
return String(formatted_date);
|
||||
char formatted_time[9];
|
||||
this->getFormattedTime(formatted_time, secs);
|
||||
snprintf(formatted_date, 23, "%4lu-%02d-%02lu %s%+03d", year, month, rawTime, formatted_time, this->_timeOffset / 3600);
|
||||
}
|
||||
|
||||
void NTPClient::end() {
|
||||
|
|
|
@ -80,7 +80,7 @@ class NTPClient {
|
|||
/**
|
||||
* @return secs argument (or 0 for current time) formatted like `hh:mm:ss`
|
||||
*/
|
||||
String getFormattedTime(unsigned long secs = 0);
|
||||
void getFormattedTime(char *formatted_time, unsigned long secs = 0);
|
||||
|
||||
/**
|
||||
* @return time in seconds since Jan. 1, 1970
|
||||
|
@ -91,7 +91,7 @@ class NTPClient {
|
|||
* @return secs argument (or 0 for current date) formatted to ISO 8601
|
||||
* like `2004-02-12T15:19:21+00:00`
|
||||
*/
|
||||
String getFormattedDate(unsigned long secs = 0);
|
||||
void getFormattedDate(char *formatted_date, unsigned long secs = 0);
|
||||
|
||||
/**
|
||||
* Stops the underlying UDP client
|
||||
|
|
|
@ -34,7 +34,7 @@ Code
|
|||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 SparkFun Electronics
|
||||
Copyright (c) 2020 SparkFun Electronics
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -24,6 +24,7 @@ Thanks to!
|
|||
* [awatterott](https://github.com/awatterott) for adding [getAltitudeCompensation()](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/18)
|
||||
* [jogi-k](https://github.com/jogi-k) for adding [teensy i2clib](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/19) support
|
||||
* [paulvha](https://github.com/paulvha) for the suggestions and corrections in [his version of the library](https://github.com/paulvha/scd30)
|
||||
* [yamamaya](https://github.com/yamamaya) for the [3ms delay](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/24)
|
||||
|
||||
Repository Contents
|
||||
-------------------
|
||||
|
@ -43,8 +44,6 @@ License Information
|
|||
|
||||
This product is _**open source**_!
|
||||
|
||||
Various bits of the code have different licenses applied. Anything SparkFun wrote is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!
|
||||
|
||||
Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.
|
||||
|
||||
Distributed as-is; no warranty is given.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name=SparkFun SCD30 Arduino Library
|
||||
version=1.0.11
|
||||
version=1.0.13
|
||||
author=SparkFun Electronics
|
||||
maintainer=SparkFun Electronics <sparkfun.com>
|
||||
sentence=Library for the Sensirion SCD30 CO2 Sensor
|
||||
|
|
|
@ -266,6 +266,8 @@ bool SCD30::readMeasurement()
|
|||
if (_i2cPort->endTransmission() != 0)
|
||||
return (0); //Sensor did not ACK
|
||||
|
||||
delay(3);
|
||||
|
||||
const uint8_t receivedBytes = _i2cPort->requestFrom((uint8_t)SCD30_ADDRESS, (uint8_t)18);
|
||||
bool error = false;
|
||||
if (_i2cPort->available())
|
||||
|
@ -358,6 +360,8 @@ bool SCD30::getSettingValue(uint16_t registerAddress, uint16_t *val)
|
|||
if (_i2cPort->endTransmission() != 0)
|
||||
return (false); //Sensor did not ACK
|
||||
|
||||
delay(3);
|
||||
|
||||
_i2cPort->requestFrom((uint8_t)SCD30_ADDRESS, (uint8_t)3); // Request data and CRC
|
||||
if (_i2cPort->available())
|
||||
{
|
||||
|
@ -389,6 +393,8 @@ uint16_t SCD30::readRegister(uint16_t registerAddress)
|
|||
if (_i2cPort->endTransmission() != 0)
|
||||
return (0); //Sensor did not ACK
|
||||
|
||||
delay(3);
|
||||
|
||||
_i2cPort->requestFrom((uint8_t)SCD30_ADDRESS, (uint8_t)2);
|
||||
if (_i2cPort->available())
|
||||
{
|
||||
|
|
|
@ -57,9 +57,10 @@
|
|||
#define COMMAND_STOP_MEAS 0x0104
|
||||
#define COMMAND_READ_FW_VER 0xD100
|
||||
|
||||
typedef union {
|
||||
byte array[4];
|
||||
float value;
|
||||
typedef union
|
||||
{
|
||||
byte array[4];
|
||||
float value;
|
||||
} ByteToFl; // paulvha
|
||||
|
||||
class SCD30
|
||||
|
@ -69,9 +70,9 @@ public:
|
|||
|
||||
bool begin(bool autoCalibrate) { return begin(Wire, autoCalibrate); }
|
||||
#ifdef USE_TEENSY3_I2C_LIB
|
||||
bool begin(i2c_t3 &wirePort = Wire, bool autoCalibrate=true, bool measBegin=true); //By default use Wire port
|
||||
bool begin(i2c_t3 &wirePort = Wire, bool autoCalibrate = false, bool measBegin = true); //By default use Wire port
|
||||
#else
|
||||
bool begin(TwoWire &wirePort = Wire, bool autoCalibrate=true, bool measBegin=true); //By default use Wire port
|
||||
bool begin(TwoWire &wirePort = Wire, bool autoCalibrate = false, bool measBegin = true); //By default use Wire port
|
||||
#endif
|
||||
|
||||
void enableDebugging(Stream &debugPort = Serial); //Turn on debug printing. If user doesn't specify then Serial will be used.
|
||||
|
@ -82,11 +83,11 @@ public:
|
|||
|
||||
// based on paulvha
|
||||
bool getSettingValue(uint16_t registerAddress, uint16_t *val);
|
||||
bool getForcedRecalibration(uint16_t *val) {return(getSettingValue(COMMAND_SET_FORCED_RECALIBRATION_FACTOR, val));}
|
||||
bool getMeasurementInterval(uint16_t *val) {return(getSettingValue(COMMAND_SET_MEASUREMENT_INTERVAL, val));}
|
||||
bool getTemperatureOffset(uint16_t *val) {return(getSettingValue(COMMAND_SET_TEMPERATURE_OFFSET, val));}
|
||||
bool getAltitudeCompensation(uint16_t *val) {return(getSettingValue(COMMAND_SET_ALTITUDE_COMPENSATION, val));}
|
||||
bool getFirmwareVersion(uint16_t *val) {return(getSettingValue(COMMAND_READ_FW_VER, val));}
|
||||
bool getForcedRecalibration(uint16_t *val) { return (getSettingValue(COMMAND_SET_FORCED_RECALIBRATION_FACTOR, val)); }
|
||||
bool getMeasurementInterval(uint16_t *val) { return (getSettingValue(COMMAND_SET_MEASUREMENT_INTERVAL, val)); }
|
||||
bool getTemperatureOffset(uint16_t *val) { return (getSettingValue(COMMAND_SET_TEMPERATURE_OFFSET, val)); }
|
||||
bool getAltitudeCompensation(uint16_t *val) { return (getSettingValue(COMMAND_SET_ALTITUDE_COMPENSATION, val)); }
|
||||
bool getFirmwareVersion(uint16_t *val) { return (getSettingValue(COMMAND_READ_FW_VER, val)); }
|
||||
|
||||
uint16_t getCO2(void);
|
||||
float getHumidity(void);
|
||||
|
@ -115,12 +116,11 @@ public:
|
|||
uint8_t computeCRC8(uint8_t data[], uint8_t len);
|
||||
|
||||
private:
|
||||
|
||||
//Variables
|
||||
#ifdef USE_TEENSY3_I2C_LIB
|
||||
i2c_t3 *_i2cPort; //The generic connection to user's chosen I2C hardware
|
||||
#else
|
||||
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
|
||||
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
|
||||
#endif
|
||||
//Global main datums
|
||||
float co2 = 0;
|
||||
|
@ -136,6 +136,5 @@ private:
|
|||
//Debug
|
||||
Stream *_debugPort; //The stream to send debug messages to if enabled. Usually Serial.
|
||||
boolean _printDebug = false; //Flag to print debugging variables
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue