Skip to content

Commit

Permalink
Implement support for I2C QMI8658 IMU
Browse files Browse the repository at this point in the history
Signed-off-by: Daniël van de Giessen <[email protected]>
  • Loading branch information
DvdGiessen committed Sep 29, 2024
1 parent 352d8a3 commit 20e7c8c
Show file tree
Hide file tree
Showing 16 changed files with 1,357 additions and 0 deletions.
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_
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

0 comments on commit 20e7c8c

Please sign in to comment.