Skip to content

Commit 4582f4d

Browse files
authored
Serial backend modules (#3192)
1 parent e64873a commit 4582f4d

35 files changed

+122
-34
lines changed

src/components/MotorOutputReordering/MotorOutputReorderingComponent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import MotorOutputReorderConfig from "./MotorOutputReorderingConfig";
22
import MotorOutputReorderCanvas from "./MotorOutputReorderingCanvas";
3+
import { mspHelper } from "../../js/msp/MSPHelper";
34

45
export default class MotorOutputReorderComponent
56
{

src/components/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import BatteryLegend from "./quad-status/BatteryLegend.vue";
1111
import BetaflightLogo from "./betaflight-logo/BetaflightLogo.vue";
1212
import StatusBar from "./status-bar/StatusBar.vue";
1313
import BatteryIcon from "./quad-status/BatteryIcon.vue";
14+
import FC from '../js/fc.js';
1415

1516
// Most of the global objects can go here at first.
1617
// It's a bit of overkill for simple components,

src/js/Beepers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
import { bit_check, bit_clear, bit_set } from './serial_backend';
22

33
class Beepers {
44
constructor(config, supportedConditions) {
@@ -105,3 +105,5 @@ class Beepers {
105105
}
106106
}
107107
}
108+
109+
export default Beepers;

src/js/Features.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
import { bit_check, bit_set, bit_clear } from "./serial_backend";
22

33
const Features = function (config) {
44
const self = this;
@@ -198,3 +198,5 @@ Features.prototype.updateData = function (featureElement) {
198198
}
199199
}
200200
};
201+
202+
export default Features;

src/js/VirtualFC.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
'use strict';
1+
import Features from "./Features";
2+
import Beepers from "./Beepers";
3+
import FC from "./fc";
24

35
const VirtualFC = {
46
// these values are manufactured to unlock all the functionality of the configurator, they dont represent actual hardware
@@ -215,3 +217,5 @@ const VirtualFC = {
215217
};
216218
},
217219
};
220+
221+
export default VirtualFC;

src/js/backup_restore.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
'use strict';
1+
import { sensor_status, update_dataflash_global, reinitializeConnection } from "./serial_backend";
2+
import GUI from "./gui";
3+
import Features from "./Features";
4+
import { i18n } from "./localization";
5+
import Beepers from "./Beepers";
6+
import FC from "./fc";
7+
import { mspHelper } from "./msp/MSPHelper";
28

39
// code below is highly experimental, although it runs fine on latest firmware
410
// the data inside nested objects needs to be verified if deep copy works properly
5-
function configuration_backup(callback) {
11+
export function configuration_backup(callback) {
612
let activeProfile = null;
713

814
let version = CONFIGURATOR.version;
@@ -245,7 +251,7 @@ function configuration_backup(callback) {
245251

246252
}
247253

248-
function configuration_restore(callback) {
254+
export function configuration_restore(callback) {
249255
let chosenFileEntry = null;
250256

251257
const accepts = [{

src/js/fc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
import { bit_check } from "./serial_backend";
22

33
const INITIAL_CONFIG = {
44
apiVersion: "0.0.0",
@@ -901,3 +901,7 @@ const FC = {
901901
QUICKRATES: 4,
902902
},
903903
};
904+
905+
// temp binding to global scope
906+
window.FC = FC;
907+
export default FC;

src/js/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import GUI from './gui.js';
44
import { get as getConfig, set as setConfig } from './ConfigStorage.js';
55
import ReleaseChecker from './release_checker.js';
66
import { tracking, createAnalytics } from './Analytics.js';
7+
import { initializeSerialBackend } from './serial_backend.js';
8+
// Currently fc is everywhere, so we need to import it here
9+
// till all is in modules
10+
import './fc.js';
11+
import './msp/MSPHelper.js';
712

813
$(document).ready(function () {
914

src/js/msp/MSPConnector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
'use strict';
1+
import MspHelper from "./MSPHelper";
2+
import { read_serial } from "../serial_backend";
23

34
const MSPConnectorImpl = function () {
45
this.baud = undefined;
@@ -74,3 +75,5 @@ MSPConnectorImpl.prototype.disconnect = function(onDisconnectCallback) {
7475

7576
MSP.disconnect_cleanup();
7677
};
78+
79+
export default MSPConnectorImpl;

src/js/msp/MSPHelper.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
'use strict';
1+
// NOTE: this is a circular dependency, needs investigating
2+
import { bit_check, sensor_status, bit_set, update_dataflash_global } from "../serial_backend";
3+
import { i18n } from "../localization";
4+
import GUI from "../gui";
5+
import FC from "../fc";
6+
import semver from 'semver';
27

38
// Used for LED_STRIP
49
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
5-
const ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order
610
const ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit
711
let ledOverlayLetters = ['t', 'o', 'b', 'v', 'i', 'w']; // in LSB bit
812

@@ -2641,3 +2645,11 @@ MSP.SDCARD_STATE_FATAL = 1;
26412645
MSP.SDCARD_STATE_CARD_INIT = 2;
26422646
MSP.SDCARD_STATE_FS_INIT = 3;
26432647
MSP.SDCARD_STATE_READY = 4;
2648+
2649+
let mspHelper;
2650+
// This is temporary, till things are moved
2651+
// to modules and every usage of this can create own
2652+
// instance or re-use existing where needed.
2653+
window.mspHelper = mspHelper = new MspHelper();
2654+
export { mspHelper };
2655+
export default MspHelper;

0 commit comments

Comments
 (0)