BME280 Lua module - `(config[3] & 0xFC) | BME280_FORCED_MODE` workaround bug fix (#3325)

This commit is contained in:
Lukáš Voborský 2020-11-11 23:07:20 +01:00 committed by GitHub
parent c4baa9f3b9
commit d279ba2fd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -130,8 +130,8 @@ function bme280_startreadout(self, callback, delay, alt)
delay = delay or BME280_SAMPLING_DELAY
if self._isbme then write_reg(self.id, self.addr, BME280_REGISTER_CONTROL_HUM, self._config[2]) end
write_reg(self.id, self.addr, BME280_REGISTER_CONTROL, math_floor(self._config[3]:byte(1)/4)+ 1)
-- math_floor(self._config[3]:byte(1)/4)+ 1
write_reg(self.id, self.addr, BME280_REGISTER_CONTROL, 4*math_floor(self._config[3]:byte(1)/4)+ 1)
-- 4*math_floor(self._config[3]:byte(1)/4)+ 1
-- an awful way to avoid bit operations but calculate (config[3] & 0xFC) | BME280_FORCED_MODE
-- Lua 5.3 integer division // would be more suitable