Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental HardlightVR Vest firmware #47

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions firmware/mode_configs/hardlight/vest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Override you configs in this file (Ctrl+Click)
#include "config/all.h"

#include <Arduino.h>
#include <Wire.h>

#include "openhaptics.h"

using namespace OH;

extern OpenHaptics App;
OpenHaptics* app = &App;

void setupMode() {

}
3 changes: 1 addition & 2 deletions ini/bhaptics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ build_flags = ${common.build_flags}
-D BHAPTICS
build_unflags = ${common.build_unflags}
build_src_filter = ${common.build_src_filter}
+<connections/ble.cpp>
+<connections/bhaptics.cpp>
lib_deps = ${common.lib_deps}
h2zero/NimBLE-Arduino@^1.4.0

[env:bhaptics_tactsuit_x16]
build_flags = ${bhaptics.build_flags}
Expand Down
18 changes: 18 additions & 0 deletions ini/hardlight.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[hardlight]
platform = ststm32
board = genericSTM32F401RE
build_flags = ${common.build_flags}
-D HARDLIGHT
build_unflags = ${common.build_unflags}
build_src_filter = ${common.build_src_filter}
lib_deps = ${common.lib_deps}
stm32duino/STM32duino FreeRTOS @ ^10.3.1

[env:hardlight_vest]
platform = ${hardlight.platform}
board = ${hardlight.board}
build_flags = ${hardlight.build_flags}
build_unflags = ${hardlight.build_unflags}
build_src_filter = ${hardlight.build_src_filter}
+<mode_configs/hardlight/vest.cpp>
lib_deps = ${hardlight.lib_deps}
6 changes: 6 additions & 0 deletions lib/arduino/output_writers/pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ uint8_t PWMOutputWriter::CHANNELS = 0;
void PWMOutputWriter::setup() {
this->chan = PWMOutputWriter::CHANNELS++;

#if defined(ARDUINO_ARCH_ESP32)
ledcSetup(this->chan, this->freq, this->resolution);
ledcAttachPin(this->pin, this->chan);
#endif
};

void PWMOutputWriter::writeOutput(oh_output_intensity_t intensity) {
#if defined(ARDUINO_ARCH_ESP32)
ledcWrite(chan, (uint16_t)map(intensity, 0, OH_OUTPUT_INTENSITY_MAX, 0, 4096));
#elif defined(ARDUINO_ARCH_STM32)
analogWrite(this->pin, (uint16_t)map(intensity, 0, OH_OUTPUT_INTENSITY_MAX, 0, 255));
#endif
}
8 changes: 7 additions & 1 deletion lib/core/logging.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#pragma once

#if defined(ARDUINO_ARCH_ESP32)
#include <esp32-hal-log.h>
#include <esp32-hal-log.h>
#elif defined(ARDUINO_ARCH_STM32)
#define log_e(...) ((void)0)
#define log_w(...) ((void)0)
#define log_i(...) ((void)0)
#define log_d(...) ((void)0)
#define log_t(...) ((void)0)
#endif
16 changes: 12 additions & 4 deletions lib/core/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
#include "logging.hpp"

#include <Arduino.h>
#include <freertos/FreeRTOS.h> // Include the base FreeRTOS definitions.
#include <freertos/task.h> // Include the task definitions.

#if defined(ARDUINO_ARCH_ESP32)
#include <freertos/FreeRTOS.h> // Include the base FreeRTOS definitions.
#include <freertos/task.h> // Include the task definitions.
#elif defined(ARDUINO_ARCH_STM32)
#include <STM32FreeRTOS.h>

#define tskNO_AFFINITY 0
#define xTaskCreateUniversal(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, xCoreID) xTaskCreate(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask)
#endif

namespace OH {
struct TaskConfig {
Expand Down Expand Up @@ -56,8 +64,8 @@ namespace OH {
this->taskConfig.coreId // xCoreID
);

assert("Failed to create task" && result == pdPASS);
if(!taskHandle) {
// assert(result == pdPASS);
if(!taskHandle || !result) {
log_e("Failed to create task %s", this->taskConfig.name);
}
};
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ lib_dir = ./lib
src_dir = ./firmware
extra_configs =
ini/bhaptics.ini
ini/hardlight.ini

[common]
build_flags =
Expand All @@ -38,7 +39,6 @@ lib_deps =
adafruit/Adafruit PWM Servo Driver Library@^2.4.0
adafruit/Adafruit INA219@^1.2.1
sparkfun/SparkFun MAX1704x Fuel Gauge Arduino Library@^1.0.4
h2zero/NimBLE-Arduino@^1.4.0

[env]
framework = arduino
Expand Down