Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 57
  • *Total: 58

Our Discord

Author Topic: Flight Control Panel A Side  (Read 123 times)

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,168
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Flight Control Panel A Side
« on: February 04, 2019, 04:34:38 PM »
This is one side of my Flight Control Panel. I Hate this code, i hate the Commands.
If anyone has a better way of doing this let me know!

const int PIN_KORRY_PUSH_TO_TEST = 16;
const int PIN_KORRY_YAW_DAMPER = 17;
const int PIN_KORRY_AUTO_SLAT_FAIL = 20;
const int PIN_KORRY_FEEL_DIFF_PRESS = 10;
const int PIN_KORRY_MACH_TRIM_FAIL = 9;
const int PIN_KORRY_SPEED_TRIM_FAIL = 6;

const int PIN_SWITCH_YAW_DAMPER = 13;
const int PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD = 18;
const int PIN_SWITCH_FLIGHT_CONTROL_A_ON = 19;
const int PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD = 14;
const int PIN_SWITCH_FLIGHT_CONTROL_B_ON = 15;

const int PIN_RELAY_YAW_DAMPER = 21;

FlightSimFloat xPlane_readonly_flt_ctr_A_cover_pos;
FlightSimFloat xPlane_readonly_flt_ctr_B_cover_pos;

FlightSimCommand Command_flt_ctr_A_cover;
FlightSimCommand Command_flt_ctr_B_cover;

FlightSimCommand Command_flt_ctr_A_up;
FlightSimCommand Command_flt_ctr_A_dn;

FlightSimFloat xPlane_flt_ctr_A_pos;

FlightSimCommand Command_flt_ctr_B_up;
FlightSimCommand Command_flt_ctr_B_dn;

FlightSimFloat xPlane_flt_ctr_B_pos;


void setup() {
  FlightSim.update();
   
  //Serial.begin(9600);
  pinMode(PIN_KORRY_PUSH_TO_TEST, OUTPUT);
  pinMode(PIN_KORRY_YAW_DAMPER, OUTPUT);
  pinMode(PIN_KORRY_AUTO_SLAT_FAIL, OUTPUT);
  pinMode(PIN_KORRY_FEEL_DIFF_PRESS, OUTPUT);
  pinMode(PIN_KORRY_MACH_TRIM_FAIL, OUTPUT);
  pinMode(PIN_KORRY_SPEED_TRIM_FAIL, OUTPUT);

  pinMode(PIN_SWITCH_YAW_DAMPER,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_A_ON,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_B_ON,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD,INPUT_PULLUP);

  pinMode(PIN_RELAY_YAW_DAMPER,OUTPUT);

  xPlane_readonly_flt_ctr_A_cover_pos = XPlaneRef("laminar/B738/switches/flt_ctr_A_cover_pos");
  xPlane_readonly_flt_ctr_B_cover_pos = XPlaneRef("laminar/B738/switches/flt_ctr_B_cover_pos");

  Command_flt_ctr_A_cover = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_A_cover");
  Command_flt_ctr_B_cover = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_B_cover");

  Command_flt_ctr_A_up = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_A_up");
  Command_flt_ctr_A_dn = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_A_dn");

  xPlane_flt_ctr_A_pos = XPlaneRef("laminar/B738/switches/flt_ctr_A_pos");

  Command_flt_ctr_B_up = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_B_up");
  Command_flt_ctr_B_dn = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_B_dn");

  xPlane_flt_ctr_B_pos = XPlaneRef("laminar/B738/switches/flt_ctr_B_pos");
}

