From 760b8d06d0474e09ffa9eb61c7ac3bc25d69819b Mon Sep 17 00:00:00 2001 From: Ghost <31184695+GHOSCHT@users.noreply.github.com> Date: Sat, 1 Aug 2020 15:43:34 +0200 Subject: [PATCH] First test of serial control --- Dashboard/app/renderer/components/Test.js | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dashboard/app/renderer/components/Test.js diff --git a/Dashboard/app/renderer/components/Test.js b/Dashboard/app/renderer/components/Test.js new file mode 100644 index 0000000..dd17330 --- /dev/null +++ b/Dashboard/app/renderer/components/Test.js @@ -0,0 +1,47 @@ +import React, { useState } from 'react'; +import { useSelector, useDispatch } from 'react-redux/'; + +export default function Test() { + const comConnection = useSelector((state) => state.comConnectionReducer); + const [comData, setComData] = useState(''); + + comConnection.parser.on('data', (data) => { + setComData(data); + }); + + const triggerOn = () => { + comConnection.port.write('on'); + }; + const triggerOff = () => { + comConnection.port.write('off'); + }; + + const triggerOne = () => { + comConnection.port.write('0'); + }; + const triggerTwo = () => { + comConnection.port.write('1'); + }; + + return ( +
{comData}
+