This repository has been archived on 2023-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
old-monorepo/Dashboard/src/App.tsx

71 lines
1.5 KiB
TypeScript
Raw Normal View History

import React from "react";
import SerialPort from "serialport";
import { createGlobalStyle } from "styled-components";
2021-07-10 12:00:50 +02:00
import Knob from "./Components/Knob";
const GlobalStyle = createGlobalStyle`
html {
border-style: solid;
border-color: #363636;
border-width: 1px;
box-sizing: border-box;
height: 100%;
border-bottom-style: hidden;
border-right-style: hidden;
}
`;
2021-07-09 13:54:25 +02:00
const App = () => {
const port = new SerialPort("COM5", {
baudRate: 9600,
autoOpen: false,
});
const handler = () => {
// eslint-disable-next-line
port.write("off", (err) => {
if (err) {
return console.log("Error on write: ", err.message);
}
console.log("message written");
});
};
return (
<div>
<GlobalStyle />
2021-07-10 14:59:10 +02:00
<Knob increase={() => { console.log("inc"); }} decrease={() => { console.log("dec"); }} toggle={() => { console.log("togg"); }} />
<button
type="button"
onClick={() => {
port.open();
}}
>
open
</button>
<button
type="button"
onClick={() => {
port.close();
}}
>
close
</button>
2021-07-10 12:00:50 +02:00
<button type="button" onClick={handler}>
send
</button>
2021-06-30 09:51:39 +02:00
<button
type="button"
onClick={() => {
const list = SerialPort.list();
2021-07-10 12:00:50 +02:00
list.then((arg) => {
console.log(arg);
});
2021-06-30 09:51:39 +02:00
}}
>
list
</button>
</div>
);
};
export default App;