[分享] 【KW41Z】步行仪2

dvd1478   2017-7-16 22:26 楼主
KW41Z蓝牙部分终于做好,其实也不算得上做好,只不过是用已成的例子进行移植。
蓝牙连接后定时上传
  1. extern unsigned long int STEPS;
  2. extern unsigned char TempSteps;                //记步缓存  100HZ 自加1
  3. static void TimerMeasurementCallback(void * pParam)
  4. {
  5.     uint32_t random = 0;
  6.     rscsMeasurement_t measurement;
  7.    
  8.     if ( rscsServiceConfig.calibrationInProgress)
  9.     {
  10.         /* Finish calibration procedure */
  11.         Rscs_FinishSensorCalibration(&rscsServiceConfig, mCalibrationSuccessful);
  12.     }

  13.     RNG_GetRandomNo(&random);
  14.    
  15.     mReportTotalDistanceCounter  = (mReportTotalDistanceCounter + 1) % 3;
  16.         
  17.     //mRscsUserData.totalDistance += random & 0x0F;
  18.     mRscsUserData.totalDistance =STEPS;

  19.     measurement.flags = gRscs_InstantStrideLengthPresent_c;
  20.    
  21.     //if (mRunningStatus)
  22.     if(TempSteps>5)
  23.     {
  24.       measurement.flags |= gRscs_RunningStatus_c;
  25.     }
  26.       
  27.     if (mReportTotalDistanceCounter == 1)  
  28.     {
  29.         measurement.flags |= gRscs_TotalDistancePresent_c;      
  30.     }
  31.     measurement.instantCadence = TempSteps;
  32.     measurement.instantStrideLength = 22;   
  33.     //measurement.instantSpeed = 256 * ( 2 + (random & 0x03 ));
  34.     measurement.instantSpeed = 256 * ( 2 + (TempSteps & 0x03 ));
  35.     measurement.totalDistance = mRscsUserData.totalDistance;
  36.    
  37.     Rscs_RecordMeasurement(service_rsc, &measurement);

  38. }


全整的代码
frdmkw41z_wireless_examples_bluetooth_running_speed_cadence_sensor_freertos.rar (2.39 MB)
(下载次数: 3, 2017-7-16 22:23 上传)



手机APP用的是NXP自代的例子
QQ图片20170716222353.jpg


下一代就是自己做APP

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复