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:
- 31:4ac70aa71542
- Parent:
- 30:ffd9be5083e6
- Child:
- 32:856ed001ce2e
--- a/main.cpp Mon Sep 06 07:31:12 2021 +0000
+++ b/main.cpp Tue Sep 07 01:26:49 2021 +0000
@@ -35,12 +35,18 @@
//#define TIMEINTERVAL
//キャリブレーション 仮値
+//No.1
//#define OFFSET_X 220
-//#define OFFSET_Y 220
-//#define OFFSET_Z -40
-#define OFFSET_X 375
-#define OFFSET_Y 340
-#define OFFSET_Z -200
+//#define OFFSET_Y 220
+//#define OFFSET_Z -40
+//No.2
+//#define OFFSET_X 375
+//#define OFFSET_Y 340
+//#define OFFSET_Z -200
+#define OFFSET_X 0
+#define OFFSET_Y 0
+#define OFFSET_Z 0
+
HAL_StatusTypeDef writeEEPROMByte(uint32_t address, uint8_t data);
uint8_t readEEPROMByte(uint32_t address);
@@ -71,9 +77,9 @@
long max_g=0;
long now_g=0;
int update=0;
-char buffer1[512] = {};
+char buffer1[4096] = {};
char buffer2[512] = {};
-char stracc1[64] = {}, stracc2[32] = {};
+char stracc1[32] = {}, stracc2[32] = {};
int lognum1 = 0, lognum2 = 0;
char filename1[32]= {};
char filename2[32]= {};
@@ -106,7 +112,7 @@
//az+= tz;
//as+= scr;
//cnt++;
- pc.printf("%d,new x:%2.2f y:%2.2f,z:%2.2f scaler = %2.2f \r\n",time(NULL),(float)tx*0.005,(float)ty*0.005,(float)tz*0.005,(float)scr*0.005);
+ pc.printf("%d,%d,new x:%2.2f y:%2.2f,z:%2.2f scaler = %2.2f \r\n",timecount,time(NULL),(float)tx*0.005,(float)ty*0.005,(float)tz*0.005,(float)scr*0.005);
//pc.printf("new x:%d y:%d,z:%d scaler = %d \r\n",tx,ty,tz,scr);
if ( max_g < scr) {
@@ -114,21 +120,16 @@
update=1;
pc.printf("%max g=%d \r\n",max_g);
//Save EEPROM
- //writeEEPROMByte(0, max_g);
for(int i = 0; i < 4; i++){
pc.printf("writerom 0x%x\r\n",(max_g >> 8*i) & 0xFF);
writeEEPROMByte(i, (max_g >> 8*i) & 0xFF);
}
- //for(int i = 0; i < 4; i++){
- //pc.printf("readEEPROM:0x%x\r\n",readEEPROMByte(i) << 8*i);
- //}
}
- sprintf(stracc1,"%d,%2.2f,%2.2f,%2.2f,%2.2f\r\n",timecount,(float)tx*0.005,(float)ty*0.005,(float)tz*0.005,(float)scr*0.005);
+ //sprintf(stracc1,"%d,%d,%2.2f,%2.2f,%2.2f,%2.2f\r\n",timecount,time(NULL),(float)tx*0.005,(float)ty*0.005,(float)tz*0.005,(float)scr*0.005);
+ sprintf(stracc1,"%d,%d,%d\r\n",timecount,time(NULL),scr);
//pc.printf("h3lis331dl:%s",stracc1);
- if(strlen(buffer1)+strlen(stracc1) > 512) {
- //pc.printf("buffer over. write file2\r\n");
-
+ if(strlen(buffer1)+strlen(stracc1) > 4096) {
ret = fprintf(fp1,"%s",buffer1);
if(ret <= 0){
pc.printf("fp1 write failed:%d. errno:%d. Reboot!!!\r\n",ret,errno);
@@ -145,11 +146,10 @@
//LIS3DH
read3axes(&tx,&ty,&tz);
scr = int_sqrt( tx*tx + ty*ty + tz*tz);
- pc.printf("old x:%d y:%d,z:%d scaler = %d max g=%2.2fG \r\n",tx,ty,tz,scr, (float)max_g/11.0f);
- sprintf(stracc2,"%d,%d\r\n",timecount,scr);
+ //pc.printf("%d,%d,old x:%d y:%d,z:%d scaler = %d\r\n",timecount,time(NULL),tx,ty,tz,scr);
+ sprintf(stracc2,"%d,%d,%d\r\n",timecount,time(NULL),scr);
//pc.printf("lis3dh:%s",stracc2);
if(strlen(buffer2)+ strlen(stracc2)> 512) {
-
ret = fprintf(fp2,"%s",buffer2);
if(ret <= 0){
pc.printf("fp2 write failed:%d. errno:%d. Reboot!!!\r\n",ret,errno);
@@ -167,7 +167,6 @@
if(time(NULL) > 86400){
//Create New File
set_time(NULL);
- //pc.printf("time over:%d\r\n",time(NULL));
timecount = 0;
fclose(fp1);
fp1 = NULL;
@@ -187,6 +186,7 @@
pc.printf("fp2 create file failed:%d\r\n",errno);
NVIC_SystemReset();
}
+ pc.printf("Create New File:%d,%d",timecount,time(NULL));
}
}