Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
dcc::MMNewPayload Struct Reference

Structure defining the volatile state for a Marklin-Motorola v2 protocol locomotive (with 28 speed steps, five functions and absolute direction). More...

#include <Loco.hxx>

Public Member Functions

unsigned get_speed_steps ()
 
unsigned get_max_fn ()
 
void set_fn_store (unsigned idx, bool value)
 Set a given function bit in storage.
 
bool get_fn_store (unsigned idx)
 Get a given function bit in storage.
 
unsigned get_fn_update_code (unsigned address)
 

Static Public Member Functions

static TrainAddressType get_address_type ()
 

Public Attributes

unsigned address_: 8
 largest address allowed is 80, but we keep a few more bits around to allow for an extension to arbitrary MM address packets.
 
unsigned lastSetSpeed_: 16
 fp16 value of the last set speed.
 
unsigned fn_: 5
 function f0-f4.
 
unsigned direction_: 1
 0: forward, 1: reverse
 
unsigned directionChanged_: 1
 Whether the direction change packet still needs to go out.
 
unsigned resvd1_: 1
 reserved
 
unsigned speed_: 4
 Speed step we last set.
 
unsigned nextRefresh_: 3
 internal refresh cycle state machine
 
unsigned isEstop_: 1
 1 if the last speed set was estop.
 
unsigned f0SetDirectional_: 1
 1 if the F0 function should be set/get in a directional way.
 
unsigned f0OnForward_: 1
 1 if directional f0 is used and f0 is on for F.
 
unsigned f0OnReverse_: 1
 1 if directional f0 is used and f0 is on for R.
 
unsigned f0BlankForward_: 1
 1 if F0 should be turned off when dir==forward.
 
unsigned f0BlankReverse_: 1
 1 if F0 should be turned off when dir==reverse.
 

Detailed Description

Structure defining the volatile state for a Marklin-Motorola v2 protocol locomotive (with 28 speed steps, five functions and absolute direction).

Definition at line 653 of file Loco.hxx.

Constructor & Destructor Documentation

◆ MMNewPayload()

dcc::MMNewPayload::MMNewPayload ( )
inline

Definition at line 655 of file Loco.hxx.

Member Function Documentation

◆ get_address_type()

static TrainAddressType dcc::MMNewPayload::get_address_type ( )
inlinestatic
Returns
what type of address this train has.

Definition at line 739 of file Loco.hxx.

◆ get_fn_store()

bool dcc::MMNewPayload::get_fn_store ( unsigned  idx)
inline

Get a given function bit in storage.

Parameters
idxfunction number, 0 to get_max_fn.
Returns
function state

Definition at line 719 of file Loco.hxx.

◆ get_fn_update_code()

unsigned dcc::MMNewPayload::get_fn_update_code ( unsigned  address)
inline
Returns
the update code to send to the packet handler for a given function value change.
Parameters
addressis the function number (0..4)

Definition at line 726 of file Loco.hxx.

◆ get_max_fn()

unsigned dcc::MMNewPayload::get_max_fn ( )
inline
Returns
the largest function number that is still valid.

Definition at line 697 of file Loco.hxx.

◆ get_speed_steps()

unsigned dcc::MMNewPayload::get_speed_steps ( )
inline
Returns
the number of speed steps (in float).

Definition at line 691 of file Loco.hxx.

◆ set_fn_store()

void dcc::MMNewPayload::set_fn_store ( unsigned  idx,
bool  value 
)
inline

Set a given function bit in storage.

Parameters
idxfunction number, 0 to get_max_fn.
valuefunction state

Definition at line 705 of file Loco.hxx.

Member Data Documentation

◆ address_

unsigned dcc::MMNewPayload::address_

largest address allowed is 80, but we keep a few more bits around to allow for an extension to arbitrary MM address packets.

Definition at line 661 of file Loco.hxx.

◆ direction_

unsigned dcc::MMNewPayload::direction_

0: forward, 1: reverse

Definition at line 667 of file Loco.hxx.

◆ directionChanged_

unsigned dcc::MMNewPayload::directionChanged_

Whether the direction change packet still needs to go out.

Definition at line 669 of file Loco.hxx.

◆ f0BlankForward_

unsigned dcc::MMNewPayload::f0BlankForward_

1 if F0 should be turned off when dir==forward.

Definition at line 686 of file Loco.hxx.

◆ f0BlankReverse_

unsigned dcc::MMNewPayload::f0BlankReverse_

1 if F0 should be turned off when dir==reverse.

Definition at line 688 of file Loco.hxx.

◆ f0OnForward_

unsigned dcc::MMNewPayload::f0OnForward_

1 if directional f0 is used and f0 is on for F.

Definition at line 682 of file Loco.hxx.

◆ f0OnReverse_

unsigned dcc::MMNewPayload::f0OnReverse_

1 if directional f0 is used and f0 is on for R.

Definition at line 684 of file Loco.hxx.

◆ f0SetDirectional_

unsigned dcc::MMNewPayload::f0SetDirectional_

1 if the F0 function should be set/get in a directional way.

Definition at line 680 of file Loco.hxx.

◆ fn_

unsigned dcc::MMNewPayload::fn_

function f0-f4.

Definition at line 665 of file Loco.hxx.

◆ isEstop_

unsigned dcc::MMNewPayload::isEstop_

1 if the last speed set was estop.

Definition at line 677 of file Loco.hxx.

◆ lastSetSpeed_

unsigned dcc::MMNewPayload::lastSetSpeed_

fp16 value of the last set speed.

Definition at line 663 of file Loco.hxx.

◆ nextRefresh_

unsigned dcc::MMNewPayload::nextRefresh_

internal refresh cycle state machine

Definition at line 675 of file Loco.hxx.

◆ resvd1_

unsigned dcc::MMNewPayload::resvd1_

reserved

Definition at line 671 of file Loco.hxx.

◆ speed_

unsigned dcc::MMNewPayload::speed_

Speed step we last set.

Definition at line 673 of file Loco.hxx.


The documentation for this struct was generated from the following file: