Skip to content

Commit

Permalink
Fix forgotten argument (which wasn't noticed due to default arguments)
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed Jul 24, 2018
1 parent b75e879 commit 4ab110c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/controller/DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ void handleDeviceDefinition(const char * key, const char * val, void * pv) {
if (key[0] == DEVICE_ATTRIB_ADDRESS) {
parseBytes(def->address, val, 8);
} else if (key[0] == DEVICE_ATTRIB_CALIBRATEADJUST) {
temp_t parsedVal = temp_t(0.0);
temp_t parsedVal = temp_t::raw(0);
const int32_t minval = temp_t(-5.0).getRaw();
const int32_t maxval = temp_t(5.0).getRaw();
if (parsedVal.fromTempString(val, tempControl.cc.tempFormat, minval, maxval)) {
if (parsedVal.fromTempString(val, tempControl.cc.tempFormat, false, minval, maxval)) {
def->calibrationAdjust = parsedVal;
}
} else if (idx >= 0) {
Expand Down Expand Up @@ -368,6 +368,7 @@ void DeviceManager::parseDeviceDefinition(Stream & p) {
static DeviceDefinition dev;

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

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

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

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

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

0 comments on commit 4ab110c

Please sign in to comment.