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

Add compatibility with multi-sensor/glove/v0.6.0 firmware #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions src/firmware/firmware-builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ export class FirmwareBuilderService {
}, ${imuConfig.optional}, ${imuConfig.intPin || 255})`;
};

/**
* Define of one sensor entry, computes the address
* For 0.6.0+ firmware versions
*/
const sensorDesc = (imuConfig: ImuConfig, index: number) => {
const imu = IMUS.find(({ type }) => type === imuConfig.type);
if (!imu) return null;

return `SENSOR_DESC_ENTRY(${imuConfig.type}, ${
imu.imuStartAddress + index * imu.addressIncrement
}, ${rotationToFirmware(imuConfig.rotation)}, DIRECT_WIRE(${imuConfig.sclPin}, ${
imuConfig.sdaPin
}), ${imuConfig.optional}, DIRECT_PIN(${imuConfig.intPin || 255}))`;
};

// this is to deal with old firmware versions where two imus where always declared
// i just use the values of the first one if i only have one
const secondImu = imusConfig.length === 1 ? imusConfig[0] : imusConfig[1];
Expand All @@ -76,6 +91,7 @@ export class FirmwareBuilderService {
#define SECOND_IMU_ROTATION ${rotationToFirmware(secondImu.rotation)}

#define MAX_IMU_COUNT ${imusConfig.length}
#define MAX_SENSORS_COUNT ${imusConfig.length}

#ifndef IMU_DESC_LIST
#define IMU_DESC_LIST \\
Expand All @@ -85,6 +101,18 @@ export class FirmwareBuilderService {
.join(' \\\n\t\t ')}
#endif

#ifndef SENSOR_DESC_LIST
#define SENSOR_DESC_LIST \\
${imusConfig
.map(sensorDesc)
.filter((imu) => !!imu)
.join(' \\\n\t\t ')}
#endif

#infdef SENSOR_INFO_LIST
#define SENSOR_INFO_LIST
#endif

#define BATTERY_MONITOR ${boardConfig.batteryType}
${
boardConfig.batteryType === BatteryType.BAT_EXTERNAL &&
Expand Down
3 changes: 3 additions & 0 deletions src/firmware/firmwares.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
},
"l0ud": {
"SlimeVR-Tracker-ESP-BMI270": ["main"]
},
"Multi-sensor/Glove": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inside the SlimeVR section at the top of the file, the { "OWNER": { "REPO": ["BRANCH", "BRANCH2"] } }

"SlimeVR-Tracker-ESP": ["glove"]
}
}