Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/7.2.x #158

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v7.2.0"
"version": "v7.2.1"
}
2 changes: 1 addition & 1 deletion doc/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = Pixelix
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = v7.2.0
PROJECT_NUMBER = v7.2.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
6 changes: 6 additions & 0 deletions lib/Common/src/ISensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class ISensor
*/
virtual void begin() = 0;

/**
* Process the sensor driver. Mainly used to read the sensor value and
* provide its data cached to the sensor channels.
*/
virtual void process() = 0;

/**
* Get sensor name.
*
Expand Down
4 changes: 3 additions & 1 deletion lib/Common/src/SensorChannelType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class SensorChannelType<float, ISensorChannel::DATA_TYPE_FLOAT32> : public ISens

/**
* Get data value.
* If there is any error, it will return NaN.
*
* @return Sensor data value
*/
Expand All @@ -182,6 +183,7 @@ class SensorChannelType<float, ISensorChannel::DATA_TYPE_FLOAT32> : public ISens

/**
* Get value as string.
* If there is any error, it will return "NAN".
*
* @param[in] precision The precision (ignored for integer values) of the value.
*
Expand All @@ -191,7 +193,7 @@ class SensorChannelType<float, ISensorChannel::DATA_TYPE_FLOAT32> : public ISens
{
float value = getValue();
String valueStr;
char buffer[20];
char buffer[20U];

(void)snprintf(buffer, sizeof(buffer), "%.*F", precision, value);
valueStr = buffer;
Expand Down
13 changes: 13 additions & 0 deletions lib/Common/src/SensorDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ void SensorDataProviderImpl::begin()
}
}

void SensorDataProviderImpl::process()
{
uint8_t index = 0U;

for(index = 0U; index < m_cnt; ++index)
{
if (nullptr != m_sensors[index])
{
m_sensors[index]->process();
}
}
}

ISensor* SensorDataProviderImpl::getSensor(uint8_t index)
{
ISensor* sensor = nullptr;
Expand Down
5 changes: 5 additions & 0 deletions lib/Common/src/SensorDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class SensorDataProviderImpl
*/
void begin();

/**
* Process the sensor drivers.
*/
void process();

/**
* Get number of installed sensor drivers, independed of the physical
* sensor availability.
Expand Down
9 changes: 9 additions & 0 deletions lib/Sensors/src/SensorBattery.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ class SensorBattery : public ISensor
*/
void begin() final;

/**
* Process the sensor driver. Mainly used to read the sensor value and
* provide its data cached to the sensor channels.
*/
void process() final
{
/* Nothing to do.*/
}

/**
* Get sensor name.
*
Expand Down
43 changes: 37 additions & 6 deletions lib/Sensors/src/SensorDhtX.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,24 @@ class DhtXTemperatureChannel : public SensorChannelFloat32
}

/**
* Get data value.
* Get the temperature.
* If there is any error, it will return NaN.
*
* @return Sensor data value in °C.
* @return Temperature in °C.
*/
float getValue() final
{
return m_driver.readTemperature() + m_offset;
/* readTemperature() will provide the last value from the cache in case
* the request period is lower than 2s.
*/
float temperature = m_driver.readTemperature();

if (false == isnan(temperature))
{
temperature += m_offset;
}

return temperature;
}

/**
Expand Down Expand Up @@ -168,13 +179,24 @@ class DhtXHumidityChannel : public SensorChannelFloat32
}

/**
* Get data value.
* Get the humidity.
* If there is any error, it will return NaN.
*
* @return Sensor data value in %.
* @return Humidity in %.
*/
float getValue() final
{
return m_driver.readHumidity() + m_offset;
/* readHumidity() will provide the last value from the cache in case
* the request period is lower than 2s.
*/
float humidity = m_driver.readHumidity();

if (false == isnan(humidity))
{
humidity += m_offset;
}

return humidity;
}

