Skip to content

Commit

Permalink
Format defines
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirenliel committed Dec 7, 2024
1 parent add0035 commit 1f87604
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 68 deletions.
42 changes: 21 additions & 21 deletions src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
// List of constants used in other places

enum class ImuID {
Unknown = 0,
MPU9250,
MPU6500,
BNO080,
BNO085,
BNO055,
MPU6050,
BNO086,
BMI160,
ICM20948,
ICM42688,
BMI270,
LSM6DS3TRC,
LSM6DSV,
LSM6DSO,
LSM6DSR,
Unknown = 0,
MPU9250,
MPU6500,
BNO080,
BNO085,
BNO055,
MPU6050,
BNO086,
BMI160,
ICM20948,
ICM42688,
BMI270,
LSM6DS3TRC,
LSM6DSV,
LSM6DSO,
LSM6DSR,
ADC_RESISTANCE,
Empty = 255
Empty = 255
};

#define IMU_UNKNOWN ErroneousSensor
Expand Down Expand Up @@ -84,10 +84,10 @@ enum class ImuID {
#define BOARD_MOCOPI 15 // Used by mocopi/moslime
#define BOARD_WEMOSWROOM02 16
#define BOARD_XIAO_ESP32C3 17
#define BOARD_HARITORA 18 // Used by Haritora/SlimeTora
#define BOARD_GLOVE_IMU_SLIMEVR_DEV 19 // IMU Glove
#define BOARD_HARITORA 18 // Used by Haritora/SlimeTora
#define BOARD_GLOVE_IMU_SLIMEVR_DEV 19 // IMU Glove

#define BOARD_DEV_RESERVED 250 // Reserved, should not be used in any release firmware
#define BOARD_DEV_RESERVED 250 // Reserved, should not be used in any release firmware

#define BAT_EXTERNAL 1
#define BAT_INTERNAL 2
Expand Down Expand Up @@ -165,4 +165,4 @@ enum class ImuID {

#include "sensors/sensorposition.h"

#endif // SLIMEVR_CONSTS_H_
#endif // SLIMEVR_CONSTS_H_
1 change: 0 additions & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
#define ENABLE_INSPECTION false

#define PROTOCOL_VERSION 19
#define FIRMWARE_VERSION "0.5.0-glove-test"

#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "UNKNOWN"
Expand Down
188 changes: 142 additions & 46 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,25 @@ PIN_IMU_SDA, PRIMARY_IMU_OPTIONAL, BMI160_QMC_REMAP) \
*/

#ifndef SENSOR_DESC_LIST
#define SENSOR_DESC_LIST \
SENSOR_DESC_ENTRY(IMU, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), PRIMARY_IMU_OPTIONAL, DIRECT_PIN(PIN_IMU_INT), 0) \
SENSOR_DESC_ENTRY(SECOND_IMU, SECONDARY_IMU_ADDRESS_TWO, SECOND_IMU_ROTATION, DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), SECONDARY_IMU_OPTIONAL, DIRECT_PIN(PIN_IMU_INT_2), 0)
#define SENSOR_DESC_LIST \
SENSOR_DESC_ENTRY( \
IMU, \
PRIMARY_IMU_ADDRESS_ONE, \
IMU_ROTATION, \
DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), \
PRIMARY_IMU_OPTIONAL, \
DIRECT_PIN(PIN_IMU_INT), \
0 \
) \
SENSOR_DESC_ENTRY( \
SECOND_IMU, \
SECONDARY_IMU_ADDRESS_TWO, \
SECOND_IMU_ROTATION, \
DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), \
SECONDARY_IMU_OPTIONAL, \
DIRECT_PIN(PIN_IMU_INT_2), \
0 \
)
#endif

#else
Expand All @@ -62,48 +78,128 @@ PIN_IMU_SDA, PRIMARY_IMU_OPTIONAL, BMI160_QMC_REMAP) \
#define TRACKER_TYPE TRACKER_TYPE_SVR_GLOVE_LEFT
#define GLOVE_SIDE GLOVE_LEFT

