Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 3
  • *Guests: 42
  • *Total: 45

Our Discord

Author Topic: Teensy LC Fuel Panel A (top)  (Read 213 times)

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,232
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Teensy LC Fuel Panel A (top)
« on: July 23, 2019, 04:48:35 PM »
Code for Fuel Panel.
With good datarefs, the code looks clean. I like this...


const int PIN_KORRY_LIGHT_PUSH_TO_TEST = 9;
const int PIN_KORRY_LIGHT_PUSH_TO_TEST_2 = 4;
const int PIN_KORRY_LIGHT_LEFT_FILTER_BYPASS = 20;
const int PIN_KORRY_LIGHT_RIGHT_FILTER_BYPASS = 16;
const int PIN_KORRY_LIGHT_VALVE_OPEN = 17;
const int PIN_KORRY_LIGHT_LEFT_FUEL_VALVE_CLOSED = 10;
const int PIN_KORRY_LIGHT_RIGHT_FUEL_VALVE_CLOSED = 3;

const int PIN_SWITCH_CROSS_FEED = 13; 

FlightSimFloat xPlane_cross_feed_pos;
FlightSimFloat xPlane_eng1_valve_closed;
FlightSimFloat xPlane_eng2_valve_closed;
FlightSimFloat xPlane_bypass_filter_1;
FlightSimFloat xPlane_bypass_filter_2;
FlightSimFloat xPlane_crossfeed;

void setup() {
 
  xPlane_cross_feed_pos = XPlaneRef("laminar/B738/knobs/cross_feed_pos");
  xPlane_eng1_valve_closed = XPlaneRef("laminar/B738/annunciator/eng1_valve_closed");
  xPlane_eng2_valve_closed = XPlaneRef("laminar/B738/annunciator/eng2_valve_closed");
  xPlane_bypass_filter_1 = XPlaneRef("laminar/B738/annunciator/bypass_filter_1");
  xPlane_bypass_filter_2 = XPlaneRef("laminar/B738/annunciator/bypass_filter_2");
  xPlane_crossfeed = XPlaneRef("laminar/B738/annunciator/crossfeed");

 
   pinMode(PIN_KORRY_LIGHT_LEFT_FILTER_BYPASS,OUTPUT);
   pinMode(PIN_KORRY_LIGHT_RIGHT_FILTER_BYPASS,OUTPUT);
   pinMode(PIN_KORRY_LIGHT_VALVE_OPEN,OUTPUT);
   pinMode(PIN_KORRY_LIGHT_LEFT_FUEL_VALVE_CLOSED,OUTPUT);
   pinMode(PIN_KORRY_LIGHT_PUSH_TO_TEST,OUTPUT);   
   pinMode(PIN_KORRY_LIGHT_RIGHT_FUEL_VALVE_CLOSED,OUTPUT);
   pinMode(PIN_KORRY_LIGHT_PUSH_TO_TEST_2,OUTPUT);

   pinMode(PIN_SWITCH_CROSS_FEED, INPUT_PULLUP);

   //Serial.begin(9600); // USB is always 12 Mbit/sec
}

