3. Raspberry Pi 4
The Raspberry Pi 4 B (3) and all the HATs/bonnets/custom boards attached provide the interface needed between the hardware layout (1) and the software on the laptop (4) not covered/provided by the Arduino Mega/Motor Shield (2). The following list of Raspberry Pi software functions is in order of implementation (I think).
Documentation of the Raspberry Pi software is done using the Sphinx software tool. I found the results of the python pydoc utility harder to include here and is now out of date.
- Raspberry Pi 4 Operating System configuration/changes.
- Traffic management between the laptop(4) and Arduino (2).
- The first critical function is the interface passing commands and status between the laptop and Arduino/Base Station.
- This WiFi connection to the laptop and serial connection to the Arduino puts the Raspberry Pi in a position to extract commands from the laptop, and monitor traffic density.
- Eliminates the wired connection between the laptop and layout..
- Traffic Monitor LEDs.
- With traffic between the laptop and Arduino passing through the Raspberry Pi we can display the traffic density.
- Unicorn HD HAT LED arrays.
- Adding the Unicorn displays supports showing the fan statues
- and later the 64 signal aspects.
- Control Raspberry Pi 4 Cooling Fan.
- The controlled fan is an asynchronous function that has no interface to the laptop.
- Display the Fan's Status on Unicorn HAT.
- Workout the asynchronous interface to display updates on the Unicorn.
- Connect the turnout status lines from Wabbits to IO Pi Plus HAT using interrupts and threading.
- Connect IO Pi interrupt lines from IO Pi to Unicorn board which breaks out the RPi GPIO pins 0, 1 & 4. (GPIO pin 26 connected to IOPi interrupt for bus 2, port 1, but not used.).
- Each of the 3 interrupt handlers process 8 of the 24 status lines from Wabbits.
- Set up interrupt handlers to include delay (low to high) and threading.
- Process commands from the Lap Top (4) & return status.
- Process Signal configuration and control commands from the laptop
- For this we need to break into the JMRI to insert Pi specific commands.
- Store configuration information on the Pi.
- Process Sensor configuration commands and return turnout status.
- Intercept (some) sensor commands from laptop.
- DCC++ sensor commands are <S...> return command status <O> or <X>.
- Returned sensor states are <Q id> sensor is triggered, <q id> sensor is NOT triggered.
- Store sensor number::Pin number configuration on the RPi.
- Control the 4 tri-color LED signals.
- The LED signals in the parking lot are simple on/off things to control.
- Add signal status to the Unicorns building on fan status
- Control the 60 56 semaphore servos/signals.
- Display semaphore aspect on Unicorn HATs
- Controlling the servos not as simple and need some hardware.
- Use the DSI display to implement random rout assignment.
Graphically the software modules/classes connections are:
- Module TT3 starts:
- module Fan
- module Traffic
- Module Fan:
- controls the RPi cooling fan
- sends fan status/CPU temperature information to module Unicorn for display.
- Module Traffic manages all communication between the RPi(3) the Laptop (4) and the Arduino (2).
- Traffic density is displayed by the Monitor class using LEDs.
- Commands for the RPi are passed to Module Command.
- Return status is passed from Module Traffic to the Laptop.
- Module Command validates and processes all commands from the Laptop for the RPi.
- RPi configuration data is maintained and stored as files.
- Commands are combined with stored data by class Sensor and Signal and passed to modules WabbitFB or Signals for execution/hardware interface.
- Module WabbitFB receives configuration information and status requests from module Command.
- Based on the status of configured sensors and request, status is sent to module traffic to be returned to the Laptop.
- Based of changes In the status of configured sensors asynchronous data is sent to Module Traffic to be sent to the Laptop.
- Module Signals receives information from module Command and
- Changes the aspect of a semaphore or LED signal
- Send changes in signal aspect to module Unicorn for display.
- Module Unicorn receives changes in status from modules Fan and Signals for display on the two Unicorn 16x16 LED arrays.