Close

Raspberry Pi - Development - Project Code Flow

A project log for Not Just Another Coffee Table

Custom coffee table with a DCC train track, automation, LEDs and a web interface

jack-flynnJack Flynn 10/03/2018 at 09:160 Comments

Development on the Raspberry Pi is all setup and running smoothly. To better understand what the Pi is doing I've created a rough flow diagram for how it's going to work.

Starting at the

Webpage Interface

The webpage interface will be more refined as we dial in the usability and technical requirements. Currently (more posts to follow) the site is running using bootstrap for styling and a couple of jquery pieces that allow for button presses and colour picking for the RGB ambient lighting. The jquery are grabbing the response from the inputs and passing them via post requests to Django.

Django Web Server

The Django web server has mostly been covered in a previous post. This nice bit of python is used to handle the data base which stores the effects objects and also display our web page interface. On receiving the post requests from the jquery elements in the site it then passes these commands to Redis using a publish method. 

Redis

Although very powerful and with plenty of uses, I am using Red-dis for it's MQ - publish:subscribe - handling which allows me to pass messages between my python scripts. I used this guide by John Grant as a helper for sorting out my python logic for passing the messages from Django to my Manager scripts. 

Automation Manager

I haven't given this any further thought other than I want to be able to create automation within the system that could handle effects like lightning change based on time, timetable for train movements and any other cool ideas that come to mind. The most likely way to do this is to have a standalone script that outputs the required messages over Redis.

Arduino Effects Manager

The script subscribes to the messages from Django via Redis, parses these messages for valid commands and then outputs the data to the Teensy/Arduino to create the lightning and other effects. Serial debugging data from the Teensy is also picked up for use as needed.

DCC Train Manager

Much the same as the Arduino Effects Manager, the script subscribes to the messages from Django via Redis, parses these messages for valid commands and then outputs the data to the Sprog to create the lightning and other effects. Data feedback from the sprog may be useful depending on how the application grows.

Discussions