Skip to content

Commit

Permalink
Merge pull request #67 from senseshift/develop
Browse files Browse the repository at this point in the history
Release 0.6.0-rc.2
  • Loading branch information
leon0399 authored Jul 13, 2023
2 parents 4337383 + 6c55df8 commit e8c32ff
Show file tree
Hide file tree
Showing 76 changed files with 3,533 additions and 2,879 deletions.
57 changes: 56 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
---
BasedOnStyle: Chromium
AccessModifierOffset: '-2'
AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: WebKit
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: 'false'
ColumnLimit: '120'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '2'
ContinuationIndentWidth: '2'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: 'true'
IndentPPDirectives: None
IndentWidth: '4'
IndentWrappedFunctionNames: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'false'
SpaceAfterCStyleCast: 'true'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'false'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never

...
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checks: 'bugprone-*,clang-analyzer-*,google-*,hicpp-*,misc-*,modernize-*,performance-*,portability-*,readability-*'
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ indent_size = 4
max_line_length = 80

[*.{c++,cc,cpp,cxx,h,h++,hh,hpp,hxx,inl,ipp,tlh,tli}]
indent_size = 2
indent_size = 4
cpp_indent_case_contents_when_block = true
cpp_new_line_before_open_brace_namespace = same_line

Expand Down
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,23 @@ jobs:
matrix:
os: [ ubuntu-latest ]
target:
- opengloves
curl_calibration_flag:
- CALIBRATION_CURL="OH::MinMaxCalibrator<uint16_t, 0, ANALOG_MAX>"
- CALIBRATION_CURL="OH::CenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
- CALIBRATION_CURL="OH::FixedCenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: [ true ]
- lucidgloves-prototype3-esp32
- lucidgloves-prototype4-esp32
coverage: [ false ]

include:
- os: ubuntu-latest
target: lucidgloves-prototype4-esp32
curl_calibration_flag: CALIBRATION_CURL="OH::MinMaxCalibrator<uint16_t, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-esp32
curl_calibration_flag: CALIBRATION_CURL="OH::CenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-esp32
curl_calibration_flag: CALIBRATION_CURL="OH::FixedCenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: true

steps:
- uses: actions/checkout@v3
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint

on:
pull_request:
branches:
- master
- develop
paths-ignore:
- '**/*.md'
push:
branches:
- master
- develop
paths-ignore:
- '**/*.md'

jobs:
clang-format:
name: clang-format - `${{ matrix.path }}`
runs-on: ubuntu-latest
strategy:
matrix:
path:
- 'lib'
- 'include'
- 'firmware'
- 'examples'
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '16'
check-path: ${{ matrix.path }}
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
- bhaptics_tactvisor
- bhaptics_tactglove_left
- bhaptics_tactglove_right

- lucidgloves-prototype3-esp32
- lucidgloves-prototype4-esp32
battery_flag:
- BATTERY_ENABLED=true
nimble_flag:
Expand Down
67 changes: 37 additions & 30 deletions examples/bhaptics-ble-bt-serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <connection_bhble.hpp>
#include <output_writers/pwm.hpp>

#include <HardwareSerial.h>
#include <BluetoothSerial.h>
#include <HardwareSerial.h>

using namespace OH;
using namespace BH;
Expand All @@ -27,44 +27,51 @@ static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTAL;

class BLECallbacks : public BHBLEConnectionCallbacks {
public:
void postInit() {
btSerial->begin("SenseShift Serial");
void postInit()
{
btSerial->begin("SenseShift Serial");
}
};

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

auto* face = new HapticPlane_Closest(faceOutputs);
app->getHapticBody()->addComponent(OUTPUT_PATH_ACCESSORY, face);
auto* face = new HapticPlane_Closest(faceOutputs);
app->getHapticBody()->addComponent(OUTPUT_PATH_ACCESSORY, face);

app->getHapticBody()->setup();
app->getHapticBody()->setup();

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

void loopMode() {
// This way is suboptimal, but hardware interrupts for Serial are not supported by the Arduino framework
if (btSerial->available()) {
Serial.print(btSerial->read());
}
if (Serial.available()) {
btSerial->write(Serial.read());
}
sleep(20);
void loopMode()
{
// This way is suboptimal, but hardware interrupts for Serial are not supported by the Arduino framework
if (btSerial->available()) {
Serial.print(btSerial->read());
}
if (Serial.available()) {
btSerial->write(Serial.read());
}
sleep(20);
}
15 changes: 9 additions & 6 deletions firmware/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ extern void loopMode();

SenseShift App;

void setup() {
setupMode();
void setup()
{
setupMode();

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

void loop() {
loopMode();
void loop()
{
loopMode();
}

#endif // ARDUINO
Expand Down
60 changes: 33 additions & 27 deletions firmware/mode_configs/bhaptics/tactal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,48 @@ SenseShift* app = &App;
static const size_t bhLayoutSize = BH_LAYOUT_TACTAL_SIZE;
static const oh_output_point_t* bhLayout[bhLayoutSize] = BH_LAYOUT_TACTAL;

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

auto* face = new HapticPlane_Closest(faceOutputs);
app->getHapticBody()->addComponent(OUTPUT_PATH_ACCESSORY, face);
auto* face = new HapticPlane_Closest(faceOutputs);
app->getHapticBody()->addComponent(OUTPUT_PATH_ACCESSORY, face);

app->getHapticBody()->setup();
app->getHapticBody()->setup();

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

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
auto* battery = new BatterySensor(
new ADCNaiveBattery(36),
&App,
{ .sampleRate = BATTERY_SAMPLE_RATE },
{ "ADC Battery", 4096, BATTERY_TASK_PRIORITY, tskNO_AFFINITY }
);
battery->begin();
auto* battery = new BatterySensor(
new ADCNaiveBattery(36),
&App,
{ .sampleRate = BATTERY_SAMPLE_RATE },
{ "ADC Battery", 4096, BATTERY_TASK_PRIORITY, tskNO_AFFINITY }
);
battery->begin();
#endif
}

void loopMode() {
// Free up the Arduino loop task
vTaskDelete(NULL);
void loopMode()
{
// Free up the Arduino loop task
vTaskDelete(NULL);
}
Loading

1 comment on commit e8c32ff

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage for this commit

38.59%

Please sign in to comment.