Skip to content

Commit 3887f07

Browse files
authored
Merge pull request #2 from esp-cpp/bugfix/start-stop
bugfix(haptics): enable repeated start/stop
2 parents c7687da + eba4a03 commit 3887f07

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ See the Getting Started Guide for full steps to configure and use ESP-IDF to bui
3939
The haptics (detent configuration, click/buzz) can be configured dynamically at
4040
run-time using the provided CLI, see screenshot below:
4141

42-
![CleanShot 2023-06-23 at 08 45 26](https://github.com/esp-cpp/bldc_test_stand/assets/213467/912aae32-a434-4969-8309-af42a4f5f4c7)
42+
![CleanShot 2023-06-23 at 13 23 44](https://github.com/esp-cpp/bldc_test_stand/assets/213467/eb2a2f37-01d0-46e3-992a-48820401c0ab)
4343

4444
As you can see, the cli also allows you to start and stop the haptic engine
4545
(default is off when the program starts) and allows you to query the position of

components/espp

Submodule espp updated 86 files

main/main.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,23 @@ extern "C" void app_main(void) {
154154
root_menu->Insert(
155155
"start",
156156
[&](std::ostream &out) {
157-
out << "Starting motor!\n";
158-
haptic_motor.start();
157+
if (!haptic_motor.is_running()) {
158+
out << "Starting motor!\n";
159+
haptic_motor.start();
160+
} else {
161+
out << "Motor already running!\n";
162+
}
159163
},
160164
"Start the motor");
161165
root_menu->Insert(
162166
"stop",
163167
[&](std::ostream &out) {
164-
out << "Stopping motor!\n";
165-
haptic_motor.stop();
168+
if (haptic_motor.is_running()) {
169+
out << "Stopping motor!\n";
170+
haptic_motor.stop();
171+
} else {
172+
out << "Motor already stopped!\n";
173+
}
166174
},
167175
"Stop the motor");
168176
root_menu->Insert(
@@ -171,6 +179,18 @@ extern "C" void app_main(void) {
171179
out << "Current position: " << haptic_motor.get_position() << "\n";
172180
},
173181
"Print the current position of the haptic motor");
182+
root_menu->Insert(
183+
"shaft_angle",
184+
[&](std::ostream &out) {
185+
out << "Current shaft angle: " << motor.get_shaft_angle() << " radians\n";
186+
},
187+
"Print the current position of the haptic motor");
188+
root_menu->Insert(
189+
"electrical_angle",
190+
[&](std::ostream &out) {
191+
out << "Current electrical angle: " << motor.get_electrical_angle() << " radians\n";
192+
},
193+
"Print the current position of the haptic motor");
174194
root_menu->Insert(
175195
"unbounded_no_detents",
176196
[&](std::ostream &out) {

0 commit comments

Comments
 (0)