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

62 lines
1.4 KiB
TypeScript
Raw Normal View History

import React from "react";
import SerialPort from "serialport";
2021-07-09 13:54:25 +02:00
import { remote } from "electron";
2021-07-09 12:34:21 +02:00
import Knob from "../assets/Knob.svg";
const App = () => {
2021-07-09 13:54:25 +02:00
// https://www.electronjs.org/docs/api/system-preferences#systempreferencesgetcolorcolor-windows-macos
console.log(remote.systemPreferences.getColor("active-border")); // border
// https://www.electronjs.org/docs/api/system-preferences#systempreferencesgetaccentcolor-windows-macos
console.log(remote.systemPreferences.getAccentColor()); // accent color
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>
2021-07-09 12:34:21 +02:00
<img src={Knob} alt="Knob" height="180px" />
<button
type="button"
onClick={() => {
port.open();
}}
>
open
</button>
<button
type="button"
onClick={() => {
port.close();
}}
>
close
</button>
<button type="button" onClick={handler}>send</button>
2021-06-30 09:51:39 +02:00
<button
type="button"
onClick={() => {
const list = SerialPort.list();
list.then((arg) => { console.log(arg); });
}}
>
list
</button>
</div>
);
};
export default App;