Skip to content

Commit

Permalink
Refactor vtx device status (#3208)
Browse files Browse the repository at this point in the history
Refactor vtx device status to use modules
  • Loading branch information
chmelevskij authored Jan 8, 2023
1 parent 4582f4d commit 05c6f86
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { i18n } from "../localization";
import GUI from "../gui";
import FC from "../fc";
import semver from 'semver';
import vtxDeviceStatusFactory from "../utils/VtxDeviceStatus/VtxDeviceStatusFactory";

// Used for LED_STRIP
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
Expand Down
1 change: 1 addition & 0 deletions src/js/tabs/vtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import GUI from '../gui';
import { tracking } from "../Analytics";
import { mspHelper } from "../msp/MSPHelper";
import FC from '../fc';
import { VtxDeviceTypes } from '../utils/VtxDeviceStatus/VtxDeviceStatus';

const vtx = {
supported: false,
Expand Down
5 changes: 4 additions & 1 deletion src/js/utils/VtxDeviceStatus/Rtc6705DeviceStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
import VtxDeviceStatus, { VtxDeviceTypes } from './VtxDeviceStatus';
import vtxDeviceStatusFactory from './VtxDeviceStatusFactory';

class VtxDeviceStatusRtc6705 extends VtxDeviceStatus {
constructor(dataView)
Expand All @@ -17,3 +18,5 @@ class VtxDeviceStatusRtc6705 extends VtxDeviceStatus {
}

vtxDeviceStatusFactory.registerVtxDeviceStatusClass(VtxDeviceStatusRtc6705);

export default VtxDeviceStatusRtc6705;
6 changes: 5 additions & 1 deletion src/js/utils/VtxDeviceStatus/SmartAudioDeviceStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';
import VtxDeviceStatus, { VtxDeviceTypes } from "./VtxDeviceStatus";
import vtxDeviceStatusFactory from "./VtxDeviceStatusFactory";
import { i18n } from "../../localization";

class VtxDeviceStatusSmartAudio extends VtxDeviceStatus {
constructor(dataView)
Expand Down Expand Up @@ -47,3 +49,5 @@ class VtxDeviceStatusSmartAudio extends VtxDeviceStatus {
}

vtxDeviceStatusFactory.registerVtxDeviceStatusClass(VtxDeviceStatusSmartAudio);

export default VtxDeviceStatusSmartAudio;
5 changes: 4 additions & 1 deletion src/js/utils/VtxDeviceStatus/TrampDeviceStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
import VtxDeviceStatus, { VtxDeviceTypes } from './VtxDeviceStatus';
import vtxDeviceStatusFactory from './VtxDeviceStatusFactory';

class VtxDeviceStatusTramp extends VtxDeviceStatus {
constructor(dataView)
Expand All @@ -17,3 +18,5 @@ class VtxDeviceStatusTramp extends VtxDeviceStatus {
}

vtxDeviceStatusFactory.registerVtxDeviceStatusClass(VtxDeviceStatusTramp);

export default VtxDeviceStatusTramp;
6 changes: 3 additions & 3 deletions src/js/utils/VtxDeviceStatus/VtxDeviceStatus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict';

const VtxDeviceTypes = {
export const VtxDeviceTypes = {
VTXDEV_UNSUPPORTED: 0, // reserved for MSP
VTXDEV_RTC6705: 1,
// 2 reserved
Expand Down Expand Up @@ -78,3 +76,5 @@ class VtxDeviceStatus
return this.constructor.staticDeviceStatusType;
}
}

export default VtxDeviceStatus;
4 changes: 2 additions & 2 deletions src/js/utils/VtxDeviceStatus/VtxDeviceStatusFactory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const vtxDeviceStatusFactory = {
_vtxDeviceStatusClasses: [],

Expand Down Expand Up @@ -38,3 +36,5 @@ const vtxDeviceStatusFactory = {
return result;
},
};

export default vtxDeviceStatusFactory;
4 changes: 3 additions & 1 deletion src/js/utils/VtxDeviceStatus/VtxMspDeviceStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
import VtxDeviceStatus, { VtxDeviceTypes } from './VtxDeviceStatus';

class VtxDeviceStatusMsp extends VtxDeviceStatus {
constructor(dataView)
Expand All @@ -17,3 +17,5 @@ class VtxDeviceStatusMsp extends VtxDeviceStatus {
}

vtxDeviceStatusFactory.registerVtxDeviceStatusClass(VtxDeviceStatusMsp);

export default VtxDeviceStatusMsp;
5 changes: 0 additions & 5 deletions src/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
<script type="text/javascript" src="./node_modules/inflection/lib/inflection.js"></script>
<script type="text/javascript" src="./js/libraries/analytics.js"></script>
<script type="text/javascript" src="./js/utils/window_watchers.js"></script>
<script type="text/javascript" src="./js/utils/VtxDeviceStatus/VtxDeviceStatusFactory.js"></script>
<script type="text/javascript" src="./js/utils/VtxDeviceStatus/VtxDeviceStatus.js"></script>
<script type="text/javascript" src="./js/utils/VtxDeviceStatus/TrampDeviceStatus.js"></script>
<script type="text/javascript" src="./js/utils/VtxDeviceStatus/SmartAudioDeviceStatus.js"></script>
<script type="text/javascript" src="./js/utils/VtxDeviceStatus/Rtc6705DeviceStatus.js"></script>
<script type="text/javascript" src="./js/data_storage.js"></script>
<script type="text/javascript" src="./js/port_handler.js"></script>
<script type="text/javascript" src="./js/port_usage.js"></script>
Expand Down

0 comments on commit 05c6f86

Please sign in to comment.