void loop() {
 FlightSim.update(); 
  // put your main code here, to run repeatedly:
 analogWrite(PIN_KORRY_PUSH_TO_TEST,255);
 analogWrite(PIN_KORRY_YAW_DAMPER,255);
 analogWrite(PIN_KORRY_AUTO_SLAT_FAIL,255);
 analogWrite(PIN_KORRY_FEEL_DIFF_PRESS,255);
 analogWrite(PIN_KORRY_MACH_TRIM_FAIL,255);
 analogWrite(PIN_KORRY_SPEED_TRIM_FAIL,255);

 digitalWrite(PIN_RELAY_YAW_DAMPER,HIGH);

 //THIS CODE IS JUST BS, MUST BE A BETTER WAY OF DOING THIS!
 
  if (xPlane_readonly_flt_ctr_A_cover_pos == 0.0f) {
    Command_flt_ctr_A_cover.once();   
  }
  if (xPlane_readonly_flt_ctr_B_cover_pos == 0.0f) {
    Command_flt_ctr_B_cover.once();   
  }

 
  if (xPlane_readonly_flt_ctr_A_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD) == LOW && xPlane_flt_ctr_A_pos != -1) {
    Command_flt_ctr_A_up.once();
    delay(200);
  }
  if (xPlane_readonly_flt_ctr_A_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_ON) == LOW && xPlane_flt_ctr_A_pos != 1) {
    Command_flt_ctr_A_dn.once();
    delay(200);
  }
  if (digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD) == HIGH && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_ON) == HIGH) {
    if (xPlane_flt_ctr_A_pos == -1)
      Command_flt_ctr_A_dn.once();
    if (xPlane_flt_ctr_A_pos == 1)
      Command_flt_ctr_A_up.once();
      delay(200);
  }



  if (xPlane_readonly_flt_ctr_B_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD) == LOW && xPlane_flt_ctr_B_pos != -1) {
    Command_flt_ctr_B_up.once();
    delay(200);
  }
  if (xPlane_readonly_flt_ctr_B_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_ON) == LOW && xPlane_flt_ctr_B_pos != 1) {
    Command_flt_ctr_B_dn.once();
    delay(200);
  }
  if (digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD) == HIGH && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_ON) == HIGH) {
    if (xPlane_flt_ctr_B_pos == -1)
      Command_flt_ctr_B_dn.once();
    if (xPlane_flt_ctr_B_pos == 1)
      Command_flt_ctr_B_up.once();
      delay(200);
  }

 
 
 //Serial.println(digitalRead(PIN_SWITCH_YAW_DAMPER));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_ON));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_ON));

 

  delay(20);
 
 
 
}

 

FlightSimExpo 2019

FsExpo

Recent Posts

FSDream Team Couatl crashes when shutting down computers - any ideas
by navymustang
[Today at 08:25:11 AM]
Teensy LC Throttle Quadrant
by ElStino737
[Today at 06:56:37 AM]
FLIGHTSIMEXPO RELEASES 2019 SPEAKER SCHEDULE, ANNOUNCES NEW PARTNERSHIP WITH EAA
by 757Simulator
[Today at 04:20:53 AM]
OEM 737NG project - Long overdue update
by 757Simulator
[Today at 04:16:43 AM]
Old Projector(s)
by kurt-olsson
[Today at 02:34:54 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[April 17, 2019, 05:10:03 AM]
Teensy as Joystick
by kurt-olsson
[April 16, 2019, 01:54:29 PM]
German B738NG Homecockpit-Projekt
by Joe Lavery
[April 15, 2019, 04:02:26 PM]
Which Processor i7 - 8700K or i7 - 9700K
by Joe Lavery
[April 15, 2019, 04:00:33 PM]
Computer / Projector Combo
by blueskydriver
[April 15, 2019, 02:50:24 PM]
Flyengravity desktop MIP
by Steenos
[April 15, 2019, 02:22:39 PM]
TV Screen Position
by Trevor Hale
[April 15, 2019, 07:17:07 AM]
Join me on Vatsim Tonight
by Trevor Hale
[April 14, 2019, 05:07:50 PM]
Interfacing real instruments in p3d
by Steve Mount
[April 14, 2019, 04:56:08 PM]
Flight Sim Visual System on Public Surplus...
by bernard S
[April 14, 2019, 12:53:56 PM]
Aerosoft Australia 747 MCP
by 737simAdelaide
[April 14, 2019, 05:16:58 AM]
CPFlight 737 EL MCP For Sale
by 737simAdelaide
[April 14, 2019, 05:12:54 AM]
CPflight radios B737.
by avan1001
[April 14, 2019, 04:12:07 AM]
Anyone can recognize this material?
by 757Simulator
[April 14, 2019, 03:21:26 AM]
F18 military trainer cockpit for sale
by navymustang
[April 13, 2019, 10:19:06 PM]
CPFlight 737 NG MCP Pro and Efis Pro
by patiju
[April 13, 2019, 01:02:33 PM]
FLIGHT ILLUSION gauges
by patiju
[April 13, 2019, 12:58:25 PM]
wanted FDS CDU
by 757Simulator
[April 13, 2019, 03:35:00 AM]
CAD assistance
by Timothy Denner
[April 12, 2019, 11:30:41 PM]
737 MAX
by mickc
[April 12, 2019, 07:20:35 PM]
Cpflight MCP737PRO
by Trevor Hale
[April 12, 2019, 09:12:36 AM]
95% finished Diamond DA62 build
by jskibo
[April 12, 2019, 09:01:31 AM]
Building a 737 MAX
by KennethGreene
[April 11, 2019, 05:37:23 PM]
Prosim and RSP TQ interfacing
by Lomaric
[April 11, 2019, 05:33:46 PM]
PCFlights.com?
by Trevor Hale
[April 11, 2019, 03:11:27 PM]