#define SENSOR_DESC_LIST \
SENSOR_DESC_ENTRY(IMU, (0x4a ^ 0x02) - 0x4a, IMU_ROTATION, DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), false, MCP_PIN(MCP_GPA6), 0) \
SENSOR_DESC_ENTRY(IMU, (0x4b ^ 0x02) - 0x4a, IMU_ROTATION, DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), true, MCP_PIN(MCP_GPA5), 0) \
SENSOR_DESC_ENTRY(IMU, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 0), true, MCP_PIN(MCP_GPB0), 0) \
SENSOR_DESC_ENTRY(IMU, SECONDARY_IMU_ADDRESS_TWO, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 0), true, MCP_PIN(MCP_GPB1), 0) \
SENSOR_DESC_ENTRY(IMU, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 1), true, MCP_PIN(MCP_GPB2), 0) \
SENSOR_DESC_ENTRY(IMU, SECONDARY_IMU_ADDRESS_TWO, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 1), true, MCP_PIN(MCP_GPB3), 0) \
SENSOR_DESC_ENTRY(IMU, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 2), true, MCP_PIN(MCP_GPB4), 0) \
SENSOR_DESC_ENTRY(IMU, SECONDARY_IMU_ADDRESS_TWO, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 2), true, MCP_PIN(MCP_GPB5), 0) \
SENSOR_DESC_ENTRY(IMU, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 3), true, MCP_PIN(MCP_GPB6), 0) \
SENSOR_DESC_ENTRY(IMU, SECONDARY_IMU_ADDRESS_TWO, IMU_ROTATION, PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 3), true, MCP_PIN(MCP_GPA1), 0)
#define SENSOR_DESC_LIST \
SENSOR_DESC_ENTRY( \
IMU, \
(0x4a ^ 0x02) - 0x4a, \
IMU_ROTATION, \
DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), \
false, \
MCP_PIN(MCP_GPA6), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
(0x4b ^ 0x02) - 0x4a, \
IMU_ROTATION, \
DIRECT_WIRE(PIN_IMU_SCL, PIN_IMU_SDA), \
true, \
MCP_PIN(MCP_GPA5), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
PRIMARY_IMU_ADDRESS_ONE, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 0), \
true, \
MCP_PIN(MCP_GPB0), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
SECONDARY_IMU_ADDRESS_TWO, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 0), \
true, \
MCP_PIN(MCP_GPB1), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
PRIMARY_IMU_ADDRESS_ONE, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 1), \
true, \
MCP_PIN(MCP_GPB2), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
SECONDARY_IMU_ADDRESS_TWO, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 1), \
true, \
MCP_PIN(MCP_GPB3), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
PRIMARY_IMU_ADDRESS_ONE, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 2), \
true, \
MCP_PIN(MCP_GPB4), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
SECONDARY_IMU_ADDRESS_TWO, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 2), \
true, \
MCP_PIN(MCP_GPB5), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
PRIMARY_IMU_ADDRESS_ONE, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 3), \
true, \
MCP_PIN(MCP_GPB6), \
0 \
) \
SENSOR_DESC_ENTRY( \
IMU, \
SECONDARY_IMU_ADDRESS_TWO, \
IMU_ROTATION, \
PCA_WIRE(PIN_IMU_SCL, PIN_IMU_SDA, PCA_ADDR, 3), \
true, \
MCP_PIN(MCP_GPA1), \
0 \
)