void loop() {
  FlightSim.update(); 
 
  analogWrite(PIN_KORRY_LIGHT_PUSH_TO_TEST,255);
  analogWrite(PIN_KORRY_LIGHT_PUSH_TO_TEST_2,255);
  analogWrite(PIN_KORRY_LIGHT_LEFT_FILTER_BYPASS,mapfloat(xPlane_bypass_filter_1, 0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_RIGHT_FILTER_BYPASS,mapfloat(xPlane_bypass_filter_2, 0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_VALVE_OPEN,mapfloat(xPlane_crossfeed, 0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_LEFT_FUEL_VALVE_CLOSED,mapfloat(xPlane_eng1_valve_closed, 0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_RIGHT_FUEL_VALVE_CLOSED, mapfloat(xPlane_eng2_valve_closed, 0,1,0,255));
 
  if (digitalRead(PIN_SWITCH_CROSS_FEED) == LOW && xPlane_cross_feed_pos != 0)
  {
    xPlane_cross_feed_pos = 0;
  }
 
  if (digitalRead(PIN_SWITCH_CROSS_FEED) == HIGH && xPlane_cross_feed_pos != 1)
  {
    xPlane_cross_feed_pos = 1;
  }
 
  //put a small delay here otherwise the processing is so fast. Lots of read/write that dont have to be so fast.
  delay(20);
}

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Offline mickc

  • I may as well be Staff!
  • *
  • Posts: 548
  • Aviation Enthusiast
  • First Name: Mick
  • Home Location: VIC, AU
Re: Teensy LC Fuel Panel A (top)
« Reply #1 on: July 23, 2019, 07:30:29 PM »
2 queries Kurt;

Are you not using the separate ENG and SPAR valve lights for the NG?

Also how are you handling the dim/brt states for valve position disagree ?

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,232
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Re: Teensy LC Fuel Panel A (top)
« Reply #2 on: July 24, 2019, 06:05:09 AM »
Hi Mick.

Unfortunatly i have annolder fuel panel from the classic, so there is only fuel valve closed korrys and no eng/spar annunciators. These are differences from the NG i will ignore in my build for now.

Regarding the logic of dim states i only read from xPlane values of 0.0 - 2.0 (mosty 1.0). So the logic is allready there so i just read it.

Hope i understood your last question and anssered it. :)

Offline bernard S

  • I may as well be Staff!
  • *
  • Posts: 559
  • Aviation Enthusiast
  • First Name: Bernard
  • Home Location: Austin TX
Re: Teensy LC Fuel Panel A (top)
« Reply #3 on: August 02, 2019, 06:09:00 PM »
what alot of work

 

Recent Posts

Free Jet Ranger.
by geneb
[Today at 06:16:52 PM]
items/oem from overhead
by gufau
[Today at 12:49:15 PM]
Hi everyone!
by jskibo
[Today at 08:05:33 AM]
737-800 Front window post size
by kurt-olsson
[Today at 03:35:11 AM]
Shipping Woes
by Caflyt
[August 22, 2019, 10:47:49 AM]
Official WF 2019 Route
by dougsnow
[August 21, 2019, 07:49:35 PM]
Worldflight 2019 Open for Business
by Trevor Hale
[August 21, 2019, 08:28:13 AM]
More ?'s - annunciators?
by kattz
[August 21, 2019, 05:44:21 AM]
Looking for annunciators
by kattz
[August 19, 2019, 10:36:39 PM]
OK, So here we go!
by Caflyt
[August 19, 2019, 02:32:28 PM]
Flight Illusion Boeing Press Gauge for sale
by XOrionFE
[August 19, 2019, 08:40:35 AM]
Shell placement and yoke placement questions
by helloo
[August 18, 2019, 02:37:26 PM]
panel sismo oh
by gufau
[August 17, 2019, 04:17:00 AM]
My next sim?
by fsaviator
[August 16, 2019, 06:54:51 PM]
What have you done for your simulator today?
by blueskydriver
[August 14, 2019, 10:35:26 AM]
Looking for gear lever from 747-400, 757
by navymustang
[August 13, 2019, 10:05:44 AM]
Quick way to attach low res/smaller file size pics in your posts...
by Vincent T.
[August 12, 2019, 09:58:46 PM]
Cant post attachments from my iphone
by Trevor Hale
[August 12, 2019, 09:26:08 AM]
For Sale: Engravity 737 Window Frames
by Caflyt
[August 11, 2019, 05:02:28 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[August 10, 2019, 01:43:57 PM]
Help identifying a connector
by kurt-olsson
[August 10, 2019, 10:59:31 AM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[August 08, 2019, 09:40:02 PM]
Flightdeck Solutions Works with X-Plane11
by Michael_B737_ATP
[August 07, 2019, 02:59:21 PM]
Boeing Dual Linked Yokes for sale
by tennyson
[August 07, 2019, 07:34:58 AM]
CPFLight Backlighting
by mickc
[August 05, 2019, 10:09:53 PM]
Three Projector 210 degree with P3D4
by Nat Crea
[August 03, 2019, 08:36:50 PM]
Looking for part numbers from the 737 NG IPC
by mickc
[August 02, 2019, 11:20:49 PM]
WF2019
by Sam Llorca
[August 02, 2019, 09:22:56 PM]
Teensy LC Fuel Panel A (top)
by bernard S
[August 02, 2019, 06:09:00 PM]
737 overhead
by nigel27
[July 28, 2019, 11:50:47 PM]