From d279ba2fd92c5124d3e3b5c5fb811dc92f2b0d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Voborsk=C3=BD?= Date: Wed, 11 Nov 2020 23:07:20 +0100 Subject: [PATCH] BME280 Lua module - `(config[3] & 0xFC) | BME280_FORCED_MODE` workaround bug fix (#3325) --- lua_modules/bme280/bme280.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua_modules/bme280/bme280.lua b/lua_modules/bme280/bme280.lua index ed0692b834..0f5c7ff2a6 100644 --- a/lua_modules/bme280/bme280.lua +++ b/lua_modules/bme280/bme280.lua @@ -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