rgb381.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. /*
  2. * ALS308.c
  3. *
  4. * Created on: 2022年4月11日
  5. * Author: amos
  6. */
  7. #include "rgb381.h"
  8. #include "TCA9548A.h"
  9. #include <string.h>
  10. #define I2C_TIMEOUT_1000MS 16000000 // 定义超时时间(毫秒)
  11. #define CARD_NO_ALIGN 3
  12. #define CARD_NO_MIN 10
  13. /****************Result define*******************/
  14. #define ResultInvalid 0 //无效
  15. #define ResultNegative 1 //阴
  16. #define ResultPositive 2 //阳
  17. ColorSensor CS[CS_MAX] = {0}; //检测孔
  18. uint8_t SensorState1=0,SensorState2=0,SensorState3=0,SensorState4=0,SensorState5=0,
  19. SensorState6=0,SensorState7=0,SensorState8=0,SensorState9=0,SensorState10=0;
  20. //extern uint8_t I2C_data;
  21. int8_t I2CWriteOneByte(I2C_HandleTypeDef *hi2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data)
  22. {
  23. // HAL 库返回值:HAL_OK 表示成功
  24. HAL_StatusTypeDef status = HAL_I2C_Mem_Write(hi2c,
  25. (uint16_t)(u8SlaveAddr << 1), // 7位地址左移1位,HAL内部会处理读写位
  26. (uint16_t)u8DataAddr, // 寄存器地址(8位)
  27. I2C_MEMADD_SIZE_8BIT, // 寄存器地址宽度 8 位
  28. &data, // 要写入的数据
  29. 1, // 数据长度(字节)
  30. 100); // 超时时间 ms
  31. if (status == HAL_OK)
  32. return 0; // 成功
  33. else
  34. return 3; // 统一返回 3(或按原函数错误码细化)
  35. }
  36. uint8_t I2CReadOneByte(I2C_HandleTypeDef *hi2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr)
  37. {
  38. uint8_t rdata = 0;
  39. HAL_StatusTypeDef status = HAL_I2C_Mem_Read(hi2c,
  40. (uint16_t)(u8SlaveAddr << 1),
  41. (uint16_t)u8DataAddr,
  42. I2C_MEMADD_SIZE_8BIT,
  43. &rdata,
  44. 1,
  45. 100);
  46. if (status == HAL_OK)
  47. return rdata;
  48. else
  49. return 0; // 失败返回 0(与原函数一致)
  50. }
  51. uint8_t I2C_data = 0;
  52. void TCA9548A_SetChannel(uint8_t ID)
  53. {
  54. /********************************************************/
  55. /**************background light--PA0*********************/
  56. /*********************WIFI_EN--PA12**********************/
  57. /**********************I2C_S0--PB3***********************/
  58. /***********************I2C_S1--PB2**********************/
  59. /**********************I2C_S2--PB1***********************/
  60. /**********************I2C_S3--PB0***********************/
  61. /**********************I2C_S4--PF5***********************/
  62. /******************Device_num1--PB15*********************/
  63. /******************Device_num2--PB14*********************/
  64. /******************Device_num3--PB13*********************/
  65. /******************Device_num4--PB12*********************/
  66. /***********************LED--PF4*************************/
  67. /***********************DEC--PB15************************/
  68. switch(ID)
  69. {
  70. case 0:
  71. I2C_data = TCA9548A_CHANNEL_0;
  72. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,ID);
  73. break;
  74. case 1:
  75. I2C_data = TCA9548A_CHANNEL_0;
  76. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  77. HAL_Delay(50);
  78. I2C_data = TCA9548A_CHANNEL_2;
  79. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  80. break;
  81. case 2:
  82. I2C_data = TCA9548A_CHANNEL_3;
  83. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  84. break;
  85. case 3:
  86. I2C_data = TCA9548A_CHANNEL_4;
  87. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  88. break;
  89. case 4:
  90. I2C_data = TCA9548A_CHANNEL_5;
  91. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  92. break;
  93. case 5:
  94. I2C_data = TCA9548A_CHANNEL_6;
  95. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  96. break;
  97. case 6:
  98. I2C_data = TCA9548A_CHANNEL_7;
  99. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  100. break;
  101. case 7:
  102. I2C_data = TCA9548A_CHANNEL_8;
  103. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  104. break;
  105. case 8:
  106. I2C_data = TCA9548A_CHANNEL_1;
  107. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  108. HAL_Delay(50);
  109. I2C_data = TCA9548A_CHANNEL_0;
  110. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  111. HAL_Delay(50);
  112. I2C_data = TCA9548A_CHANNEL_2;
  113. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  114. break;
  115. case 9:
  116. // I2C_data = TCA9548A_CHANNEL_0;
  117. // I2CWriteOneByte(I2C0,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  118. // DelayMS(100);
  119. I2C_data = TCA9548A_CHANNEL_3;
  120. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  121. break;
  122. case 10:
  123. // I2C_data = TCA9548A_CHANNEL_0;
  124. // I2CWriteOneByte(I2C0,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  125. // DelayMS(100);
  126. I2C_data = TCA9548A_CHANNEL_4;
  127. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  128. break;
  129. default:
  130. break;
  131. }
  132. }
  133. void SensorMeasurementFactor(uint8_t measfactor)
  134. {
  135. I2CWriteOneByte(&hi2c1,RGB381_ADDR,RGB381_MeasRate,measfactor);
  136. }
  137. void SensorSetGain(uint8_t gain)
  138. {
  139. I2CWriteOneByte(&hi2c1,RGB381_ADDR,RGB381_Gain,gain);
  140. }
  141. uint8_t SensorGetID(uint8_t ID)
  142. {
  143. TCA9548A_SetChannel(ID);
  144. HAL_Delay(100);
  145. return I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_PartID);
  146. // return I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_PartID);
  147. }
  148. void SensorGetRawData(ColorSensor *CS)
  149. {
  150. uint32_t u32Timeout = I2C_TIMEOUT_1000MS; // 转换为时钟周期数
  151. uint32_t u32StartTick = sysinf.ms_conter;
  152. uint32_t u32LastTick;
  153. uint32_t time;
  154. TCA9548A_SetChannel(CS->ID);
  155. HAL_Delay(40);
  156. u32LastTick = sysinf.ms_conter;
  157. time = u32LastTick - u32StartTick;
  158. while((I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_MainState)&0x08)==0x08){
  159. // 超时检测
  160. u32LastTick = sysinf.ms_conter;
  161. time = u32LastTick - u32StartTick;
  162. if(u32LastTick < u32StartTick){
  163. time = u32LastTick + 0x1000000 - u32StartTick;
  164. }
  165. if ((time) > u32Timeout) {
  166. CS->RDR = 0;
  167. Van_Device_Printf(VAN_LOG_ERROR, "error_state :%d\n",time);
  168. return; // 返回超时错误码
  169. }
  170. };
  171. HAL_Delay(10);
  172. // LOG_E("error_state :%d\n",time);
  173. CS->RDR=(I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataLow)|
  174. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataMid)<<8)|
  175. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataHIG)<<16));
  176. if(CS->RDR == 0){
  177. HAL_Delay(10);
  178. CS->RDR=(I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataLow)|
  179. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataMid)<<8)|
  180. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataHIG)<<16));
  181. if(CS->RDR == 0){
  182. Van_Device_Printf(VAN_LOG_ERROR, "error_Data\n");
  183. }
  184. }
  185. // CS->RDG=(I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_G_DataLow)|
  186. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_G_DataMid)<<8)|
  187. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_G_DataHIG)<<16));
  188. // CS->RDB=(I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_B_DataLow)|
  189. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_B_DataMid)<<8)|
  190. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_B_DataHIG)<<16));
  191. }
  192. void SensorEnable(void)
  193. {
  194. I2CWriteOneByte(&hi2c1,RGB381_ADDR,RGB381_MainCtrl,CS_Modle|ALS_Active);
  195. HAL_Delay(10);
  196. }
  197. uint8_t SensorInit(ColorSensor *CS)
  198. {
  199. Refresh_IWDG();
  200. if(SensorGetID(CS->ID)==0xC2)// device id is 0xC2
  201. {
  202. SensorEnable();
  203. SensorMeasurementFactor(ALS_MeasRes_17B|ALS_MeasRate_50ms);
  204. SensorSetGain(ALS_Gain_9X);
  205. CS->TtMax=0.0;
  206. // CS->TtNow=0.0;
  207. // CS->ColDifInit=0.0;
  208. // CS->ColDifNow=0.0;
  209. // CS->ColDifMax=0.0;
  210. CS->Tt=30.0;
  211. CS->STD=0.0;
  212. CS->average=0.0;
  213. memset(CS->SAMP, 0, sizeof(CS->SAMP));
  214. CS->std_num=0;
  215. CS->gain=0;
  216. SensorGetRawData(CS);
  217. for(int i = 0; i < 10; i++)
  218. {
  219. if(CS->RDR > CS_RDR_MIN)
  220. return 0;
  221. HAL_Delay(100);
  222. Refresh_IWDG();
  223. SensorGetRawData(CS);
  224. }
  225. return 1;
  226. }
  227. else
  228. return 1;
  229. }
  230. int SensorSelfCheckPass(void)
  231. {
  232. SensorState1=SensorInit(&CS[0]);
  233. SensorState2=SensorInit(&CS[1]);
  234. SensorState3=SensorInit(&CS[2]);
  235. SensorState4=SensorInit(&CS[3]);
  236. SensorState5=SensorInit(&CS[4]);
  237. SensorState6=SensorInit(&CS[5]);
  238. SensorState7=SensorInit(&CS[6]);
  239. SensorState8=SensorInit(&CS[7]);
  240. SensorState9=SensorInit(&CS[8]);
  241. SensorState10=SensorInit(&CS[9]);
  242. if(SensorState1|SensorState2|SensorState3|SensorState4|SensorState5|SensorState6|SensorState7|SensorState8|SensorState9|SensorState10)
  243. return 0;
  244. else return 1;
  245. }
  246. void SensorGetCalData(ColorSensor *CS)
  247. {
  248. // SensorGetRawData(CS);
  249. //CS->AccArea+=CS->RtR;
  250. }
  251. void SensorInitial(void)
  252. {
  253. CS[0].ID = Sensor1;
  254. CS[1].ID = Sensor2;
  255. CS[2].ID = Sensor3;
  256. CS[3].ID = Sensor4;
  257. CS[4].ID = Sensor5;
  258. CS[5].ID = Sensor6;
  259. CS[6].ID = Sensor7;
  260. CS[7].ID = Sensor8;
  261. CS[8].ID = Sensor9;
  262. CS[9].ID = Sensor10;
  263. }
  264. int Returntozero(ColorSensor *CS) //lxx-add-2022.12.26
  265. {
  266. Refresh_IWDG();
  267. SensorGetRawData(CS);
  268. CS->CDR = (float)CS->RDR;
  269. if(CS->RDR < CARD_NO_MIN){
  270. return 1;
  271. }
  272. if(CS->RDC/CS->RDR > CARD_NO_ALIGN){
  273. return 1;
  274. }
  275. return 0;
  276. }
  277. void Get_SAMP_DATA(ColorSensor *CS)
  278. {
  279. CS->SAMP[0] = CS->RtR;
  280. // CS->CALCU_SAMP[samp_num] = (uint16_t)CS->RtR;
  281. }
  282. void Get_Tt(ColorSensor *CS)
  283. {
  284. if(CS->Tt == 30.0)
  285. {
  286. if(CS->RtR>(10*fabs(CS->STD)+CS->average))
  287. {
  288. CS->std_num++;
  289. if(CS->std_num==5) //连续5次
  290. {
  291. // CS->Tt = (sampleTimes-(5-1))/6.0f; //每分钟6次;
  292. }
  293. }
  294. else
  295. {
  296. CS->std_num=0;
  297. }
  298. }
  299. }
  300. void Get_average(ColorSensor *CS)
  301. {
  302. float sum= 0;
  303. int i = 0;
  304. for(i=0;i<SAMP_SIZE;i++)
  305. {
  306. sum += CS->SAMP[i];
  307. }
  308. CS->average = sum/(SAMP_SIZE);
  309. }
  310. void Get_STD(ColorSensor *CS)
  311. {
  312. int i = 0;
  313. float sum = 0;
  314. for(i=0;i<SAMP_SIZE;i++)
  315. {
  316. sum += (CS->SAMP[i]-CS->average)*(CS->SAMP[i]-CS->average);
  317. }
  318. CS->STD = sqrtf(sum / (SAMP_SIZE - 1));
  319. }
  320. void Get_GAIN(ColorSensor *CS) //lxx_add_2023.07.27
  321. {
  322. Refresh_IWDG();
  323. SensorGetRawData(CS);
  324. CS->RDC = (float)CS->RDR;
  325. if(CS->RDC < CS_RDR_MIN)
  326. {
  327. // error_set(ERROR_SENSOR_SELF_CHECK);
  328. return;
  329. }
  330. CS->gain = 1000.0/(float)CS->RDC;
  331. }
  332. void Sensor_calibration_data(ColorSensor *CS) //lxx_add_2023.07.27
  333. {
  334. CS->RtR = (CS->CDR-CS->RDR)*CS->gain;
  335. }
  336. void sample_first_zero(void)
  337. {
  338. for (int i = 0; i < CS_MAX; i++)
  339. {
  340. Returntozero(&CS[i]);
  341. //从零点输出
  342. Sensor_calibration_data(&CS[i]);
  343. }
  344. }
  345. int check_first_zero(void)
  346. {
  347. int noAlignNum = 0;
  348. for (int i = 0; i < CS_MAX; i++)
  349. {
  350. if(Returntozero(&CS[i]) == 1){
  351. noAlignNum ++;
  352. }
  353. }
  354. if(noAlignNum == 0){
  355. error_clear();
  356. return 0;
  357. }else{
  358. error_set(ERROR_SENSOR_CARD_CHECK);
  359. return 1;
  360. }
  361. }
  362. void sample_calibrate_calc(uint32_t times)
  363. {
  364. for (int i = 0; i < CS_MAX; i++)
  365. {
  366. Refresh_IWDG();
  367. SensorGetRawData(&CS[i]); // get the original data every 1S
  368. if(CS->RDR == 0){
  369. // if(!(g_cfg.skip_CheckOrRun & SKIP_CHECK_CARDINSERT)){
  370. // error_set(ERROR_SENSOR_SELF_CHECK);
  371. // return;
  372. // }
  373. }
  374. Sensor_calibration_data(&CS[i]);
  375. }
  376. if (times < 19)
  377. {
  378. for (int i = 0; i < CS_MAX; i++)
  379. {
  380. Get_SAMP_DATA(&CS[i]);// save the returntozero data in 30minutes
  381. }
  382. // samp_num++;
  383. }
  384. }
  385. void sample_calc_avg_std(void)
  386. {
  387. for (int i = 0; i < CS_MAX; i++)
  388. {
  389. Get_average(&CS[i]);
  390. Get_STD(&CS[i]);
  391. }
  392. }
  393. void sample_calc_tt(void)
  394. {
  395. for (int i = 0; i < CS_MAX; i++)
  396. {
  397. Get_Tt(&CS[i]);
  398. }
  399. }
  400. void SingleChannelJudge(ColorSensor *CS)
  401. {
  402. if(CS->TtMin < CS->Tt && CS->Tt < CS->TtMax)
  403. {
  404. CS->Result=ResultPositive;
  405. }
  406. else
  407. {
  408. CS->Result=ResultNegative;
  409. }
  410. }
  411. void SystemResaultJudge(void)
  412. {
  413. int nc_index = 0; //内参
  414. uint8_t *p = &result.hole1_result; //孔结果
  415. result.Devicenum = 0;
  416. strcpy(result.card_num,sysinf.psmMaster.card_param_info.pid);
  417. // result.card_num = card_param_info.pid;
  418. result.hole1_item = sysinf.psmMaster.card_param_info.hole_info[0].item;
  419. result.hole2_item = sysinf.psmMaster.card_param_info.hole_info[1].item;
  420. result.hole3_item = sysinf.psmMaster.card_param_info.hole_info[2].item;
  421. result.hole4_item = sysinf.psmMaster.card_param_info.hole_info[3].item;
  422. result.hole5_item = sysinf.psmMaster.card_param_info.hole_info[4].item;
  423. result.hole6_item = sysinf.psmMaster.card_param_info.hole_info[5].item;
  424. result.hole7_item = sysinf.psmMaster.card_param_info.hole_info[6].item;
  425. result.hole8_item = sysinf.psmMaster.card_param_info.hole_info[7].item;
  426. result.hole9_item = sysinf.psmMaster.card_param_info.hole_info[8].item;
  427. result.hole10_item = sysinf.psmMaster.card_param_info.hole_info[9].item;
  428. result.hole1_Tt[0] = (uint8_t)CS[0].Tt;
  429. result.hole1_Tt[1] = (uint8_t)((CS[0].Tt-(uint8_t)CS[0].Tt)*100);
  430. result.hole2_Tt[0] = (uint8_t)CS[1].Tt;
  431. result.hole2_Tt[1] = (uint8_t)((CS[1].Tt-(uint8_t)CS[1].Tt)*100);
  432. result.hole3_Tt[0] = (uint8_t)CS[2].Tt;
  433. result.hole3_Tt[1] = (uint8_t)((CS[2].Tt-(uint8_t)CS[2].Tt)*100);
  434. result.hole4_Tt[0] = (uint8_t)CS[3].Tt;
  435. result.hole4_Tt[1] = (uint8_t)((CS[3].Tt-(uint8_t)CS[3].Tt)*100);
  436. result.hole5_Tt[0] = (uint8_t)CS[4].Tt;
  437. result.hole5_Tt[1] = (uint8_t)((CS[4].Tt-(uint8_t)CS[4].Tt)*100);
  438. result.hole6_Tt[0] = (uint8_t)CS[5].Tt;
  439. result.hole6_Tt[1] = (uint8_t)((CS[5].Tt-(uint8_t)CS[5].Tt)*100);
  440. result.hole7_Tt[0] = (uint8_t)CS[6].Tt;
  441. result.hole7_Tt[1] = (uint8_t)((CS[6].Tt-(uint8_t)CS[6].Tt)*100);
  442. result.hole8_Tt[0] = (uint8_t)CS[7].Tt;
  443. result.hole8_Tt[1] = (uint8_t)((CS[7].Tt-(uint8_t)CS[7].Tt)*100);
  444. result.hole9_Tt[0] = (uint8_t)CS[8].Tt;
  445. result.hole9_Tt[1] = (uint8_t)((CS[8].Tt-(uint8_t)CS[8].Tt)*100);
  446. result.hole10_Tt[0] = (uint8_t)CS[9].Tt;
  447. result.hole10_Tt[1] = (uint8_t)((CS[9].Tt-(uint8_t)CS[9].Tt)*100);
  448. //判断孔结果
  449. for (int i = 0; i < CS_MAX; i++)
  450. {
  451. SingleChannelJudge(&CS[i]);
  452. *p = CS[i].Result;
  453. p += 5;
  454. }
  455. //找id == -1
  456. for(nc_index = 0; nc_index < 10; nc_index++)
  457. {
  458. if(sysinf.psmMaster.card_param_info.hole_info[nc_index].item == 0xFF)
  459. break;
  460. }
  461. if(nc_index == 10)
  462. {
  463. nc_index = 0;
  464. }
  465. //判断最终检测结果
  466. p = &result.hole1_item_result; //检测结果
  467. if(CS[nc_index].Result == ResultPositive) //内参结果为阳
  468. {
  469. for (int i = 0; i < CS_MAX; i++)
  470. {
  471. if(CS[i].Result==ResultPositive) //孔结果为阳,最终结果为阳
  472. {
  473. *p = ResultPositive;
  474. }
  475. else //否则,最终结果为阴
  476. {
  477. *p = ResultNegative;
  478. }
  479. p += 5;
  480. }
  481. }
  482. else //内参结果为阴
  483. {
  484. for (int i = 0; i < CS_MAX; i++)
  485. {
  486. if(CS[i].Result==ResultPositive) //孔结果为阳,最终结果为阳
  487. {
  488. *p = ResultPositive;
  489. }
  490. else //否则,最终结果无效
  491. {
  492. *p = ResultInvalid;
  493. }
  494. p += 5;
  495. }
  496. }
  497. //内参自身检测结果,等于孔结果
  498. p = &result.hole1_item_result; //检测结果
  499. p += 5*nc_index;
  500. *p = CS[nc_index].Result;
  501. }
  502. void sample_calc_result(void)
  503. {
  504. for (int i = 0; i < CS_MAX; i++)
  505. {
  506. //从二维码获取Tt范围
  507. CS[i].TtMax = sysinf.psmMaster.card_param_info.hole_info[i].TtMax[0] + sysinf.psmMaster.card_param_info.hole_info[i].TtMax[1] / 100.0f;
  508. CS[i].TtMin = sysinf.psmMaster.card_param_info.hole_info[i].TtMin[0] + sysinf.psmMaster.card_param_info.hole_info[i].TtMin[1] / 100.0f;
  509. }
  510. SystemResaultJudge();
  511. }
  512. void calc_balance(void)
  513. {
  514. // 获取插卡前白平衡值
  515. for (int i = 0; i < CS_MAX; i++)
  516. {
  517. Get_GAIN(&CS[i]);
  518. }
  519. }