Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement QMI8658 gyro/accelerometer support #1161

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ src/addons/input_macro.cpp
src/addons/snes_input.cpp
src/addons/tilt.cpp
src/addons/spi_analog_ads1256.cpp
src/addons/i2c_qmi8658.cpp
${PROTO_OUTPUT_DIR}/enums.pb.c
${PROTO_OUTPUT_DIR}/config.pb.c
)
Expand Down Expand Up @@ -262,6 +263,7 @@ WiiExtension
SNESpad
pico_mbedtls
nanopb
QMI8658
)

target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down
35 changes: 35 additions & 0 deletions headers/addons/i2c_qmi8658.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef _I2C_QMI8658_H
#define _I2C_QMI8658_H

extern "C" {
#include "QMI8658.h"
}

#include "gpaddon.h"

#include "GamepadEnums.h"
#include "peripheralmanager.h"

#ifndef I2C_QMI8658_ENABLED
#define I2C_QMI8658_ENABLED 0
#endif

// Analog Module Name
#define I2C_QMI8658_Name "I2C_QMI8658"

class I2CQMI8658Input : public GPAddon {
public:
virtual bool available();
virtual void setup();
virtual void preprocess() {}
virtual void process();
virtual std::string name() { return I2C_QMI8658_Name; }
private:
PeripheralI2C *i2c;
uint32_t uIntervalMS;
uint32_t nextTimer;
int16_t acc[3];
int16_t gyro[3];
};

#endif // _I2C_QMI8658_H_
4 changes: 2 additions & 2 deletions headers/gamepad/GamepadAuxState.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ struct GamepadAuxSensors
GamepadAux3DRelativeSensor mouse;

GamepadAux3DSensor touchpad[GAMEPAD_AUX_MAX_TOUCHPADS];
GamepadAux3DSensor gyroscope;
GamepadAux3DSensor accelerometer;
GamepadAux3DRelativeSensor gyroscope;
GamepadAux3DRelativeSensor accelerometer;
GamepadAux3DSensor magnetometer;
GamepadAux4DSensor timeOfFlight;

Expand Down
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ add_subdirectory(PlayerLEDs)
add_subdirectory(rndis)
add_subdirectory(WiiExtension)
add_subdirectory(SNESpad)
add_subdirectory(QMI8658)
4 changes: 4 additions & 0 deletions lib/QMI8658/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_library(QMI8658 QMI8658.c)
target_link_libraries(QMI8658 PUBLIC PicoPeripherals)
target_include_directories(QMI8658 INTERFACE .)
target_include_directories(QMI8658 PUBLIC . PicoPeripherals)
Loading