jfitter / MLX90614

MLX90614 IR Thermometer Driver Library for Arduino
GNU General Public License v3.0
16 stars 13 forks source link

A bug was found in the test #8

Closed ynkady closed 4 years ago

ynkady commented 4 years ago

void MLX90614::setEmissivity(float emiss) {

_rwError = 0;
uint16_t e = int(emiss * 65535. + 0.5);

Here, the conversion result is converted to an int, and there will be errors when entering parameters. For example, the input emmiss is 0.9, 0.95, and the final value is all the same, and the final value is set to 0.5. 改正:‘ Change int to uint16_t, it works. uint16_t e = uint16_t (emiss * 65535. + 0.5); if((emiss > 1.0) || (e < 6553)) _rwError |= MLX90614_INVALIDATA; else { writeEEProm(MLX90614_EMISS, e); //writeEEProm(MLX90614_EMISS, 58982); Serial.print("Set Emissivity Succsece:"); Serial.print(e); } }

jfitter commented 4 years ago

B#$%R it's a typo left over from some earlier incantation. I will fix it tonight. The int (C++style cast) is redundant. Only this is required uint16_t e = emiss * 65535. + 0.5;

jfitter commented 4 years ago

Fixed