Skip to content

Commit

Permalink
Merge pull request #79 from senseshift/refactor/namespace
Browse files Browse the repository at this point in the history
refactor: apply new `SenseShift` namespace and directory
  • Loading branch information
leon0399 authored Aug 24, 2023
2 parents 2598d7e + bb73823 commit 6ae3811
Show file tree
Hide file tree
Showing 82 changed files with 893 additions and 1,041 deletions.
4 changes: 1 addition & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ AllowAllConstructorInitializersOnNextLine: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
# TODO
# AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: 'false'
Expand Down
51 changes: 30 additions & 21 deletions .github/scripts/get_firmware_name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ getBhapticsName() {
echo "::debug::Getting bHaptics name for $target"
echo "::debug::Flags are $flags"

if [[ $flags =~ BLUETOOTH_USE_NIMBLE=true ]]; then
if [[ $flags =~ SENSESHIFT_BLE_USE_NIMBLE=true ]]; then
echo "::debug::Nimble is enabled, appending +nimble to the target"
target="$target+nimble"
fi

if [[ $flags =~ BATTERY_ENABLED=true ]]; then
if [[ $flags =~ SENSESHIFT_BATTERY_ENABLED=true ]]; then
echo "::debug::Battery is enabled, appending +battery to the target"
target="$target+battery"
fi

if [[ $flags =~ SERIAL_PLOTTER=true ]]; then
if [[ $flags =~ SENSESHIFT_SERIAL_PLOTTER=true ]]; then
echo "::debug::Serial Plotter is enabled, appending +serialplotter to the target"
target="$target+serialplotter"
fi
Expand All @@ -32,6 +32,22 @@ getBhapticsName() {
fi
}

handleCalibrationFlag() {
local target=$1
local flag=$2
local prefix=$3

if [[ $flag =~ MinMaxCalibrator ]]; then
target="$target+${prefix}_minmax"
elif [[ $flag =~ FixedCenterPointDeviationCalibrator ]]; then
target="$target+${prefix}_fcpd"
elif [[ $flag =~ CenterPointDeviationCalibrator ]]; then
target="$target+${prefix}_cpd"
fi

echo "$target"
}

getOpenGlovesName() {
local target=$1
# rest of params
Expand All @@ -43,27 +59,20 @@ getOpenGlovesName() {
if [[ $flags =~ OPENGLOVES_COMM_SERIAL ]]; then
echo "::debug::Serial is enabled, appending +serial to the target"
target="$target+serial"
fi

if [[ $flags =~ OPENGLOVES_COMM_BTSERIAL ]]; then
elif [[ $flags =~ OPENGLOVES_COMM_BTSERIAL ]]; then
echo "::debug::Bluetooth Serial is enabled, appending +bluetooth to the target"
target="$target+bluetooth"
fi

if [[ $flags =~ CALIBRATION_CURL=OH::MinMaxCalibrator ]]; then
echo "::debug::MinMaxCalibrator is enabled, appending +curl_minmax to the target"
target="$target+curl_minmaxcalib"
fi

if [[ $flags =~ CALIBRATION_CURL=OH::CenterPointDeviationCalibrator ]]; then
echo "::debug::CenterPointDeviationCalibrator is enabled, appending +curl_cpcalib to the target"
target="$target+curl_cpcalib"
fi
for flag in "${@:2}"; do
if [[ $flag =~ CALIBRATION_CURL ]]; then
target=$(handleCalibrationFlag "$target" "$flag" "curl_calib")
fi

if [[ $flags =~ CALIBRATION_CURL=OH::FixedCenterPointDeviationCalibrator ]]; then
echo "::debug::FixedCenterPointDeviationCalibrator is enabled, appending +curl_fcpcalib to the target"
target="$target+curl_fcpcalib"
fi
if [[ $flag =~ CALIBRATION_SPLAY ]]; then
target=$(handleCalibrationFlag "$target" "$flag" "splay_calib")
fi
done

echo "firmware=$target"
if [[ -n "$GITHUB_ACTIONS" ]]; then
Expand All @@ -77,9 +86,9 @@ getOpenGlovesName() {
target=$1
echo "::debug::Target is $target"
if [[ $target =~ ^(bhaptics) ]]; then
getBhapticsName $@
getBhapticsName "${@}"
elif [[ $target =~ ^(opengloves|lucidgloves|indexer) ]]; then
getOpenGlovesName $@
getOpenGlovesName "${@}"
else
echo "::error::Unknown target $target"
exit 1
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ jobs:
- bhaptics_tactal
- bhaptics_tactvisor
- bhaptics_tactglove_right
battery_flag: [ BATTERY_ENABLED=true ]
serial_plotter_flag: [ SERIAL_PLOTTER=false ]
nimble_flag: [ BLUETOOTH_USE_NIMBLE=false ]
battery_flag: [ SENSESHIFT_BATTERY_ENABLED=true ]
serial_plotter_flag: [ SENSESHIFT_SERIAL_PLOTTER=false ]
nimble_flag: [ SENSESHIFT_BLE_USE_NIMBLE=false ]
coverage: [ false ]

include:
# Extra tests for x40, as it uses the most features
- target: bhaptics_tactsuit_x40
os: ubuntu-latest
coverage: true
battery_flag: BATTERY_ENABLED=true
serial_plotter_flag: SERIAL_PLOTTER=true
nimble_flag: BLUETOOTH_USE_NIMBLE=true
battery_flag: SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=true
nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=true
# - target: bhaptics_tactsuit_x40
# os: ubuntu-latest
# coverage: true
# battery_flag: BATTERY_ENABLED=true
# serial_plotter_flag: SERIAL_PLOTTER=true
# nimble_flag: BLUETOOTH_USE_NIMBLE=false
# battery_flag: SENSESHIFT_BATTERY_ENABLED=true
# serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=true
# nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=false
- target: bhaptics_tactsuit_x40
os: ubuntu-latest
coverage: false
battery_flag: BATTERY_ENABLED=true
serial_plotter_flag: SERIAL_PLOTTER=false
nimble_flag: BLUETOOTH_USE_NIMBLE=true
battery_flag: SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=false
nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=true

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -177,15 +177,15 @@ jobs:
include:
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="OH::MinMaxCalibrator<uint16_t, 0, ANALOG_MAX>"
curl_calibration_flag: CALIBRATION_CURL="::SenseShift::Calibration::MinMaxCalibrator<uint16_t, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="OH::CenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
curl_calibration_flag: CALIBRATION_CURL="::SenseShift::Calibration::CenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="OH::FixedCenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
curl_calibration_flag: CALIBRATION_CURL="::SenseShift::Calibration::FixedCenterPointDeviationCalibrator<uint16_t, 20, 270, 0, ANALOG_MAX>"
coverage: true
- os: ubuntu-latest
target: indexer-csf
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:

# Enabling all flags to test build for every feature
battery_flag:
- BATTERY_ENABLED=true
- SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag:
- SERIAL_PLOTTER=true
- SENSESHIFT_SERIAL_PLOTTER=true

steps:
- name: Checkout repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
- bhaptics_tactglove_left
- bhaptics_tactglove_right
battery_flag:
- BATTERY_ENABLED=true
- SENSESHIFT_BATTERY_ENABLED=true
nimble_flag:
- BLUETOOTH_USE_NIMBLE=true
- SENSESHIFT_BLE_USE_NIMBLE=true

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 1 addition & 5 deletions examples/bhaptics-ble-bt-serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <BluetoothSerial.h>
#include <HardwareSerial.h>

using namespace OH;
using namespace BH;

extern SenseShift App;
Expand All @@ -27,10 +26,7 @@ static const ::SenseShift::Body::Haptics::Position_t* bhLayout[bhLayoutSize] = B

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

void setupMode()
Expand Down
22 changes: 12 additions & 10 deletions firmware/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include <Arduino.h>
#endif // ARDUINO

#if defined(SERIAL_PLOTTER) && SERIAL_PLOTTER == true
#include <components/serial_plotter.hpp>
#endif // SERIAL_PLOTTER
#if defined(SENSESHIFT_SERIAL_PLOTTER) && SENSESHIFT_SERIAL_PLOTTER == true
#include <senseshift/arduino/components/serial_plotter.hpp>
#endif // SENSESHIFT_SERIAL_PLOTTER

#ifndef SERIAL_PLOTTER_PORT
#define SERIAL_PLOTTER_PORT Serial
#endif // SERIAL_PLOTTER_PORT
#ifndef SENSESHIFT_SERIAL_PLOTTER_PORT
#define SENSESHIFT_SERIAL_PLOTTER_PORT Serial
#endif // SENSESHIFT_SERIAL_PLOTTER_PORT

#ifndef PIO_UNIT_TESTING

Expand All @@ -25,11 +25,13 @@ void setup()
{
setupMode();

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

void loop()
Expand Down
23 changes: 12 additions & 11 deletions firmware/mode_configs/bhaptics/tactal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@

#include "senseshift.h"

#include <senseshift/arduino/input/sensor/analog.hpp>
#include <senseshift/arduino/output/pwm.hpp>
#include <senseshift/battery/sensor.hpp>
#include <senseshift/bh/ble/connection.hpp>
#include <senseshift/bh/devices.hpp>
#include <senseshift/bh/encoding.hpp>
#include <senseshift/freertos/battery.hpp>

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
#include "battery/adc_naive.hpp"
#endif

using namespace OH;
using namespace SenseShift;
using namespace SenseShift::Arduino::Output;
using namespace SenseShift::Arduino::Input;
using namespace SenseShift::FreeRTOS::Battery;
using namespace SenseShift::FreeRTOS::Input;
using namespace SenseShift::Battery;
using namespace SenseShift::BH;
using namespace SenseShift::Body::Haptics;

Expand Down Expand Up @@ -53,12 +55,11 @@ void setupMode()
);
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 }
#if defined(SENSESHIFT_BATTERY_ENABLED) && SENSESHIFT_BATTERY_ENABLED == true
auto* battery = new TaskedSensor<BatteryState>(
new BatterySensor(new NaiveBatterySensor(new AnalogSensor(36)), app),
SENSESHIFT_BATTERY_SAMPLE_RATE,
{ "ADC Battery", 4096, SENSESHIFT_BATTERY_TASK_PRIORITY, tskNO_AFFINITY }
);
battery->begin();
#endif
Expand Down
26 changes: 13 additions & 13 deletions firmware/mode_configs/bhaptics/tactglove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
#include <Arduino.h>
#include <Wire.h>

#include <utility.hpp>

#include "senseshift.h"

#include <senseshift/arduino/input/sensor/analog.hpp>
#include <senseshift/arduino/output/pwm.hpp>
#include <senseshift/battery/sensor.hpp>
#include <senseshift/bh/ble/connection.hpp>
#include <senseshift/bh/devices.hpp>
#include <senseshift/bh/encoding.hpp>
#include <senseshift/freertos/battery.hpp>
#include <senseshift/utility.hpp>

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
#include <battery/adc_naive.hpp>
#endif

using namespace OH;
using namespace SenseShift;
using namespace SenseShift::Arduino::Output;
using namespace SenseShift::Arduino::Input;
using namespace SenseShift::FreeRTOS::Battery;
using namespace SenseShift::FreeRTOS::Input;
using namespace SenseShift::Battery;
using namespace SenseShift::BH;
using namespace SenseShift::Body::Haptics;

Expand Down Expand Up @@ -62,12 +63,11 @@ void setupMode()
);
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 }
#if defined(SENSESHIFT_BATTERY_ENABLED) && SENSESHIFT_BATTERY_ENABLED == true
auto* battery = new TaskedSensor<BatteryState>(
new BatterySensor(new NaiveBatterySensor(new AnalogSensor(36)), app),
SENSESHIFT_BATTERY_SAMPLE_RATE,
{ "ADC Battery", 4096, SENSESHIFT_BATTERY_TASK_PRIORITY, tskNO_AFFINITY }
);
battery->begin();
#endif
Expand Down
23 changes: 12 additions & 11 deletions firmware/mode_configs/bhaptics/tactosy2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@

#include "senseshift.h"

#include <senseshift/arduino/input/sensor/analog.hpp>
#include <senseshift/arduino/output/pwm.hpp>
#include <senseshift/battery/sensor.hpp>
#include <senseshift/bh/ble/connection.hpp>
#include <senseshift/bh/devices.hpp>
#include <senseshift/bh/encoding.hpp>
#include <senseshift/freertos/battery.hpp>

#if defined(BATTERY_ENABLED) && BATTERY_ENABLED == true
#include <battery/adc_naive.hpp>
#endif

using namespace OH;
using namespace SenseShift;
using namespace SenseShift::Arduino::Output;
using namespace SenseShift::Arduino::Input;
using namespace SenseShift::FreeRTOS::Battery;
using namespace SenseShift::FreeRTOS::Input;
using namespace SenseShift::Battery;
using namespace SenseShift::BH;
using namespace SenseShift::Body::Haptics;

Expand Down Expand Up @@ -54,12 +56,11 @@ void setupMode()
);
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 }
#if defined(SENSESHIFT_BATTERY_ENABLED) && SENSESHIFT_BATTERY_ENABLED == true
auto* battery = new TaskedSensor<BatteryState>(
new BatterySensor(new NaiveBatterySensor(new AnalogSensor(36)), app),
SENSESHIFT_BATTERY_SAMPLE_RATE,
{ "ADC Battery", 4096, SENSESHIFT_BATTERY_TASK_PRIORITY, tskNO_AFFINITY }
);
battery->begin();
#endif
Expand Down
Loading

1 comment on commit 6ae3811

@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

39.65%

Please sign in to comment.