Proxy LCD – desktop application

In first part we saw a summary (hardware and software) of remote LCD. Such remote LCD works on NodeMCU and can be accessed via network. It was first stage of bigger project.
Now is time for second part, a desktop application. Its main task is to manage remote LCDs and provide a way to send content from computer to display.
One may add/remove node and set a stream option. What is stream option?
App works in two ways (one for now :P, second option in 3rd phase) if it receive content and it is not a proper packet it iterates over all added lcds and streams data to them. Difference between display and stream is that stream as name says is just a data stream and it send chars one after another. When it reaches end of available space on display it starts over.
In case of packet it will send formatted content to node.

Get from GitHub

Part 1 – remote LCD

Upgrades:
CLI on Raspberry Pi

Design

Lets think a little bit about all why? where? when?
Whole design process base on fact that we will use PyQt5, CharLCD and iot_message. In my last app PyQt done its job perfectly so I’m using it further.

We have strongly defined modules in this application. Lets look at them:

To reflect lcd in system we will use CharLCD with WiFi driver. But such entry do not have stream and friendly name property. So lets encapsulate it with Display class. Display is an object with lcd and additional properties.

Good place to store added displays and configuration is an ini file. With just five attributes we may describe lcd. This is a task for config and ConfigParser. This configuration is also our repository for lcd’s. And as with repositories, we may seek, add or delete entries.

tcp_server – it is a threaded TCP server based on QTcpServer. Its task is to get incoming connection and spawn handler for it. Handler’s job is to receive content and pass it further by emitting pyqtSignal.

If something emits a signal, something must connect to it. This something is stream_content. It’s job is to receive content and detect its type. Next step is defined by type. If it is just a text, stream it to all displays with stream enabled. Other type will be defined in 3rd phase of project.

App require GUI and main_view is a good place to keep it. This GUI has a menu, toolbar and huge table with display’s list. We may call add, edit and delete from it.

To add or edit display we need another view with form. And to display the display 🙂 on form we have display_view.

I tried to keep with loose coupling approach and design above modules with it in mind. How it works? Not perfectly:) Like merging configuration and repository in one file. But exp gained and lesson learnt 🙂

All in all everything starts in main file, like starting stream_server, initialize stream_content and launch main view.

Run application

We have a remote LCD. We have an application. What now ?
First we need to do some configuration. Edit settings.ini and set broadcast_ip to your broadcast IP or leave it empty for auto-detection. I have to assign it manually because I have few interfaces and auto only hits wrong one 🙂
Do not forget to set nice node_name.

Lets look at the main app window:
screen1

Main part of app takes table. This table shows added displays. When you select a row you can edit or delete entity.
Add and exit is always visible.

New display require friendly name, remote node name, size and availability for stream.

Testing

How to test all this ?
Run:

telnet 127.0.0.1 5054

and write something:

Hello from the desktop application !

screen_telnet

And the result is:
screen_lcd

Summary

With this app is easy to stream any data from any project to display. Just connect to port 5054 (or yours) and send data.

Just after finishing this post I found the bug. If we send national character display crashes and NodeMCU restarts. Something to fix in near future 🙂

Part 1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s