Open geronimoooooooo opened 5 years ago
Hey geronimoooooooo,
Can you give me more information about your development environment?
What is the board that are you using? What is IDE version?
Thanks!
I use a M5Stack Core basic (ESP32) as "board". The sensor GY-91 is connected to the m5stack with a grove i2c 4 pin cable. The IDE is PlatformIO. Everything should be up to date.
I just tested your code with Arduino IDE 1.8.8 and got the (SAME) following error
sketch\MPU9250.cpp: In member function 'mag_scale MPU9250::get_mag_scale()': sketch\MPU9250.cpp:208:55: error: invalid conversion from 'int' to 'mag_scale' [-fpermissive] return((__read_byte(AK8963_ADDRESS, AK8963_CNTL)>>4)&0x01);
The error makes sense -at least to me- because you have "someTerm &0x01" . You are kinda checking if a specific bit (&0x01) in "someTerm" is set to 1. I do not think that __read_byete() returns the type mag _scale that is returned by the function get_mag_scale()
Make 2 changes?
replace in .cpp mag_scale with uint8_t
uint8_t MPU9250::get_mag_scale() { return((__read_byte(AK8963_ADDRESS, AK8963_CNTL)>>4)&0x01); }
replace in .h
mag_scale get_mag_scale();
with
uint8_t get_mag_scale();
Make 2 changes?
replace in .cpp mag_scale with uint8_t
uint8_t MPU9250::get_mag_scale() { return((__read_byte(AK8963_ADDRESS, AK8963_CNTL)>>4)&0x01); }
replace in .h mag_scale get_mag_scale(); with uint8_t get_mag_scale();
You are correct. Please, create a pull request.
The issue is that using typedef enum
create by default a "int" (so mag_scale is a int), while the return of function __read_byte
is uint8_t. I doesn't understand why I didn't get a error.
Hi, right now I am having the same problem. have the tried the same two changes but I couldn't solve this. Is there another change needed in the .cpp or .h files? Btw, thanks for the library!
Hi, right now I am having the same problem. have the tried the same two changes but I couldn't solve this. Is there another change needed in the .cpp or .h files? Btw, thanks for the library!
Which board are you using?
ESP32
I haven't tested the library on ESP32, only on Arduino Uno and Mega. I have ESP32, but it is not with me now.
Can you make the correction in the code? Eventually I will, but it will be closer to Christmas.
Okey, thank you for your early responses. I wish I could fix the issue but idk what is exactly the problem because changing the same lines as geronimoooooo that doesn't work for me.
Hey mate, there seams to be an error in the .cpp file?
mag_scale MPU9250::get_mag_scale() { return((__read_byte(AK8963_ADDRESS, AK8963_CNTL)>>4)&0x01); }
it says that the returned value is not of type mag_scale