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

fix(bHaptics): prevent I2C bus being deallocated #143

Draft
wants to merge 1 commit into
base: develop
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 arch/esp32/esp32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ lib_deps =
lib_ignore =
segger_rtt
ESP32 BLE Arduino

monitor_filters = esp32_exception_decoder
2 changes: 2 additions & 0 deletions firmware/variants/bhaptics/bhaptics.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[base:bhaptics]
extends = arch:esp32

platform = ${arch:esp32.platform}
platform_packages =
${arch:esp32.platform_packages}
Expand Down
14 changes: 7 additions & 7 deletions firmware/variants/bhaptics/tactal/tactal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Application* app = &App;

static const std::array<Position, BH_LAYOUT_TACTAL_SIZE> bhLayout = { BH_LAYOUT_TACTAL };

// Configure PWM pins to their positions on the face
const auto faceOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26), new LedcOutput(27), new LedcOutput(14) },
// clang-format on
});

void setup()
{
// Configure PWM pins to their positions on the face
const auto faceOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26), new LedcOutput(27), new LedcOutput(14) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::FaceFront, new FloatPlane(faceOutputs));

app->getVibroBody()->setup();
Expand Down
16 changes: 8 additions & 8 deletions firmware/variants/bhaptics/tactosy2/tactosy2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@

static const std::array<Position, BH_LAYOUT_TACTOSY2_SIZE> bhLayout = { BH_LAYOUT_TACTOSY2 };

// Configure PWM pins to their positions on the forearm
auto forearmOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25) },
{ new LedcOutput(26), new LedcOutput(27), new LedcOutput(14) },
// clang-format on
});

void setup()
{
// Configure PWM pins to their positions on the forearm
auto forearmOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25) },
{ new LedcOutput(26), new LedcOutput(27), new LedcOutput(14) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::Accessory, new FloatPlane(forearmOutputs));

Check warning on line 42 in firmware/variants/bhaptics/tactosy2/tactosy2.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosy2_forearm_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

Check warning on line 42 in firmware/variants/bhaptics/tactosy2/tactosy2.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosy2_forearm_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

app->getVibroBody()->setup();

Expand All @@ -50,7 +50,7 @@
.serialNumber = BH_SERIAL_NUMBER,
},
[](std::string& value) -> void {
Decoder::applyPlain(app->getVibroBody(), value, bhLayout, Effect::Vibro, Target::Accessory);

Check warning on line 53 in firmware/variants/bhaptics/tactosy2/tactosy2.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosy2_forearm_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

Check warning on line 53 in firmware/variants/bhaptics/tactosy2/tactosy2.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosy2_forearm_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]
},
app
);
Expand Down
18 changes: 9 additions & 9 deletions firmware/variants/bhaptics/tactosyf/tactosyf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@

static const std::array<Position, BH_LAYOUT_TACTOSYF_SIZE> bhLayout = { BH_LAYOUT_TACTOSYF };

// Configure PWM pins to their positions on the feet
auto footOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32) },
{ new LedcOutput(33) },
{ new LedcOutput(25) },
// clang-format on
});

void setup()
{
// Configure PWM pins to their positions on the feet
auto footOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32) },
{ new LedcOutput(33) },
{ new LedcOutput(25) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::Accessory, new FloatPlane(footOutputs));

Check warning on line 43 in firmware/variants/bhaptics/tactosyf/tactosyf.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyf_foot_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

Check warning on line 43 in firmware/variants/bhaptics/tactosyf/tactosyf.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyf_foot_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

app->getVibroBody()->setup();

Expand All @@ -51,7 +51,7 @@
.serialNumber = BH_SERIAL_NUMBER,
},
[](std::string& value) -> void {
Decoder::applyPlain(app->getVibroBody(), value, bhLayout, Effect::Vibro, Target::Accessory);

Check warning on line 54 in firmware/variants/bhaptics/tactosyf/tactosyf.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyf_foot_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

Check warning on line 54 in firmware/variants/bhaptics/tactosyf/tactosyf.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyf_foot_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]
},
app
);
Expand Down
18 changes: 9 additions & 9 deletions firmware/variants/bhaptics/tactosyh/tactosyh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@

