This article was translated to English, and was originally published for deviceplus.jp.
The second entry in our “Crystal Signal Pi” series will focus on the middleware.
On Crystal Signal Pi middleware, there are four menus on the panel: “Control Panel,” “Log,” “Settings,” and “ctrl.” Because you can easily check on the light-up patterns, it’ll be extremely helpful when working on DIY projects using Crystal Signal Pi in the future.
Let’s look at how to view and use each screen.
In this article, we’ll be using the same Raspberry Pi setup that we used last time.
As soon as you access the Raspberry Pi IP address from the browser, we’ll get started. The IP address used in this article is “192.168.0.9.”
The ‘Control Panel’ and ‘Ctrl’ Screens
On the “Control Panel” screen, running the “Alarm Setting” from the Crystal Signal Pi browser will bring up the “Status Response” window. The “Status Response” window is where you’ll find the “Ctrl” screen.
For more info on how to use the tools check out the Software User Manual, or for English information check out GitHub (As of August 2017, it seems like GitHub has the newer version).
How to use Web UI Function
By moving the slider around, you can control the LED color (RGB value) and the speed of the light flash here.
Light up/Light flash/De-synchronized flashing buttons can all be switched here.
De-synchronized flashing is a function that makes the RGB colors change simultaneously with each light flash. While the lights are flashing, the colors will change as well.
infoText contains the service agreement
You can choose HTML and JSON for the application response display.
Clicking on the “Turn off alert” button will turn off the LED lights.
Clicking on the “Send” button will set your alerts to the current settings.
There are three light-up types for the LED lights. You can set these up by using the buttons.
The standard “Light up” function where the LED light illuminates with a designated color of your choice
The “Light flash” function that flashes the LED light continuously
The “De-synchronized flashing,” which combines the “Light flash” function with randomized colors (For a better idea on the “De-synchronized flashing” function, refer to the video link in the “Setting up the LED” part of the article of this series)
Selecting a color can be done here by moving around the slider. For a more detailed breakdown on each programming, refer to the table from the “How to use API functions” PDF.
How to use API functions
The value for each LED RGB can be set from a scale of 0 to 255
This selects the “Light up”/”Light flash” function for the LED. Setting the value at 0 will put it at “Light up,” 1 for “Light flash,” and 2 for “De-synchronized flashing.” The default value is set at 0.
When this is set at mode=1, this selects the flashing lights at intervals of a millisecond. The default value is at 1000 (per sec).
When this is set at mode=1, this selects the number of flashes. The default value is set at 0 (Unlimited).
This selects when an alert will occur and stop. The default value is at 0, meaning an alert will occur (LED lights will light up). Selecting ack=1, regardless of other parameters, will turn off the LED light.
Selecting json=1 will send the current Crystal Signal Pi settings by JSON format. When this happens, it’ll ignore all other parameters. This is a parameter for acquiring the current settings without side effects from shell script etc.
This contains the service agreement.
The color select on the upper left side of the screen can be adjusted easily.
The upper right slider, “period,” is the interval between light flashes. This is very effective whenever “Light flash” or “De-synchronized flashing” is being implemented. The larger the values are, the slower the changes between flashes become, creating a fade-in fade-out type of effect. In addition, even if the value is the same for “Light flash” and “De-synchronized flashing,” the speed will be different between the two (“Light flash” is the faster of the two).
The “repeat” function at the bottom controls the number of flashes for the LED light. This is active only when “Light flash” is being implemented. At 0, the number of flashes will be set at unlimited.
“Info Text” allows you to set the character strings for the service agreements.
The URL character string with parameters included is automatically displayed on the “QueryString” column.
For example, when setting up the parameters for the middleware in the beginning, a URL like below will be displayed (Clicking on the “Send” button brings up the window).
<strong>http://（Raspberry Pi IP Address）/ctrl/?color=100,80,0&mode=0&repeat=0&period=1000&json=0</strong>
Moving the sliders, pressing on the buttons, or just playing around with any of the operations will begin each function every time (it will run send). When stopping an operation, try pressing on the “Turn off alert” button. Or, if you’d like to resume with the same values, press the “Send” button.
This is the “Status Response” window. When inputting “Html” in the response window, info on parameters will be displayed on this window.
When “Json” is selected, the character string will be in JSON format like in Fig. 3. It looks like this method is used for whenever you’d like to pass along any of the values to the programmer’s side.
On the “Log” screen, you can look at and check all past operations done on “Crystal Signal Pi.”
Whenever operations are done on the browser, the logs will be changed in real time accordingly. However, the logs aren’t updated automatically when there have been changes to the program or button operations (We’ll get to that later). Instead, you’d have to use the “Update Log” button.
Although the log data isn’t saved permanently, use “Delete Log” whenever you’d like to delete a recent login manually.
When an alert is on, it’ll display “pending” in the status line with each line highlighted in red like in Fig. 4.
Clicking on the “Turn off alert” button will switch the alert off and change the status to “acknowledge” with a green background indicating this.
When a LED light isn’t lit up even though an alert has been turned on (red background color), such if you were to have RGB set at all 0, for example, the system will think that the number of flashes have been met when set at “Light flash.” This is convenient for times when you can’t tell just by the way the LED is flashing.
If you were to click on the “Parameter” line, it’ll bring up the speech bubble indicating all the parameters.
Admittedly, the first time I saw the “Button Settings” window made me realize that these buttons even existed. It was then that I started looking for where that one main “button” could be.
On the acrylic board, there’s a round, orange-colored part totally removed from everything else. This is the button for Crystal Signal Pi. I wonder if it’s because of the size, but the button is a little sturdy (try pushing it all the way until you hear a click). Afterward, hold down the button for a while for it to register.
You can set total of four operations; “normal short push” and “long push,” for both “while ON” and “while OFF”.
Clicking on the drop-down window will display a list of all the programs that can be used. By default, there are three types of scripts prepared (As of August 2017).
Ack.sh: Deletes all alerts
AckNewestOnly.sh: Deletes the newest alert
AlarmSound.sh: An alert in a female voice will repeat twice, “Alert Occurring”（Voice file：/var/lib/crystal-signal/sounds/alarm.wav)
“Ack.sh” and “AckNewestOnly.sh” show the difference when multiple alerts are generated. In Fig. 10, after two alerts have been sent, it’ll register as if each script has been implemented via button. (In the Fig.10, to tell by the IP the alerts were sent from two different IPs, one from each IP.)
“Ack.sh” deletes all the alerts. For “AckNewestOnly.sh,” only new alerts (alerts sent from the top row/after) will be deleted, placing previous settings active.
Going to “Light up” and setting the “Standard push” to “AckNewestOnly.sh,” we tried sending out alerts from two terminals.
After sending five alerts from orange→yellow→white→pink→blue, in that order, for the first button operation, we went back to pink, and then continued with white→yellow→orange→turn off. Doing it like that, you can always go back one step before.
Each program file is stored in the location below. Whenever you want to add new programs, try making them in this directory.
Even if “Implement after an alert has occurred” in “General Settings” is toggled on, you can set this operation up as you would with a button. In the “Light setting,” you can set the brightness of the LED from 40% to 100%.
This setting will be saved even after a restart or reboot.
That goes over how to use the middleware on Crystal Signal Pi.
By looking at how to play around with the middleware, we got a good idea of what kind of functions Crystal Signal Pi can handle.
In next article, let’s try making some tools on Crystal Signal Pi!