Skip to content

Commit

Permalink
fix(OpenGloves): tick input sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
leon0399 committed Feb 10, 2024
1 parent 825e6f0 commit 61f9492
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion firmware/mode_configs/opengloves/opengloves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void setupMode()
auto* pinch = new BUTTON_CLASS(PIN_BUTTON_PINCH, BUTTON_PINCH_INVERT);
#endif

OpenGlovesTrackingComponent::Config const tracking_config(2000, false);
Serial.begin(115200);
OpenGlovesTrackingComponent::Config tracking_config(2000, false);
auto* opengloves_tracking =
new OpenGlovesTrackingComponent(tracking_config, input_sensors, new StreamTransport(Serial));

Check warning on line 159 in firmware/mode_configs/opengloves/opengloves.cpp

View check run for this annotation

Codecov / codecov/patch

firmware/mode_configs/opengloves/opengloves.cpp#L156-L159

Added lines #L156 - L159 were not covered by tests

Expand Down
2 changes: 1 addition & 1 deletion lib/opengloves/opengloves/opengloves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace og {
length - written,
"%c%u",
'A' + i,
ifloor<std::uint8_t, float>(finger_curl * MAX_ANALOG_VALUE)
ifloor<std::uint16_t, float>(finger_curl * MAX_ANALOG_VALUE)
);
}
#else
Expand Down
2 changes: 1 addition & 1 deletion lib/opengloves/senseshift/opengloves/opengloves.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace SenseShift::OpenGloves {

auto collectData() -> og::InputPeripheralData

Check warning on line 76 in lib/opengloves/senseshift/opengloves/opengloves.hpp

View check run for this annotation

Codecov / codecov/patch

lib/opengloves/senseshift/opengloves/opengloves.hpp#L76

Added line #L76 was not covered by tests
{
og::InputPeripheralData data;
og::InputPeripheralData data{};

Check warning on line 78 in lib/opengloves/senseshift/opengloves/opengloves.hpp

View check run for this annotation

Codecov / codecov/patch

lib/opengloves/senseshift/opengloves/opengloves.hpp#L78

Added line #L78 was not covered by tests

const auto& curls = this->curl.fingers;
const auto& splays = this->splay.fingers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <Arduino.h>

#include <array>
#include <cstddef>
#include <optional>

Expand Down Expand Up @@ -32,8 +33,8 @@ namespace SenseShift::OpenGloves {
}
};

OpenGlovesTrackingComponent(Config config, InputSensors& input_sensors, ITransport* communication) :
config(config), input_sensors_(std::move(input_sensors)), communication_(communication)
OpenGlovesTrackingComponent(Config& config, InputSensors& input_sensors, ITransport* communication) :
config_(config), input_sensors_(std::move(input_sensors)), communication_(communication)

Check warning on line 37 in lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp

View check run for this annotation

Codecov / codecov/patch

lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp#L36-L37

Added lines #L36 - L37 were not covered by tests
{
this->encoder_ = new og::AlphaEncoder();
}

Check warning on line 40 in lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp

View check run for this annotation

Codecov / codecov/patch

lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp#L39-L40

Added lines #L39 - L40 were not covered by tests
Expand All @@ -46,15 +47,16 @@ namespace SenseShift::OpenGloves {

void tick() override

Check warning on line 48 in lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp

View check run for this annotation

Codecov / codecov/patch

lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp#L48

Added line #L48 was not covered by tests
{
this->input_sensors_.tick();
const auto data = this->input_sensors_.collectData();

char buffer[256];
this->encoder_->encode_input(data, buffer, sizeof(buffer));
this->communication_->send(buffer, sizeof(buffer));
const auto length = this->encoder_->encode_input(data, buffer.data(), buffer.size());
this->communication_->send(buffer.data(), length);
}

Check warning on line 54 in lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp

View check run for this annotation

Codecov / codecov/patch

lib/opengloves_freertos/senseshift/opengloves/opengloves_task.hpp#L50-L54

Added lines #L50 - L54 were not covered by tests

private:
Config& config;
std::array<char, 256> buffer;

Config& config_;
InputSensors input_sensors_;
ITransport* communication_;
og::IEncoder* encoder_;
Expand Down

0 comments on commit 61f9492

Please sign in to comment.