STS_RR_R125/mlx90640/mlx90640_user.c

36 lines
1.3 KiB
C

#include "mlx90640_user.h"
#include "sys_app.h"
uint16_t frame[834];
float emissivity=0.15f; //0.95f
uint8_t mlx90640_init(uint8_t refresh_rate,paramsMLX90640 *mlx90640)
{
int status;
MLX90640_SetRefreshRate(MLX90640_ADDR, refresh_rate);
MLX90640_SetChessMode(MLX90640_ADDR);
status = MLX90640_DumpEE(MLX90640_ADDR, eeMLX90640);
if (status != 0)
APP_LOG(TS_OFF, VLEVEL_L, "\r\nload system parameters error with code:%d\r\n",status);
status = MLX90640_ExtractParameters(eeMLX90640, mlx90640);
if (status != 0)
APP_LOG(TS_OFF, VLEVEL_L,"\r\nParameter extraction failed with error code:%d\r\n",status);
return status;
}
uint8_t mlx90640_get_temp_mat(paramsMLX90640 *mlx90640,float*tempmat)
{
int status;
status = MLX90640_GetFrameData(MLX90640_ADDR, frame);
while(status<0)
{
status = MLX90640_GetFrameData(MLX90640_ADDR, frame);
APP_LOG(TS_OFF, VLEVEL_L,"GetFrame Error: %d\r\n",status);
}
float vdd = MLX90640_GetVdd(frame, mlx90640);
float Ta = MLX90640_GetTa(frame, mlx90640);
float tr = Ta - TA_SHIFT; //Reflected temperature based on the sensor ambient temperature
MLX90640_CalculateTo(frame, mlx90640, emissivity , tr, tempmat);
return 0;
}