Closed parkview closed 4 years ago
Whoops, lost the formatting inside the code lines. Of course, there should be a new line after the semi colon.
For me, this was line 149: reg = min(reg, 7); // constrain(reg, 0, 7) but reg is an uint so...
I will check this a.s.a.p What processor do you use? uno or esp?
How do you call - readProm(uint8_t reg) ? Can you cast the parameter to uint8_t ?
all ok. I have fixed the compiling issues at my place. It will help anyone else downloading and using the code though.
Hey, thanks for the code though. Very handy.
Cheers,
Paul Australia.
On Sat, 27 Jun 2020 at 23:46, Rob Tillaart notifications@github.com wrote:
I will check this a.s.a.p
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/MS5611/issues/1#issuecomment-650577127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM7FEAFNAB24RFJPRYD333RYYH3VANCNFSM4OKBZC6A .
--
Cheers,
Paul Hamilton Busselton
Thanks Paul,
The problem is the min macro. I propose
uint16_t MS5611::readProm(uint8_t reg)
{
uint8_t promCRCregister = 7; // last EEPROM register Page13 datasheet.
if (reg > promCRCregister) return 0;
uint8_t offset = reg * 2;
command(MS5611_CMD_READ_PROM + offset);
if (_result == 0)
{
int nr = Wire.requestFrom(_address, (uint8_t)2);
if (nr >= 2)
{
uint16_t val = Wire.read() * 256;
val += Wire.read();
return val;
}
return 0;
}
return 0;
}
instead of maxNum I checked the datasheet for the meaning of the value 7, Furthermore I replaced the min macro by explicit code and returned 0 in case of register index out of range
Thanks,
Received this error when compiling MS5611.cpp Version 0.2:
C:\Users\User1\.platformio\lib\MS5611_ID1351\MS5611.cpp:150:19: note: deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int') reg = min(reg, 7); // constrain(reg, 0, 7) but reg is an uint so...
My fix was to assign a variable the line before with the same type (uint8_t) as 'reg', ie:
uint8_t maxNum = 7; reg = min(reg, maxNum); // constrain(reg, 0, 7) but reg is an uint so...