Skip to content

Commit 42579b1

Browse files
authored
Merge pull request #4 from cparata/master
Fix I2C constructor
2 parents f2388f8 + 901102f commit 42579b1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/LIS2MDLSensor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
* @param i2c object of an helper class which handles the I2C peripheral
4848
* @param address the address of the component's instance
4949
*/
50-
LIS2MDLSensor::LIS2MDLSensor(TwoWire *i2c, uint8_t address) : dev_i2c(i2c), address(address)
50+
LIS2MDLSensor::LIS2MDLSensor(TwoWire *i2c) : dev_i2c(i2c)
5151
{
5252
dev_spi = NULL;
5353
reg_ctx.write_reg = LIS2MDL_io_write;
5454
reg_ctx.read_reg = LIS2MDL_io_read;
5555
reg_ctx.handle = (void *)this;
56-
mag_is_enabled = 0;
56+
address = LIS2MDL_I2C_ADD;
57+
mag_is_enabled = 0U;
5758
}
5859

5960
/** Constructor
@@ -67,8 +68,8 @@ LIS2MDLSensor::LIS2MDLSensor(SPIClass *spi, int cs_pin, uint32_t spi_speed) : de
6768
reg_ctx.read_reg = LIS2MDL_io_read;
6869
reg_ctx.handle = (void *)this;
6970
dev_i2c = NULL;
70-
address = 0;
71-
mag_is_enabled = 0;
71+
address = 0U;
72+
mag_is_enabled = 0U;
7273
}
7374

7475
/**
@@ -187,7 +188,7 @@ LIS2MDLStatusTypeDef LIS2MDLSensor::Enable()
187188
return LIS2MDL_ERROR;
188189
}
189190

190-
mag_is_enabled = 1;
191+
mag_is_enabled = 1U;
191192

192193
return LIS2MDL_OK;
193194
}
@@ -210,7 +211,7 @@ LIS2MDLStatusTypeDef LIS2MDLSensor::Disable()
210211
return LIS2MDL_ERROR;
211212
}
212213

213-
mag_is_enabled = 0;
214+
mag_is_enabled = 0U;
214215

215216
return LIS2MDL_OK;
216217
}

src/LIS2MDLSensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef struct
8585
class LIS2MDLSensor
8686
{
8787
public:
88-
LIS2MDLSensor(TwoWire *i2c, uint8_t address=LIS2MDL_I2C_ADD);
88+
LIS2MDLSensor(TwoWire *i2c);
8989
LIS2MDLSensor(SPIClass *spi, int cs_pin, uint32_t spi_speed=2000000);
9090
LIS2MDLStatusTypeDef begin();
9191
LIS2MDLStatusTypeDef end();

0 commit comments

Comments
 (0)