ADXL345 I2C + LCD + EEPROM
Diff: ADXL345_I2C.cpp
- Revision:
- 3:b4f3f0b17f41
- Parent:
- 2:84e6d627c619
- Child:
- 4:d36db669ff1c
--- a/ADXL345_I2C.cpp Thu Aug 01 08:13:05 2013 +0000 +++ b/ADXL345_I2C.cpp Fri May 24 17:27:15 2019 +0000 @@ -142,6 +142,45 @@ } +void ADXL345_I2C::LCDprint(float X, float Y, float Z){ + // X + stringstream ss; + ss << X; + string x = "X : " + ss.str(); + uint8_t length = x.size(); + char dataX[length + 2]; + dataX[0] = LCD_CURSOR; + dataX[1] = 0; + for(uint8_t pop = 0; pop < length; pop++){ + dataX[pop + 2] = x[pop]; + } + i2c_.write(LCD, dataX, length); + + // Y + ss << Y; + string y = "Y : " + ss.str(); + length = y.size(); + char dataY[length + 2]; + dataY[0] = LCD_CURSOR; + dataY[1] = 0x40; + for(uint8_t pop = 0; pop < length; pop++){ + dataY[pop + 2] = y[pop]; + } + i2c_.write(LCD, dataY, length); + + // Z + ss << Z; + string z = "z : " + ss.str(); + length = z.size(); + char dataZ[length + 2]; + dataZ[0] = LCD_CURSOR; + dataZ[1] = 0x14; + for(uint8_t pop = 0; pop < length; pop++){ + dataZ[pop + 2] = z[pop]; + } + i2c_.write(LCD, dataZ, length); +} + char ADXL345_I2C::getDeviceID() { return SingleByteRead(ADXL345_DEVID_REG);