Update DEV_Sensors.h

This commit is contained in:
Gregg 2021-02-23 09:56:45 -06:00
parent 396e3322a9
commit 6f589af43a
1 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera
// of Celsius or Fahrenheit for each Service, it does not appear to work as advertised. // of Celsius or Fahrenheit for each Service, it does not appear to work as advertised.
temp=new Characteristic::CurrentTemperature(30.0); // instantiate the Current Temperature Characteristic temp=new Characteristic::CurrentTemperature(30.0); // instantiate the Current Temperature Characteristic
new SpanRange(-50,100,0.5); // expand the range from the HAP default of 0-100 to -50 to 100 to allow for negative temperatures new SpanRange(-50,100,1); // expand the range from the HAP default of 0-100 to -50 to 100 to allow for negative temperatures
Serial.print("Configuring Temperature Sensor"); // initialization message Serial.print("Configuring Temperature Sensor"); // initialization message
Serial.print("\n"); Serial.print("\n");
@ -39,7 +39,7 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera
void loop(){ void loop(){
if(temp->timeVal()>5000){ // check time elapsed since last update and proceed only if greater than 5 seconds if(temp->timeVal()>5000){ // check time elapsed since last update and proceed only if greater than 5 seconds
float temperature=temp->getVal<float>()+0.5; // "simulate" a half-degree temperature change... float temperature=temp->getVal<float>()+0.5; // "simulate" a half-degree temperature change (it's okay that we set step size in SpanRange to 1)...
if(temperature>35.0) // ...but cap the maximum at 35C before starting over at -30C if(temperature>35.0) // ...but cap the maximum at 35C before starting over at -30C
temperature=-30.0; temperature=-30.0;