/**
Expand Down Expand Up @@ -251,6 +273,15 @@ class SensorDhtX : public ISensor
*/
void begin() final;

/**
* Process the sensor driver. Mainly used to read the sensor value and
* provide its data cached to the sensor channels.
*/
void process() final
{
/* Nothing to do.*/
}

/**
* Get sensor name.
*
Expand Down
9 changes: 9 additions & 0 deletions lib/Sensors/src/SensorLdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ class SensorLdr : public ISensor
*/
void begin() final;

/**
* Process the sensor driver. Mainly used to read the sensor value and
* provide its data cached to the sensor channels.
*/
void process() final
{
/* Nothing to do.*/
}

/**
* Get sensor name.
*
Expand Down
8 changes: 8 additions & 0 deletions lib/Sensors/src/SensorSht3X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ void SensorSht3X::begin()
}
}

void SensorSht3X::process()
{
if (true == m_isAvailable)
{
(void)m_driver.readSample();
}
}

const char* SensorSht3X::getName() const
{
/* Model can not be read back and the automatic detection may be enabled,
Expand Down
34 changes: 28 additions & 6 deletions lib/Sensors/src/SensorSht3X.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,21 @@ class Sht3XTemperatureChannel : public SensorChannelFloat32
}

/**
* Get data value.
* Get the temperature.
* If there is any error, it will return NaN.
*
* @return Sensor data value in °C.
* @return Temperature in °C.
*/
float getValue() final
{
return m_driver.getTemperature() + m_offset;
float temperature = m_driver.getTemperature();

if (false == isnan(temperature))
{
temperature += m_offset;
}

return temperature;
}

/**
Expand Down Expand Up @@ -168,13 +176,21 @@ class Sht3XHumidityChannel : public SensorChannelFloat32
}

/**
* Get data value.
* Get the humidity.
* If there is any error, it will return NaN.
*
* @return Sensor data value in %.
* @return Humidity in %.
*/
float getValue() final
{
return m_driver.getHumidity() + m_offset;
float humidity = m_driver.getHumidity();

if (false == isnan(humidity))
{
humidity += m_offset;
}

return humidity;
}

/**
Expand Down Expand Up @@ -239,6 +255,12 @@ class SensorSht3X : public ISensor
*/
void begin() final;

/**
* Process the sensor driver. Mainly used to read the sensor value and
* provide its data cached to the sensor channels.
*/
void process() final;

/**
* Get sensor name.
*
Expand Down
8 changes: 4 additions & 4 deletions lib/TempHumidPlugin/src/TempHumidPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void TempHumidPlugin::process(bool isConnected)
{
m_humidity = humidity;

LOG_INFO("Humidity: %3.1f %%", m_humidity);
LOG_INFO("Humidity: %3.0f %%", m_humidity);
}
}
}
Expand Down Expand Up @@ -266,7 +266,7 @@ void TempHumidPlugin::handleTemperature()
}
else
{
char valueReducedPrecison[6] = { 0 }; /* Holds a value in lower precision for display. */
char valueReducedPrecison[10] = { 0 }; /* Holds a value in lower precision for display. */
String text;

/* Generate temperature string with reduced precision and add unit °C. */
Expand All @@ -289,10 +289,10 @@ void TempHumidPlugin::handleHumidity()
}
else
{
char valueReducedPrecison[4] = { 0 }; /* Holds a value in lower precision for display. */
char valueReducedPrecison[10] = { 0 }; /* Holds a value in lower precision for display. */
String text;

(void)snprintf(valueReducedPrecison, sizeof(valueReducedPrecison), "%3f", m_humidity);
(void)snprintf(valueReducedPrecison, sizeof(valueReducedPrecison), "%3.0f", m_humidity);
text = "\\calign";
text += valueReducedPrecison;
text += ISensorChannel::channelTypeToUnit(m_humiditySensorCh->getType());
Expand Down
Loading