static const std::array<Position, BH_LAYOUT_TACTOSYH_SIZE> bhLayout = { BH_LAYOUT_TACTOSYH };

// Configure PWM pins to their positions on the hands
auto handOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32) },
{ new LedcOutput(33) },
{ new LedcOutput(25) }
// clang-format on
});

void setup()
{
// Configure PWM pins to their positions on the hands
auto handOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32) },
{ new LedcOutput(33) },
{ new LedcOutput(25) }
// clang-format on
});

app->getVibroBody()->addTarget(Target::Accessory, new FloatPlane(handOutputs));

Check warning on line 43 in firmware/variants/bhaptics/tactosyh/tactosyh.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyh_hand_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

Check warning on line 43 in firmware/variants/bhaptics/tactosyh/tactosyh.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyh_hand_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

app->getVibroBody()->setup();

Expand All @@ -51,7 +51,7 @@
.serialNumber = BH_SERIAL_NUMBER,
},
[](std::string& value) -> void {
Decoder::applyPlain(app->getVibroBody(), value, bhLayout, Effect::Vibro, Target::Accessory);

Check warning on line 54 in firmware/variants/bhaptics/tactosyh/tactosyh.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyh_hand_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]

Check warning on line 54 in firmware/variants/bhaptics/tactosyh/tactosyh.cpp

View workflow job for this annotation

GitHub Actions / Build bhaptics_tactosyh_hand_right without coverage, -D SS_BATTERY_ENABLED=true

'SenseShift::Body::Haptics::Target::Accessory' is deprecated [-Wdeprecated-declarations]
},
app
);
Expand Down
28 changes: 14 additions & 14 deletions firmware/variants/bhaptics/tactsuit_x16/tactsuit_x16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ static const std::array<OutputLayout, BH_LAYOUT_TACTSUITX16_SIZE> bhLayout = { B
// Ouput indices, responsible for x40 => x16 grouping
static const std::array<std::uint8_t, BH_LAYOUT_TACTSUITX16_GROUPS_SIZE> layoutGroups = BH_LAYOUT_TACTSUITX16_GROUPS;

// Configure PWM pins to their positions on the vest
auto frontOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26) },
{ new LedcOutput(27), new LedcOutput(14), new LedcOutput(12), new LedcOutput(13) },
// clang-format on
});
auto backOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(19), new LedcOutput(18), new LedcOutput(5), new LedcOutput(17) },
{ new LedcOutput(16), new LedcOutput(4), new LedcOutput(2), new LedcOutput(15) },
// clang-format on
});

void setup()
{
// Configure PWM pins to their positions on the vest
auto frontOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26) },
{ new LedcOutput(27), new LedcOutput(14), new LedcOutput(12), new LedcOutput(13) },
// clang-format on
});
auto backOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(19), new LedcOutput(18), new LedcOutput(5), new LedcOutput(17) },
{ new LedcOutput(16), new LedcOutput(4), new LedcOutput(2), new LedcOutput(15) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::ChestFront, new FloatPlane(frontOutputs));
app->getVibroBody()->addTarget(Target::ChestBack, new FloatPlane(backOutputs));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,34 @@ static const std::array<OutputLayout, BH_LAYOUT_TACTSUITX16_SIZE> bhLayout = { B
// Ouput indices, responsible for x40 => x16 grouping
static const std::array<std::uint8_t, BH_LAYOUT_TACTSUITX16_GROUPS_SIZE> layoutGroups = BH_LAYOUT_TACTSUITX16_GROUPS;

auto pwm = i2cdev::PCA9685(0x40, I2CDev);

// Assign the pins on the configured PCA9685 to positions on the vest
auto frontOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm, 0), new PCA9685Output(pwm, 1), new PCA9685Output(pwm, 2), new PCA9685Output(pwm, 3) },
{ new PCA9685Output(pwm, 4), new PCA9685Output(pwm, 5), new PCA9685Output(pwm, 6), new PCA9685Output(pwm, 7) },
// clang-format on
});
auto backOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm, 8), new PCA9685Output(pwm, 9), new PCA9685Output(pwm, 10), new PCA9685Output(pwm, 11) },
{ new PCA9685Output(pwm, 12), new PCA9685Output(pwm, 13), new PCA9685Output(pwm, 14), new PCA9685Output(pwm, 15) },
// clang-format on
});

