Skip to content

Commit ddfb361

Browse files
committed
Optimize act set
1 parent 4c1bf66 commit ddfb361

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/module/syscmd/cmd_act.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,23 @@ static rt_size_t act_device_write(actuator_dev_t act_dev, rt_uint16_t chan_sel,
5757
{
5858
rt_size_t ret = size;
5959

60+
/* Suspend controller output */
61+
mcn_suspend(MCN_HUB(control_output));
62+
63+
printf("Press any key to stop...\n");
64+
6065
if (act_dev->config.protocol == ACT_PROTOCOL_PWM) {
6166
ret = rt_device_write(&act_dev->parent, chan_sel, chan_val, size);
62-
} else if (act_dev->config.protocol == ACT_PROTOCOL_DSHOT) {
63-
printf("Press any key to stop...\n");
64-
65-
/* Suspend controller output */
66-
mcn_suspend(MCN_HUB(control_output));
67+
while (1) {
68+
/* type any key to exit */
69+
if (syscmd_has_input()) {
70+
syscmd_flush();
71+
break;
72+
}
6773

74+
systime_msleep(10);
75+
}
76+
} else if (act_dev->config.protocol == ACT_PROTOCOL_DSHOT) {
6877
while (1) {
6978
/* type any key to exit */
7079
if (syscmd_has_input()) {
@@ -81,14 +90,14 @@ static rt_size_t act_device_write(actuator_dev_t act_dev, rt_uint16_t chan_sel,
8190

8291
systime_msleep(10);
8392
}
84-
85-
/* Resume controller output */
86-
mcn_resume(MCN_HUB(control_output));
8793
} else {
8894
/* Unknown protocol */
8995
ret = 0;
9096
}
9197

98+
/* Resume controller output */
99+
mcn_resume(MCN_HUB(control_output));
100+
92101
return ret;
93102
}
94103

0 commit comments

Comments
 (0)