#if GLOVE_SIDE == GLOVE_LEFT
#define SENSOR_INFO_LIST \
SENSOR_INFO_ENTRY(0, POSITION_LEFT_HAND) \
SENSOR_INFO_ENTRY(1, POSITION_LEFT_LITTLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(2, POSITION_LEFT_RING_INTERMEDIATE) \
SENSOR_INFO_ENTRY(3, POSITION_LEFT_RING_DISTAL) \
SENSOR_INFO_ENTRY(4, POSITION_LEFT_MIDDLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(5, POSITION_LEFT_MIDDLE_DISTAL) \
SENSOR_INFO_ENTRY(6, POSITION_LEFT_INDEX_INTERMEDIATE) \
SENSOR_INFO_ENTRY(7, POSITION_LEFT_INDEX_DISTAL) \
SENSOR_INFO_ENTRY(8, POSITION_LEFT_THUMB_PROXIMAL) \
SENSOR_INFO_ENTRY(9, POSITION_LEFT_THUMB_DISTAL)
#define SENSOR_INFO_LIST \
SENSOR_INFO_ENTRY(0, POSITION_LEFT_HAND) \
SENSOR_INFO_ENTRY(1, POSITION_LEFT_LITTLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(2, POSITION_LEFT_RING_INTERMEDIATE) \
SENSOR_INFO_ENTRY(3, POSITION_LEFT_RING_DISTAL) \
SENSOR_INFO_ENTRY(4, POSITION_LEFT_MIDDLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(5, POSITION_LEFT_MIDDLE_DISTAL) \
SENSOR_INFO_ENTRY(6, POSITION_LEFT_INDEX_INTERMEDIATE) \
SENSOR_INFO_ENTRY(7, POSITION_LEFT_INDEX_DISTAL) \
SENSOR_INFO_ENTRY(8, POSITION_LEFT_THUMB_PROXIMAL) \
SENSOR_INFO_ENTRY(9, POSITION_LEFT_THUMB_DISTAL)
#elif GLOVE_SDIE == GLOVE_RIGHT
#define SENSOR_INFO_LIST \
SENSOR_INFO_ENTRY(0, POSITION_RIGHT_HAND) \
SENSOR_INFO_ENTRY(1, POSITION_RIGHT_LITTLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(2, POSITION_RIGHT_RING_INTERMEDIATE) \
SENSOR_INFO_ENTRY(3, POSITION_RIGHT_RING_DISTAL) \
SENSOR_INFO_ENTRY(4, POSITION_RIGHT_MIDDLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(5, POSITION_RIGHT_MIDDLE_DISTAL) \
SENSOR_INFO_ENTRY(6, POSITION_RIGHT_INDEX_INTERMEDIATE) \
SENSOR_INFO_ENTRY(7, POSITION_RIGHT_INDEX_DISTAL) \
SENSOR_INFO_ENTRY(8, POSITION_RIGHT_THUMB_PROXIMAL) \
SENSOR_INFO_ENTRY(9, POSITION_RIGHT_THUMB_DISTAL)
#else // GLOVE_SDIE
#define SENSOR_INFO_LIST \
SENSOR_INFO_ENTRY(0, POSITION_RIGHT_HAND) \
SENSOR_INFO_ENTRY(1, POSITION_RIGHT_LITTLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(2, POSITION_RIGHT_RING_INTERMEDIATE) \
SENSOR_INFO_ENTRY(3, POSITION_RIGHT_RING_DISTAL) \
SENSOR_INFO_ENTRY(4, POSITION_RIGHT_MIDDLE_INTERMEDIATE) \
SENSOR_INFO_ENTRY(5, POSITION_RIGHT_MIDDLE_DISTAL) \
SENSOR_INFO_ENTRY(6, POSITION_RIGHT_INDEX_INTERMEDIATE) \
SENSOR_INFO_ENTRY(7, POSITION_RIGHT_INDEX_DISTAL) \
SENSOR_INFO_ENTRY(8, POSITION_RIGHT_THUMB_PROXIMAL) \
SENSOR_INFO_ENTRY(9, POSITION_RIGHT_THUMB_DISTAL)
#else // GLOVE_SDIE
#error "Glove side not defined"
#endif // GLOVE_SDIE
#endif // GLOVE_SDIE

#endif // SENSOR_DESC_LIST
#endif // BOARD != BOARD_GLOVE_IMU_SLIMEVR_DEV
#endif // SENSOR_DESC_LIST
#endif // BOARD != BOARD_GLOVE_IMU_SLIMEVR_DEV

// Battery monitoring options (comment to disable):
// BAT_EXTERNAL for ADC pin,
Expand Down Expand Up @@ -247,13 +343,13 @@ PIN_IMU_SDA, PRIMARY_IMU_OPTIONAL, BMI160_QMC_REMAP) \
#define LED_PIN 16
#define LED_INVERTED true
#elif BOARD == BOARD_XIAO_ESP32C3
#define PIN_IMU_SDA 6 // D4
#define PIN_IMU_SCL 7 // D5
#define PIN_IMU_INT 5 // D3
#define PIN_IMU_INT_2 10 // D10
#define LED_PIN 4 // D2
#define PIN_IMU_SDA 6 // D4
#define PIN_IMU_SCL 7 // D5
#define PIN_IMU_INT 5 // D3
#define PIN_IMU_INT_2 10 // D10
#define LED_PIN 4 // D2
#define LED_INVERTED false
#define PIN_BATTERY_LEVEL 2 // D0 / A0
#define PIN_BATTERY_LEVEL 2 // D0 / A0
#ifndef BATTERY_SHIELD_RESISTANCE
#define BATTERY_SHIELD_RESISTANCE 0
#endif
Expand Down

0 comments on commit 1f87604

Please sign in to comment.