Comment out currently unused code
This commit is contained in:
parent
ef131929b9
commit
1826475284
1 changed files with 42 additions and 44 deletions
|
@ -1,8 +1,6 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
import { useSelector } from "react-redux";
|
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { RootState } from "typesafe-actions";
|
// import { RootState } from "typesafe-actions";
|
||||||
import Knob from "./Knob";
|
|
||||||
|
|
||||||
const KnobContainer = styled.div`
|
const KnobContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -10,47 +8,50 @@ justify-content: space-between;
|
||||||
margin: 1rem;
|
margin: 1rem;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const KnobSection = () => {
|
const KnobSection = () =>
|
||||||
const [status, setStatus] = useState([{ id: 0, value: 0 }, { id: 1, value: 0 }, { id: 2, value: 0 }, { id: 3, value: 0 }]);
|
// const [status, setStatus] = useState([{ id: 0, value: 0 }, { id: 1, value: 0 }, { id: 2, value: 0 }, { id: 3, value: 0 }]);
|
||||||
const serialConnection = useSelector<RootState, RootState["serialConnection"]>((state) => state.serialConnection);
|
// const serialConnection = useSelector<RootState, RootState["serialConnection"]>((state) => state.serialConnection);
|
||||||
|
|
||||||
const SerialDataListener = (data: string) => {
|
// const SerialDataListener = (data: string) => {
|
||||||
const parsedData = data.split(",");
|
// const parsedData = data.split(",");
|
||||||
console.log(parsedData);
|
// console.log(parsedData);
|
||||||
setStatus(status.map((element) => ({ ...element, value: parseInt(parsedData[element.id], 10) })));
|
// setStatus(status.map((element) => ({ ...element, value: parseInt(parsedData[element.id], 10) })));
|
||||||
};
|
// };
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (serialConnection.portController !== null) {
|
// if (serialConnection.portController !== null) {
|
||||||
serialConnection.portController.parser.on("data", SerialDataListener);
|
// serialConnection.portController.parser.on("data", SerialDataListener);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return () => {
|
// return () => {
|
||||||
if (serialConnection.portController !== null) {
|
// if (serialConnection.portController !== null) {
|
||||||
serialConnection.portController.parser.removeListener("data", SerialDataListener);
|
// serialConnection.portController.parser.removeListener("data", SerialDataListener);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}, [serialConnection]);
|
// }, [serialConnection]);
|
||||||
|
|
||||||
const sendIncreaseHandler = (index: number) => {
|
// const sendIncreaseHandler = (index: number) => {
|
||||||
if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
// // if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||||
serialConnection.portController.port.write(`${index}i`);
|
// // serialConnection.portController.port.write(`${index}i`);
|
||||||
}
|
// // }
|
||||||
};
|
// console.log(index);
|
||||||
const sendDecreaseHandler = (index: number) => {
|
// };
|
||||||
if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
// const sendDecreaseHandler = (index: number) => {
|
||||||
serialConnection.portController.port.write(`${index}d`);
|
// // if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||||
}
|
// // serialConnection.portController.port.write(`${index}d`);
|
||||||
};
|
// // }
|
||||||
const sendToggleHandler = (index: number) => {
|
// console.log(index);
|
||||||
if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
// };
|
||||||
serialConnection.portController.port.write(`${index}t`);
|
// const sendToggleHandler = (index: number) => {
|
||||||
}
|
// // if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||||
};
|
// // serialConnection.portController.port.write(`${index}t`);
|
||||||
|
// // }
|
||||||
return (
|
// console.log(index);
|
||||||
|
// };
|
||||||
|
// eslint-disable-next-line implicit-arrow-linebreak
|
||||||
|
(
|
||||||
<KnobContainer>
|
<KnobContainer>
|
||||||
{status.map((element) => (
|
{/* {status.map((element) => (
|
||||||
<Knob
|
<Knob
|
||||||
key={element.id}
|
key={element.id}
|
||||||
increase={() => { sendIncreaseHandler(element.id); }}
|
increase={() => { sendIncreaseHandler(element.id); }}
|
||||||
|
@ -58,10 +59,7 @@ const KnobSection = () => {
|
||||||
toggle={() => { sendToggleHandler(element.id); }}
|
toggle={() => { sendToggleHandler(element.id); }}
|
||||||
status={Math.floor((element.value / 255) * 100)}
|
status={Math.floor((element.value / 255) * 100)}
|
||||||
/>
|
/>
|
||||||
))}
|
))} */}
|
||||||
</KnobContainer>
|
</KnobContainer>
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
export default KnobSection;
|
export default KnobSection;
|
||||||
|
|
Reference in a new issue