Skip to content

Commit 616fd31

Browse files
committed
Merge branch 'imuf-only' of https://github.com/mricho/Nemesis into imuf-only
2 parents fa28c74 + 9e51d56 commit 616fd31

File tree

17 files changed

+226
-70
lines changed

17 files changed

+226
-70
lines changed

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
work correctly both with client-side routing and a non-root public URL.
2020
Learn how to configure a non-root public URL by running `npm run build`.
2121
-->
22-
<title>Nemesis</title>
22+
<title>EmuFlight IMUF Flasher</title>
2323
<style>
2424
body, html {
2525
font-family:Roboto, sans-serif;

src/App.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import Disconnected from "./Views/Disconnected";
44
import ImufView from "./Views/ImufView/ImufView";
55
import DfuView from "./Views/DfuView/DfuView";
66
import FCConnector from "./utilities/FCConnector";
7+
import ImufOnly from "./Views/ImufOnly";
78
import themes from "./Themes/Dark";
89
import { MuiThemeProvider } from "@material-ui/core/styles";
910
import "./App.css";
1011

1112
export const FCConfigContext = React.createContext({});
1213

1314
export class App extends Component {
15+
1416
constructor(props) {
1517
super(props);
1618
this.state = {
@@ -19,7 +21,7 @@ export class App extends Component {
1921
theme: themes.dark
2022
};
2123
}
22-
24+
2325
detectFc = device => {
2426
if (device.progress || device.telemetry) {
2527
return;
@@ -140,7 +142,7 @@ export class App extends Component {
140142
} else if (this.state.connected) {
141143
return (
142144
<MuiThemeProvider theme={this.state.theme}>
143-
<Connected
145+
<ImufOnly
144146
appVersion={this.state.appVersion}
145147
rebooting={this.state.rebooting}
146148
handleSave={this.handleSave}

src/Views/CliView/CliView.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import MenuItem from "@material-ui/core/MenuItem";
33
import TextField from "@material-ui/core/TextField";
44
import SwipeableDrawer from "@material-ui/core/SwipeableDrawer";
55
import FCConnector from "../../utilities/FCConnector";
6+
import MenuItem from "@material-ui/core/MenuItem";
67
import "./CliView.css";
78

89
export default class CliView extends Component {
@@ -83,7 +84,7 @@ export default class CliView extends Component {
8384
{!this.state.open &&
8485
!this.state.disabled && (
8586
<MenuItem
86-
style={{ display: "flex", padding: 8 }}
87+
style={{ display: "flex" }}
8788
onClick={() => {
8889
this.toggleCli(true);
8990
}}

src/Views/ImufOnly.js

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
import React, { Component } from "react";
2+
import Paper from "@material-ui/core/Paper";
3+
import ConfigListView from "./ConfigListView/ConfigListView";
4+
import FCConnector from "../utilities/FCConnector";
5+
import AssistantView from "./Assistants/AssistantView";
6+
import "./Connected.css";
7+
import { FCConfigContext } from "../App";
8+
import ResponsiveDrawerView from "./ResponsiveDrawerView";
9+
import Typography from "@material-ui/core/Typography";
10+
11+
export default class Connected extends Component {
12+
constructor(props) {
13+
super(props);
14+
this.routes = props.fcConfig.routes;
15+
this.routeFeatures = props.fcConfig.routeFeatures;
16+
this.state = {
17+
theme: props.theme,
18+
isBxF: props.fcConfig.isBxF,
19+
pid_profile: props.fcConfig.currentPidProfile,
20+
rate_profile: props.fcConfig.currentRateProfile,
21+
craftName: props.fcConfig.name,
22+
isDirty: false,
23+
mobileOpen: false,
24+
currentRoute: props.fcConfig.startingRoute
25+
};
26+
}
27+
28+
getRouteFeatures(key) {
29+
if (this.routeFeatures[key]) {
30+
return this.props.fcConfig.features.values
31+
.filter(feat => {
32+
return this.routeFeatures[key].indexOf(feat.id) > -1;
33+
})
34+
.map(feature => {
35+
if (feature.hasPort) {
36+
feature.ports = this.props.fcConfig.ports;
37+
}
38+
return feature;
39+
});
40+
}
41+
}
42+
43+
getRouteItems = (fcConfig, sort = false) => {
44+
let keys = Object.keys(fcConfig);
45+
if (sort) {
46+
keys.sort();
47+
}
48+
return keys
49+
.filter(key => {
50+
if (this.state.filterOn) {
51+
return (
52+
fcConfig[key].id &&
53+
fcConfig[key].id.indexOf(this.state.filterOn) > -1
54+
);
55+
}
56+
if (this.state.currentRoute.key === "ADVANCED") {
57+
return fcConfig[key].id && !fcConfig[key].route;
58+
}
59+
return fcConfig[key].route === this.state.currentRoute.key;
60+
})
61+
.map(k => fcConfig[k]);
62+
};
63+
64+
handleDrawerToggle = () => {
65+
if (this.state.mobileOpen) {
66+
FCConnector.pauseTelemetry();
67+
} else {
68+
FCConnector.resumeTelemetry();
69+
}
70+
this.setState({ mobileOpen: !this.state.mobileOpen });
71+
};
72+
73+
handleClickAway = () => {
74+
if (this.state.mobileOpen) {
75+
this.setState({ mobileOpen: false });
76+
}
77+
};
78+
79+
handleSearch = event => {
80+
this.setState({ filterOn: event.target.value });
81+
};
82+
83+
handleSave = () => {
84+
this.setState({ isDirty: false });
85+
return this.props.handleSave().then(config => {
86+
this.setState({ fcConfig: config });
87+
});
88+
};
89+
90+
handleMenuItemClick = key => {
91+
let newRoute = this.routes.find(route => route.key === key);
92+
if (this.state.isDirty) {
93+
// this.handleSave();
94+
//TODO: save EEPROM
95+
}
96+
this.setState({
97+
filterOn: undefined,
98+
mobileOpen: false,
99+
currentRoute: newRoute
100+
});
101+
};
102+
103+
notifyDirty = (isDirty, item, newValue) => {
104+
if (isDirty) {
105+
this.setState({ isDirty: isDirty });
106+
}
107+
};
108+
109+
openAssistant(routeName) {
110+
FCConnector.pauseTelemetry();
111+
this.setState({ openAssistant: true, assistantType: routeName });
112+
}
113+
closeAssistant() {
114+
this.setState({ openAssistant: false, assistantType: "" });
115+
FCConnector.resumeTelemetry();
116+
}
117+
render() {
118+
let contents;
119+
let mergedProfile = this.props.fcConfig;
120+
switch (this.state.currentRoute.key) {
121+
case "PFC":
122+
contents = (
123+
<Paper>
124+
<div>
125+
<Typography variant="h5">IMUF only version</Typography>
126+
</div>
127+
</Paper>
128+
);
129+
break;
130+
default:
131+
contents = (
132+
<ConfigListView
133+
fcConfig={mergedProfile}
134+
features={this.getRouteFeatures(this.state.currentRoute.key)}
135+
notifyDirty={(isDirty, item, newValue) =>
136+
this.notifyDirty(isDirty, item, newValue)
137+
}
138+
items={this.getRouteItems(mergedProfile, true)}
139+
/>
140+
);
141+
break;
142+
}
143+
144+
return (
145+
<Paper className={`connected-root ${mergedProfile.version.fw}`}>
146+
<FCConfigContext.Provider value={mergedProfile}>
147+
<ResponsiveDrawerView
148+
routes={this.routes}
149+
goToImuf={this.props.goToImuf}
150+
fcConfig={mergedProfile}
151+
mobileOpen={this.state.mobileOpen}
152+
onClose={() => {
153+
this.setState({ mobileOpen: false });
154+
}}
155+
handleMenuItemClick={this.handleMenuItemClick}
156+
handleClickAway={this.handleClickAway}
157+
appVersion={this.props.appVersion}
158+
/>
159+
{contents}
160+
</FCConfigContext.Provider>
161+
</Paper>
162+
);
163+
}
164+
}

src/Views/ResponsiveDrawerView.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,15 @@ function ResponsiveDrawer(props) {
7272
style={{ marginBottom: -20, marginLeft: 16 }}
7373
color="textSecondary"
7474
>
75-
<FormattedMessage
76-
id="disconnected.title"
77-
values={{ version: props.appVersion }}
78-
/>
75+
IMUF Flasher
7976
</Typography>
8077

8178
<Divider style={{ marginTop: "30px" }} />
8279
<VersionInfoView
8380
goToImuf={props.goToImuf}
8481
version={props.fcConfig.version}
8582
imuf={props.fcConfig.imuf}
83+
theme={props.theme}
8684
/>
8785
<Divider />
8886
<List style={{ display: "block" }}>

src/Views/VersionInfoView.js

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React, { Component } from "react";
22
import List from "@material-ui/core/List";
33
import MenuItem from "@material-ui/core/MenuItem";
4-
import Popover from "@material-ui/core/Popover";
54
import Launch from "@material-ui/icons/Launch";
6-
import FCConnector from "../utilities/FCConnector";
5+
import Divider from "@material-ui/core/Divider";
76
import { FormattedMessage } from "react-intl";
8-
7+
import CliView from "./CliView/CliView";
98
export default class VersionInfoView extends Component {
109
constructor(props) {
1110
super(props);
1211

1312
this.goToImuf = props.goToImuf;
1413
this.state = props.version;
1514
this.state.open = false;
15+
this.state.theme = props.theme;
1616
}
1717

1818
handleClick = event => {
@@ -31,54 +31,45 @@ export default class VersionInfoView extends Component {
3131
};
3232
render() {
3333
return (
34-
<MenuItem style={{ display: "flex" }} onClick={this.handleClick}>
35-
<FormattedMessage id="common.version-info" />
36-
<Popover
37-
open={this.state.open}
38-
anchorEl={this.state.anchorEl}
39-
anchorOrigin={{ horizontal: "left", vertical: "bottom" }}
40-
onClose={() => this.setState({ open: false })}
41-
>
42-
<List>
43-
<MenuItem>
44-
{
45-
<FormattedMessage
46-
id="info.firmware"
47-
values={{ value: this.state.fw }}
48-
/>
49-
}
50-
</MenuItem>
51-
<MenuItem>
52-
{
53-
<FormattedMessage
54-
id="info.target"
55-
values={{ value: this.state.target }}
56-
/>
57-
}
58-
</MenuItem>
59-
<MenuItem style={{ display: "flex" }}>
60-
<div style={{ flexGrow: 1 }}>
61-
<FormattedMessage
62-
id="info.version"
63-
values={{ value: this.state.version }}
64-
/>
65-
</div>
66-
<Launch onClick={() => FCConnector.goToDFU(this.state)} />
67-
</MenuItem>
68-
{this.state.imuf && (
69-
<MenuItem style={{ display: "flex" }}>
70-
<div style={{ flexGrow: 1 }}>
71-
<FormattedMessage
72-
id="info.imuf"
73-
values={{ value: this.state.imuf }}
74-
/>
75-
</div>
76-
<Launch onClick={() => this.goToImuf()} />
77-
</MenuItem>
78-
)}
79-
</List>
80-
</Popover>
81-
</MenuItem>
34+
<List>
35+
<MenuItem>
36+
{
37+
<FormattedMessage
38+
id="info.firmware"
39+
values={{ value: this.state.fw }}
40+
/>
41+
}
42+
</MenuItem>
43+
<MenuItem>
44+
{
45+
<FormattedMessage
46+
id="info.target"
47+
values={{ value: this.state.target }}
48+
/>
49+
}
50+
</MenuItem>
51+
<MenuItem style={{ display: "flex" }}>
52+
<div style={{ flexGrow: 1 }}>
53+
<FormattedMessage
54+
id="info.version"
55+
values={{ value: this.state.version }}
56+
/>
57+
</div>
58+
</MenuItem>
59+
{this.state.imuf && (
60+
<MenuItem style={{ display: "flex" }}>
61+
<div style={{ flexGrow: 1 }}>
62+
<FormattedMessage
63+
id="info.imuf"
64+
values={{ value: this.state.imuf }}
65+
/>
66+
</div>
67+
<Launch onClick={() => this.goToImuf()} />
68+
</MenuItem>
69+
)}
70+
<Divider style={{ marginTop: "10px", marginBottom: "10px" }} />
71+
<CliView theme={this.state.theme} />
72+
</List>
8273
);
8374
}
8475
}

src/translations/cn.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"route.ADVANCED": "ADVANCED",
102102
"safety.remove-props": "Please remove the propellers from your quad before proceeding!",
103103
"safety.accepts-risk": "I ACCEPT",
104-
"disconnected.title": "Nemesis v{version}",
104+
"disconnected.title": "IMUF Flasher",
105105
"disconnected.headline": "Please connect a compatible FC",
106106
"disconnected.autodetect": "We will automatically detect it...",
107107
"disconnected.incompatible": "Incompatible device, there be dragons ahead...",

src/translations/cz.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"route.ADVANCED": "ADVANCED",
102102
"safety.remove-props": "Please remove the propellers from your quad before proceeding!",
103103
"safety.accepts-risk": "I ACCEPT",
104-
"disconnected.title": "Nemesis v{version}",
104+
"disconnected.title": "IMUF Flasher",
105105
"disconnected.headline": "Please connect a compatible FC",
106106
"disconnected.autodetect": "We will automatically detect it...",
107107
"disconnected.incompatible": "Incompatible device, there be dragons ahead...",

src/translations/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"route.ADVANCED": "ADVANCED",
102102
"safety.remove-props": "Please remove the propellers from your quad before proceeding!",
103103
"safety.accepts-risk": "I ACCEPT",
104-
"disconnected.title": "Nemesis v{version}",
104+
"disconnected.title": "IMUF Flasher",
105105
"disconnected.headline": "Please connect a compatible FC",
106106
"disconnected.autodetect": "We will automatically detect it...",
107107
"disconnected.incompatible": "Incompatible device, there be dragons ahead...",

src/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"route.ADVANCED": "ADVANCED",
113113
"safety.remove-props": "Please remove the propellers from your quad before proceeding!",
114114
"safety.accepts-risk": "I ACCEPT",
115-
"disconnected.title": "Nemesis v{version}",
115+
"disconnected.title": "IMUF Flasher",
116116
"disconnected.headline": "Please connect a compatible FC",
117117
"disconnected.autodetect": "We will automatically detect it...",
118118
"disconnected.incompatible": "Incompatible device, there be dragons ahead...",

0 commit comments

Comments
 (0)