void setup()
{
Wire.begin();

// Configure the PCA9685s
auto pwm = i2cdev::PCA9685(0x40, I2CDev);
if (pwm.setFrequency(PWM_FREQUENCY) != I2CDEV_RESULT_OK) {
LOG_E("pca9685", "Failed to set frequency");
}
if (pwm.wakeup() != I2CDEV_RESULT_OK) {
LOG_E("pca9685", "Failed to wake up");
}

// Assign the pins on the configured PCA9685 to positions on the vest
auto frontOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm, 0), new PCA9685Output(pwm, 1), new PCA9685Output(pwm, 2), new PCA9685Output(pwm, 3) },
{ new PCA9685Output(pwm, 4), new PCA9685Output(pwm, 5), new PCA9685Output(pwm, 6), new PCA9685Output(pwm, 7) },
// clang-format on
});
auto backOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm, 8), new PCA9685Output(pwm, 9), new PCA9685Output(pwm, 10), new PCA9685Output(pwm, 11) },
{ new PCA9685Output(pwm, 12), new PCA9685Output(pwm, 13), new PCA9685Output(pwm, 14), new PCA9685Output(pwm, 15) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::ChestFront, new FloatPlane(frontOutputs));
app->getVibroBody()->addTarget(Target::ChestBack, new FloatPlane(backOutputs));

Expand Down
46 changes: 23 additions & 23 deletions firmware/variants/bhaptics/tactsuit_x40/tactsuit_x40.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,48 @@ Application* app = &App;

static const std::array<OutputLayout, BH_LAYOUT_TACTSUITX40_SIZE> bhLayout = { BH_LAYOUT_TACTSUITX40 };

auto pwm0 = i2cdev::PCA9685(0x40, I2CDev);
auto pwm1 = i2cdev::PCA9685(0x41, I2CDev);

// Assign the pins on the configured PCA9685s and PWM pins to locations on the vest
auto frontOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm0, 0), new PCA9685Output(pwm0, 1), new PCA9685Output(pwm0, 2), new PCA9685Output(pwm0, 3) },
{ new PCA9685Output(pwm0, 4), new PCA9685Output(pwm0, 5), new PCA9685Output(pwm0, 6), new PCA9685Output(pwm0, 7) },
{ new PCA9685Output(pwm0, 8), new PCA9685Output(pwm0, 9), new PCA9685Output(pwm0, 10), new PCA9685Output(pwm0, 11) },
{ new PCA9685Output(pwm0, 12), new PCA9685Output(pwm0, 13), new PCA9685Output(pwm0, 14), new PCA9685Output(pwm0, 15) },
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26) },
// clang-format on
});
auto backOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm1, 0), new PCA9685Output(pwm1, 1), new PCA9685Output(pwm1, 2), new PCA9685Output(pwm1, 3) },
{ new PCA9685Output(pwm1, 4), new PCA9685Output(pwm1, 5), new PCA9685Output(pwm1, 6), new PCA9685Output(pwm1, 7) },
{ new PCA9685Output(pwm1, 8), new PCA9685Output(pwm1, 9), new PCA9685Output(pwm1, 10), new PCA9685Output(pwm1, 11) },
{ new PCA9685Output(pwm1, 12), new PCA9685Output(pwm1, 13), new PCA9685Output(pwm1, 14), new PCA9685Output(pwm1, 15) },
{ new LedcOutput(27), new LedcOutput(14), new LedcOutput(12), new LedcOutput(13) },
// clang-format on
});

