Bladeren bron

2024.06.19

Signed-off-by: gaochunhui <gaochunhui@cpyypt.cn>
gaochunhui 1 jaar geleden
bovenliggende
commit
ea33140881
2 gewijzigde bestanden met toevoegingen van 10 en 4 verwijderingen
  1. 9 4
      App/xspDataOpt.c
  2. 1 0
      App/xspDataOpt.h

+ 9 - 4
App/xspDataOpt.c

@@ -554,6 +554,7 @@ void save_record_to_flash(uint8_t recordMode)
 //        printf("~~~~~~~~~~~~~~addtime = %d, oil = %d\n",addTime, g_xspCollDa.curDisp.oil);
 //    }
 
+    g_xspCollDa.lastbSaveRecord = 0;
     if((recordMode == 0x01) &&(g_xspCollDa.bcheckDa == 0) ){//
 
         if((g_xspCollDa.curDisp.amount == 888888) || (g_xspCollDa.curDisp.oil == 888888)) return;
@@ -779,6 +780,7 @@ void analysis_7seg_code(uint8_t _7egDa[])
             printf("显示屏显示为0.00, 加油开始.......\n");
             if(g_xspCollDa.bSaveRecode == 0x01) {// 判断是否需要存储记录
                 save_record_to_flash(0x00);
+                printf("xsp change 00 save\n");
                 g_xspCollDa.bSaveRecode = 0x00;
             }
             memset(&g_xspCollDa.lastDisp, 0, sizeof(dispData));
@@ -830,9 +832,10 @@ void analysis_7seg_code(uint8_t _7egDa[])
         else {
             if((temp.amount==0x00)&&(temp.oil==0x00)){
                 //printf("ccccccccccccccccccc\n");
-                if(g_xspCollDa.bSaveRecode == 0x01) {// 判断是否需要存储记录
+                if(g_xspCollDa.lastbSaveRecord == 0x01) {// 判断是否需要存储记录
                     save_record_to_flash(0x00);
-                    g_xspCollDa.bSaveRecode = 0x00;
+                    printf("xsp change 01 save\n");
+                    g_xspCollDa.lastbSaveRecord = 0x00;
                 }
                 memset(&g_xspCollDa.lastDisp, 0, sizeof(dispData));
                 memset(&g_xspCollDa.curDisp, 0, sizeof(dispData));
@@ -928,9 +931,10 @@ void analysis_7seg_code(uint8_t _7egDa[])
                     }
                     else g_xspCollDa.startToprog = 0;
                     if(g_xspCollDa.startToprog > 5){
-                        if(g_xspCollDa.bSaveRecode==0x01){
+                        if(g_xspCollDa.lastbSaveRecord==0x01){
                             save_record_to_flash(0x00);
-                            g_xspCollDa.bSaveRecode = 0x00;
+                            printf("xsp change 02 save\n");
+                            g_xspCollDa.lastbSaveRecord = 0x00;
                         }
                         memcpy(&g_xspCollDa.lastDisp,&temp,sizeof(dispData));
                         g_xspCollDa.lastTick1 = g_xspCollDa.lastTick;
@@ -959,6 +963,7 @@ void analysis_7seg_code(uint8_t _7egDa[])
                 memcpy(&g_xspCollDa.lastDisp, &temp, sizeof(dispData));
                 g_xspCollDa.curstatus = STATUS_STOP; // 加油停止
                 g_xspCollDa.bstart00 = 0;
+                g_xspCollDa.lastbSaveRecord = g_xspCollDa.bSaveRecode;
             }
             if (g_xspCollDa.curstatus == STATUS_STOP) printf("加油中止,");
             else if (g_xspCollDa.curstatus == STATUS_END) printf("加油结束,");

+ 1 - 0
App/xspDataOpt.h

@@ -102,6 +102,7 @@ typedef struct xsp_coll_data_ {
     uint32_t lastTick;   // 上一次记录的时间戳
     uint32_t lastcomTick; // 只要变化不管数据的对错,就记录时间戳,
     uint8_t bSaveRecode; // 是否需要存储当次的交易记录
+    uint8_t lastbSaveRecord; // 上一笔交易是否需要存储(只用于逻辑判断时)
     uint32_t errorNum;   // 在加油开始的状态下,统计错误的次数
     uint32_t  startToprog; // 小额增长变化次数(从加油开始,到加油中的判断过程
     uint64_t lastTamout;