Update BH1750.c

This commit is contained in:
David Lin 2021-01-14 21:02:54 +08:00 committed by GitHub
parent 81d576b988
commit 53874f055d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 19 deletions

View File

@ -9,10 +9,10 @@ int result;
/***************************************************************
* : Init_BH1750
* : BH1750
* :
* :
* : Init_BH1750
* : BH1750
* :
* :
***************************************************************/
void Init_BH1750(void)
{
@ -21,10 +21,10 @@ void Init_BH1750(void)
}
/***************************************************************
* : Start_BH1750
* : BH1750
* :
* :
* : Start_BH1750
* : BH1750
* :
* :
***************************************************************/
void Start_BH1750(void)
{
@ -35,19 +35,19 @@ void Start_BH1750(void)
/***************************************************************
* : Convert_BH1750
* :
* :
* :
* : Convert_BH1750
* :
* :
* :
***************************************************************/
float Convert_BH1750(void)
{
Start_BH1750();
HAL_Delay(180);
HAL_I2C_Master_Receive(&hi2c1, BH1750_Addr+1,BUF,2,0xff);
result=BUF[0];
result=(result<<8)+BUF[1]; //合成数据,即光照数据
result_lx=(float)(result/1.2);
return result_lx;
Start_BH1750();
HAL_Delay(180);
HAL_I2C_Master_Receive(&hi2c1, BH1750_Addr+1,BUF,2,0xff);
result=BUF[0];
result=(result<<8)+BUF[1]; //合成数据,即光照数据
result_lx=(float)(result/1.2);
return result_lx;
}