Skip to content

ToggleButton

Talbot edited this page Nov 30, 2021 · 1 revision

Class Name

ToggleButtonT

Description

A single button (often momentary) where the falling edge of the button will alternate between two different messages to DCS. This is a very flexible control that can be used creatively for more than just buttons. Note that no message/argument is sent on the rising edge so this should not be used if the DCS control needs to be released (Use Switch2Pos for that).

Standard Template Name

ToggleButton

Constructor

ToggleButton(const char* msg, const char* argA, const char* argB, char pin)

  • msg - The message to send to DCS when the button is activated.
  • argA - The argument (aka value) to send to DCS on odd counts of falling edges.
  • argB - The argument (aka value) to send to DCS on even counts of falling edges.
  • pin - The pin the button is connected to.

Template

template <unsigned long pollIntervalMs = POLL_EVERY_TIME>

  • pollIntervalMs - Time in milliseconds between times this control should be sampled. Increase for less time sensitive controls to lower the CPU load required for this control.

Example 1

DcsBios::ToggleButton lampTestBtn("LAMP_TEST_BTN", "0", "1", 1); // Pin 1 will toggle the state of the lamp test button each time the control has a rising edge

Example 2

DcsBios::ToggleButton tacanVol("TACAN_VOL", 1, "6553" "52428"); // Pin 1 will toggle the TACAN volume between a low (10%) and high (80%)

Example 3

typedef DcsBios::ToggleButtonT<200> LowPriorityToggleButton; // A custom toggle button that will use less cpu on each loop

LowPriorityToggleButton("TACAN_XY", "0", "1", 1); // Toggle TACAN X/Y channel each time the button is pressed