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 { useSelector } from "react-redux";
|
||||
import React from "react";
|
||||
import styled from "styled-components";
|
||||
import { RootState } from "typesafe-actions";
|
||||
import Knob from "./Knob";
|
||||
// import { RootState } from "typesafe-actions";
|
||||
|
||||
const KnobContainer = styled.div`
|
||||
display: flex;
|
||||
|
@ -10,47 +8,50 @@ justify-content: space-between;
|
|||
margin: 1rem;
|
||||
`;
|
||||
|
||||
const KnobSection = () => {
|
||||
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 KnobSection = () =>
|
||||
// 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 SerialDataListener = (data: string) => {
|
||||
const parsedData = data.split(",");
|
||||
console.log(parsedData);
|
||||
setStatus(status.map((element) => ({ ...element, value: parseInt(parsedData[element.id], 10) })));
|
||||
};
|
||||
// const SerialDataListener = (data: string) => {
|
||||
// const parsedData = data.split(",");
|
||||
// console.log(parsedData);
|
||||
// setStatus(status.map((element) => ({ ...element, value: parseInt(parsedData[element.id], 10) })));
|
||||
// };
|
||||
|
||||
useEffect(() => {
|
||||
if (serialConnection.portController !== null) {
|
||||
serialConnection.portController.parser.on("data", SerialDataListener);
|
||||
}
|
||||
// useEffect(() => {
|
||||
// if (serialConnection.portController !== null) {
|
||||
// serialConnection.portController.parser.on("data", SerialDataListener);
|
||||
// }
|
||||
|
||||
return () => {
|
||||
if (serialConnection.portController !== null) {
|
||||
serialConnection.portController.parser.removeListener("data", SerialDataListener);
|
||||
}
|
||||
};
|
||||
}, [serialConnection]);
|
||||
// return () => {
|
||||
// if (serialConnection.portController !== null) {
|
||||
// serialConnection.portController.parser.removeListener("data", SerialDataListener);
|
||||
// }
|
||||
// };
|
||||
// }, [serialConnection]);
|
||||
|
||||
const sendIncreaseHandler = (index: number) => {
|
||||
if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||
serialConnection.portController.port.write(`${index}i`);
|
||||
}
|
||||
};
|
||||
const sendDecreaseHandler = (index: number) => {
|
||||
if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||
serialConnection.portController.port.write(`${index}d`);
|
||||
}
|
||||
};
|
||||
const sendToggleHandler = (index: number) => {
|
||||
if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||
serialConnection.portController.port.write(`${index}t`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
// const sendIncreaseHandler = (index: number) => {
|
||||
// // if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||
// // serialConnection.portController.port.write(`${index}i`);
|
||||
// // }
|
||||
// console.log(index);
|
||||
// };
|
||||
// const sendDecreaseHandler = (index: number) => {
|
||||
// // if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||
// // serialConnection.portController.port.write(`${index}d`);
|
||||
// // }
|
||||
// console.log(index);
|
||||
// };
|
||||
// const sendToggleHandler = (index: number) => {
|
||||
// // if (serialConnection.portController !== null && serialConnection.portController.port !== null) {
|
||||
// // serialConnection.portController.port.write(`${index}t`);
|
||||
// // }
|
||||
// console.log(index);
|
||||
// };
|
||||
// eslint-disable-next-line implicit-arrow-linebreak
|
||||
(
|
||||
<KnobContainer>
|
||||
{status.map((element) => (
|
||||
{/* {status.map((element) => (
|
||||
<Knob
|
||||
key={element.id}
|
||||
increase={() => { sendIncreaseHandler(element.id); }}
|
||||
|
@ -58,10 +59,7 @@ const KnobSection = () => {
|
|||
toggle={() => { sendToggleHandler(element.id); }}
|
||||
status={Math.floor((element.value / 255) * 100)}
|
||||
/>
|
||||
))}
|
||||
))} */}
|
||||
</KnobContainer>
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
export default KnobSection;
|
||||
|
|
Reference in a new issue