Does anyone know what the LCD4Linux project is? Yes, it is a design that allows various information to be displayed on the LCD via USB. You need a module, a display, and your own or someone else’s soldering skills. I will not argue – this is a good project, I have two displays myself.
There is also another way. On the auction site you can buy cheap tablet or tablet with a damaged battery with Android system. The problem is writing or finding an application that will display the information on an Android device. For this purpose, I wrote the LCD4Android application.
2. What is LCD4Android
LCD4Android is an Android application that allows you to view various data on your Android device.
Features:
free,
no ads (why silt the system?),
runs Android 4.4 KitKat up,
does not allow the screen to turn off during operation,
the data is displayed on a web browser form based on the WebKit engine,
knowledge of HTML and preferably also JavaScript is required,
data can be received: from the server, via Bluetooth, or via USB.
3. License, Sources and Installation
I grant a license CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)
Source is on github (https://github.com/nitro2010/LCD4Android)
There is also the latest version of the application – click on ‘Releases’ and LCD4Android-version.apk. You just need to install this application yourself – via ADB, AirDroid, you can also transfer it to an SD card via a USB cable and install the application from the file manager there. The application is not in the Google Play Store. The APK version I release is signed with a key.
4. Use
Warning! The examples and programs were tested on Linux Mint
After installing, run the application. The application will run in full screen without any bars, horizontally, the application will not allow the screen lock to start. Additional options are available under the MENU phone button.
As mentioned earlier, the application displays the data in HTML format, with some JavaScript admixed.
The application displays information on the browser form with the following settings:
- no horizontal and vertical sliding sliders (sliding is still possible with your finger),
- JavaScript enabled,
- popup option disabled,
- zoom buttons disabled
- implemented “AndroidJS” interface for communication between JavaScript and Android
The application currently supports 3 modes of obtaining information, which are available in MENU => Choose connection type:
5. WWW server
In this mode, data is downloaded from the web server. We set up an HTTP server wherever we want, we create pages that read data from the server, or “display something”. Transitions between pages can be made by adding e.g.
where after 10 seconds the page will go to the page named screen2.html
As an example, I created 2 pages: datetime.html (which displays the current date and time) and memory.html (which shows the amount of memory used on Linux). Both scripts use jQuery. Additionally, we have the memory.used.sh script in Bash, which saves the current memory usage to the memory.used.txt file. We should call it every second, for example:
while [ 1 ]; do ./memory.used.sh ; sleep 1; done
In the application, change the URL: MENU -> Change URL to Server to the server address. For me it is: 192.168.1.185:8080/datetime.html, we approve and we have information from the server.
On the server, we can do what we want and in what language we want, as long as the result to the browser will be sent in accordance with text / html and utf-8 encoding.
You should also remember that our information does not extend beyond the device screen.
Source codes: lcd4android_conn_www.zip (you can download from Download -> Scripts)
6. Bluetooth
In this mode, we can send data (text) from another device. After selecting this mode, we will get a message on the screen “I am waiting for data from Bluetooth Device”. The device listens on 2 channels: safe and unsafe. The type can be selected from the MENU, but it’s better to leave both. You only need to write an application that will send the text to our main application.
Safe Channel ID: a1869bd4a0d647a3886db8d7579f8cc7
Dangerous channel ID: 4f41adbe088a48b3b77db90a5b65d7e8
For testing purposes, I created a JAVA application that uses the BlueCove library to transfer data via Bluetooth.
Application sources: JavaBluetoothEchoClient.zip (you can download from Download -> Scripts)
Application: bluetooth_client.jar (you can download from Download -> Programs)
It can be called from Windows and Linux.
First, we create a file called, say, file.txt with any text. We can also add HTML tags.
java -jar bluetooth_client.jar discovery – shows all nearby Bluetooth devices that have visibility set.
java -jar bluetooth_client.jar service-secure FILE DEVICE – sends the contents of FILE via a secure channel [enter the path to this file] to the device DEVICE [enter the device ID].
java -jar bluetooth_client.jar service-insecure FILE DEVICE – sends the content via a dangerous channel FILE [we enter the path to this file] to the device DEVICE [we enter the device ID].
An example of the operation can be seen in the screenshot below:
7. USB cable
In this mode, data is read via the USB cable. More precisely, data is sent to the phone and the data is read from the phone. Data can be sent via ADB. We can send all html and javascript files to the phone at once.
Here is the procedure:
- We create the main file named: lcd4android.html. In this file we put the main and essential part of our application. For this we provide various javascript files that are needed for our application.
- We pack our files into one zip archive.
- We send the data to the phone. And here is the dependence from which one location the application can read:
/data/data/eu.webnitro.lcd4android/files/ – internal folder in the system
/storage/sdcardX/eu.webnitro.lcd4android/files/ – folder on internal or external card
additionally the application will read one of the two folders named 0 or 1. Folders are meant to sync. If the application is currently reading from folder 0, send to 1, if from 1 to 0.
We extract the files on the phone from the archive.
We send the lcd4android.page file as a synchronization file.
The application reads the synchronization file every 5 seconds, whether it has come to change the folder and reads another html file.
Warning! You can also send via ADB wirelessly, just install a program on the phone, e.g. adb wifi.
For this purpose, I have created the BASH script adb_shell.sh for the Linux platform (you can download it from the Download -> Scripts section)
It’s important to have adb installed on your system.
My script can send data via ADB via WiFi or USB.
This mode is set in the type_connection variable – if we want to send via USB, set it as usb, if via wifi – net.
Then, depending on the connection type – if we chose WiFi, set the connection_net variable, where we enter the IP address and port on which ADB works on the phone, if we chose USB in the connection_usb variable, we enter the phone ID. We can get it via adb devices.
In the path_files variable we set where we have saved html and javascript files that are to be loaded to the phone.
The rest of the section is broken down depending on which connection you choose, but both parts do the same:
– get the path where the files are to be loaded from the application settings file
– packs files from a given folder on our computer
– determines to which folder 0 or 1 the zip archive will be loaded
– send the archive to a folder on the phone
– extract files on the phone
– send a sychronization file
This way, new content should appear on your phone.
As an example, I used the clock from the previous section. Just load the archive and the clock will appear on the phone screen.
Note: In version 0.6 there is a problem that if we use usb, after closing and restarting the application, it is not known why it reads the file from folder 0. The reason is the Constants.USB_PAGE variable which takes the value 0 even if the synchronization file does not exist. Fortunately, if 2 new content comes, it will be displayed.
Source codes: lcd4android_clock.zip (you can download from the Download section -> Scripts)
AndroidJS interface
A special interface called AndroidJS, which connects JavaScript to Android, has been implemented in the application. Not everything can be done with JS on Android. Currently it allows you to play the alarm under the PlayAlert () function. Other helpful features can also be added.
PlayAlert () – plays a sound file – alarm on the phone
As an example, a bar has been created, where a new value appears every second, when it exceeds 90%, a sound is heard.
This function can be used when, for example, there is insufficient memory in the system.
Remember to manually adjust the audio volume yourself.
Source codes: lcd4android_randomprocessor.zip (you can download from the Download section -> Scripts)
MENU options:
|- Server WWW (Serwer WWW)
|- Bluetooth
|- Choose USB (Wybierz USB)
———————————————————————-
|- Change URL to Server (Zmień URL do Serwera)
|- Reload (Przeładuj [formatkę do wyświetlania informacji])
———————————————————————-
|- BT Connection type (Typ połączenia Bluetooth)
|—|- Secure connection (Bezpieczne połączenie)
|—|- Insecure connection (Niebezpieczne połączenie)
|—|- Secure and Insecure connection (Połączenie bezpieczne i niebezpieczne)
|—|- Make discoverable (Stwórz widzialnym urządzenie)
|—|- Pairing devices (Paruj urządzenia)
———————————————————————-
|- USB: Choose Storage (wybierz magazyn)
———————————————————————-
|- Close app (Zamknij aplikację)
A: In my opinion server or USB connection. In these types you can display javascript and pictures. Only static text in Bluetooth.
2. Will there be any server application for the server type?
A: Maybe, but only for Linux.
3. Can I somehow develop the project?
A: Of course, if you see bugs that you can fix, or if you developed a project with some significant features, you can download the project from github to your computer, work on your copy and send the best results to me on github. New requests to merge files will appear in the project in the Pull Requests section. I will see if the new changes are worthwhile.