void setup()
{
Wire.begin();

// Configure the PCA9685s
auto pwm0 = i2cdev::PCA9685(0x40, I2CDev);
if (pwm0.setFrequency(PWM_FREQUENCY) != I2CDEV_RESULT_OK) {
LOG_E("pca9685", "Failed to set frequency");
}
if (pwm0.wakeup() != I2CDEV_RESULT_OK) {
LOG_E("pca9685", "Failed to wake up");
}

auto pwm1 = i2cdev::PCA9685(0x41, I2CDev);
if (pwm1.setFrequency(PWM_FREQUENCY) != I2CDEV_RESULT_OK) {
LOG_E("pca9685", "Failed to set frequency");
}
if (pwm1.wakeup() != I2CDEV_RESULT_OK) {
LOG_E("pca9685", "Failed to wake up");
}

// Assign the pins on the configured PCA9685s and PWM pins to locations on the
// vest
auto frontOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm0, 0), new PCA9685Output(pwm0, 1), new PCA9685Output(pwm0, 2), new PCA9685Output(pwm0, 3) },
{ new PCA9685Output(pwm0, 4), new PCA9685Output(pwm0, 5), new PCA9685Output(pwm0, 6), new PCA9685Output(pwm0, 7) },
{ new PCA9685Output(pwm0, 8), new PCA9685Output(pwm0, 9), new PCA9685Output(pwm0, 10), new PCA9685Output(pwm0, 11) },
{ new PCA9685Output(pwm0, 12), new PCA9685Output(pwm0, 13), new PCA9685Output(pwm0, 14), new PCA9685Output(pwm0, 15) },
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26) },
// clang-format on
});
auto backOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new PCA9685Output(pwm1, 0), new PCA9685Output(pwm1, 1), new PCA9685Output(pwm1, 2), new PCA9685Output(pwm1, 3) },
{ new PCA9685Output(pwm1, 4), new PCA9685Output(pwm1, 5), new PCA9685Output(pwm1, 6), new PCA9685Output(pwm1, 7) },
{ new PCA9685Output(pwm1, 8), new PCA9685Output(pwm1, 9), new PCA9685Output(pwm1, 10), new PCA9685Output(pwm1, 11) },
{ new PCA9685Output(pwm1, 12), new PCA9685Output(pwm1, 13), new PCA9685Output(pwm1, 14), new PCA9685Output(pwm1, 15) },
{ new LedcOutput(27), new LedcOutput(14), new LedcOutput(12), new LedcOutput(13) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::ChestFront, new FloatPlane(frontOutputs));
app->getVibroBody()->addTarget(Target::ChestBack, new FloatPlane(backOutputs));

Expand Down
14 changes: 7 additions & 7 deletions firmware/variants/bhaptics/tactvisor/tactvisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Application* app = &App;

static const std::array<Position, BH_LAYOUT_TACTVISOR_SIZE> bhLayout = { BH_LAYOUT_TACTVISOR };

// Configure PWM pins to their positions on the face
auto faceOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26) },
// clang-format on
});

void setup()
{
// Configure PWM pins to their positions on the face
auto faceOutputs = PlaneMapper_Margin::mapMatrixCoordinates<FloatPlane::Actuator*>({
// clang-format off
{ new LedcOutput(32), new LedcOutput(33), new LedcOutput(25), new LedcOutput(26) },
// clang-format on
});

app->getVibroBody()->addTarget(Target::FaceFront, new FloatPlane(faceOutputs));

app->getVibroBody()->setup();
Expand Down
Loading