ADXL345 I2C + LCD + EEPROM
Revision 4:d36db669ff1c, committed 2019-05-24
- Comitter:
- RobotManYt
- Date:
- Fri May 24 18:00:07 2019 +0000
- Parent:
- 3:b4f3f0b17f41
- Commit message:
- EEPROM + LCD/NHD;
Changed in this revision
| ADXL345_I2C.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ADXL345_I2C.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ADXL345_I2C.cpp Fri May 24 17:27:15 2019 +0000
+++ b/ADXL345_I2C.cpp Fri May 24 18:00:07 2019 +0000
@@ -142,11 +142,17 @@
}
+void ADXL345_I2C::writeEEPROM(char *data, uint8_t lenght){
+ i2c_.write(EEPROM_WRITE, data, lenght, 0);
+}
+
+
void ADXL345_I2C::LCDprint(float X, float Y, float Z){
// X
- stringstream ss;
- ss << X;
- string x = "X : " + ss.str();
+ char txtX[10];
+ sprintf(txtX, "%.3f", X);
+ string x = txtX;
+ x = "X: " + x;
uint8_t length = x.size();
char dataX[length + 2];
dataX[0] = LCD_CURSOR;
@@ -157,8 +163,10 @@
i2c_.write(LCD, dataX, length);
// Y
- ss << Y;
- string y = "Y : " + ss.str();
+ char txtY[10];
+ sprintf(txtY, "%.3f", Y);
+ string y = txtX;
+ y = "Y: " + y;
length = y.size();
char dataY[length + 2];
dataY[0] = LCD_CURSOR;
@@ -169,8 +177,10 @@
i2c_.write(LCD, dataY, length);
// Z
- ss << Z;
- string z = "z : " + ss.str();
+ char txtZ[10];
+ sprintf(txtZ, "%.3f", Z);
+ string z = txtZ;
+ z = "Z: " + z;
length = z.size();
char dataZ[length + 2];
dataZ[0] = LCD_CURSOR;
--- a/ADXL345_I2C.h Fri May 24 17:27:15 2019 +0000
+++ b/ADXL345_I2C.h Fri May 24 18:00:07 2019 +0000
@@ -127,6 +127,10 @@
+
+#define EEPROM_READ 0xA6
+#define EEPROM_WRITE 0XA7
+
#define LCD 0x50
#define LCD_ON 0x41
#define LCD_OFF 0x42
@@ -157,6 +161,8 @@
* x-axis, y-axis and z-axis [in that order].
*/
void getOutput(int* readings);
+
+ void writeEEPROM(char *data, uint8_t lenght);
void LCDprint(float X, float Y, float Z);