-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,329 additions
and
1,236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
BasedOnStyle: Chromium | ||
AllowShortBlocksOnASingleLine: 'false' | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLoopsOnASingleLine: 'false' | ||
CompactNamespaces: 'false' | ||
Language: Cpp | ||
NamespaceIndentation: All | ||
PointerAlignment: Left | ||
ReflowComments: 'true' | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
#include "auto_output.h" | ||
|
||
Point2D* getPoint(uint16_t x, uint16_t y, uint16_t x_max, uint16_t y_max) | ||
{ | ||
const uint16_t x_coord = 1 == x_max ? 1 : UINT16_MAX * (1 / ((float)x_max - 1)) * ((float)x); | ||
const uint16_t y_coord = 1 == y_max ? 1 : UINT16_MAX * (1 / ((float)y_max - 1)) * ((float)y); | ||
Point2D* getPoint(uint16_t x, uint16_t y, uint16_t x_max, uint16_t y_max) { | ||
const uint16_t x_coord = | ||
1 == x_max ? 1 : UINT16_MAX * (1 / ((float)x_max - 1)) * ((float)x); | ||
const uint16_t y_coord = | ||
1 == y_max ? 1 : UINT16_MAX * (1 / ((float)y_max - 1)) * ((float)y); | ||
|
||
return new Point2D(x_coord, y_coord); | ||
return new Point2D(x_coord, y_coord); | ||
} | ||
|
||
outputMap_t transformAutoOutput(std::vector<std::vector<OutputWriter*>> map2d) | ||
{ | ||
outputMap_t points{}; | ||
outputMap_t transformAutoOutput(std::vector<std::vector<OutputWriter*>> map2d) { | ||
outputMap_t points{}; | ||
|
||
size_t y_max = map2d.size(); | ||
size_t y_max = map2d.size(); | ||
|
||
for (size_t y = 0; y < y_max; ++y) | ||
{ | ||
auto row = map2d.at(y); | ||
size_t x_max = row.size(); | ||
for (size_t y = 0; y < y_max; ++y) { | ||
auto row = map2d.at(y); | ||
size_t x_max = row.size(); | ||
|
||
for (size_t x = 0; x < x_max; ++x) | ||
{ | ||
OutputWriter* wr = row.at(x); | ||
Point2D* coord = getPoint(x, y, x_max, y_max); | ||
for (size_t x = 0; x < x_max; ++x) { | ||
OutputWriter* wr = row.at(x); | ||
Point2D* coord = getPoint(x, y, x_max, y_max); | ||
|
||
points[*coord] = wr; | ||
} | ||
points[*coord] = wr; | ||
} | ||
} | ||
|
||
return points; | ||
} | ||
return points; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#include "battery/abstract_battery.h" | ||
#include <Arduino.h> | ||
|
||
void AbstractBattery::loop() | ||
{ | ||
auto now_ms = millis(); | ||
void AbstractBattery::loop() { | ||
auto now_ms = millis(); | ||
|
||
if (now_ms - this->last_battery_sample >= BATTERY_SAMPLE_RATE) { | ||
this->last_battery_sample = now_ms; | ||
if (now_ms - this->last_battery_sample >= BATTERY_SAMPLE_RATE) { | ||
this->last_battery_sample = now_ms; | ||
|
||
this->level = this->updateLevel(); | ||
this->level = this->updateLevel(); | ||
|
||
Serial.printf(">>\t%s: %3u (took %lu ms)\n", __PRETTY_FUNCTION__, this->level, now_ms - millis()); | ||
} | ||
Serial.printf(">>\t%s: %3u (took %lu ms)\n", __PRETTY_FUNCTION__, | ||
this->level, now_ms - millis()); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "openhaptics.h" | ||
#include "battery/ina219.h" | ||
#include "config/battery.h" | ||
|
||
void INA219_BatteryLevel::setup() | ||
{ | ||
this->active = this->sensor->begin(); | ||
} | ||
|
||
uint8_t INA219_BatteryLevel::updateLevel() | ||
{ | ||
if (!this->active) { | ||
return 0; | ||
} | ||
|
||
auto batteryVoltage = this->sensor->getBusVoltage_V(); | ||
// TODO: change this linear transformation to smth more useful | ||
auto batteryPercentage = (batteryVoltage - 3.0) / 0.96; | ||
|
||
return map(batteryPercentage, 0.0f, 1.0f, 0, 255); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#include "component.h" | ||
|
||
void Component::setup() | ||
{} | ||
|
||
void Component::loop() | ||
{} | ||
#include "component.h" | ||
|
||
void Component::setup() {} | ||
|
||
void Component::loop() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
#include "openhaptics.h" | ||
#include "components/serial_plotter.h" | ||
|
||
void SerialPlotter_OutputStates::setup() | ||
{ | ||
this->serial->begin(115200); | ||
} | ||
|
||
void SerialPlotter_OutputStates::loop() | ||
{ | ||
for (auto &_c : *App.getOutput()->getComponents()) | ||
{ | ||
for (auto &_s : *_c.second->getOutputStates()) | ||
{ | ||
this->serial->printf("%5u \t", _s.second.intensity); | ||
} | ||
} | ||
this->serial->println(); | ||
} | ||
#include "components/serial_plotter.h" | ||
#include "openhaptics.h" | ||
|
||
void SerialPlotter_OutputStates::setup() { | ||
this->serial->begin(115200); | ||
} | ||
|
||
void SerialPlotter_OutputStates::loop() { | ||
for (auto& _c : *App.getOutput()->getComponents()) { | ||
for (auto& _s : *_c.second->getOutputStates()) { | ||
this->serial->printf("%5u \t", _s.second.intensity); | ||
} | ||
} | ||
this->serial->println(); | ||
} |
Oops, something went wrong.