Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

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

Our Discord

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

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,209
  • 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);
 
 
 
}

 

Recent Posts

X-Plane 11 multi-monitor & Fly Elise-ng - tuto
by blueskydriver
[July 20, 2019, 05:33:45 AM]
FOR SALE: CA & FO Cockpit Seats with J Rails
by Philip
[July 19, 2019, 04:23:24 PM]
For sale
by TNT
[July 18, 2019, 07:57:29 PM]
For Sale: Dual Linked Rudder Pedals RSP
by Philip
[July 17, 2019, 06:47:22 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[July 17, 2019, 02:55:53 PM]
Boeing 737 Dual Linked Yokes
by tennyson
[July 16, 2019, 08:59:28 PM]
Flyengravity desktop MIP (SOLD)
by patiju
[July 16, 2019, 02:01:48 PM]
Flight deck solutions FDS-B737NG-PRO-MX- rudder pedal
by Mach7
[July 16, 2019, 04:52:26 AM]
Korry 318 gets hot.
by Joe Lavery
[July 16, 2019, 03:49:14 AM]
What have you done for your simulator today?
by blueskydriver
[July 14, 2019, 10:25:43 AM]
Where to find or how to make this switch guard?
by blueskydriver
[July 13, 2019, 03:46:30 AM]
NIB 747-400 ThrottleTek + FDS CDUs x2 [SOLD]
by blueskydriver
[July 12, 2019, 10:53:12 PM]
FDS 5V IBL Dimmer and Expansion Board / Pokeys 57E (SOLD)
by fsaviator
[July 10, 2019, 08:35:14 PM]
PM MCP.ini Question...
by ScottThePilot
[July 10, 2019, 12:56:38 PM]
Stab Trim Indicator...
by ScottThePilot
[July 09, 2019, 12:56:42 PM]
Teensy LC Throttle Quadrant
by kurt-olsson
[July 08, 2019, 08:09:41 AM]
Multiple Teensys, sketch upload question
by kurt-olsson
[July 08, 2019, 08:05:27 AM]
Anders Simparts - Summer info
by archen
[July 07, 2019, 03:30:31 AM]
Group buy - Oshino OL-2405BP lamps - interested?
by kattz
[July 03, 2019, 09:26:22 PM]
Prosim737 Ver 2 license for sale
by ifeliciano
[July 02, 2019, 09:58:37 AM]
Anyone have this connector and possibly a clamp as well for the yoke?
by mickc
[July 01, 2019, 08:01:04 PM]
Happy Canada Day
by jackpilot
[July 01, 2019, 10:09:40 AM]
MH 370 Article
by FredK
[June 30, 2019, 07:28:41 PM]
Calling any B747 mechs... please help
by kattz
[June 30, 2019, 06:08:50 PM]
International shipping?
by jackpilot
[June 27, 2019, 08:29:07 AM]
Flooring Installed!
by jackpilot
[June 25, 2019, 05:49:57 PM]
How much room between center pedestal and seat?
by jackpilot
[June 25, 2019, 08:19:42 AM]
2020 Microsoft Flight Simulator - new at E3 2019
by blueskydriver
[June 24, 2019, 02:29:16 PM]
How to install DZUS fasteners?
by Buster99
[June 22, 2019, 04:12:34 PM]
Desert Air Spares - Trustworthy?
by kattz
[June 22, 2019, 12:40:51 PM]