Skip to content

Commit 4ab110c

Browse files
committed
Fix forgotten argument (which wasn't noticed due to default arguments)
1 parent b75e879 commit 4ab110c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/controller/DeviceManager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ void handleDeviceDefinition(const char * key, const char * val, void * pv) {
331331
if (key[0] == DEVICE_ATTRIB_ADDRESS) {
332332
parseBytes(def->address, val, 8);
333333
} else if (key[0] == DEVICE_ATTRIB_CALIBRATEADJUST) {
334-
temp_t parsedVal = temp_t(0.0);
334+
temp_t parsedVal = temp_t::raw(0);
335335
const int32_t minval = temp_t(-5.0).getRaw();
336336
const int32_t maxval = temp_t(5.0).getRaw();
337-
if (parsedVal.fromTempString(val, tempControl.cc.tempFormat, minval, maxval)) {
337+
if (parsedVal.fromTempString(val, tempControl.cc.tempFormat, false, minval, maxval)) {
338338
def->calibrationAdjust = parsedVal;
339339
}
340340
} else if (idx >= 0) {
@@ -368,6 +368,7 @@ void DeviceManager::parseDeviceDefinition(Stream & p) {
368368
static DeviceDefinition dev;
369369

370370
fill((int8_t *) &dev, sizeof(dev)); // fills with all -1
371+
dev.calibrationAdjust == temp_t::invalid();
371372
piLink.parseJson(&handleDeviceDefinition, &dev);
372373

373374
if (!inRangeInt8(dev.id, 0, NUM_DEVICE_SLOTS)) // no device id given, or it's out of range, can't do anything else.
@@ -392,12 +393,11 @@ void DeviceManager::parseDeviceDefinition(Stream & p) {
392393

393394
assignIfSet(dev.pio, &target.hw.settings.actuator.pio);
394395

395-
int8_t * calibrationAdjustAsInt8 = reinterpret_cast<int8_t*>(&dev.calibrationAdjust);
396-
if(calibrationAdjustAsInt8[0] != -1 && calibrationAdjustAsInt8[1] != -1 ){ // set by fill
396+
if(temp_t::invalid() != dev.calibrationAdjust){
397397
target.hw.settings.sensor.calibration = dev.calibrationAdjust;
398398
}
399399
else{
400-
target.hw.settings.sensor.calibration = temp_t(0.0);
400+
target.hw.settings.sensor.calibration = temp_t::raw(0);
401401
}
402402

403403
if (dev.address[0] != 0xFF) // first byte is family identifier. I don't have a complete list, but so far 0xFF is not used.

0 commit comments

Comments
 (0)