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.
Dependencies: mbed SDFileSystem_
Diff: main.cpp
- Revision:
- 16:1caaa96ae3eb
- Parent:
- 15:12d0699ad423
- Child:
- 17:039d304c4a9c
--- a/main.cpp Thu Sep 02 09:24:44 2021 +0000
+++ b/main.cpp Fri Sep 03 01:52:11 2021 +0000
@@ -64,9 +64,9 @@
unsigned long timecount = 0;
int oldcount = 0;
//uint8_t maxacc = 0;
-long max_g=0;
-long now_g;
-int update;
+float max_g=0;
+float now_g=0;
+int update=0;
char buffer1[512] = {};
char buffer2[512] = {};
char stracc1[32] = {}, stracc2[32] = {};
@@ -84,7 +84,7 @@
void sub(){
short tx=0,ty=0,tz=0;
- long scr=0;
+ float scr=0;
//static long ax,ay,az,as;
//static int cnt;
@@ -95,7 +95,7 @@
tz += OFFSET_Z;
//スカラー値変換
- scr = int_sqrt( tx*tx + ty*ty + tz*tz);
+ scr = int_sqrt( tx*tx + ty*ty + tz*tz) * 0.005;// 195mg/digit
now_g = scr;
//ax+= tx;
@@ -103,7 +103,7 @@
//az+= tz;
//as+= scr;
//cnt++;
- pc.printf("new x:%d y:%d,z:%d scaler = %d max g=%2.2fG \r\n",tx,ty,tz,scr, (float)max_g/11.0f);
+ pc.printf("new x:%f y:%f,z:%f scaler = %f \r\n",tx*0.005,ty*0.005,tz*0.005,scr);
if ( max_g < scr) {
max_g = scr;
update=1;
@@ -129,15 +129,6 @@
sprintf(buffer1,"%s%s",buffer1,stracc1);
}
- /*
- //16回平均
- if ((cnt & 0x0f)== 0) {
- float asc = (float)as / 11.0f /16.0f;
- pc.printf("avarage x:%d\ty:%d\tz:%d\tscaler=%d\t%2.2fG \r\n",ax/16,ay/16,az/16,as/16, asc );
- as=ax=ay=az=0;
- }
- */
-
if(oldcount == 10){
//LIS3DH
read3axes(&tx,&ty,&tz);