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);
}
}
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;
void MLX90614::setEmissivity(float emiss) {
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); } }