Skip to content

How Does the LED Sign Work?

Evan Ugarte edited this page Oct 4, 2023 · 8 revisions

The infrastructure to print pages from the SCE website works well to control other peripherals. Writing to the LED sign is slightly simpler than printing and only involves Core-v4, AWS SQS and a Quasar. Below is a high level diagram of the sign messaging system.

How Website Talks to LED Sign

To demonstrate the functionality of the LED sign, let's start at Core-v4's webpage to update the sign.

Explanation of Each Component

Core-v4

A request is made through Core-v4's led sign page:

example request

When the user fills out the required fields and hits submit, it will make a post request to the SCE backend in Core-v4/src/APIFunctions/LedSign.js:53. For more information about Core-v4's code structure, check the respective wiki page.

Core-v4's backend recieves the request in Core-v4/api/peripheral_api/routes/LedSign.js:22 which sends the update sign request to AWS SQS

Pushing Messages to SQS

After the user submits data to update the sign, Core-v4's backend pushes a message to a Queue in Amazon's Simple Queue Service (SQS). Below is an example message pushed to the queue:

{
    "scrollSpeed": 25,
    "backgroundColor": "#0000FF",
    "textColor": "#00FF00",
    "borderColor": "#FF0000",
    "text": "Welcome to SCE!",
}
  • Note: the range of the scrollSpeed field is 0-50

Once Quasar recieves a message from the LED queue, the message's data is sent to the LED sign in the form of an HTTP request. The LED sign has a REST API Quasar uses to write messages to it. If the LED sign has an IP address of 10.8.0.1, Quasar would send a request to http://10.8.0.1/api/update-sign, with the message data encoded as JSON in the HTTP request body.

The Physical LED Sign

The LED sign is running a Python server using Flask and can be found at SCE-Development/rpi-led-controller. The code to recieve HTTP request from Quasar can be found on SCE-Development/rpi-led-controller/server.py:60. The handler makes use of the SignMessage class to write to the sign. It converts the data from the HTTP request to a shell command on SCE-Development/rpi-led-controller/sign_message.py:18.

On the sign, the received message translates to the command:

./sce_sign.exe \
 --set-speed <speed> px/vsync \
 --set-background-color <background color>
 --set-font-color <font color> \
 --set-border-color <border color> \
 --set-font-filename ./10x20.bdf \
 --set-brightness 66% \
 --set-text <text here>

the sign would show the message with the below colors:

Fun Facts

  1. This sign was built as a group project lead by @kammce a long long time ago.
  2. The actual text scrolling algorithm can be found in the aforementioned project's repo, kammce/sce-led-sign.
  3. SCE initially controlled the LED sign remotely with gRPC, specifically SCE-Development/led_sign/led_sign_server.py:42