piloChambert/RPI-I2C-Joystick

Error at void requestEvent()

Opened this issue · 2 comments

Rya31 commented

I'm not the most adequate with Arduino and it's code, so I can't fully figure it out, though it seems to be a false value reading. the line of code it refers to is at the very end.

i2c_gamepad.ino: In function ‘void requestEvent()’:
i2c_gamepad.ino:346:64: error: invalid conversion from ‘char*’ to ‘const uint8_t* {aka const unsigned char*}’ [-fpermissive]
In file included from i2c_gamepad.ino:1:0:
/usr/share/arduino/libraries/Wire/Wire.h:61:20: note: initializing argument 1 of ‘virtual size_t TwoWire::write(const uint8_t*, size_t)’
virtual size_t write(const uint8_t *, size_t);
^

It's seems to be a cast problem, but I can't reproduce it, I'm compiling with Arduino 1.8.1. Which one are you using? (I might have to update mine :)
Anyway, you should be able to fix it by changing the cast of joystickStatus, instead of (char *) use (uint8_t *):
Wire.write((uint8_t *)&joystickStatus, sizeof(I2CJoystickStatus));

Rya31 commented

thanks, it seems I'm currently using 2.1. also, now that I read the error again, I'm kind of disappointed that I didn't try const uint8_t or uint8_t. aww, well, I'll learn...