From fdcac8015efef1a950369cc33f0e59a13a5873a9 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Mon, 25 Jun 2018 15:48:52 +0100 Subject: [PATCH] Added page support --- functions/MLX90640_API.cpp | 62 +++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/functions/MLX90640_API.cpp b/functions/MLX90640_API.cpp index e763c71..b7b7399 100644 --- a/functions/MLX90640_API.cpp +++ b/functions/MLX90640_API.cpp @@ -261,6 +261,66 @@ int MLX90640_GetCurMode(uint8_t slaveAddr) //------------------------------------------------------------------------------ +int MLX90640_SetDeviceMode(uint8_t slaveAddr, uint8_t deviceMode) +{ + uint16_t controlRegister1; + int value; + int error; + + value = (deviceMode & 0x01)<<4; + + error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1); + if(error == 0) + { + value = (controlRegister1 & 0b1111111111111101) | value; + error = MLX90640_I2CWrite(slaveAddr, 0x800D, value); + } + + return error; +} + +//------------------------------------------------------------------------------ + +int MLX90640_SetSubPageRepeat(uint8_t slaveAddr, uint8_t subPageRepeat) +{ + uint16_t controlRegister1; + int value; + int error; + + value = (subPageRepeat & 0x01)<<3; + + error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1); + if(error == 0) + { + value = (controlRegister1 & 0b1111111111110111) | value; + error = MLX90640_I2CWrite(slaveAddr, 0x800D, value); + } + + return error; +} + +//------------------------------------------------------------------------------ + +int MLX90640_SetSubPage(uint8_t slaveAddr, uint8_t subPage) +{ + uint16_t controlRegister1; + int value; + int error; + + value = (subPage & 0x01)<<4; + + error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1); + if(error == 0) + { + value = (controlRegister1 & 0b1111111110001111) | value; + error = MLX90640_I2CWrite(slaveAddr, 0x800D, value); + } + + return error; +} + +//------------------------------------------------------------------------------ + void MLX90640_CalculateTo(uint16_t *frameData, const paramsMLX90640 *params, float emissivity, float tr, float *result) { float vdd; @@ -1180,4 +1240,4 @@ int ExtractDeviatingPixels(uint16_t *eeData, paramsMLX90640 *mlx90640) } return -7; - } \ No newline at end of file + }