Skip to content

Commit

Permalink
Merge branch 'hotfix/v0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
leon0399 committed Mar 27, 2023
2 parents 4d23832 + 8be46e7 commit 40f0fee
Show file tree
Hide file tree
Showing 27 changed files with 257 additions and 310 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Build your own DIY haptic vest, haptic gloves and more!
[![GitHub](https://img.shields.io/github/stars/openhaptics/openhaptics-firmware.svg)](https://github.com/openhaptics/openhaptics-firmware)
[![Contributor Covenant](https://img.shields.io/badge/code_of_conduct-contributor_covenant_v2.1-ff69b4)](/CODE_OF_CONDUCT.md)


## Configuration, flashing and connecting

The main documentation on this project is located on [openhaptics.github.io](https://openhaptics.github.io/)

* [Getting Started](https://openhaptics.github.io/docs/getting-started)
* **NEW** [Build Guides](https://openhaptics.github.io/guides/getting-started)
* [Hardware Schematics](https://github.com/openhaptics/openhaptics-hardware)
* [Flashing Firmware](https://openhaptics.github.io/docs/category/flashing-firmware)

Expand Down Expand Up @@ -58,9 +58,9 @@ Please note, that documentation is still work-in-progress

| Board | Status |
| :------------------- | :----------: |
| Internal ADC | 🚧 |
| MAX1704x | 🚧 |
| INA219 | 🚧 |
| Internal ADC | |
| MAX1704x | |
| INA219 | |
| MCP3021 | 🚧 |
| STUSB4500 | 🚧 |

Expand All @@ -73,15 +73,15 @@ Please note, that documentation is still work-in-progress

## Supported devices

| Device | Supported Devices | Retail price | Hardware |
| :-------------------- | :------------------- | -----------: | :-------------------------------------------------------------------------------------------------- |
| Haptics Face Interface | Tactal | US $149 | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-face-interface) |
| Haptic Gloves | TactGlove | US $299 | PWM on pins `32`, `33`, `25`, `26`, `27`, `14` |
| Haptic Sleeves | Tactosy for arms | US $249 | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-forearm-sleeve) |
| Haptic Hand Gauntlet | Tactosy for hands | US $249 | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-gauntlet) |
| Haptic Feet Device | Tactosy for feet | US $249 | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-feet-device) |
| X16 Haptic Vest | TactSuit X16 | US $299 | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#x16-haptic-vest) |
| X40 Haptic Vest | TactSuit X40, Tactot | US $499 | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#x40-haptic-vest) |
| Device | Supported Devices | Retail price | DIY Price | Hardware |
| :-------------------- | :------------------- | -----------: | --------: | :-------------------------------------------------------------------------------------------------- |
| Haptics Face Interface | Tactal | US $149 | ~20$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-face-interface) |
| Haptic Gloves | TactGlove | US $299 | ~20$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-glove) |
| Haptic Sleeves | Tactosy for arms | US $249 | ~20$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-forearm-sleeve) |
| Haptic Hand Gauntlet | Tactosy for hands | US $249 | ~20$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-gauntlet) |
| Haptic Feet Device | Tactosy for feet | US $249 | ~20$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#haptic-feet-device) |
| X16 Haptic Vest | TactSuit X16 | US $299 | ~40$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#x16-haptic-vest) |
| X40 Haptic Vest | TactSuit X40, Tactot | US $499 | ~70$ | See [Hardware Reference](https://github.com/openhaptics/openhaptics-hardware#x40-haptic-vest) |

## For Developers

Expand Down
16 changes: 9 additions & 7 deletions firmware/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@

#ifndef PIO_UNIT_TESTING

extern void setupMode(OpenHaptics* app);
extern void setupMode();

#if defined(ARDUINO)

static OpenHaptics App;
OpenHaptics App;

void setup() {
Serial.begin(115200);
setupMode(&App);

setupMode();

#if defined(SERIAL_PLOTTER) && SERIAL_PLOTTER == true
auto* serialOutputState = new OH::SerialPlotter_OutputStates<HardwareSerial>(Serial, App.getOutput());
App.registerComponent(serialOutputState);
serialOutputState->begin();
#endif // SERIAL_PLOTTER

App.begin();

// Free up the Arduino loop task
vTaskDelete(NULL);
}

void loop() {}
void loop() {
// Arduino loop task is deleted in setup()
// Delete the `vTaskDelete(NULL);` line in setup() to enable this function
}

#endif // ARDUINO

Expand Down
34 changes: 24 additions & 10 deletions firmware/mode_configs/bhaptics/tactal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,47 @@
using namespace OH;
using namespace BH;

static const size_t bhLayoutSize = BH_LAYOUT_TACTAL_SIZE;
static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTAL;
extern OpenHaptics App;
OpenHaptics* app = &App;

void setupMode(OpenHaptics* app) {
// ========= Output =========

const size_t bhLayoutSize = BH_LAYOUT_TACTAL_SIZE;
const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTAL;

// ========= Connection =========

// ========= Battery =========

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
#endif

void setupMode() {
// Configure PWM pins to their positions on the face
auto faceOutputs = mapMatrixCoordinates<AbstractOutputWriter>({
// clang-format off
{new PWMOutputWriter(32), new PWMOutputWriter(33), new PWMOutputWriter(25), new PWMOutputWriter(26), new PWMOutputWriter(27), new PWMOutputWriter(14)},
// clang-format on
});
ClosestOutputComponent* face = new ClosestOutputComponent(OUTPUT_PATH_ACCESSORY, faceOutputs);

OutputComponent* face = new ClosestOutputComponent(OUTPUT_PATH_ACCESSORY, faceOutputs);
app->getOutput()->addComponent(face);

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
app->setBattery(battery);
#endif
app->getOutput()->setup();

uint8_t serialNumber[BH_SERIAL_NUMBER_LENGTH] = BH_SERIAL_NUMBER;
ConnectionBHBLE_Config config = {
.deviceName = BLUETOOTH_NAME,
.appearance = BH_BLE_APPEARANCE,
.serialNumber = serialNumber,
};
AbstractConnection* bhBleConnection = new ConnectionBHBLE(&config, [app](std::string& value)->void {
AbstractConnection* bhBleConnection = new ConnectionBHBLE(config, [](std::string& value)->void {
plainOutputTransformer(app->getOutput(), value, bhLayout, bhLayoutSize, OUTPUT_PATH_ACCESSORY);
}, app);
app->setConnection(bhBleConnection);
bhBleConnection->begin();

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, &App, tskNO_AFFINITY);
battery->begin();
#endif
}
24 changes: 16 additions & 8 deletions firmware/mode_configs/bhaptics/tactglove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
using namespace OH;
using namespace BH;

extern OpenHaptics App;
OpenHaptics* app = &App;

#pragma region bHaptics_trash

// TODO: all of this will need to be re-written to use the new output paths system, when time comes
Expand All @@ -44,30 +47,35 @@ static const oh_output_point_t* bhLayout[bhLayoutSize] = {

#pragma endregion bHaptics_trash

void setupMode(OpenHaptics* app) {
void setupMode() {
// Configure PWM pins to their positions on the glove
auto gloveOutputs = mapMatrixCoordinates<AbstractOutputWriter>({
// clang-format off
{new PWMOutputWriter(32), new PWMOutputWriter(33), new PWMOutputWriter(25), new PWMOutputWriter(26), new PWMOutputWriter(27), new PWMOutputWriter(14)},
{
new PWMOutputWriter(32), new PWMOutputWriter(33), new PWMOutputWriter(25), new PWMOutputWriter(26), new PWMOutputWriter(27),
new PWMOutputWriter(14)
},
// clang-format on
});

OutputComponent* glove = new ClosestOutputComponent(OUTPUT_PATH_ACCESSORY, gloveOutputs);
app->getOutput()->addComponent(glove);

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
app->setBattery(battery);
#endif
app->getOutput()->setup();

uint8_t serialNumber[BH_SERIAL_NUMBER_LENGTH] = BH_SERIAL_NUMBER;
ConnectionBHBLE_Config config = {
.deviceName = BLUETOOTH_NAME,
.appearance = BH_BLE_APPEARANCE,
.serialNumber = serialNumber,
};
AbstractConnection* bhBleConnection = new ConnectionBHBLE(&config, [app](std::string& value)->void {
AbstractConnection* bhBleConnection = new ConnectionBHBLE(config, [](std::string& value)->void {
plainOutputTransformer(app->getOutput(), value, bhLayout, bhLayoutSize, OUTPUT_PATH_ACCESSORY);
}, app);
app->setConnection(bhBleConnection);
bhBleConnection->begin();

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
battery->begin();
#endif
}
19 changes: 12 additions & 7 deletions firmware/mode_configs/bhaptics/tactosy2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
using namespace OH;
using namespace BH;

extern OpenHaptics App;
OpenHaptics* app = &App;

static const size_t bhLayoutSize = BH_LAYOUT_TACTOSY2_SIZE;
static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTOSY2;

void setupMode(OpenHaptics* app) {
void setupMode() {
// Configure PWM pins to their positions on the forearm
auto forearmOutputs = mapMatrixCoordinates<AbstractOutputWriter>({
// clang-format off
Expand All @@ -32,19 +35,21 @@ void setupMode(OpenHaptics* app) {
OutputComponent* forearm = new ClosestOutputComponent(OUTPUT_PATH_ACCESSORY, forearmOutputs);
app->getOutput()->addComponent(forearm);

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
app->setBattery(battery);
#endif
app->getOutput()->setup();

uint8_t serialNumber[BH_SERIAL_NUMBER_LENGTH] = BH_SERIAL_NUMBER;
ConnectionBHBLE_Config config = {
.deviceName = BLUETOOTH_NAME,
.appearance = BH_BLE_APPEARANCE,
.serialNumber = serialNumber,
};
AbstractConnection* bhBleConnection = new ConnectionBHBLE(&config, [app](std::string& value)->void {
AbstractConnection* bhBleConnection = new ConnectionBHBLE(config, [](std::string& value)->void {
plainOutputTransformer(app->getOutput(), value, bhLayout, bhLayoutSize, OUTPUT_PATH_ACCESSORY);
}, app);
app->setConnection(bhBleConnection);
bhBleConnection->begin();

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
battery->begin();
#endif
}
27 changes: 17 additions & 10 deletions firmware/mode_configs/bhaptics/tactosyf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,40 @@
using namespace OH;
using namespace BH;

static const size_t bhLayoutSize = BH_LAYOUT_TACTOSYF_SIZE;
static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTOSYF;
extern OpenHaptics App;
OpenHaptics* app = &App;

void setupMode() {
static const size_t bhLayoutSize = BH_LAYOUT_TACTOSYF_SIZE;
static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTOSYF;

void setupMode(OpenHaptics* app) {
// Configure PWM pins to their positions on the feet
auto footOutputs = mapMatrixCoordinates<AbstractOutputWriter>({
// clang-format off
{new PWMOutputWriter(32), new PWMOutputWriter(33), new PWMOutputWriter(25)}
{ new PWMOutputWriter(32) },
{ new PWMOutputWriter(33) },
{ new PWMOutputWriter(25) },
// clang-format on
});

OutputComponent* foot = new ClosestOutputComponent(OUTPUT_PATH_ACCESSORY, footOutputs);
app->getOutput()->addComponent(foot);

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
app->setBattery(battery);
#endif
app->getOutput()->setup();

uint8_t serialNumber[BH_SERIAL_NUMBER_LENGTH] = BH_SERIAL_NUMBER;
ConnectionBHBLE_Config config = {
.deviceName = BLUETOOTH_NAME,
.appearance = BH_BLE_APPEARANCE,
.serialNumber = serialNumber,
};
AbstractConnection* bhBleConnection = new ConnectionBHBLE(&config, [app](std::string& value)->void {
AbstractConnection* bhBleConnection = new ConnectionBHBLE(config, [](std::string& value)->void {
plainOutputTransformer(app->getOutput(), value, bhLayout, bhLayoutSize, OUTPUT_PATH_ACCESSORY);
}, app);
app->setConnection(bhBleConnection);
bhBleConnection->begin();

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
battery->begin();
#endif
}
19 changes: 12 additions & 7 deletions firmware/mode_configs/bhaptics/tactosyh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
using namespace OH;
using namespace BH;

extern OpenHaptics App;
OpenHaptics* app = &App;

static const size_t bhLayoutSize = BH_LAYOUT_TACTOSYH_SIZE;
static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTOSYH;

void setupMode(OpenHaptics* app) {
void setupMode() {
// Configure PWM pins to their positions on the hands
auto handOutputs = mapMatrixCoordinates<AbstractOutputWriter>({
// clang-format off
Expand All @@ -33,19 +36,21 @@ void setupMode(OpenHaptics* app) {
OutputComponent* hand = new ClosestOutputComponent(OUTPUT_PATH_ACCESSORY, handOutputs);
app->getOutput()->addComponent(hand);

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
app->setBattery(battery);
#endif
app->getOutput()->setup();

uint8_t serialNumber[BH_SERIAL_NUMBER_LENGTH] = BH_SERIAL_NUMBER;
ConnectionBHBLE_Config config = {
.deviceName = BLUETOOTH_NAME,
.appearance = BH_BLE_APPEARANCE,
.serialNumber = serialNumber,
};
AbstractConnection* bhBleConnection = new ConnectionBHBLE(&config, [app](std::string& value)->void {
AbstractConnection* bhBleConnection = new ConnectionBHBLE(config, [](std::string& value)->void {
plainOutputTransformer(app->getOutput(), value, bhLayout, bhLayoutSize, OUTPUT_PATH_ACCESSORY);
}, app);
app->setConnection(bhBleConnection);
bhBleConnection->begin();

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
battery->begin();
#endif
}
19 changes: 12 additions & 7 deletions firmware/mode_configs/bhaptics/tactsuit_x16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
using namespace OH;
using namespace BH;

extern OpenHaptics App;
OpenHaptics* app = &App;

static const oh_output_point_t* bhLayout[] = BH_LAYOUT_TACTSUITX16;
static const size_t bhLayoutSize = BH_LAYOUT_TACTSUITX16_SIZE;

// Ouput indices, responsible for x40 => x16 grouping
static const size_t layoutGroupsSize = BH_LAYOUT_TACTSUITX16_GROUPS_SIZE;
static const uint8_t layoutGroups[layoutGroupsSize] = BH_LAYOUT_TACTSUITX16_GROUPS;

void setupMode(OpenHaptics* app) {
void setupMode() {
// Configure PWM pins to their positions on the vest
auto frontOutputs = mapMatrixCoordinates<AbstractOutputWriter>({
// clang-format off
Expand All @@ -45,19 +48,21 @@ void setupMode(OpenHaptics* app) {
app->getOutput()->addComponent(chestFront);
app->getOutput()->addComponent(chestBack);

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
app->setBattery(battery);
#endif
app->getOutput()->setup();

uint8_t serialNumber[BH_SERIAL_NUMBER_LENGTH] = BH_SERIAL_NUMBER;
ConnectionBHBLE_Config config = {
.deviceName = BLUETOOTH_NAME,
.appearance = BH_BLE_APPEARANCE,
.serialNumber = serialNumber,
};
AbstractConnection* bhBleConnection = new ConnectionBHBLE(&config, [app](std::string& value)->void {
AbstractConnection* bhBleConnection = new ConnectionBHBLE(config, [](std::string& value)->void {
vestX16OutputTransformer(app->getOutput(), value, bhLayout, bhLayoutSize, layoutGroups, layoutGroupsSize);
}, app);
app->setConnection(bhBleConnection);
bhBleConnection->begin();

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
AbstractBattery* battery = new ADCNaiveBattery(36, { .sampleRate = BATTERY_SAMPLE_RATE }, app, tskNO_AFFINITY);
battery->begin();
#endif
}
Loading

0 comments on commit 40f0fee

Please sign in to comment.