During this week I decided to create application which will be connected to my Hall sensor board from “Input devices” week, will read incoming levels and show it on the screen.
As I am working as front-end developer and using JavaScript every day, I choose this language for implementation.
I want application to work everywhere, so I need to choose cross-platform solution. Electron framework is such solution.
Impressing list of apps, build on Electron:
I can bootstrap the application, by cloning the repository, as recommended in tutorial
git clone https://github.com/electron/electron-quick-start
After this, I have project template, ready to fill it with features.
For installing dependencies, I should type in console npm run install
For development, I can type in console npm run start
.
As I’m working with board via serial interface, I need library which will send and receive data through serial port. I searched some time and found serialport
npm package, which utilizes this function.
What I should do is just type npm i serialport –save
in my console, to install this package as dependency.
Main functions from this library is:
create connection to port
const port = new SerialPort(magPort.comName, { baudRate: 9600 })
and then properly set up parser
var ByteLength = SerialPort.parsers.ByteLength
var parser = port.pipe(new ByteLength({length:1}));
All next actions dependent on what you want. in my case, I animate slider using received value of magnetic field.
Full repository I pushed to GitHub: