Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:4a0b5f2947d1, committed 2015-01-20
- Comitter:
- giogal
- Date:
- Tue Jan 20 11:33:52 2015 +0000
- Parent:
- 1:1df877428dff
- Child:
- 3:58faa1496c51
- Commit message:
- Seciao;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 20 08:13:03 2015 +0000
+++ b/main.cpp Tue Jan 20 11:33:52 2015 +0000
@@ -61,7 +61,14 @@
char x_str[8];
char y_str[8];
char z_str[8];
-
+ //inizializziamo il registro di controllo a 0 per poterlo settare
+ char data[2] = {CNTRL_REG_1, 0x00};
+ i2c.write(address, data, 2);
+
+ //settiamo il registro di controllo
+ char data_wr_2[2]={CNTRL_REG_1, 0x3B};
+ i2c.write(address,data_wr_2, 2);
+ /*
//inizializziamo il registro di controllo a 0 per poterlo settare
char data[2] = {CNTRL_REG_1, 0x00};
i2c.write(address, data, 2);
@@ -73,10 +80,10 @@
char data_reg2[2] = {CNTRL_REG_2, (stato_reg2 |4)};
i2c.write(address, data_reg2, 2);
- //settiamo il registro di controllo
+ settiamo il registro di controllo
char data_reg1[2]={CNTRL_REG_1, 0xFB};
i2c.write(address,data_reg1, 2);
-
+*/
while (true) {
i2c.write(address,&stato,1,true);
@@ -97,24 +104,32 @@
i2c.read(address,&y_buffer,1,false);
x = conversion(x_buffer);
-
- y = conversion(y_buffer);
-
- z = conversion(z_buffer);
-
- }
x = x*2.551 + 50;
sprintf(x_str,"%f",x);
VAL_TO_SPI( x_str[0], x_str[1], 134);
- printf("ciao");
+ printf("X = %c %c", x_str[0], x_str[1]);
+ printf("\r\n");
+ y = conversion(y_buffer);
y = y*2.551 + 50;
sprintf(y_str,"%f",y);
VAL_TO_SPI( y_str[0], y_str[1], 132);
+ printf("Y = %c %c", y_str[0], y_str[1]);
+ printf("\r\n");
+ z = conversion(z_buffer);
z = z*2.551 + 50;
sprintf(z_str,"%f",z);
VAL_TO_SPI( z_str[0], z_str[1], 130);
+ printf("Z = %c %c", z_str[0], z_str[1]);
+ printf("\r\n");
+
+ }
+
+
+
+
+
}
}
@@ -163,7 +178,7 @@
{
val+= 1;
}
- val = (float) val/64;
+ val = (float) val/6.4;
return val;
}