Pedestal working with flightgear

Signed-off-by: fly <merspieler@alwaysdata.net>
This commit is contained in:
fly 2024-11-06 22:40:54 +01:00
parent 77012efc31
commit d36a360980
6 changed files with 316 additions and 144 deletions

View file

@ -13,27 +13,28 @@ Inputs report usually via USB HID so you only have to map them.
* 1 Byte for the reportId (always value 1)
* 2 Bytes for the brightness of the integrated lighting (range 0-48000)
* 2 Bytes for the brightness of the rudder trim display (range 0-48000)
* 2 Bytes for indicator LEDs, each bit controls one item:
* 0x0001: DOOR OPEN
* 0x0002: DOOR FAULT
* 0x0004: ENG 1 FAULT
* 0x0008: ENG 1 FIRE
* 0x0010: ENG 2 FAULT
* 0x0020: ENG 2 FIRE
* 2 Bytes for ECAM page LEDs
* 0x0001: ECAM CLR
* 0x0002: ECAM APU
* 0x0004: ECAM ENG
* 0x0008: ECAM COND
* 0x0010: ECAM BLEED
* 0x0020: ECAM STS
* 0x0040: ECAM DOOR
* 0x0080: ECAM PRESS
* 0x0100: ECAM WHEEL
* 0x0200: ECAM ELEC
* 0x0400: ECAM F/CTL
* 0x0800: ECAM HYD
* 0x1000: ECAM FUEL
* 2 Bytes for generic controls (such as calibration)
* 4 Bytes for indicator LEDs, each bit controls one item:
* 0x00000001: ECAM CLR
* 0x00000002: ECAM APU
* 0x00000004: ECAM ENG
* 0x00000008: ECAM COND
* 0x00000010: ECAM BLEED
* 0x00000020: ECAM STS
* 0x00000040: ECAM DOOR
* 0x00000080: ECAM PRESS
* 0x00000100: ECAM WHEEL
* 0x00000200: ECAM ELEC
* 0x00000400: ECAM F/CTL
* 0x00000800: ECAM HYD
* 0x00001000: ECAM FUEL
* 0x00002000: DOOR OPEN
* 0x00004000: DOOR FAULT
* 0x00008000: ENG 1 FAULT
* 0x00010000: ENG 1 FIRE
* 0x00020000: ENG 2 FAULT
* 0x00040000: ENG 2 FIRE
## Pinout
### General pins
PA15|Backlight PWM

View file

@ -51,11 +51,7 @@ usage = ['Generic Desktop', 'Z']
logicalValueRange = [0, 65535]
[[applicationCollection.inputReport.variableItem]]
usageRange = ['Button', 'Button 1', 'Button 32']
logicalValueRange = [0, 1]
[[applicationCollection.inputReport.variableItem]]
usageRange = ['Button', 'Button 1', 'Button 32']
usageRange = ['Button', 'Button 1', 'Button 64']
logicalValueRange = [0, 1]
[[applicationCollection.outputReport]]

View file

@ -34,21 +34,18 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[
0x09, 0x32, // UsageId(Z[0x0032])
0x09, 0x32, // UsageId(Z[0x0032])
0x15, 0x00, // LogicalMinimum(0)
0x27, 0xFF, 0xFF, 0x00, 0x00, // LogicalMaximum(65,535)
0x26, 0xFF, 0x0F, // LogicalMaximum(4,095)
0x95, 0x0B, // ReportCount(11)
0x75, 0x10, // ReportSize(16)
0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)
0xC0, // EndCollection()
0x05, 0x09, // UsagePage(Button[0x0009])
0x19, 0x01, // UsageIdMin(Button 1[0x0001])
0x29, 0x20, // UsageIdMax(Button 32[0x0020])
0x29, 0x40, // UsageIdMax(Button 64[0x0040])
0x25, 0x01, // LogicalMaximum(1)
0x95, 0x20, // ReportCount(32)
0x95, 0x40, // ReportCount(64)
0x75, 0x01, // ReportSize(1)
0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)
0x19, 0x01, // UsageIdMin(Button 1[0x0001])
0x29, 0x20, // UsageIdMax(Button 32[0x0020])
0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)
0x05, 0x0E, // UsagePage(Haptics[0x000E])
0x09, 0x21, // UsageId(Manual Trigger[0x0021])
0x09, 0x21, // UsageId(Manual Trigger[0x0021])
@ -87,7 +84,8 @@ pub struct CustomOutputReport {
pub integ_lt: u16,
pub rudder_trim_brightness: u16,
pub generic: u16,
pub leds: u32,
pub leds_ecam: u16,
pub leds: u16,
}
pub struct CustomDevice<'a, B: UsbBus> {

View file

@ -382,35 +382,35 @@ fn main() -> ! {
// Buttons
let mut buttons: u32 = 0;
if io_pins.pa0.is_high() { buttons += 0x1; }
if io_pins.pa1.is_high() { buttons += 0x2; }
if io_pins.pa4.is_high() { buttons += 0x4; }
if io_pins.pa8.is_high() { buttons += 0x8; }
if io_pins.pa9.is_high() { buttons += 0x10; }
if io_pins.pa10.is_high() { buttons += 0x20; }
if io_pins.pb4.is_high() { buttons += 0x40; }
if io_pins.pb5.is_high() { buttons += 0x80; }
if io_pins.pb8.is_high() { buttons += 0x100; }
if io_pins.pb9.is_high() { buttons += 0x200; }
if io_pins.pc4.is_high() { buttons += 0x400; }
if io_pins.pc5.is_high() { buttons += 0x800; }
if io_pins.pc6.is_high() { buttons += 0x1000; }
if io_pins.pc9.is_high() { buttons += 0x0200; }
if io_pins.pc13.is_high() { buttons += 0x4000; }
if io_pins.pc14.is_high() { buttons += 0x8000; }
if io_pins.pc15.is_high() { buttons += 0x10000; }
if io_pins.pd1.is_high() { buttons += 0x20000; }
if io_pins.pd3.is_high() { buttons += 0x40000; }
if io_pins.pd4.is_high() { buttons += 0x80000; }
if io_pins.pd5.is_high() { buttons += 0x100000; }
if io_pins.pd6.is_high() { buttons += 0x200000; }
if io_pins.pd7.is_high() { buttons += 0x400000; }
if io_pins.pd13.is_high() { buttons += 0x800000; }
if io_pins.pd14.is_high() { buttons += 0x1000000; }
if io_pins.pd15.is_high() { buttons += 0x2000000; }
if io_pins.pe0.is_high() { buttons += 0x4000000; }
if io_pins.pe5.is_high() { buttons += 0x8000000; }
if io_pins.pe6.is_high() { buttons += 0x10000000; }
if io_pins.pa0.is_low() { buttons += 0x1; }
if io_pins.pa1.is_low() { buttons += 0x2; }
if io_pins.pa4.is_low() { buttons += 0x4; }
if io_pins.pa8.is_low() { buttons += 0x8; }
if io_pins.pa9.is_low() { buttons += 0x10; }
if io_pins.pa10.is_low() { buttons += 0x20; }
if io_pins.pb4.is_low() { buttons += 0x40; }
if io_pins.pb5.is_low() { buttons += 0x80; }
if io_pins.pb8.is_low() { buttons += 0x100; }
if io_pins.pb9.is_low() { buttons += 0x200; }
if io_pins.pc4.is_low() { buttons += 0x400; }
if io_pins.pc5.is_low() { buttons += 0x800; }
if io_pins.pc6.is_low() { buttons += 0x1000; }
if io_pins.pc9.is_low() { buttons += 0x2000; }
if io_pins.pc13.is_low() { buttons += 0x4000; }
if io_pins.pc14.is_low() { buttons += 0x8000; }
if io_pins.pc15.is_low() { buttons += 0x10000; }
if io_pins.pd1.is_low() { buttons += 0x20000; }
if io_pins.pd3.is_low() { buttons += 0x40000; }
if io_pins.pd4.is_low() { buttons += 0x80000; }
if io_pins.pd5.is_low() { buttons += 0x100000; }
if io_pins.pd6.is_low() { buttons += 0x200000; }
if io_pins.pd7.is_low() { buttons += 0x400000; }
if io_pins.pd13.is_low() { buttons += 0x800000; }
if io_pins.pd14.is_low() { buttons += 0x1000000; }
if io_pins.pd15.is_low() { buttons += 0x2000000; }
if io_pins.pe0.is_low() { buttons += 0x4000000; }
if io_pins.pe5.is_low() { buttons += 0x8000000; }
if io_pins.pe6.is_low() { buttons += 0x10000000; }
// ECAM Keyboard matrix
let mut ecam_buttons_read: u32 = 0;
@ -494,15 +494,15 @@ fn main() -> ! {
let mut ecam_row = [0; 3];
let mut ecam_col = [0; 6];
// Match row and col
if output.leds & 0x54A != 0 { ecam_row[0] = 1; }
if output.leds & 0x1A94 != 0 { ecam_row[1] = 1; }
if output.leds & 0x21 != 0 { ecam_row[2] = 1; }
if output.leds & 0x6 != 0 { ecam_col[0] = 1; }
if output.leds & 0x18 != 0 { ecam_col[1] = 1; }
if output.leds & 0xE0 != 0 { ecam_col[2] = 1; }
if output.leds & 0x300 != 0 { ecam_col[3] = 1; }
if output.leds & 0xC00 != 0 { ecam_col[4] = 1; }
if output.leds & 0x1001 != 0 { ecam_col[5] = 1; }
if output.leds_ecam & 0x54A != 0 { ecam_row[0] = 1; }
if output.leds_ecam & 0x1A94 != 0 { ecam_row[1] = 1; }
if output.leds_ecam & 0x21 != 0 { ecam_row[2] = 1; }
if output.leds_ecam & 0x6 != 0 { ecam_col[0] = 1; }
if output.leds_ecam & 0x18 != 0 { ecam_col[1] = 1; }
if output.leds_ecam & 0xE0 != 0 { ecam_col[2] = 1; }
if output.leds_ecam & 0x300 != 0 { ecam_col[3] = 1; }
if output.leds_ecam & 0xC00 != 0 { ecam_col[4] = 1; }
if output.leds_ecam & 0x1001 != 0 { ecam_col[5] = 1; }
// Set ECAM Out
define_ecam_output_states_row!(0, pb12, ecam_row, io_pins); // Row 1
define_ecam_output_states_row!(1, pe13, ecam_row, io_pins); // Row 2
@ -514,12 +514,12 @@ fn main() -> ! {
define_ecam_output_states_col!(4, pd8, ecam_col, io_pins); // Col 5
define_ecam_output_states_col!(5, pb11, ecam_col, io_pins); // Col 6
// Other Indicators
define_output_states!(0x2000, pb7, output, io_pins); // DOOR OPEN
define_output_states!(0x4000, pb6, output, io_pins); // DOOR FAULT
define_output_states!(0x8000, pe2, output, io_pins); // ENG 1 FAULT
define_output_states!(0x10000, pe1, output, io_pins); // ENG 1 FIRE
define_output_states!(0x20000, pe3, output, io_pins); // ENG 2 FAULT
define_output_states!(0x40000, pe4, output, io_pins); // ENG 2 FIRE
define_output_states!(0x1, pb7, output, io_pins); // DOOR OPEN
define_output_states!(0x2, pb6, output, io_pins); // DOOR FAULT
define_output_states!(0x4, pe2, output, io_pins); // ENG 1 FAULT
define_output_states!(0x8, pe1, output, io_pins); // ENG 1 FIRE
define_output_states!(0x10, pe3, output, io_pins); // ENG 2 FAULT
define_output_states!(0x20, pe4, output, io_pins); // ENG 2 FIRE
// Check generic input field
// Calibration bit

View file

@ -7,32 +7,274 @@
<open>
<![CDATA[
setprop("/FLC/Pedestal/backlight", 0);
setprop("/FLC/Pedestal/rudder-trim-display-brightness", 0);
setprop("/FLC/Pedestal/generic", 0);
setprop("/FLC/Pedestal/leds-ecam", 0);
setprop("/FLC/Pedestal/leds", 0);
var updateBacklight = func(){
setprop('/FLC/Pedestal/backlight', getprop('/controls/lighting/main-panel-norm') * 48000);
}
var updateDisplayBacklight = func(){
setprop('/FLC/Pedestal/rudder-trim-display-brightness', getprop('/controls/lighting/main-panel-norm-digital') * 48000);
}
var updateLeds = func(){
}
var lis1 = setlistener('/controls/lighting/main-panel-norm', updateBacklight);
var lis2 = setlistener('/controls/lighting/main-panel-norm-digital', updateDisplayBacklight);
]]>
</open>
</nasal>
<!-- Outputs -->
<event>
<name>vendor-0</name>
<name>unknown-0</name>
<setting>
<property>/FLC/Pedestal/backlight</property>
</setting>
</event>
<event>
<name>vendor-1</name>
<name>unknown-1</name>
<setting>
<property>/FLC/Pedestal/rudder-trim-display-brightness</property>
</setting>
</event>
<event>
<name>unknown-2</name>
<setting>
<property>/FLC/Pedestal/generic</property>
</setting>
</event>
<event>
<name>vendor-2</name>
<name>unknown-3</name>
<setting>
<property>/FLC/Pedestal/leds-ecam</property>
</setting>
</event>
<event>
<name>unknown-4</name>
<setting>
<property>/FLC/Pedestal/leds</property>
</setting>
</event>
<!-- Axis -->
<event>
<name>abs-z-translate-4</name>
<desc type="string">FloodTL Pedestal</desc>
<binding>
<command type="string">property-scale</command>
<property type="string">/controls/lighting/ped-flood-knb</property>
<factor type="double">0.000244140625</factor>
<offset type="double">0</offset>
<power type="double">1</power>
</binding>
</event>
<event>
<name>abs-z-translate-7</name>
<desc type="string">FloodTL Main Panel</desc>
<binding>
<command type="string">property-scale</command>
<property type="string">/controls/lighting/main-flood-knb</property>
<factor type="double">0.000244140625</factor>
<offset type="double">0</offset>
<power type="double">1</power>
</binding>
</event>
<event>
<name>abs-z-translate-8</name>
<desc type="string">IntegLT</desc>
<binding>
<command type="string">property-scale</command>
<property type="string">/controls/lighting/main-panel-knb</property>
<factor type="double">0.000244140625</factor>
<offset type="double">0</offset>
<power type="double">1</power>
</binding>
</event>
<!-- Buttons -->
<event>
<name>button-4</name>
<desc type="string">Switching ATT Capt</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/att-hdg</property>
<value>-1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/att-hdg</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-5</name>
<desc type="string">Switching AIR Capt</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/air-data</property>
<value>-1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/air-data</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-6</name>
<desc type="string">Switching ATT FO</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/att-hdg</property>
<value>1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/att-hdg</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-9</name>
<desc type="string">Door Unlock</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/doors/doorc-switch</property>
<value>-1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/doors/doorc-switch</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-10</name>
<desc type="string">Door Lock</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/doors/doorc-switch</property>
<value>1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/doors/doorc-switch</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-13</name>
<desc type="string">Switching AIR FO</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/air-data</property>
<value>-1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/air-data</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-14</name>
<desc type="string">Switching AIR FO</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/air-data</property>
<value>1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/navigation/switching/air-data</property>
<value>0</value>
</binding>
</mod-up>
</event>
<event>
<name>button-15</name>
<desc type="string">ENG Mode Crank</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/ignition/start-sw</property>
<value>0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/ignition/start-sw</property>
<value>1</value>
</binding>
</mod-up>
</event>
<event>
<name>button-16</name>
<desc type="string">ENG Mode Start</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/ignition/start-sw</property>
<value>2</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/ignition/start-sw</property>
<value>1</value>
</binding>
</mod-up>
</event>
<event>
<name>button-28</name>
<desc type="string">ENG Master 1</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/engines/engine[0]/cutoff-switch</property>
<value>0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/engines/engine[0]/cutoff-switch</property>
<value>1</value>
</binding>
</mod-up>
</event>
<event>
<name>button-29</name>
<desc type="string">ENG Master 2</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>/controls/engines/engine[1]/cutoff-switch</property>
<value>0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/engines/engine[1]/cutoff-switch</property>
<value>1</value>
</binding>
</mod-up>
</event>
</PropertyList>

View file

@ -1,65 +0,0 @@
<?xml version="1.0"?>
<PropertyList>
<name type="string">FLC Meow Pedestal box</name>
<axis>
<desc type="string">IntegLT</desc>
<binding>
<command type="string">property-scale</command>
<property type="string">/controls/lighting/main-panel-knb</property>
<factor type="double">0.5</factor>
<offset type="double">1</offset>
<power type="double">1</power>
</binding>
</axis>
<axis n="1">
<desc type="string">FloodTL</desc>
<binding>
<command type="string">property-scale</command>
<property type="string">/controls/lighting/main-flood-knb</property>
<factor type="double">0.5</factor>
<offset type="double">1</offset>
<power type="double">1</power>
</binding>
</axis>
<button>
<desc type="string">Ext Power</desc>
<repeatable type="string">false</repeatable>
<binding>
<command type="string">property-toggle</command>
<property>/controls/electrical/switches/ext-pwr</property>
</binding>
</button>
<button n="1">
<desc type="string">ENG Master 1</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>controls/engines/engine[0]/cutoff-switch</property>
<value>0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>controls/engines/engine[0]/cutoff-switch</property>
<value>1</value>
</binding>
</mod-up>
</button>
<button n="2">
<desc type="string">ENG Master 2</desc>
<repeatable type="string">false</repeatable>
<binding>
<command>property-assign</command>
<property>controls/engines/engine[1]/cutoff-switch</property>
<value>0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>controls/engines/engine[1]/cutoff-switch</property>
<value>1</value>
</binding>
</mod-up>
</button>
</PropertyList>