i2c smbus filter function corrupting variables
问题 I have a simple function #define AMB_FILTER 0.7f int32_t fValue; (this is declared in the class header) int32_t Ambient::filter(uint32_t raw) { // If we have no preliminary fValue we don't need to calculate a filter if(fValue == -1) { fValue = raw; return fValue; } float y, yy; y = (1.0f - AMB_FILTER) * (float) raw; yy = AMB_FILTER * (float) fValue; fValue = (int32_t) (y + yy); printf("filter raw %d y %f yy %f fValue %d\n",raw, y, yy, fValue); return fValue; } It takes in a value that was