{"id":25863862,"url":"https://github.com/jonmorrissmith/rgb_matrix_train_departure_board","last_synced_at":"2025-03-02T00:26:46.325Z","repository":{"id":277053842,"uuid":"930528527","full_name":"jonmorrissmith/RGB_Matrix_Train_Departure_Board","owner":"jonmorrissmith","description":"A Raspberry Pi powered RGB Matrix real-time train departure board with optional UI control.","archived":false,"fork":false,"pushed_at":"2025-02-28T14:11:07.000Z","size":3381,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T17:14:03.215Z","etag":null,"topics":["cpp","python","railway-information-portal","raspberry-pi","rgb-matrix","rgb-matrix-bonnet","rgb-matrix-led-panel","train-running-status"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonmorrissmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-10T19:25:38.000Z","updated_at":"2025-02-28T13:14:38.000Z","dependencies_parsed_at":"2025-02-11T22:26:16.437Z","dependency_job_id":"c3561512-c1aa-42cb-b83e-46dabfa6cbbb","html_url":"https://github.com/jonmorrissmith/RGB_Matrix_Train_Departure_Board","commit_stats":null,"previous_names":["jonmorrissmith/rgb_matrix_train_departure_board"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmorrissmith%2FRGB_Matrix_Train_Departure_Board","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmorrissmith%2FRGB_Matrix_Train_Departure_Board/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmorrissmith%2FRGB_Matrix_Train_Departure_Board/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmorrissmith%2FRGB_Matrix_Train_Departure_Board/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonmorrissmith","download_url":"https://codeload.github.com/jonmorrissmith/RGB_Matrix_Train_Departure_Board/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241443436,"owners_count":19963744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","python","railway-information-portal","raspberry-pi","rgb-matrix","rgb-matrix-bonnet","rgb-matrix-led-panel","train-running-status"],"created_at":"2025-03-02T00:26:44.963Z","updated_at":"2025-03-02T00:26:46.309Z","avatar_url":"https://github.com/jonmorrissmith.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RGB Matrix Train Departure Board\nRather than paying rather a lot of money, you can build you're own RGB matrix train departure board.\n\nCurrently configured to show:\n* The next train from your favourite station to your favourite destination\n* Calling points (with optional estimated time of departure)\n* The following two departures\n* Optional display of delay reasons and other messages\n\nAll configured using a light-weight web-page you can access on any device.\n\nComponents are a Raspberry Pi, an interface (Adafruit bonnet), some RGB matrices and a power-supply.\n\n# Motivation\nBeing a life-long train fan I've always wanted my own departure board, and as a regular commuter one which shows my usual route.\n\nOver the years I've looked at flip-dot displays and various other mechanisms and then saw LED dot-matrix displays become available for purchase.\n\nThese look amazing... however the price is staggering, as is the monthly-subscription some require for what is freely available data.\n\nMy thought -  _\"How hard can it be\"_.\n\nAnd here we are - the Raspberry Pi RGB matrix departure board and companion [Raspberry Pi fork of Huxley2](https://github.com/jonmorrissmith/jonms-Huxley2).\n\n# This documentation is evolving\nIn this second version (1st March) there's still gaps, however it's a lot more complete than it was.\n\nHappy to help with any questions - best to do that via github so others can share the wisdom.\n\nUpdates, changes, modifications and enhancements welcome!\n\n# Hardware\n## The TL:DR\n* [Three P2, 5V, 128*64 pixel colour modules with a HUB75E interface from Ali Express](https://www.aliexpress.com/item/32913063042.html)\n* [A 1GB Raspberry Pi 4 from Pimoroni](https://shop.pimoroni.com/products/raspberry-pi-4?variant=31856486416467)\n* [Adafruit RGB Matrix Bonnet for Raspberry Pi from Pimoroni](https://shop.pimoroni.com/products/adafruit-rgb-matrix-bonnet-for-raspberry-pi?variant=2257849155594)\n* A 5V power-supply capable of delivering at least 5 Amps\n\n## Some RGB matrix boards.\nI purchased [three P2, 5V, 128*64 pixel colour modules with a HUB75E interface from Ali Express](https://www.aliexpress.com/item/32913063042.html).\n\nThree is a good size and three is limit for a chain of panels with the matrix library I used.  However you could have up to three rows of three.\n\nThere are a myriad sellers on Ali Express and elsewhere. I suspect there's little to differentiate between offerings.\n\n## A Raspberry Pi\nYou could purchase [a 1GB Raspberry Pi 4 from Pimoroni](https://shop.pimoroni.com/products/raspberry-pi-4?variant=31856486416467) - I'm not plugging Pimoroni, it's just that they also stock the RGB Matrix Bonnet so you can save on postage.\n\nI used a Raspberry Pi 4 which was unloved and needed a new purpose. \n\n**Note** that the RGB matrix library doesn't yet work with a Pi 5. I'll update when it does as the increased power of the Pi 5 will be welcome!\n\n## An RGB matrix-driver \nThis project was built with an [Adafruit RGB Matrix Bonnet for Raspberry Pi from Pimoroni](https://shop.pimoroni.com/products/adafruit-rgb-matrix-bonnet-for-raspberry-pi?variant=2257849155594)\n\nSpecification on the [Adafruit site](https://learn.adafruit.com/adafruit-rgb-matrix-bonnet-for-raspberry-pi).  \n\nIf there are other mechanisms which folk can recommend then let me know!  \n\n## 16 way ribbon cable\nMost sellers provide these with the matrix panels. If you're making your own then your mantra has to be \"Short Is Good\".\n\n## Some power!\nI used a bench-top adjustable power supply to provide 5v and up to 5A for the matrix boards and the Raspberry Pi.\n\nThe nature of the panels means that current can vary quite wildly.  For the departure board with three panels it runs at about 1.5A to 2.0A.\n\nI'd recommend getting something substantial as the \"all pixels on\" power is just around 3.5A with my configuration... and let's face it, you're going to want to play about with it!\n\nThe [Words about power](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/wiring.md#a-word-about-power) in the RGB Matrix documentation is worth a read.\n\n## Anything else on hardware?\nI'd highly recommend reading the detail on the [hzeller rpi-rgb-led-matrix - Let's Do It!](https://github.com/hzeller/rpi-rgb-led-matrix?tab=readme-ov-file#lets-do-it) documentation as it answers every question you can think of.\nIt's an awesome resource and fabulous software. More of that below!\n\n## Putting it all together\nDetails below are for the Adafruit Bonnet\n\nFor other adapters see the [RGB Matrix - wiring](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/wiring.md) documentation.\n\n### Improving Flicker ###\nAs highlighted [here](https://github.com/hzeller/rpi-rgb-led-matrix?tab=readme-ov-file#improving-flicker) in the RGB documentation, an optional change to connect pins 4 and 18 on the hat/bonnet.\n\nI did this by soldering a row of pins to the bonnet and using a modified connector to make it easy to add/remove the modification.\n![Picture of pins and connector](https://github.com/jonmorrissmith/RGB_Matrix_Train_Departure_Board/blob/main/Bonnet_Jumpers.jpg)\n\n### Address E pad modification ###\nAs highlighted [here](https://github.com/hzeller/rpi-rgb-led-matrix?tab=readme-ov-file#new-adafruit-rgb-matrix-hat-with-address-e-pads) in the RBG documentation, a change required for the size and type of panels I used.\n![Picture of soldere blob connecting the two pads](https://github.com/jonmorrissmith/RGB_Matrix_Train_Departure_Board/blob/main/Bonnet_Soldering.jpg)\n\nAs a side note, I had to chop some pins off a connector on the Pi as they hit the bonnet - I suspect I may regret that at some point when the Pi gets used for something else.\n\n### Connecting to the panels ###\n\nOnly thing to watch for is to make sure that your ribbon cables are short and connect from 'Outputs' to 'Inputs' (should be labelled or have an arrow on the matrix boards\n\n### Connecting the power ###\n\nNoting the [advice about power](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/wiring.md#a-word-about-power) in the RGB Matrix documentation.\n\nConnect to the panels and the 5v screw-connectors on the Adafruit bonnet to power to the Raspberry Pi.\n\nAs noted in the documentation, the Raspberry Pi doesn't have enough juice to power the panels.\n\n# Setting up the Raspberry Pi #\n\n## Install the OS ##\n\nThere are more tutorials than you can shake a stick at on how to install an OS on a Raspberry Pi.\n\nI went for the 'OS Lite (64bit)' maximise CPU cycles the matrix driver can use by having a cut-down OS. Set up ssh and Wifi in the Raspberry Pi Imager tool.\n\nOnce installed there was the usual upgrade/update and disable/uninstall anything unecessary.\n\nI would strongly recommend following [using a minimal raspbian distribution](https://github.com/hzeller/rpi-rgb-led-matrix?tab=readme-ov-file#use-minimal-raspbian-distribution) for more detail.\n\nWhat is described what I did in Feb 2025. Detail in the rpi-rgb-matrix repository will be the most recent recommendations.\n\n* Set `dtparam=audio=off` in `/boot/firmware/config.txt`\n* Add `isolcpus=3` **to the end** of the parameters in `/boot/firmware/cmdline.txt` to isolate a CPU.\n* Example - `console=serial0,115200 console=tty1 root=PARTUUID=9f23843a-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=GB isolcpus=3`\n* Remove unecessary services with `sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio`\n\nrun `lsmod` and to check for the snd_bcm2835 module.\n\nExample:\n```\n$lsmod | grep snd_bcm2835\nsnd_bcm2835            24576  0\nsnd_pcm               139264  5 snd_bcm2835,snd_soc_hdmi_codec,snd_compress,snd_soc_core,snd_pcm_dmaengine\nsnd                   110592  6 snd_bcm2835,snd_soc_hdmi_codec,snd_timer,snd_compress,snd_soc_core,snd_pcm\n```\nIf it's there then blacklist it:\n```\ncat \u003c\u003cEOF | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf\nblacklist snd_bcm2835\nEOF\n\nsudo update-initramfs -u\n```\nThen reboot - `sudo reboot` to get a nice clean and sparkly install.\n\n**Note** At the rsk of stating the obvious, when adding options to `cmdline.txt` put them on the same line as the existing arguments. No newlines allowed.\n\n## Installing packages you'll need\nIn no particular order:\n* Git - `sudo apt install git`.\n* JSON for modern C++ - `sudo apt install nlohmann-json3-dev`.\n* curl (should be there already) - `sudo apt install libcurl4`.\n* curl C++ wrappers - `sudo apt install libcurlpp-dev`.\n\n\n## Install the RGB Matrix Software ##\n\nTake a clone of the RPI RGB Matrix repository - `git clone https://github.com/hzeller/rpi-rgb-led-matrix`.\n\nCompile the library\n```\ncd rpi-rgb-matrix\nmake\n```\nA pre-emptive read of the [Troubleshooting section](https://github.com/hzeller/rpi-rgb-led-matrix?tab=readme-ov-file#troubleshooting) will help you get ahead of issues.\n\nEnjoy the demos in the `examples-api-use` directory.\nIf you've got the configuration described here then you can start with this:\n```\nsudo ./demo -D9 --led-rows=64 --led-cols=128 --led-chain=3 --led-gpio-mapping=adafruit-hat\n```\nHave fun!\n\n# So what about the train data? #\nThe source of the data is the [Live Departure Boards Web Service (LDBWS / OpenLDBWS)](https://lite.realtime.nationalrail.co.uk/OpenLDBWS/)\n\nYou'll need to register to be able to access the data - this is pretty straightforward via the [Open LDBWS Registration page](https://realtime.nationalrail.co.uk/OpenLDBWSRegistration).  Make a note of the key (although they email it to you aswell).\n\nI'll include more links later - there is a wealth of information out there on train data and a mind-boggling amount of information you can get access too (although it's not all free).  The [Open Rail Data wiki](https://wiki.openraildata.com/index.php/Main_Page) is an awesome resource as is the list of [Open Rail data repositories](https://github.com/openraildata) here on Github.\n\n**However** the data is only available from Network Rail via SOAP.  Not my forte.  If you're a Python programmer then you can go to the [Open Rail Data repository](https://github.com/openraildata) however, being an old lag and liking the enhanced performance of a compiled executable, C++ was the way to go.  I'm not about to try to ingest SOAP with C++.\n\n## Huxley2 to the rescue ##\nHuxley2 is a cross-platform JSON proxy for the GB railway Live Departure Boards SOAP API and is [here on Github](https://github.com/jpsingleton/Huxley2). More detail on [this site which includes a demo server](https://huxley2.azurewebsites.net).\n\nI've create a fork of Huxley2 with modifications for running locally on a raspberry Pi - [Huxley 2 for Raspberry Pi](https://github.com/jonmorrissmith/jonms-Huxley2).\n\nHowever you can also install on Azure. The instructions for this are fabulous are are available [on this blog post](https://unop.uk/huxley-2-release).\n\nWith the monochrome cofiguration below a local-install doesn't affect performance.\n\nIf you go for colour (or increase `led-pwm-bits` from 1) then you may see fickering when updates happen.\n\n# The final Steps #\n\n## Installing the RGB Matrix Train Departure Board software ##\nFrom this repository - `git clone https://github.com/jonmorrissmith/RGB_Matrix_Train_Departure_Board`\n\nEdit the configuration in config.h in to your default settings\n\n_Note_ - these have been optimised for black and white and speed:\n```\nclass Config {\nprivate:\n    std::map\u003cstd::string, std::string\u003e settings;\n    \n    const std::map\u003cstd::string, std::string\u003e defaults = {\n        {\"from\", \"XXX\"},                                               // Your default origin\n        {\"to\", \"XXX\"},                                                 // Your default destination\n        {\"APIURL\", \"https://XXX\"},                                     // URL for your train data\n        {\"fontPath\", \"/home/XXX/rpi-rgb-led-matrix/fonts/9x18.bdf\"},   // font directory\n        {\"scroll_slowdown_sleep_ms\", \"15\"},                            // Speed of scroll for calling points\n        {\"refresh_interval_seconds\", \"60\"},                            // How often the data refreshes\n        {\"matrixcols\", \"128\"},                                         // number of LED columns in a matrix panel\n        {\"matrixrows\", \"64\"},                                          // number of LED rows in a matrix panel\n        {\"matrixchain_length\", \"3\"},                                   // number of panels chained together\n        {\"matrixparallel\", \"1\"},                                       // number of rows of panels\n        {\"matrixhardware_mapping\", \"adafruit-hat-pwm\"},                // hardware configuration\n        {\"gpio_slowdown\", \"4\"},                                        // basic performance tuning\n        {\"first_line_y\", \"18\"},                                        // where the first line of text will appear\n        {\"second_line_y\", \"38\"},                                       // where the second line of text will appear\n        {\"third_line_y\", \"58\"},                                        // where the third line of text will appear\n        {\"third_line_refresh_seconds\", \"10\"},                          // How often the 3rd line refreshes\n        {\"ShowCallingPointETD\", \"Yes\"},                                // show the estimated time of departure for each calling point.\n        {\"ShowMessages\", \"Yes\"},                                       // show any messages on the third row in adddition to the 2nd and 3rd departures\n        \n        // RGB Matrix defaults - see https://github.com/hzeller/rpi-rgb-led-matrix for details\n        {\"led-multiplexing\", \"0\"},\n        {\"led-pixel-mapper\", \"\"},\n        {\"led-pwm-bits\", \"1\"},\n        {\"led-brightness\", \"100\"},\n        {\"led-scan-mode\", \"0\"},\n        {\"led-row-addr-type\", \"0\"},\n        {\"led-show-refresh\", \"false\"},\n        {\"led-limit-refresh\", \"0\"},\n        {\"led-inverse\", \"false\"},\n        {\"led-rgb-sequence\", \"RGB\"},\n        {\"led-pwm-lsb-nanoseconds\", \"130\"},\n        {\"led-pwm-dither-bits\", \"0\"},\n        {\"led-no-hardware-pulse\", \"false\"},\n        {\"led-panel-type\", \"\"},\n        {\"led-daemon\", \"false\"},\n        {\"led-no-drop-privs\", \"false\"},\n        {\"led-drop-priv-user\", \"daemon\"},\n        {\"led-drop-priv-group\", \"daemon\"}\n    };\n```\n\nAnd compile (may take a while)!\n\n`g++ -O3 -std=c++11 traindisplay.cpp -o traindisplay -lrgbmatrix -lcurl -lpthread -I/home/\u003cyour path\u003e/rpi-rgb-led-matrix/include -L/home/\u003cyour path\u003e/rpi-rgb-led-matrix/lib`\n\n# And finally Cyril... and finally Esther #\n## Permissions for your home directory ##\nYou need to make your home directory world readable - you need to run the executable as root, and root needs permissions.\n```\ncd\ncd ..\nls\n```\nand you'll see your home directory.\nMake this world-readable `chmod 755 \u003chome directory name\u003e`\n\n## Tweak your configuration file ##\nThis can be used to over-ride settings in the configuration class and other customisations.\n\nDetail of the RGB Matrix library parameters is available [here in the RGB Matrix documentation](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/README.md#changing-parameters-via-command-line-flags)\n\n```\n# Train Display Configuration File\n# Lines starting with # are comments\n\n# Station codes\nfrom=XXX\nto=XXX\n\n# API Configuration\nAPIURL=https://XXX\n\n# Display font configuration\nfontPath=/home/XXX/rpi-rgb-led-matrix/fonts/9x18.bdf\n\n# Timing parameters (in milliseconds/seconds)\nscroll_slowdown_sleep_ms=15\nrefresh_interval_seconds=60\nthird_line_refresh_seconds=10\n\n# Matrix hardware configuration\nmatrixcols=128\nmatrixrows=64\nmatrixchain_length=3\nmatrixparallel=1\nmatrixhardware_mapping=adafruit-hat-pwm\ngpio_slowdown=2\n\n# Display layout configuration (vertical positions)\nfirst_line_y=18\nsecond_line_y=38\nthird_line_y=58\n\n# Feature configuration\nShowCallingPointETD=Yes\nShowMessages=Yes\n\n# RGB Matrix Library Configuration Parameters\n# Please do not put comments on the same line as values\n\n# Panel type settings\nled-multiplexing=0\nled-pixel-mapper=\nled-panel-type=\n\n# Display quality settings\nled-pwm-bits=1\nled-brightness=100\nled-scan-mode=0\nled-row-addr-type=0\n\n# Refresh rate settings\nled-show-refresh=false\nled-limit-refresh=0\n\n# Color settings\nled-inverse=false\nled-rgb-sequence=RGB\n\n# Advanced PWM settings\nled-pwm-lsb-nanoseconds=130\nled-pwm-dither-bits=0\nled-no-hardware-pulse=false\n\n# Privilege/daemon settings\nled-daemon=false\nled-no-drop-privs=false\nled-drop-priv-user=daemon\nled-drop-priv-group=daemon\n```\n# Enjoy Your Departure Board #\n\nTwo options available\n\n## Command Line Operation ##\n\nFour options all of which also support a '-d' option for debugging information\n\nUse the default configuration in the executable\n\n`sudo ./traindisplay`\n\nUse the default configuration in the executable and specify origin and destination\n\n`sudo ./traindisplay SAC STP`\n\nUse your configuration file\n\n`sudo ./traindisplay -f \u003cconfig file\u003e`\n\nCombination of the above\n\n`sudo ./traindisplay SAC STP -f \u003cconfig file\u003e`\n\n## Lightweight User Interface ##\n\nGood for parameter tweaking and easy operation\n\n### Set up the User Interface ###\n\nEdit the `ui-config.txt` file to reflect your installation (probably just need to replace XXX with your home directory)\n```\nExecutable_directory - /home/XXX/RGB_Matrix_Train_Departure_Board\nExecutable_command_line - sudo /home/XXX/RGB_Matrix_Train_Departure_Board/traindisplay -f /home/XXX/RGB_Matrix_Train_Departure_Board/config.txt\nPort - 8080\nDefaults_Config_file - /home/XXX/RGB_Matrix_Train_Departure_Board/default-config.txt\n```\nThe `default-config.txt` file gives you something to revert to if your tweaking goes astray!\n\nJust copy your existing configuration file.\n```\ncp config.txt default-config.txt\n```\n\nFinally make sure the `config_server.py` script is executable\n```\nchmod 755 config_server.py\n```\nand then start the configuration server\n```\n./config_server.py\n```\nYou should see something like:\n```\nStarting server on port 8080...\n```\nwhich indicates you can do away with manual configuration editing and enjoy the minimal UI experience!\n\n### Connect to the User Interface ###\nWith the above configuration you can tweak away to your hearts content at `http://\u003cIP address of your Raspberry Pi\u003e:8080`\n\nEnjoy!\n\n### Troubleshooting ###\nI suspect that most of this will centre around the RGB display library:\n* [Changing parameters](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/README.md#changing-parameters-via-command-line-flags)\n* [Troubleshooting](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/README.md#troubleshooting)\n\nOtherwise feel free to raise an Issue here on github and I'll try to help!\n\n# Huge thanks to... #\n\n[James Singleton's Huxley2](https://github.com/jpsingleton/Huxley2)\n\n[Hzeller RPI RGB LED Matrix](https://github.com/hzeller/rpi-rgb-led-matrix)\n\n[Nlohmann JSON for modern C++](https://github.com/nlohmann/json)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonmorrissmith%2Frgb_matrix_train_departure_board","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonmorrissmith%2Frgb_matrix_train_departure_board","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonmorrissmith%2Frgb_matrix_train_departure_board/lists"}