Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 60
  • *Total: 61

Our Discord

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

Offline kurt-olsson

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

For Sale: Jetmax 737 TQ - Texas, USA
by MistyBlue
[Today at 02:19:22 PM]
What have you done for your simulator today?
by MistyBlue
[Today at 02:17:28 PM]
FSUIPC 5 Button Limitations
by GyverX
[February 18, 2019, 05:33:55 PM]
Operating System Blues
by Joe Lavery
[February 18, 2019, 02:47:27 PM]
Virtual FO software
by fsaviator
[February 18, 2019, 02:36:20 PM]
Join me on Vatsim Tonight
by Trevor Hale
[February 17, 2019, 01:48:52 PM]
Throttle
by 727737Nut
[February 17, 2019, 09:14:54 AM]
737 NG Throttle Levers
by mickc
[February 17, 2019, 05:02:01 AM]
For sale: A set of faceplate panel for pedestal
by mickc
[February 17, 2019, 05:01:07 AM]
FlyAB Simparts: A new supplier for your OEM needs
by Trevor Hale
[February 16, 2019, 10:51:54 PM]
B737-800 Flight Sim for sale $85,000.00
by Rob_b
[February 16, 2019, 12:47:11 AM]
PC upgrade-build-or buy advice??
by iwik
[February 15, 2019, 06:47:11 PM]
Which Processor i7 - 8700K or i7 - 9700K
by Joe Lavery
[February 15, 2019, 05:39:06 PM]
Anyone seen OEM 737-900 ER Throttle Quadrant?
by Fly_AB
[February 15, 2019, 10:32:18 AM]
For Sale: P&P Opencockpit VHF, Transponder, and ADF
by Fly_AB
[February 15, 2019, 09:08:24 AM]
737 DIY MIP For Sale
by Trevor Hale
[February 14, 2019, 11:03:35 AM]
New supplier for your sim
by Fcoq
[February 14, 2019, 12:18:44 AM]
For Sale Prosim 737 v2.03 License
by mdavenport
[February 12, 2019, 04:00:00 PM]
Complete 737-800 cockpit - moving sale
by navymustang
[February 10, 2019, 12:50:48 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[February 10, 2019, 09:31:17 AM]
Revolution Simproducts out of business?
by fsaviator
[February 09, 2019, 12:18:30 PM]
For sale: CPFlight MIP737SE
by Fly_AB
[February 08, 2019, 11:29:26 PM]
For sale: Engravity sixpack pairs --- SOLD
by Fly_AB
[February 08, 2019, 08:32:04 PM]
German B738NG Homecockpit-Projekt
by MjTom
[February 08, 2019, 08:00:54 AM]
Updating Navigraph FMC Data - Project Magenta / ProSim
by Trevor Hale
[February 08, 2019, 07:41:50 AM]
737 Demonstrator For Sale
by Trevor Hale
[February 08, 2019, 07:39:34 AM]
Looking for B737NG or A320 SIM for Home Use
by KingAviation
[February 08, 2019, 03:17:35 AM]
Zibo 737 FlightControl Dataref/Commands
by kurt-olsson
[February 05, 2019, 05:34:35 PM]
Wrong hiegth above ground when landing and P3D set for Panel Only
by FredK
[February 05, 2019, 12:58:20 AM]
Flight Control Panel A Side
by kurt-olsson
[February 04, 2019, 04:34:38 PM]