Skip to main content

Turnouts Configuration

The Turnouts section lets you define every turnout on your layout, assign it to a hardware device, configure its DCC index and servo/relay pins, and organize turnouts with tags and custom sort order. Turnout data is stored in Firebase Firestore at layouts/{layoutId}/turnouts and is used by the Throttle app, Routes, and the server for real-time control.

Turnouts list view

Turnout List

The main turnouts view (/turnouts) displays your turnouts in a toolbar-topped list. The toolbar provides three actions:

ButtonIconFunction
ViewEyeSwitch between Card View and By Device grouping
FilterFilterShow or hide tag-based filters
SortSort VariantOpen the drag-and-drop sorter dialog

View Modes

The view mode preference is persisted in local storage (@DEJA/prefs/turnoutsView) so it carries across sessions.

  • Card View -- Each turnout is displayed as an individual card in a responsive grid. This is the default view, ideal for quick scanning.
  • By Device -- Turnouts are grouped by their assigned hardware device, making it easy to see which turnouts are wired to each controller board.

An "Add" tile appears at the start of the list as a visual prompt to create new turnouts.

Sorting Turnouts

Click the sort button to open the Sort Turnouts dialog. This presents all turnouts as draggable buttons arranged in a grid (up to 8 columns on wide screens). Drag and drop to reorder, then click Save to persist the new order. Each turnout's order field is updated in Firestore, and the new sequence is reflected across all apps.

Turnout sorter dialog

Turnout Labels View

A dedicated labels view is available at /turnouts/labels for generating printable label sheets for your layout's turnout identification.

Adding a Turnout

Navigate to /turnouts/new or click the Add tile. The turnout form collects the following fields:

Core Fields

FieldDescriptionRequired
NameA display name (e.g., "Main Yard Lead", "East Siding")Yes
IndexThe DCC turnout index as configured on the CommandStationYes
DescriptionAn optional text description of the turnout's location or purposeNo
StraightThe servo position or pin value for the straight (closed) routeYes
DivergentThe servo position or pin value for the divergent (thrown) routeYes

The turnout ID is auto-generated from the name, index, and device using the slugify utility (e.g., main-yard-lead-1-dccex).

Picker Fields

Below the text fields, four large picker buttons let you configure additional properties. Clicking each button opens a dialog:

  • Type -- Select the turnout mechanism type. Available options: Kato (default), Servo, Tortoise (coming soon), and DCC (coming soon).
  • Device -- Choose which hardware device controls this turnout. The picker lists all devices registered in your layout.
  • Color -- Pick a display color for the turnout card in the UI.
  • Effect -- Optionally link an effect that triggers when the turnout is thrown (e.g., a sound effect or animation).

Tags

A tag picker component lets you assign tags to the turnout for filtering purposes. Tags are layout-level metadata that you can create and manage from the Layout Configuration page.

Turnout form

Editing a Turnout

Click any turnout card in the list to navigate to /turnouts/:turnoutId. The edit form is identical to the add form, pre-populated with the existing turnout data. Make changes and click Submit to save, or Close to discard.

Turnout Types

The system supports the following turnout mechanism types:

TypeDescriptionStatus
KatoKato Unitrack electric turnouts controlled via pulse signalsAvailable
ServoHobby servos controlled via PWM signal for precise position controlAvailable
TortoiseCircuitron Tortoise slow-motion switch machinesComing soon
DCCDCC-controlled accessory decoders for turnout motorsComing soon

The turnout type determines how the DEJA.js server translates the straight/divergent values into hardware commands.

Data Structure

Each turnout document in Firestore has the following shape:

FieldTypeDescription
idstringAuto-generated slug identifier
namestringDisplay name
descstringOptional description
turnoutIdxnumberDCC turnout index
straightnumberStraight/closed position value
divergentnumberDivergent/thrown position value
typestringMechanism type (kato, servo, etc.)
devicestringID of the controlling hardware device
colorstringDisplay color name
tagsstring[]Tag identifiers for filtering
statebooleanCurrent state (false = straight, true = thrown)
effectIdstringOptional linked effect ID
ordernumberSort order

Data Flow

When a turnout state changes (either from the Throttle app or a Route execution):

  1. The Firestore document at layouts/{layoutId}/turnouts/{turnoutId} is updated.
  2. The server's Firestore listener in modules/turnouts.ts picks up the change.
  3. The server calls dcc.sendTurnout(), which sends <T idx state> over USB serial to the CommandStation.
  4. The CommandStation activates the turnout on the layout.

Related Pages