Skip to content

Commit ca09909

Browse files
author
Ivan Efimov
committed
Motor direction dialog for Dshot escs
1 parent 0f8a291 commit ca09909

File tree

20 files changed

+1255
-104
lines changed

20 files changed

+1255
-104
lines changed

locales/en/messages.json

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@
25702570
"message": "<strong>Safety notice</strong><br /><strong class=\"message-negative\">Remove all propellers to prevent injury!</strong><br />The motors will <strong>spin up!</strong>"
25712571
},
25722572
"motorsRemapDialogExplanations": {
2573-
"message": "<strong>Information notice</strong><br />Motors will spin up one by one and you will be able to select which motor is spinning. The battery should be plugged in, correct ESC protocol should be selected. This utility can only re-arrange currently active motors. More complex re-mapping requires the CLI Resource command. Refer to this <a href=\"https://github.com/betaflight/betaflight/wiki/Betaflight-resource-remapping\" target=\"_blank\" rel=\"noopener noreferrer\">Wiki page</a>."
2573+
"message": "<strong>Information notice</strong><br />Motors will spin up one by one and you will be able to select which motor is spinning. The battery should be plugged in, correct ESC protocol should be selected. This utility can only re-arrange currently active motors. More complex re-mapping requires the CLI Resource command. Refer to this <a href=\"https://github.com/betaflight/betaflight/wiki/Betaflight-resource-remapping\" target=\"_blank\" rel=\"noopener noreferrer\">Wiki page</a>."
25742574
},
25752575
"motorsRemapDialogSave": {
25762576
"message": "Save"
@@ -2579,6 +2579,82 @@
25792579
"message": "Start over"
25802580
},
25812581

