jvpernis / esp32-ps3

Control your ESP32 projects with a PS3 controller!
319 stars 86 forks source link

gyroscope data - help #36

Open Naruto128 opened 3 years ago

Naruto128 commented 3 years ago

hello, how can I get the gyroscope values ​​of the " axes x", and "the axis y" ??

//      to display the gryoscope data: */

    Serial.print(Ps3.data.sensor.gyroscope.z);
//------------------------///
ps3_sensor_t ps3_parse_packet_sensor( uint8_t *packet )
{
    ps3_sensor_t ps3_sensor;

    const uint16_t int_offset = 0x200;

    ps3_sensor.accelerometer.x = (packet[ps3_packet_index_sensor_accelerometer_x] << 8) + packet[ps3_packet_index_sensor_accelerometer_x+1] - int_offset;
    ps3_sensor.accelerometer.y = (packet[ps3_packet_index_sensor_accelerometer_y] << 8) + packet[ps3_packet_index_sensor_accelerometer_y+1] - int_offset;
    ps3_sensor.accelerometer.z = (packet[ps3_packet_index_sensor_accelerometer_z] << 8) + packet[ps3_packet_index_sensor_accelerometer_z+1] - int_offset;
    ps3_sensor.gyroscope.z     = (packet[ps3_packet_index_sensor_gyroscope_z]     << 8) + packet[ps3_packet_index_sensor_gyroscope_z+1]     - int_offset;

    return ps3_sensor;

}