From 59ae1079825a85b363916049f6dec468e9e357c6 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 13 Mar 2023 09:34:56 +0000 Subject: [PATCH] BME280: Avoid runtime memory allocation. --- drivers/bme280/bme280.cpp | 5 ++++- drivers/bme280/bme280.hpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/bme280/bme280.cpp b/drivers/bme280/bme280.cpp index 5091162a..1e7090ec 100644 --- a/drivers/bme280/bme280.cpp +++ b/drivers/bme280/bme280.cpp @@ -11,7 +11,10 @@ namespace pimoroni { gpio_pull_up(interrupt); } - device.intf_ptr = new i2c_intf_ptr{.i2c = i2c, .address = address}; + i2c_interface.i2c = i2c; + i2c_interface.address = address; + + device.intf_ptr = &i2c_interface; device.intf = bme280_intf::BME280_I2C_INTF; device.read = (bme280_read_fptr_t)&read_bytes; device.write = (bme280_write_fptr_t)&write_bytes; diff --git a/drivers/bme280/bme280.hpp b/drivers/bme280/bme280.hpp index cc255e54..706d87c3 100644 --- a/drivers/bme280/bme280.hpp +++ b/drivers/bme280/bme280.hpp @@ -26,6 +26,8 @@ namespace pimoroni { bool status; }; + i2c_intf_ptr i2c_interface; + bool debug = false; bool init();