2582+
"escDshotDirectionDialog-Title": {
2583+
"message": "Motor Direction - <strong class=\"message-negative-italic\">Warning: Ensure props are removed!</strong>"
2584+
},
2585+
"escDshotDirectionDialog-SelectMotor": {
2586+
"message": "Select one or all motors"
2587+
},
2588+
"escDshotDirectionDialog-SelectMotorSafety": {
2589+
"message": "Motors will spin when selected!"
2590+
},
2591+
"escDshotDirectionDialog-RiskNotice": {
2592+
"message": "<strong>Safety notice</strong><br /><strong class=\"message-negative-italic\">Remove all propellers to prevent injury!</strong><br />The motors will <strong>spin up</strong> immediately when selected!"
2593+
},
2594+
"escDshotDirectionDialog-UnderstandRisks": {
2595+
"message": "<strong>I understand the risks</strong>,<br />all propellers are removed."
2596+
},
2597+
"escDshotDirectionDialog-InformationNotice": {
2598+
"message": "<strong>Information notice</strong><br />To change the motor directions, the battery must be plugged in and the correct ESC protocol must be set up in the $t(tabConfiguration.message) tab. Note that not all Dshot ESCs will work with this dialog. Check your ESC firmware."
2599+
},
2600+
"escDshotDirectionDialog-NormalInformationNotice": {
2601+
"message": "Set motor spin direction by selecting and spinning each motor individually."
2602+
},
2603+
"escDshotDirectionDialog-WizardInformationNotice": {
2604+
"message": "Resets all motor spin directions, then allows the user to choose which to reverse."
2605+
},
2606+
"escDshotDirectionDialog-Open": {
2607+
"message": "Motor direction"
2608+
},
2609+
"escDshotDirectionDialog-CommandNormal": {
2610+
"message": "Normal"
2611+
},
2612+
"escDshotDirectionDialog-CommandReverse": {
2613+
"message": "Reverse"
2614+
},
2615+
"escDshotDirectionDialog-CommandSpin": {
2616+
"message": "Test motor"
2617+
},
2618+
"escDshotDirectionDialog-ReleaseButtonToStop": {
2619+
"message": "Release button to stop"
2620+
},
2621+
"escDshotDirectionDialog-ReleaseToStop": {
2622+
"message": "Release to stop"
2623+
},
2624+
"escDshotDirectionDialog-Start": {
2625+
"message": "Individually"
2626+
},
2627+
"escDshotDirectionDialog-StartWizard": {
2628+
"message": "Wizard"
2629+
},
2630+
"escDshotDirectionDialog-SetDirectionHint": {
2631+
"message": "Change direction of selected motor(s)"
2632+
},
2633+
"escDshotDirectionDialog-SetDirectionHintSafety": {
2634+
"message": "Motors will spin when setting the direction!"
2635+
},
2636+
"escDshotDirectionDialog-WrongProtocolText": {
2637+
"message": "Feature works with DSHOT ESCs only.<br />Verify that your ESC (electric speed controller) supports DSHOT protocol and change it on $t(tabConfiguration.message) tab."
2638+
},
2639+
"escDshotDirectionDialog-WrongMixerText": {
2640+
"message": "Number of motors is 0.<br />Verify the current Mixer on $t(tabConfiguration.message) tab or setup a custom one through CLI. Refer to this <a href=\"https://github.com/betaflight/betaflight/blob/master/docs/Mixer.md\" target=\"_blank\" rel=\"noopener noreferrer\">Wiki page</a>."
2641+
},
2642+
"escDshotDirectionDialog-WrongFirmwareText": {
2643+
"message": "Update the firmware.<br /> Make sure you are using the latest firmware: Betaflight 4.3 or newer."
2644+
},
2645+
"escDshotDirectionDialog-WizardActionHint": {
2646+
"message": "Click on motor numbers individually to change spin direction"
2647+
},
2648+
"escDshotDirectionDialog-WizardActionHintSecondLine": {
2649+
"message": "Verify all motors are spinning correctly"
2650+
},
2651+
"escDshotDirectionDialog-SpinWizard": {
2652+
"message": "Start / spin motors"
2653+
},
2654+
"escDshotDirectionDialog-StopWizard": {
2655+
"message": "Stop motors"
2656+
},
2657+
25822658
"sensorsInfo": {
25832659
"message": "Keep in mind that using fast update periods and rendering multiple graphs at the same time is resource heavy and will burn your battery quicker if you use a laptop.<br />We recommend to only render graphs for sensors you are interested in while using reasonable update periods."
25842660
},
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<div class="escDshotDirection-Component">
2+
<h3 i18n="escDshotDirectionDialog-Title" class="escDshotDirection-ComponentHeader"></h3>
3+
<div class="componentContent" id="escDshotDirectionDialog-ConfigErrors">
4+
<div class="escDshotDirectionErrorTextBlock" id="escDshotDirectionDialog-WrongProtocol" i18n="escDshotDirectionDialog-WrongProtocolText"></div>
5+
<div class="escDshotDirectionErrorTextBlock" id="escDshotDirectionDialog-WrongMixer" i18n="escDshotDirectionDialog-WrongMixerText"></div>
6+
<div class="escDshotDirectionErrorTextBlock" id="escDshotDirectionDialog-WrongFirmware" i18n="escDshotDirectionDialog-WrongFirmwareText"></div>
7+
</div>
8+
<div class="componentContent" id="escDshotDirectionDialog-MainContent">
9+
<div id="escDshotDirectionDialog-MixerPreview" class="grey">
10+
<img id="escDshotDirectionDialog-MixerPreviewImg" alt="" src="./resources/motor_order/custom.svg" />
11+
</div>
12+
<div id="escDshotDirectionDialog-NormalDialog" class="display-contents">
13+
<h4 id="escDshotDirectionDialog-ActionHint" i18n="escDshotDirectionDialog-SelectMotor"></h4>
14+
<h4 id="escDshotDirectionDialog-ActionHintSafety" i18n="escDshotDirectionDialog-SelectMotorSafety"></h4>
15+
<div id="escDshotDirectionDialog-SelectMotorButtonsWrapper">
16+
</div>
17+
<div id = "escDshotDirectionDialog-SecondActionBlock" class="display-contents">
18+
<h4 id="escDshotDirectionDialog-SecondHint" i18n="escDshotDirectionDialog-SetDirectionHint"></h4>
19+
<h4 id="escDshotDirectionDialog-SecondHintSafety" i18n="escDshotDirectionDialog-SetDirectionHintSafety"></h4>
20+
<div id="escDshotDirectionDialog-CommandsWrapper">
21+
<a href="#" id="escDshotDirectionDialog-RotationNormal" class="regular-button" i18n="escDshotDirectionDialog-CommandNormal"></a>
22+
<a href="#" id="escDshotDirectionDialog-RotationReverse" class="regular-button" i18n="escDshotDirectionDialog-CommandReverse"></a>
23+
</div>
24+
</div>
25+
</div>
26+
<div id="escDshotDirectionDialog-WizardDialog" class="display-contents">
27+
<a href="#" id="escDshotDirectionDialog-SpinWizard" class="regular-button" i18n="escDshotDirectionDialog-SpinWizard"></a>
28+
<div id="escDshotDirectionDialog-SpinningWizard" class="display-contents">
29+
<h4 id="escDshotDirectionDialog-WizardActionHint" i18n="escDshotDirectionDialog-WizardActionHint"></h4>
30+
<h4 id="escDshotDirectionDialog-WizardActionHintSecondLine" i18n="escDshotDirectionDialog-WizardActionHintSecondLine"></h4>
31+
<div id="escDshotDirectionDialog-WizardMotorButtons">
32+
</div>
33+
<a href="#" id="escDshotDirectionDialog-StopWizard" class="regular-button" i18n="escDshotDirectionDialog-StopWizard"></a>
34+
</div>
35+
</div>
36+
</div>
37+
<div class="componentContent" id="escDshotDirectionDialog-Warning">
38+
<div>
39+
<p class="escDshotDirectionDialog-RiskNoticeText" i18n="escDshotDirectionDialog-RiskNotice"></p>
40+
<div class="escDshotDirectionToggleParentContainer">
41+
<div class="escDshotDirectionToggleNarrow">
42+
<input id="escDshotDirectionDialog-safetyCheckbox" type="checkbox" class="toggle"/>
43+
</div>
44+
<div class="escDshotDirectionDialog-ToggleWide">
45+
<span class="motorsEnableTestMode escDshotDirectionDialog-RiskNoticeText" i18n="escDshotDirectionDialog-UnderstandRisks"></span>
46+
</div>
47+
</div>
48+
<div class="escDshotDirectionDialog-InformationNotice" i18n="escDshotDirectionDialog-InformationNotice"></div>
49+
50+
<div id="escDshotDirectionDialog-StartWizardBlock" class="escDshotDirectionDialog-StartBlock">
51+
<div class="escDshotDirectionDialog-Buttons">
52+
<a href="#" id="escDshotDirectionDialog-StartWizard" class="regular-button escDshotDirectionDialog-StartButton" i18n="escDshotDirectionDialog-StartWizard"></a>
53+
</div>
54+
<div class="escDshotDirectionDialog-Description" i18n="escDshotDirectionDialog-WizardInformationNotice"></div>
55+
</div>
56+
57+
<div id="escDshotDirectionDialog-StartNormalBlock" class="escDshotDirectionDialog-StartBlock">
58+
<div class="escDshotDirectionDialog-Buttons">
59+
<a href="#" id="escDshotDirectionDialog-Start" class="regular-button escDshotDirectionDialog-StartButton" i18n="escDshotDirectionDialog-Start"></a>
60+
</div>
61+
<div class="escDshotDirectionDialog-Description" i18n="escDshotDirectionDialog-NormalInformationNotice"></div>
62+
</div>
63+
64+
</div>
65+
</div>
66+
</div>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
'use strict';
2+
3+
class EscDshotCommandQueue
4+
{
5+
constructor (intervalMs)
6+
{
7+
this._intervalId = null;
8+
this._interval = intervalMs;
9+
this._queue = [];
10+
this._purging = false;
11+
}
12+
13+
pushCommand(command, buffer)
14+
{
15+
this._queue.push([command, buffer]);
16+
}
17+
18+
pushPause(milliseconds)
19+
{
20+
const counter = Math.ceil(milliseconds / this._interval);
21+
22+
for (let i = 0; i < counter; i++) {
23+
this.pushCommand(null, null);
24+
}
25+
}
26+
27+
start()
28+
{
29+
if (null === this._intervalId) {
30+
this._intervalId = setInterval(
31+
() => { this._checkQueue(); },
32+
this._interval);
33+
}
34+
}
35+
36+
stop()
37+
{
38+
if(null !== this._intervalId) {
39+
clearInterval(this._intervalId);
40+
this._intervalId = null;
41+
}
42+
}
43+
44+
stopWhenEmpty()
45+
{
46+
this._purging = true;
47+
}
48+
49+
clear()
50+
{
51+
this._queue = [];
52+
}
53+
54+
_checkQueue()
55+
{
56+
if (0 !== this._queue.length) {
57+
const command = this._queue.shift();
58+
59+
if (null !== command[0]) {
60+
MSP.send_message(command[0], command[1]);
61+
}
62+
} else if (this._purging) {
63+
this._purging = false;
64+
this.stop();
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)