45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |  |
53 |
54 |
55 |
56 | $projectname $projectnumber
57 |
58 | $projectbrief
59 | |
60 |
61 |
62 |
63 |
64 | $projectbrief
65 | |
66 |
67 |
68 |
69 |
70 |
71 | $searchbox |
72 |
73 |
74 |
75 |
76 |
77 |
78 | | $searchbox |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/docs/css/doxygen-awesome-sidebar-only.css:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | Doxygen Awesome
4 | https://github.com/jothepro/doxygen-awesome-css
5 |
6 | MIT License
7 |
8 | Copyright (c) 2021 - 2023 jothepro
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | SOFTWARE.
27 |
28 | */
29 |
30 | html {
31 | /* side nav width. MUST be = `TREEVIEW_WIDTH`.
32 | * Make sure it is wide enough to contain the page title (logo + title + version)
33 | */
34 | --side-nav-fixed-width: 335px;
35 | --menu-display: none;
36 |
37 | --top-height: 120px;
38 | --toc-sticky-top: -25px;
39 | --toc-max-height: calc(100vh - 2 * var(--spacing-medium) - 25px);
40 | }
41 |
42 | #projectname {
43 | white-space: nowrap;
44 | }
45 |
46 |
47 | @media screen and (min-width: 768px) {
48 | html {
49 | --searchbar-background: var(--page-background-color);
50 | }
51 |
52 | #side-nav {
53 | min-width: var(--side-nav-fixed-width);
54 | max-width: var(--side-nav-fixed-width);
55 | top: var(--top-height);
56 | overflow: visible;
57 | }
58 |
59 | #nav-tree, #side-nav {
60 | height: calc(100vh - var(--top-height)) !important;
61 | }
62 |
63 | #nav-tree {
64 | padding: 0;
65 | }
66 |
67 | #top {
68 | display: block;
69 | border-bottom: none;
70 | height: var(--top-height);
71 | margin-bottom: calc(0px - var(--top-height));
72 | max-width: var(--side-nav-fixed-width);
73 | overflow: hidden;
74 | background: var(--side-nav-background);
75 | }
76 | #main-nav {
77 | float: left;
78 | padding-right: 0;
79 | }
80 |
81 | .ui-resizable-handle {
82 | cursor: default;
83 | width: 1px !important;
84 | background: var(--separator-color);
85 | box-shadow: 0 calc(-2 * var(--top-height)) 0 0 var(--separator-color);
86 | }
87 |
88 | #nav-path {
89 | position: fixed;
90 | right: 0;
91 | left: var(--side-nav-fixed-width);
92 | bottom: 0;
93 | width: auto;
94 | }
95 |
96 | #doc-content {
97 | height: calc(100vh - 31px) !important;
98 | padding-bottom: calc(3 * var(--spacing-large));
99 | padding-top: calc(var(--top-height) - 80px);
100 | box-sizing: border-box;
101 | margin-left: var(--side-nav-fixed-width) !important;
102 | }
103 |
104 | #MSearchBox {
105 | width: calc(var(--side-nav-fixed-width) - calc(2 * var(--spacing-medium)));
106 | }
107 |
108 | #MSearchField {
109 | width: calc(var(--side-nav-fixed-width) - calc(2 * var(--spacing-medium)) - 65px);
110 | }
111 |
112 | #MSearchResultsWindow {
113 | left: var(--spacing-medium) !important;
114 | right: auto;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/docs/css/doxygen-awesome-fragment-copy-button.js:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | Doxygen Awesome
4 | https://github.com/jothepro/doxygen-awesome-css
5 |
6 | MIT License
7 |
8 | Copyright (c) 2022 - 2023 jothepro
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | SOFTWARE.
27 |
28 | */
29 |
30 | class DoxygenAwesomeFragmentCopyButton extends HTMLElement {
31 | constructor() {
32 | super();
33 | this.onclick=this.copyContent
34 | }
35 | static title = "Copy to clipboard"
36 | static copyIcon = `
`
37 | static successIcon = `
`
38 | static successDuration = 980
39 | static init() {
40 | $(function() {
41 | $(document).ready(function() {
42 | if(navigator.clipboard) {
43 | const fragments = document.getElementsByClassName("fragment")
44 | for(const fragment of fragments) {
45 | const fragmentWrapper = document.createElement("div")
46 | fragmentWrapper.className = "doxygen-awesome-fragment-wrapper"
47 | const fragmentCopyButton = document.createElement("doxygen-awesome-fragment-copy-button")
48 | fragmentCopyButton.innerHTML = DoxygenAwesomeFragmentCopyButton.copyIcon
49 | fragmentCopyButton.title = DoxygenAwesomeFragmentCopyButton.title
50 |
51 | fragment.parentNode.replaceChild(fragmentWrapper, fragment)
52 | fragmentWrapper.appendChild(fragment)
53 | fragmentWrapper.appendChild(fragmentCopyButton)
54 |
55 | }
56 | }
57 | })
58 | })
59 | }
60 |
61 |
62 | copyContent() {
63 | const content = this.previousSibling.cloneNode(true)
64 | // filter out line number from file listings
65 | content.querySelectorAll(".lineno, .ttc").forEach((node) => {
66 | node.remove()
67 | })
68 | let textContent = content.textContent
69 | // remove trailing newlines that appear in file listings
70 | let numberOfTrailingNewlines = 0
71 | while(textContent.charAt(textContent.length - (numberOfTrailingNewlines + 1)) == '\n') {
72 | numberOfTrailingNewlines++;
73 | }
74 | textContent = textContent.substring(0, textContent.length - numberOfTrailingNewlines)
75 | navigator.clipboard.writeText(textContent);
76 | this.classList.add("success")
77 | this.innerHTML = DoxygenAwesomeFragmentCopyButton.successIcon
78 | window.setTimeout(() => {
79 | this.classList.remove("success")
80 | this.innerHTML = DoxygenAwesomeFragmentCopyButton.copyIcon
81 | }, DoxygenAwesomeFragmentCopyButton.successDuration);
82 | }
83 | }
84 |
85 | customElements.define("doxygen-awesome-fragment-copy-button", DoxygenAwesomeFragmentCopyButton)
86 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yaml:
--------------------------------------------------------------------------------
1 | name: Feature/Enhancement Request
2 | description: Request a new feature or enhancement
3 | title: "[FEATURE REQUEST]: "
4 | labels: ["Type: Enhancement", "Triage Required"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out this feature request! OpenHornet lives on its community contributions and reports!
10 | - type: input
11 | id: contact
12 | attributes:
13 | label: Discord Username
14 | description: How can we get in touch with you if we need more info?
15 | placeholder: ex. Noctum#4085
16 | validations:
17 | required: false
18 | - type: textarea
19 | id: summary
20 | attributes:
21 | label: Feature/Enhancement Summary
22 | description: Please summarize your issue here. Be as specific as possible.
23 | placeholder: Tell us what you want see!
24 | validations:
25 | required: true
26 | - type: textarea
27 | id: actual-results
28 | attributes:
29 | label: Actual Results
30 | description: What actually happened?
31 | placeholder: Be very specific. The more detail, the better we can analyze the issue. Copy/Paste error messages directly and completely. Context matters!
32 | validations:
33 | required: true
34 | - type: textarea
35 | id: images
36 | attributes:
37 | label: Screenshots/Images/Files
38 | description: Pictures/Files are worth 1000 words. Take some pictures or a video of the unexpected behavior, show us where you think the bad code is, put together a quick power point description of the issue, drop in a .INO file of a fix you made - you can't put too much information here!
39 | placeholder: You can just paste images, videos or files in this field...
40 | validations:
41 | required: false
42 | - type: input
43 | id: part-numbers
44 | attributes:
45 | label: Applicable File Names
46 | description: List the file(s) this issue applies to.
47 | placeholder: ex. 1A1A1-RS485_BUS_MASTER_UIP.ino, 1A2-MASTER_ARM_PANEL.ino, etc.
48 | validations:
49 | required: true
50 | - type: dropdown
51 | id: version
52 | attributes:
53 | label: Release Version
54 | description: What release are you working with?
55 | options:
56 | - v0.3.0
57 | - v0.2.0
58 | - pre-v0.2.0 (Early Development/Alpha)
59 | validations:
60 | required: true
61 | - type: dropdown
62 | id: category
63 | attributes:
64 | label: Category
65 | description: Is this a mechanical and/or electrical issue or artwork? Mechanical being physical parts like structure, seat, mechanisms, etc. Electrical would be PCBs, wiring, etc. Artwork would be placards, stickers, dataplates or a vector art issue. (You may select more than one.)
66 | multiple: true
67 | options:
68 | - embedded (Arduino Sketches/Microcontroller embedded software)
69 | - Libraries & Dependencies (Arduino Libraries, etc)
70 | - DCS-BIOS
71 | - Documentation
72 | validations:
73 | required: true
74 | - type: dropdown
75 | id: end-item
76 | attributes:
77 | label: Applicable End Item(s)
78 | description: What End Item(s) does this issue apply to?
79 | multiple: true
80 | options:
81 | - Top Level Assembly (TLA)
82 | - Upper Instrument Panel (UIP)
83 | - Lower Instrument Panel (LIP)
84 | - Center Tub (CT)
85 | - Left Console (LCON)
86 | - Right Console (RCON)
87 | - Flight Stick
88 | - Throttle
89 | validations:
90 | required: true
91 | - type: checkboxes
92 | id: built-to-print
93 | attributes:
94 | label: Hardware is built to print & this software is tested on that hardware?
95 | description: Did you build this part to the relevant drawing, using parts specified by OpenHornet? (It's okay if you didn't, just describe how you deviated in the Miscellaneous Info text area below.)
96 | options:
97 | - label: I built (or attempted to build) the part to the OpenHornet print without any deviations and tested the software on it.
98 | - label: I am not building this part to the OH print. (List deviations in detail in the Miscellaneous Info text area below.)
99 | required: true
100 | - type: textarea
101 | id: misc
102 | attributes:
103 | label: Miscellaneous Info
104 | description: Do you have any additional information not previously covered?
105 | placeholder: This space would be to provide specific code snippets and versions, list deviations from the OpenHornet build, or provide any information that is not covered elsewhere in this report.
106 | validations:
107 | required: false
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug.yaml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: File a bug report
3 | title: "[Bug]: "
4 | labels: ["Type: Bug/Obsolesce", "Triage Required"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out this bug report! OpenHornet lives on its community contributions and reports!
10 | - type: input
11 | id: contact
12 | attributes:
13 | label: Discord Username
14 | description: How can we get in touch with you if we need more info?
15 | placeholder: ex. Noctum#4085
16 | validations:
17 | required: false
18 | - type: textarea
19 | id: summary
20 | attributes:
21 | label: Bug Summary
22 | description: Please summarize your issue here. Be as specific as possible.
23 | placeholder: Tell us what you see!
24 | validations:
25 | required: true
26 | - type: textarea
27 | id: expected-results
28 | attributes:
29 | label: Expected Results
30 | description: What did you expect to happen?
31 | placeholder: Be very specific. The more detail, the better we can analyze the issue.
32 | validations:
33 | required: true
34 | - type: textarea
35 | id: actual-results
36 | attributes:
37 | label: Actual Results
38 | description: What actually happened?
39 | placeholder: Be very specific. The more detail, the better we can analyze the issue. Copy/Paste error messages directly and completely. Context matters!
40 | validations:
41 | required: true
42 | - type: textarea
43 | id: images
44 | attributes:
45 | label: Screenshots/Images/Files
46 | description: Pictures/Files are worth 1000 words. Take some pictures or a video of the unexpected behavior, show us where you think the bad code is, put together a quick power point description of the issue, drop in a .INO file of a fix you made - you can't put too much information here!
47 | placeholder: You can just paste images, videos or files in this field...
48 | validations:
49 | required: false
50 | - type: input
51 | id: part-numbers
52 | attributes:
53 | label: Applicable File Names
54 | description: List the file(s) this issue applies to.
55 | placeholder: ex. 1A1A1-RS485_BUS_MASTER_UIP.ino, 1A2-MASTER_ARM_PANEL.ino, etc.
56 | validations:
57 | required: true
58 | - type: dropdown
59 | id: version
60 | attributes:
61 | label: Release Version
62 | description: What release are you working with?
63 | options:
64 | - v0.3.0
65 | - v0.2.0
66 | - pre-v0.2.0 (Early Development/Alpha)
67 | validations:
68 | required: true
69 | - type: dropdown
70 | id: category
71 | attributes:
72 | label: Category
73 | description: Is this a mechanical and/or electrical issue or artwork? Mechanical being physical parts like structure, seat, mechanisms, etc. Electrical would be PCBs, wiring, etc. Artwork would be placards, stickers, dataplates or a vector art issue. (You may select more than one.)
74 | multiple: true
75 | options:
76 | - embedded (Arduino Sketches/Microcontroller embedded software)
77 | - Libraries & Dependencies (Arduino Libraries, etc)
78 | - DCS-BIOS
79 | - Documentation
80 | validations:
81 | required: true
82 | - type: dropdown
83 | id: end-item
84 | attributes:
85 | label: Applicable End Item(s)
86 | description: What End Item(s) does this issue apply to?
87 | multiple: true
88 | options:
89 | - Top Level Assembly (TLA)
90 | - Upper Instrument Panel (UIP)
91 | - Lower Instrument Panel (LIP)
92 | - Center Tub (CT)
93 | - Left Console (LCON)
94 | - Right Console (RCON)
95 | - Flight Stick
96 | - Throttle
97 | validations:
98 | required: true
99 | - type: checkboxes
100 | id: built-to-print
101 | attributes:
102 | label: Hardware is built to print & this software is tested on that hardware?
103 | description: Did you build this part to the relevant drawing, using parts specified by OpenHornet? (It's okay if you didn't, just describe how you deviated in the Miscellaneous Info text area below.)
104 | options:
105 | - label: I built (or attempted to build) the part to the OpenHornet print without any deviations and tested the software on it.
106 | - label: I am not building this part to the OH print. (List deviations in detail in the Miscellaneous Info text area below.)
107 | required: true
108 | - type: textarea
109 | id: misc
110 | attributes:
111 | label: Miscellaneous Info
112 | description: Do you have any additional information not previously covered?
113 | placeholder: This space would be to provide specific code snippets and versions, list deviations from the OpenHornet build, or provide any information that is not covered elsewhere in this report.
114 | validations:
115 | required: false
--------------------------------------------------------------------------------
/embedded/OH1_Upper_Instrument_Panel/1A6-SPIN_RCVY_PANEL/1A6-SPIN_RCVY_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 1A6-SPIN_RCVY_PANEL.ino
35 | * @author Arribe
36 | * @date 03.02.2024
37 | * @version 0.0.3
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the SPIN RCVY panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 1A6
44 | * * **Intended Board:** ABSIS ALE
45 | * * **RS485 Bus Address:** 5
46 | *
47 |
48 | * ##Wiring diagram:
49 | * PIN | Function
50 | * --- | ---
51 | * A3 | HMD Brightness
52 | * A2 | IR Off
53 | * D2 | IR Override
54 | * D3 | Spin Recovery, with cover
55 | *
56 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
57 | * It also sets the address of this slave device. The slave address should be
58 | * between 1 and 126 and must be unique among all devices on the same bus.
59 | *
60 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
61 | *
62 | * #define DCSBIOS_RS485_SLAVE 1 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
63 | */
64 |
65 | /**
66 | * Check if we're on a Mega328 or Mega2560 and define the correct
67 | * serial interface
68 | *
69 | */
70 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
71 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
72 | #else
73 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
74 | #endif
75 |
76 | #ifdef __AVR__
77 | #include
78 | #endif
79 |
80 | /**
81 | * The Arduino pin that is connected to the
82 | * RE and DE pins on the RS-485 transceiver.
83 | */
84 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
85 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
86 |
87 | #include "DcsBios.h"
88 |
89 | // Define pins for DCS-BIOS per interconnect diagram.
90 | #define HMD_A A3 ///< HMD Brightness
91 | #define IR_OFF A2 ///< IR Off
92 | #define IR_ORIDE 2 ///< IR Override
93 | #define SPIN_RCVY 3 ///< Spin Recovery, with cover
94 |
95 | // Connect switches to DCS-BIOS
96 | DcsBios::Potentiometer hmdOffBrt("HMD_OFF_BRT", HMD_A);
97 | DcsBios::Switch3Pos irCoolSw("IR_COOL_SW", IR_ORIDE, IR_OFF);
98 | DcsBios::SwitchWithCover2Pos spinRecoverySw("SPIN_RECOVERY_SW", "SPIN_RECOVERY_COVER", SPIN_RCVY);
99 |
100 | /**
101 | * Arduino Setup Function
102 | *
103 | * Arduino standard Setup Function. Code who should be executed
104 | * only once at the program start, belongs in this function.
105 | */
106 | void setup() {
107 |
108 | // Run DCS Bios setup function
109 | DcsBios::setup();
110 | }
111 |
112 | /**
113 | * Arduino Loop Function
114 | *
115 | * Arduino standard Loop Function. Code who should be executed
116 | * over and over in a loop, belongs in this function.
117 | */
118 | void loop() {
119 |
120 | //Run DCS Bios loop function
121 | DcsBios::loop();
122 | }
--------------------------------------------------------------------------------
/embedded/OH1_Upper_Instrument_Panel/1A2-MASTER_ARM_PANEL/1A2-MASTER_ARM_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 1A2-MASTER_ARM_PANEL.ino
35 | * @author Sandra Carroll (smgvbest@gmail.com), Arribe
36 | * @date 3.02.2024
37 | * @version 0.0.2
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the MASTER ARM panel.
40 | *
41 | * @details This sketch is for the UIP Master Arm Panel.
42 | *
43 | * * **Reference Designator:** 1A2
44 | * * **Intended Board:** ABSIS ALE
45 | * * **RS485 Bus Address:** 1
46 | *
47 | * ###Wiring diagram:
48 | *
49 | * PIN | Function
50 | * --- | ---
51 | * A1 | Emergency Jettison Switch
52 | * A2 | Air to Ground Select
53 | * A3 | Ready/Discharge Switch
54 | * D2 | Air to Air Select
55 | * D3 | Master Arm Switch
56 | *
57 | *
58 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
59 | * It also sets the address of this slave device. The slave address should be
60 | * between 1 and 126 and must be unique among all devices on the same bus.
61 | *
62 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
63 | * #define DCSBIOS_RS485_SLAVE 1 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
64 | */
65 |
66 | /**
67 | * Check if we're on a Mega328 or Mega2560 and define the correct
68 | * serial interface
69 | *
70 | */
71 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
72 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
73 | #else
74 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
75 | #endif
76 |
77 | #ifdef __AVR__
78 | #include
79 | #endif
80 |
81 | /**
82 | * The Arduino pin that is connected to the
83 | * RE and DE pins on the RS-485 transceiver.
84 | */
85 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
86 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
87 |
88 | #include "DcsBios.h"
89 |
90 | //Declare pins for DCS-BIOS per interconnect diagram.
91 | #define E_JETT_SW A1 ///< Emergency Jettison Switch
92 | #define AG_SW A2 ///< Air to Ground Select
93 | #define READY_SW A3 ///< Ready/Discharge Switch
94 | #define AA_SW 2 ///< Air to Air Select
95 | #define MSTR_ARM_SW 3 ///< Master Arm Switch
96 |
97 | // Connect switches to DCS-BIOS
98 | DcsBios::Switch2Pos masterArmSw("MASTER_ARM_SW", MSTR_ARM_SW);
99 | DcsBios::Switch2Pos masterModeAa("MASTER_MODE_AA", AA_SW);
100 | DcsBios::Switch2Pos masterModeAg("MASTER_MODE_AG", AG_SW);
101 | DcsBios::Switch2Pos emerJettBtn("EMER_JETT_BTN", E_JETT_SW);
102 | DcsBios::Switch2Pos fireExtBtn("FIRE_EXT_BTN", READY_SW);
103 |
104 | /**
105 | * @brief
106 | * Arduino Setup Function
107 | *
108 | * Arduino standard Setup Function. Code who should be executed
109 | * only once at the program start, belongs in this function.
110 | */
111 | void setup() {
112 |
113 | // Run DCS Bios setup function
114 | DcsBios::setup();
115 |
116 | }
117 |
118 | /**
119 | * @brief Arduino Loop Function
120 | *
121 | * Arduino standard Loop Function. Code who should be executed
122 | * over and over in a loop, belongs in this function.
123 | */
124 | void loop() {
125 |
126 | //Run DCS Bios loop function
127 | DcsBios::loop();
128 |
129 | }
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A4A2-EXT_LIGHTS_PANEL/4A4A2-EXT_LIGHTS_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A4A2-EXT_LIGHTS_PANEL.ino
35 | * @author Arribe
36 | * @date 03.03.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the EXT LIGHTS panel, GEN TIE panel & ECM DISP switch.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 4A4A2
44 | * * **Intended Board:** ABSIS ALE
45 | * * **RS485 Bus Address:** 4
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * A3 | Formation Lights Brightness
51 | * 2 | Strobe Dim
52 | * A2 | Position Lights Brightness
53 | * 3 | Strobe Bright
54 | * A1 | Inter-Wing Tank Inhibit
55 | * 4 | Gen Tie Switch
56 | * A0 | Counter Measure Dispenser Switch
57 | *
58 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
59 | * It also sets the address of this slave device. The slave address should be
60 | * between 1 and 126 and must be unique among all devices on the same bus.
61 | *
62 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
63 |
64 | #define DCSBIOS_RS485_SLAVE 4 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
65 | */
66 |
67 | /**
68 | * Check if we're on a Mega328 or Mega2560 and define the correct
69 | * serial interface
70 | *
71 | */
72 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
73 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
74 | #else
75 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
76 | #endif
77 |
78 | #ifdef __AVR__
79 | #include
80 | #endif
81 |
82 | /**
83 | * The Arduino pin that is connected to the
84 | * RE and DE pins on the RS-485 transceiver.
85 | */
86 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
87 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
88 |
89 | #include "DcsBios.h"
90 |
91 | // Define pins for DCS-BIOS per interconnect diagram.
92 | #define FORM_A A3 ///< Formation Lights Brightness
93 | #define STROBE_SW1 2 ///< Strobe Dim
94 | #define POSI_A A2 ///< Position Lights Brightness
95 | #define STROBE_SW2 3 ///< Strobe Bright
96 | #define INTRW_SW1 A1 ///< Inter-Wing Tank Inhibit
97 | #define GENTIE_SW1 4 ///< Gen Tie Switch
98 | #define DISP_SW1 A0 ///< Counter Measure Dispenser Switch
99 |
100 | // Connect switches to DCS-BIOS
101 | DcsBios::Potentiometer formationDimmer("FORMATION_DIMMER", FORM_A);
102 | DcsBios::Switch2Pos intWngTankSw("INT_WNG_TANK_SW", INTRW_SW1);
103 | DcsBios::Potentiometer positionDimmer("POSITION_DIMMER", POSI_A);
104 | DcsBios::Switch3Pos strobeSw("STROBE_SW", STROBE_SW1, STROBE_SW2);
105 | DcsBios::SwitchWithCover2Pos genTieSw("GEN_TIE_SW", "GEN_TIE_COVER", GENTIE_SW1);
106 | DcsBios::Switch2Pos cmsdDispenseBtn("CMSD_DISPENSE_BTN", DISP_SW1);
107 |
108 | /**
109 | * Arduino Setup Function
110 | *
111 | * Arduino standard Setup Function. Code who should be executed
112 | * only once at the program start, belongs in this function.
113 | */
114 | void setup() {
115 |
116 | // Run DCS Bios setup function
117 | DcsBios::setup();
118 | }
119 |
120 | /**
121 | * Arduino Loop Function
122 | *
123 | * Arduino standard Loop Function. Code who should be executed
124 | * over and over in a loop, belongs in this function.
125 | */
126 | void loop() {
127 |
128 | //Run DCS Bios loop function
129 | DcsBios::loop();
130 | }
--------------------------------------------------------------------------------
/embedded/OH5_Right_Console/5A6A1-INTR_LT_PANEL/5A6A1-INTR_LT_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 5A6A1-INTR_LT_PANEL.ino
35 | * @author Arribe
36 | * @date 03.11.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the INTR LT panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 5A6A1
44 | * * **Intended Board:** ABSIS ALE
45 | * * **RS485 Bus Address:** 5
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * A3 | Light Test
51 | * 2 | NVG Mode
52 | * 3 | Day Mode
53 | * A2 | Warning / Caution Brightness
54 | * A1 | Chart Brightness
55 | * 6 | Console Brightness
56 | * 8 | Intrument Panel Brightness
57 | * 10 | Flood Brightness
58 | *
59 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
60 | * It also sets the address of this slave device. The slave address should be
61 | * between 1 and 126 and must be unique among all devices on the same bus.
62 | *
63 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
64 |
65 | #define DCSBIOS_RS485_SLAVE 5 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
66 | */
67 |
68 | /**
69 | * Check if we're on a Mega328 or Mega2560 and define the correct
70 | * serial interface
71 | *
72 | */
73 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
74 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
75 | #else
76 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
77 | #endif
78 |
79 | #ifdef __AVR__
80 | #include
81 | #endif
82 |
83 | /**
84 | * The Arduino pin that is connected to the
85 | * RE and DE pins on the RS-485 transceiver.
86 | */
87 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
88 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
89 |
90 | #include "DcsBios.h"
91 |
92 | // Define pins for DCS-BIOS per interconnect diagram.
93 | #define TEST A3 ///< Light Test
94 | #define NVG 2 ///< NVG Mode
95 | #define DAY 3 ///< Day Mode
96 | #define WAR_CAUT A2 ///< Warning / Caution Brightness
97 | #define CHART A1 ///< Chart Brightness
98 | #define CONSOLES 6 ///< Console Brightness
99 | #define INST_PNL 8 ///< Intrument Panel Brightness
100 | #define FLOOD 10 ///< Flood Brightness
101 |
102 | // Connect switches to DCS-BIOS
103 | DcsBios::Potentiometer chartDimmer("CHART_DIMMER", CHART);
104 | DcsBios::Switch3Pos cockkpitLightModeSw("COCKKPIT_LIGHT_MODE_SW", NVG, DAY);
105 | DcsBios::Potentiometer consolesDimmer("CONSOLES_DIMMER", CONSOLES);
106 | DcsBios::Potentiometer floodDimmer("FLOOD_DIMMER", FLOOD);
107 | DcsBios::Potentiometer instPnlDimmer("INST_PNL_DIMMER", INST_PNL);
108 | DcsBios::Switch2Pos lightsTestSw("LIGHTS_TEST_SW", TEST);
109 | DcsBios::Potentiometer warnCautionDimmer("WARN_CAUTION_DIMMER", WAR_CAUT);
110 |
111 | /**
112 | * Arduino Setup Function
113 | *
114 | * Arduino standard Setup Function. Code who should be executed
115 | * only once at the programm start, belongs in this function.
116 | */
117 | void setup() {
118 |
119 | // Run DCS Bios setup function
120 | DcsBios::setup();
121 | }
122 |
123 | /**
124 | * Arduino Loop Function
125 | *
126 | * Arduino standard Loop Function. Code who should be executed
127 | * over and over in a loop, belongs in this function.
128 | */
129 | void loop() {
130 |
131 | //Run DCS Bios loop function
132 | DcsBios::loop();
133 | }
134 |
--------------------------------------------------------------------------------
/embedded/OH1_Upper_Instrument_Panel/1A7-HUD_PANEL/1A7-HUD_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 1A7-HUD_PANEL.ino
35 | * @author Arribe
36 | * @date 02.29.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the HUD panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 1A7
44 | * * **Intended Board:** ABSIS ALE
45 | * * **RS485 Bus Address:** 3
46 | *
47 | * *##Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * A0 | AOA Indexer
51 | * A1 | HUD Balance
52 | * A2 | HUD Black Level
53 | * A3 | HUD Brightness
54 | * 6 | HUD Symbology REJ2
55 | * 7 | Video Control W/B
56 | * 8 | ALT BARO
57 | * 9 | ATT STBY
58 | * 10 | ATT INS
59 | * 14 | Day Switch
60 | * 15 | HUD Symbology NORM
61 | * 16 | Video Control OFF
62 | *
63 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
64 | * It also sets the address of this slave device. The slave address should be
65 | * between 1 and 126 and must be unique among all devices on the same bus.
66 | *
67 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
68 | *
69 | * #define DCSBIOS_RS485_SLAVE 1 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
70 | */
71 |
72 | /**
73 | * Check if we're on a Mega328 or Mega2560 and define the correct
74 | * serial interface
75 | *
76 | */
77 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
78 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
79 | #else
80 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
81 | #endif
82 |
83 | #ifdef __AVR__
84 | #include
85 | #endif
86 |
87 | /**
88 | * The Arduino pin that is connected to the
89 | * RE and DE pins on the RS-485 transceiver.
90 | */
91 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
92 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
93 |
94 | #include "DcsBios.h"
95 |
96 | // Define pins for DCS-BIOS per interconnect diagram.
97 | #define AOA_A A0 ///< AOA Indexer
98 | #define BAL_A A1 ///< HUD Balance
99 | #define BLK_A A2 ///< HUD Black Level
100 | #define BRT_A A3 ///< HUD Brightness
101 | #define REJ_2 6 ///< HUD Symbology REJ2
102 | #define WB_WB 7 ///< Video Control W/B
103 | #define ALT_BARO 8 ///< ALT BARO
104 | #define ATT_STBY 9 ///< ATT STBY
105 | #define ATT_INS 10 ///< ATT INS
106 | #define DAY_SW 14 ///< Day Switch
107 | #define REJ_NORM 15 ///< HUD Symbology NORM
108 | #define WB_OFF 16 ///< Video Control OFF
109 |
110 | // Connect switches to DCS-BIOS
111 | DcsBios::Switch2Pos hudAltSw("HUD_ALT_SW", ALT_BARO);
112 | DcsBios::Potentiometer hudAoaIndexer("HUD_AOA_INDEXER", AOA_A);
113 | DcsBios::Switch3Pos hudAttSw("HUD_ATT_SW", ATT_STBY, ATT_INS);
114 | DcsBios::Potentiometer hudBalance("HUD_BALANCE", BAL_A);
115 | DcsBios::Potentiometer hudBlackLvl("HUD_BLACK_LVL", BLK_A);
116 | DcsBios::Potentiometer hudSymBrt("HUD_SYM_BRT", BRT_A);
117 | DcsBios::Switch2Pos hudSymBrtSelect("HUD_SYM_BRT_SELECT", DAY_SW);
118 | DcsBios::Switch3Pos hudSymRejSw("HUD_SYM_REJ_SW", REJ_2, REJ_NORM);
119 | DcsBios::Switch3Pos hudVideoControlSw("HUD_VIDEO_CONTROL_SW", WB_OFF, WB_WB);
120 |
121 | /**
122 | * Arduino Setup Function
123 | *
124 | * Arduino standard Setup Function. Code who should be executed
125 | * only once at the program start, belongs in this function.
126 | */
127 | void setup() {
128 |
129 | // Run DCS Bios setup function
130 | DcsBios::setup();
131 |
132 | }
133 |
134 | /**
135 | * Arduino Loop Function
136 | *
137 | * Arduino standard Loop Function. Code who should be executed
138 | * over and over in a loop, belongs in this function.
139 | */
140 | void loop() {
141 |
142 | //Run DCS Bios loop function
143 | DcsBios::loop();
144 |
145 | }
--------------------------------------------------------------------------------
/embedded/OH3_Center_Tub/3A2A1-SEAT_CONTROLS/3A2A1-SEAT_CONTROLS.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 3A2A1-SEAT_CONTROLS.ino
35 | * @author Arribe
36 | * @date 03.13.2024
37 | * @version u.0.0.1 (untested)
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @warning This sketch is based on a wiring diagram, and was not yet fully tested on hardware.\n *The ejection handle pull, seat arm/disarm, and manual release override have been tested on hardware.
40 | * The seat up/down, and shoulder harness lock/unlock was validated via BORT by observing DCS output values and ensuring those inputs line up with the DCS Bios Switch codes' inputs.*
41 | *
42 | * @brief Controls all seat controls and handles.
43 | *
44 | * @details
45 | *
46 | * * **Reference Designator:** 3A2A1
47 | * * **Intended Board:** ABSIS ALE
48 | * * **RS485 Bus Address:** 9
49 | *
50 | * ### Wiring diagram:
51 | * PIN | Function
52 | * --- | ---
53 | * A3 | Seat Harness Lock - forward position
54 | * 2 | Seat Harness Unlock - aft position
55 | * A2 | Seat Up - switch aft
56 | * 3 | Seat Down - switch forward
57 | * A1 | Eject
58 | * 15 | Seat Arm
59 | * 6 | Harness Release
60 | *
61 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
62 | * It also sets the address of this slave device. The slave address should be
63 | * between 1 and 126 and must be unique among all devices on the same bus.
64 | *
65 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
66 |
67 | #define DCSBIOS_RS485_SLAVE 9 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
68 | */
69 |
70 | /**
71 | * Check if we're on a Mega328 or Mega2560 and define the correct
72 | * serial interface
73 | *
74 | */
75 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
76 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
77 | #else
78 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
79 | #endif
80 |
81 | #ifdef __AVR__
82 | #include
83 | #endif
84 |
85 | /**
86 | * The Arduino pin that is connected to the
87 | * RE and DE pins on the RS-485 transceiver.
88 | */
89 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
90 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
91 |
92 | #include "DcsBios.h"
93 |
94 | // Define pins for DCS-BIOS per interconnect diagram.
95 | #define SEAT_HARNESS_LOCK A3 ///< Seat Harness Lock - forward position
96 | #define SEAT_HARNESS_UNLOCK 2 ///< Seat Harness Unlock - aft position
97 | #define SEAT_UP A2 ///< Seat Up - switch aft
98 | #define SEAT_DOWN 3 ///< Seat Down - switch forward
99 | #define EJECT A1 ///< Eject
100 | #define SEAT_ARM 15 ///< Seat Arm
101 | #define HARNESS_RELEASE 6 ///< Harness Release
102 |
103 | // Connect switches to DCS-BIOS
104 | DcsBios::Switch2Pos ejectionHandleSw("EJECTION_HANDLE_SW", EJECT);
105 | DcsBios::Switch2Pos ejectionSeatArmed("EJECTION_SEAT_ARMED", SEAT_ARM, true); ///< For proper control alignment the swith movement needs to be inverted. The seat is armed when DCS Bios value = 0, but physical switch is normally open.
106 | DcsBios::Switch2Pos ejectionSeatMnlOvrd("EJECTION_SEAT_MNL_OVRD", HARNESS_RELEASE);
107 | DcsBios::Switch3Pos seatHeightSw("SEAT_HEIGHT_SW", SEAT_UP, SEAT_DOWN ); ///< Verified order via BORT by observing DCS output value
108 |
109 | const byte shldrHarnessSwPins[2] = {SEAT_HARNESS_UNLOCK, SEAT_HARNESS_LOCK}; ///< Verified order via BORT by observing DCS output value
110 | DcsBios::SwitchMultiPos shldrHarnessSw("SHLDR_HARNESS_SW", shldrHarnessSwPins, 2);
111 |
112 |
113 | /**
114 | * Arduino Setup Function
115 | *
116 | * Arduino standard Setup Function. Code who should be executed
117 | * only once at the programm start, belongs in this function.
118 | */
119 | void setup() {
120 |
121 | // Run DCS Bios setup function
122 | DcsBios::setup();
123 | }
124 |
125 | /**
126 | * Arduino Loop Function
127 | *
128 | * Arduino standard Loop Function. Code who should be executed
129 | * over and over in a loop, belongs in this function.
130 | */
131 | void loop() {
132 |
133 | //Run DCS Bios loop function
134 | DcsBios::loop();
135 | }
136 |
--------------------------------------------------------------------------------
/embedded/OH5_Right_Console/5A9A1-KY58_PANEL/5A9A1-KY58_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 5A9A1-KY58_PANEL.ino
35 | * @author Arribe
36 | * @date 03.10.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the KY58 panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 5A9A1
44 | * * **Intended Board:** ABSIS ALE
45 | * * **RS485 Bus Address:** 8
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * A3 | Mode - Plaintext
51 | * 2 | Mode - En(C)rypted - comm 2 radio
52 | * A2 | Mode - Load cryptographic key (no practical purpose in the sim).
53 | * 3 | Mode - Recieve Variable (no practical purpose in the sim).
54 | * A1 | TD
55 | * 4 | Off
56 | * 15 | Zero CH 1 - 5 (not implemented in the sim).
57 | * 6 | CH 1
58 | * 14 | CH 2
59 | * 7 | CH 3
60 | * 16 | CH 4
61 | * 8 | CH 5
62 | * 10 | CH 6
63 | * 9 | Zero All (not implemented in the sim).
64 |
65 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
66 | * It also sets the address of this slave device. The slave address should be
67 | * between 1 and 126 and must be unique among all devices on the same bus.
68 | *
69 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
70 |
71 | #define DCSBIOS_RS485_SLAVE 8 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
72 | */
73 |
74 | /**
75 | * Check if we're on a Mega328 or Mega2560 and define the correct
76 | * serial interface
77 | *
78 | */
79 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
80 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
81 | #else
82 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
83 | #endif
84 |
85 | #ifdef __AVR__
86 | #include
87 | #endif
88 |
89 | /**
90 | * The Arduino pin that is connected to the
91 | * RE and DE pins on the RS-485 transceiver.
92 | */
93 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
94 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
95 |
96 | #include "DcsBios.h"
97 |
98 | // Define pins for DCS-BIOS per interconnect diagram.
99 | #define MODE_P A3 ///< Mode - Plaintext
100 | #define MODE_C 2 ///< Mode - En(C)rypted - comm 2 radio
101 | #define MODE_LD A2 ///< Mode - Load cryptographic key (no practical purpose in the sim).
102 | #define MODE_RV 3 ///< Mode - Recieve Variable (no practical purpose in the sim).
103 | #define TD A1 ///< Power TD
104 | #define OFF 4 ///< Power Off
105 | #define KY_VOL A0 ///< KY58 Volume
106 | #define CH_Z1_5 15 ///< Zero CH 1 - 5
107 | #define CH_1 6 ///< CH 1
108 | #define CH_2 14 ///< CH 2
109 | #define CH_3 7 ///< CH 3
110 | #define CH_4 16 ///< CH 4
111 | #define CH_5 8 ///< CH 5
112 | #define CH_6 10 ///< CH 6
113 | #define CH_ZALL 9 ///< Zero All
114 |
115 | // Connect switches to DCS-BIOS
116 | /// KY-58 Fill Select Knob pins, Z 1-5/1/2/3/4/5/6/Z ALL - 5A9A1SW2 CHANNEL
117 | const byte ky58FillSelectPins[8] = {CH_Z1_5, CH_1, CH_2, CH_3, CH_4, CH_5, CH_6, CH_ZALL};
118 | /// @note The sim does not allow rotating the KY58 Fill Select knob to Z all or Z 1-5, and if it did there isn't a way to reload the cryptographic keys.
119 | DcsBios::SwitchMultiPos ky58FillSelect("KY58_FILL_SELECT", ky58FillSelectPins, 8);
120 |
121 | ///KY-58 Mode Select Knob, P/C/LD/RV - 5A9A1SW1 MODE
122 | const byte ky58ModeSelectPins[4] = {MODE_P, MODE_C, MODE_LD, MODE_RV};
123 | DcsBios::SwitchMultiPos ky58ModeSelect("KY58_MODE_SELECT", ky58ModeSelectPins, 4);
124 |
125 | DcsBios::Switch3Pos ky58PowerSelect("KY58_POWER_SELECT", TD, OFF);
126 | DcsBios::Potentiometer ky58Volume("KY58_VOLUME", KY_VOL);
127 |
128 | /**
129 | * Arduino Setup Function
130 | *
131 | * Arduino standard Setup Function. Code who should be executed
132 | * only once at the programm start, belongs in this function.
133 | */
134 | void setup() {
135 |
136 | // Run DCS Bios setup function
137 | DcsBios::setup();
138 | }
139 |
140 | /**
141 | * Arduino Loop Function
142 | *
143 | * Arduino standard Loop Function. Code who should be executed
144 | * over and over in a loop, belongs in this function.
145 | */
146 | void loop() {
147 |
148 | //Run DCS Bios loop function
149 | DcsBios::loop();
150 | }
151 |
--------------------------------------------------------------------------------
/embedded/templates/OHSketchTemplate/OHSketchTemplate.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file OHSketchTemplate.ino
35 | * @author
36 | * @date
37 | * @version u.0.0.1 (untested)
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @warning This sketch is based on a wiring diagram, and was not yet tested on hardware. (Remove this line once tested on hardware and in system.)
40 | * @brief
41 | *
42 | * @details This is the OpenHornet Sketch Template. It should be used as a starting point for every new sketch.
43 | * Please copy the whole OHSketchTemplate folder to start, and ensure the correct line in the Makefile is uncommented.
44 | *
45 | * * **Reference Designator:**
46 | * * **Intended Board:**
47 | * * **RS485 Bus Address:**
48 | *
49 | * ### Wiring diagram:
50 | * PIN | Function
51 | * --- | ---
52 | * 1 | function 1
53 | * 2 | function 2
54 | * 3 | function 3
55 | *
56 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
57 | * It also sets the address of this slave device. The slave address should be
58 | * between 1 and 126 and must be unique among all devices on the same bus.
59 | *
60 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
61 |
62 | #define DCSBIOS_RS485_SLAVE 1 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
63 | */
64 |
65 | /**
66 | * Check if we're on a Mega328 or Mega2560 and define the correct
67 | * serial interface
68 | *
69 | */
70 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
71 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
72 | #else
73 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
74 | #endif
75 |
76 | #ifdef __AVR__
77 | #include
78 | #endif
79 |
80 | /**
81 | * The Arduino pin that is connected to the
82 | * RE and DE pins on the RS-485 transceiver.
83 | */
84 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
85 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
86 |
87 | #include "DcsBios.h"
88 |
89 | // Define pins for DCS-BIOS per interconnect diagram.
90 | #define PIN_NAME1 A1 ///< function 1
91 | #define PIN_NAME2 A2 ///< function 2
92 |
93 | //Declare variables for custom non-DCS logic
94 | bool wowLeft = true; ///< Update variables as needed and update this Doxygen comment, or remove line/section if not needed.
95 | bool wowRight = true; ///< Update variables as needed and update this Doxygen comment, or remove line/section if not needed.
96 |
97 | // Connect switches to DCS-BIOS
98 | DcsBios::Switch2Pos emergencyGearRotate("EMERGENCY_GEAR_ROTATE", PIN_NAME1); //delete example and this comment.
99 |
100 | // DCSBios reads to save airplane state information.
101 | void onExtWowLeftChange(unsigned int newValue) {
102 | wowLeft = newValue;
103 | } DcsBios::IntegerBuffer extWowLeftBuffer(0x74d8, 0x0100, 8, onExtWowLeftChange);
104 |
105 |
106 | /**
107 | * Arduino Setup Function
108 | *
109 | * Arduino standard Setup Function. Code who should be executed
110 | * only once at the programm start, belongs in this function.
111 | */
112 | void setup() {
113 |
114 | // Run DCS Bios setup function
115 | DcsBios::setup();
116 | }
117 |
118 | /**
119 | * Arduino Loop Function
120 | *
121 | * Arduino standard Loop Function. Code who should be executed
122 | * over and over in a loop, belongs in this function.
123 | */
124 | void loop() {
125 |
126 | //Run DCS Bios loop function
127 | DcsBios::loop();
128 | }
129 |
130 | /**
131 | * A brief description on a single line, ended by a period or blank line.
132 | *
133 | * A longer comment, which may stretch over several lines and may include other things like:
134 | * Lists:
135 | * - list points
136 | * + nested list points
137 | * - more list points
138 | *
139 | * # Headers Level 1
140 | * ## Headers Level 2
141 | * ### Headers Level 3
142 | *
143 | * > Block quotes
144 | *
145 | * **Emphasis**
146 | * _Emphasis_
147 | *
148 | * `code()`
149 | *
150 | * even Tables are supported:
151 | * First Header | Second Header
152 | * ------------- | -------------
153 | * Content Cell | Content Cell
154 | * Content Cell | Content Cell
155 | *
156 | * Links:
157 | * [More about markdown support](http://www.doxygen.nl/manual/markdown.html)
158 | *
159 | * @param myParam1 Description of 1st parameter.
160 | * @param myParam2 Description of 2nd parameter.
161 | * @returns Description of returned value.
162 | */
163 | int sampleFunction(int myParam1, int myParam2) {
164 | int myReturn;
165 | return myReturn;
166 | }
167 |
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A2A1-LDG_GEAR_PANEL/4A2A1-LDG_GEAR_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A2A1-LDG_GEAR_PANEL.ino
35 | * @author Arribe
36 | * @date 2/28/2024
37 | * @version 0.0.3
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the LDG GEAR panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 4A2A1
44 | * * **Intended Board:** ABSIS ALE /w Relay Module
45 | * * **RS485 Bus Address:** 1
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * A1 | Landing Gear Emergency Rotate and Pull
51 | * A2 | Landing Gear Down Lock Override Button
52 | * A3 | Landing Gear Warning Silence Button
53 | * 2 | Landing Gear Down Lock Solenoid
54 | * 3 | Landing Gear Limit Switch (handle raise / lower)
55 | * 4 | Landing Gear Lollipop LED
56 | *
57 | *
58 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
59 | * It also sets the address of this slave device. The slave address should be
60 | * between 1 and 126 and must be unique among all devices on the same bus.
61 | *
62 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
63 | *
64 | // #define DCSBIOS_RS485_SLAVE 1
65 | */
66 |
67 | /**
68 | * Check if we're on a Mega328 or Mega2560 and define the correct
69 | * serial interface
70 | */
71 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
72 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
73 | #else
74 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
75 | #endif
76 |
77 | #ifdef __AVR__
78 | #include
79 | #endif
80 |
81 | /**
82 | * The Arduino pin that is connected to the
83 | * RE and DE pins on the RS-485 transceiver.
84 | */
85 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
86 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
87 |
88 | #include "DcsBios.h"
89 |
90 |
91 | // Define pins for DCS-BIOS per interconnect diagram.
92 | #define LG_EMERG A1 ///< Landing Gear Emergency Rotate and Pull
93 | #define LG_ORIDE A2 ///< Landing Gear Down Lock Override Button
94 | #define LG_WARN A3 ///< Landing Gear Warning Silence Button
95 | #define LG_LEVER_SOLENOID 2 ///< Landing Gear Down Lock Solenoid
96 | #define LG_LIMIT 3 ///< Landing Gear Limit Switch (handle raise / lower)
97 | #define LG_LED 4 ///< Landing Gear Lollipop LED
98 |
99 | //Declare variables for down lock logic
100 | bool wowLeft = true; ///< Initializing weight-on-wheel value for cold/ground start.
101 | bool wowRight = true; ///< Initializing weight-on-wheel value for cold/ground start.
102 | bool wowNose = true; ///< Initializing weight-on-wheel value for cold/ground start.
103 | bool downLockOverride = false; ///< Initializing value for down lock override to not pressed.
104 |
105 | // Connect switches to DCS-BIOS
106 | DcsBios::Switch2Pos emergencyGearRotate("EMERGENCY_GEAR_ROTATE", LG_EMERG);
107 | DcsBios::Switch2Pos gearDownlockOverrideBtn("GEAR_DOWNLOCK_OVERRIDE_BTN", LG_ORIDE);
108 | DcsBios::Switch2Pos gearLever("GEAR_LEVER", LG_LIMIT);
109 | DcsBios::Switch2Pos gearSilenceBtn("GEAR_SILENCE_BTN", LG_WARN);
110 | DcsBios::LED landingGearHandleLt(0x747e, 0x0800, LG_LED);
111 |
112 | // DCSBios reads to save airplane state information.
113 | void onExtWowLeftChange(unsigned int newValue) {
114 | wowLeft = newValue;
115 | } DcsBios::IntegerBuffer extWowLeftBuffer(0x74d8, 0x0100, 8, onExtWowLeftChange);
116 |
117 | void onExtWowNoseChange(unsigned int newValue) {
118 | wowNose = newValue;
119 | } DcsBios::IntegerBuffer extWowNoseBuffer(0x74d6, 0x4000, 14, onExtWowNoseChange);
120 |
121 | void onExtWowRightChange(unsigned int newValue) {
122 | wowRight = newValue;
123 | } DcsBios::IntegerBuffer extWowRightBuffer(0x74d6, 0x8000, 15, onExtWowRightChange);
124 |
125 | void onGearDownlockOverrideBtnChange(unsigned int newValue) {
126 | downLockOverride = newValue;
127 | } DcsBios::IntegerBuffer gearDownlockOverrideBtnBuffer(0x747e, 0x4000, 14, onGearDownlockOverrideBtnChange);
128 |
129 | /**
130 | * Arduino Setup Function
131 | *
132 | * Code that should be executed only once at the program start, belongs in this function.
133 | */
134 | void setup() {
135 |
136 | // Run DCS Bios setup function
137 | DcsBios::setup();
138 |
139 | pinMode(LG_LEVER_SOLENOID, OUTPUT);
140 | digitalWrite(LG_LEVER_SOLENOID, LOW); //initialize solenoid to off
141 | }
142 |
143 | /**
144 | * Arduino Loop Function
145 | *
146 | * Arduino standard Loop Function. Code who should be executed
147 | * over and over in a loop, belongs in this function.
148 | */
149 | void loop() {
150 |
151 | //Run DCS Bios loop function
152 | DcsBios::loop();
153 |
154 | /**
155 | * ### Landing Gear Down Lock Logic
156 | * -# If landing gear handle in down position and lock override pushed, then activate solenoid to **unlock** handle. \n
157 | * -# If landing gear handle in down position and NO weight on wheels, then activate solenoid to **unlock** handle. \n
158 | * -# IF landing gear handle is down and there is weight on at least one wheel, then turn off solenoid to **lock** handle down. \n
159 | * -# If landing gear handle is up turn off solenoid, handle cannot physically be locked in up position. \n
160 | * \n
161 | * @remark Digital reads of switch state will allow the landing gear handle to operate using the downlock override button
162 | * without needing to have the sim running.
163 | */
164 | if (digitalRead(LG_LIMIT) == 1) { //Switch closed, gear handle is down
165 | if (downLockOverride == true || !digitalRead(LG_ORIDE) == true) { // Override switched pushed virtually in sim or physically in pit, turn on solenoid to unlock gear handle.
166 | digitalWrite(LG_LEVER_SOLENOID, HIGH);
167 | } else if (wowLeft == wowRight == wowNose == false) { //No weight on any wheel, turn on solenoid to unlock the gear handle
168 | digitalWrite(LG_LEVER_SOLENOID, HIGH);
169 | } else { // gear handle is down and there is weight on at least one wheel, turn off solenoid to lock the handle down.
170 | digitalWrite(LG_LEVER_SOLENOID, LOW);
171 | }
172 | } else { //gear handle up, turn off solenoid
173 | digitalWrite(LG_LEVER_SOLENOID, LOW);
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A6A1-FCS_PANEL/4A6A1-FCS_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A6A1-FCS_PANEL.ino
35 | * @author Arribe
36 | * @date 03.04.2024
37 | * @version u.0.0.1 (partially tested)
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @warning This sketch is based on a wiring diagram, but the Rudder trim speed is set to full-on.
40 | * The rudder trim speed is untested, the test hardware was wired directly to always run at full power.
41 | * All other features are tested.
42 | * @brief Controls the FCS panel.
43 | *
44 | * @todo Implement the RUD_TRIM_SPD usage. I found the motor was painfully slow even when wired to run at fullspeed, so never implemented a slower speed in code.
45 | *
46 | * @details
47 | *
48 | * * **Reference Designator:** 4A6A1
49 | * * **Intended Board:** ABSIS ALE
50 | * * **RS485 Bus Address:** 7
51 | *
52 | * ### Wiring diagram:
53 | * PIN | Function
54 | * --- | ---
55 | * 15 | Take-Off Switch
56 | * 6 | Rudder Trim Speed - not used
57 | * 14 | Rudder Trim Direction - Counter-Clockwise.
58 | * 15 | Rudder Trim Direction - Clockwise.
59 | * 8 | Rudder Trim Potentiometer
60 | * 10 | FCS Reset
61 | * 9 | Gain Covered Switch
62 | *
63 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
64 | * It also sets the address of this slave device. The slave address should be
65 | * between 1 and 126 and must be unique among all devices on the same bus.
66 | *
67 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
68 |
69 | #define DCSBIOS_RS485_SLAVE 7 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
70 | */
71 |
72 | /**
73 | * Check if we're on a Mega328 or Mega2560 and define the correct
74 | * serial interface
75 | *
76 | */
77 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
78 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
79 | #else
80 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
81 | #endif
82 |
83 | #ifdef __AVR__
84 | #include
85 | #endif
86 |
87 | /**
88 | * The Arduino pin that is connected to the
89 | * RE and DE pins on the RS-485 transceiver.
90 | */
91 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
92 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
93 |
94 | #include "DcsBios.h"
95 |
96 | // Define pins for DCS-BIOS per interconnect diagram.
97 | #define TO_SW1 15 ///< Take-Off Switch
98 | #define RUD_TRIM_SPD 6 ///< Rudder Trim Speed
99 | #define RUD_TRIM_DIR_A 14 ///< Rudder Trim Direction - Counter-Clockwise.
100 | #define RUD_TRIM_DIR_B 7 ///< Rudder Trim Direction - Clockwise.
101 | #define RUD_TRIM_A 8 ///< Rudder Trim Potentiometer
102 | #define RESET_SW1 10 ///< FCS Reset
103 | #define GAIN_SW1 9 ///< Gain Covered Switch
104 |
105 | //Declare variables for custom non-DCS logic
106 | unsigned int rudTrimPosition = 0; ///< Rudder trim position used to track position of the motorized potentiomter as it spins towards center.
107 |
108 | // Connect switches to DCS-BIOS
109 | DcsBios::Switch2Pos fcsResetBtn("FCS_RESET_BTN", RESET_SW1);
110 | DcsBios::SwitchWithCover2Pos gainSwitch("GAIN_SWITCH", "GAIN_SWITCH_COVER", GAIN_SW1);
111 | DcsBios::Potentiometer rudTrimPot("RUD_TRIM", RUD_TRIM_A);
112 | DcsBios::Switch2Pos toTrimBtn("TO_TRIM_BTN", TO_SW1);
113 |
114 | /**
115 | * Helper function to run the motorized potentiometer counter-clockwise.
116 | *
117 | * @param duration is the time in miliseconds to run the motor.
118 | */
119 | void turnCounterClockwise(int duration) {
120 | digitalWrite(RUD_TRIM_DIR_B, LOW); // Set one side low to spin.
121 | digitalWrite(RUD_TRIM_DIR_A, HIGH);
122 | delay(duration);
123 | digitalWrite(RUD_TRIM_DIR_B, HIGH); // Set both pins to same state to STOP
124 | }
125 |
126 | /**
127 | * Helper function to run the motorized potentiometer clockwise.
128 | *
129 | * @param duration is the time in miliseconds to run the motor.
130 | */
131 | void turnClockwise(int duration) {
132 | digitalWrite(RUD_TRIM_DIR_B, HIGH);
133 | digitalWrite(RUD_TRIM_DIR_A, LOW); // Set one side low to spin.
134 | delay(duration);
135 | digitalWrite(RUD_TRIM_DIR_B, LOW); // Set both pins to same state to STOP
136 | }
137 |
138 | /**
139 | * When the TO button is pressed (physically or virtually in the sim) run the motor in the correct direction to center potentiometer.
140 | *
141 | * Based on the rudder trim position in sim.
142 | * -# If the rudder trim is > 32767 run the motor **counter-clockwise** for 1 miliseconds at a time until the rudder trim potentiometer is centered.
143 | * -# If the rudder trim is < 32767 run the motor **clockwise** for 1 miliseconds at a time until the rudder trim potentiometer is centered.
144 | * @note the analogRead of the Rudder Trim is between 0 and 1023. 511 is close enough to center for the sim.
145 | *
146 | * @attention After the TO button is pushed inputs on the FCS panel to the sim are blocked until the rudder trim is centered.\n *It will take time!*
147 | */
148 | void onToTrimBtnChange(unsigned int newValue) {
149 | if (rudTrimPosition > 32767) {
150 | while (analogRead(RUD_TRIM_A) > 511)
151 | turnCounterClockwise(1);
152 | return;
153 | }
154 | if (rudTrimPosition < 32767) {
155 | while (analogRead(RUD_TRIM_A) < 511)
156 | turnClockwise(1);
157 | return;
158 | }
159 | } DcsBios::IntegerBuffer toTrimBtnBuffer(0x74b4, 0x2000, 13, onToTrimBtnChange);
160 |
161 | void onRudTrimChange(unsigned int newValue) {
162 | rudTrimPosition = newValue;
163 | } DcsBios::IntegerBuffer rudTrimBuffer(0x7528, 0xffff, 0, onRudTrimChange);
164 |
165 | /**
166 | * Arduino Setup Function
167 | *
168 | * Arduino standard Setup Function. Code who should be executed
169 | * only once at the programm start, belongs in this function.
170 | *
171 | * @warning The Rudder Trim Speed is untested, the motor is slow even at full power. Input is blocked while the rudder trim is centering.
172 | *
173 | */
174 | void setup() {
175 |
176 | // Run DCS Bios setup function
177 | DcsBios::setup();
178 |
179 | pinMode(RUD_TRIM_DIR_A, OUTPUT);
180 | pinMode(RUD_TRIM_DIR_B, OUTPUT);
181 | pinMode(RUD_TRIM_SPD, OUTPUT);
182 |
183 | digitalWrite(RUD_TRIM_DIR_A, LOW);
184 | digitalWrite(RUD_TRIM_DIR_B, LOW);
185 | analogWrite(RUD_TRIM_SPD, 1023);
186 | }
187 |
188 | /**
189 | * Arduino Loop Function
190 | *
191 | * Arduino standard Loop Function. Code who should be executed
192 | * over and over in a loop, belongs in this function.
193 | */
194 | void loop() {
195 |
196 | //Run DCS Bios loop function
197 | DcsBios::loop();
198 | }
--------------------------------------------------------------------------------
/docs/css/doxygen-awesome-darkmode-toggle.js:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | Doxygen Awesome
4 | https://github.com/jothepro/doxygen-awesome-css
5 |
6 | MIT License
7 |
8 | Copyright (c) 2021 - 2023 jothepro
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | SOFTWARE.
27 |
28 | */
29 |
30 | class DoxygenAwesomeDarkModeToggle extends HTMLElement {
31 | // SVG icons from https://fonts.google.com/icons
32 | // Licensed under the Apache 2.0 license:
33 | // https://www.apache.org/licenses/LICENSE-2.0.html
34 | static lightModeIcon = ``
35 | static darkModeIcon = ``
36 | static title = "Toggle Light/Dark Mode"
37 |
38 | static prefersLightModeInDarkModeKey = "prefers-light-mode-in-dark-mode"
39 | static prefersDarkModeInLightModeKey = "prefers-dark-mode-in-light-mode"
40 |
41 | static _staticConstructor = function() {
42 | DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.userPreference)
43 | // Update the color scheme when the browsers preference changes
44 | // without user interaction on the website.
45 | window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
46 | DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()
47 | })
48 | // Update the color scheme when the tab is made visible again.
49 | // It is possible that the appearance was changed in another tab
50 | // while this tab was in the background.
51 | document.addEventListener("visibilitychange", visibilityState => {
52 | if (document.visibilityState === 'visible') {
53 | DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()
54 | }
55 | });
56 | }()
57 |
58 | static init() {
59 | $(function() {
60 | $(document).ready(function() {
61 | const toggleButton = document.createElement('doxygen-awesome-dark-mode-toggle')
62 | toggleButton.title = DoxygenAwesomeDarkModeToggle.title
63 | toggleButton.updateIcon()
64 |
65 | window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
66 | toggleButton.updateIcon()
67 | })
68 | document.addEventListener("visibilitychange", visibilityState => {
69 | if (document.visibilityState === 'visible') {
70 | toggleButton.updateIcon()
71 | }
72 | });
73 |
74 | $(document).ready(function(){
75 | document.getElementById("MSearchBox").parentNode.appendChild(toggleButton)
76 | })
77 | $(window).resize(function(){
78 | document.getElementById("MSearchBox").parentNode.appendChild(toggleButton)
79 | })
80 | })
81 | })
82 | }
83 |
84 | constructor() {
85 | super();
86 | this.onclick=this.toggleDarkMode
87 | }
88 |
89 | /**
90 | * @returns `true` for dark-mode, `false` for light-mode system preference
91 | */
92 | static get systemPreference() {
93 | return window.matchMedia('(prefers-color-scheme: dark)').matches
94 | }
95 |
96 | /**
97 | * @returns `true` for dark-mode, `false` for light-mode user preference
98 | */
99 | static get userPreference() {
100 | return (!DoxygenAwesomeDarkModeToggle.systemPreference && localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)) ||
101 | (DoxygenAwesomeDarkModeToggle.systemPreference && !localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey))
102 | }
103 |
104 | static set userPreference(userPreference) {
105 | DoxygenAwesomeDarkModeToggle.darkModeEnabled = userPreference
106 | if(!userPreference) {
107 | if(DoxygenAwesomeDarkModeToggle.systemPreference) {
108 | localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey, true)
109 | } else {
110 | localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)
111 | }
112 | } else {
113 | if(!DoxygenAwesomeDarkModeToggle.systemPreference) {
114 | localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey, true)
115 | } else {
116 | localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey)
117 | }
118 | }
119 | DoxygenAwesomeDarkModeToggle.onUserPreferenceChanged()
120 | }
121 |
122 | static enableDarkMode(enable) {
123 | if(enable) {
124 | DoxygenAwesomeDarkModeToggle.darkModeEnabled = true
125 | document.documentElement.classList.add("dark-mode")
126 | document.documentElement.classList.remove("light-mode")
127 | } else {
128 | DoxygenAwesomeDarkModeToggle.darkModeEnabled = false
129 | document.documentElement.classList.remove("dark-mode")
130 | document.documentElement.classList.add("light-mode")
131 | }
132 | }
133 |
134 | static onSystemPreferenceChanged() {
135 | DoxygenAwesomeDarkModeToggle.darkModeEnabled = DoxygenAwesomeDarkModeToggle.userPreference
136 | DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)
137 | }
138 |
139 | static onUserPreferenceChanged() {
140 | DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)
141 | }
142 |
143 | toggleDarkMode() {
144 | DoxygenAwesomeDarkModeToggle.userPreference = !DoxygenAwesomeDarkModeToggle.userPreference
145 | this.updateIcon()
146 | }
147 |
148 | updateIcon() {
149 | if(DoxygenAwesomeDarkModeToggle.darkModeEnabled) {
150 | this.innerHTML = DoxygenAwesomeDarkModeToggle.darkModeIcon
151 | } else {
152 | this.innerHTML = DoxygenAwesomeDarkModeToggle.lightModeIcon
153 | }
154 | }
155 | }
156 |
157 | customElements.define("doxygen-awesome-dark-mode-toggle", DoxygenAwesomeDarkModeToggle);
158 |
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A7A2-OBOGS_PANEL/4A7A2-OBOGS_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A7A2-OBOGS_PANEL.ino
35 | * @author Arribe
36 | * @date 03.05.2024
37 | * @version u.0.0.1 (partially untested)
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @warning This sketch is based on a wiring diagram for the NUC Switch, but it was not yet tested on hardware. The NUC Switch is a simple 2 position DCSBios switch. It is highly likely it will work fine.
40 | * All other switches were tested successfully.
41 | * @brief Controls the OBOGS panel, MC & HYD ISO panel, & NUC WPN panel.
42 | *
43 | * @details
44 | *
45 | * * **Reference Designator:** 4A7A2
46 | * * **Intended Board:** ABSIS ALE
47 | * * **RS485 Bus Address:** 10
48 | *
49 | * ### Wiring diagram:
50 | * PIN | Function
51 | * --- | ---
52 | * A3 | Onboard Oxygenerator
53 | * 2 | Oxygen Flow Rate
54 | * A2 | Nuclear Weapon Consent (**NOT** implemented in DCS)
55 | * 3 | MC 1 OFF
56 | * A1 | MC 2 OFF
57 | * 4 | HYD Override
58 | *
59 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
60 | * It also sets the address of this slave device. The slave address should be
61 | * between 1 and 126 and must be unique among all devices on the same bus.
62 | *
63 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
64 |
65 | #define DCSBIOS_RS485_SLAVE 10 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
66 | */
67 |
68 | /**
69 | * Check if we're on a Mega328 or Mega2560 and define the correct
70 | * serial interface
71 | *
72 | */
73 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
74 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
75 | #else
76 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
77 | #endif
78 |
79 | #ifdef __AVR__
80 | #include
81 | #endif
82 |
83 | /**
84 | * The Arduino pin that is connected to the
85 | * RE and DE pins on the RS-485 transceiver.
86 | */
87 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
88 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
89 |
90 | #include "DcsBios.h"
91 |
92 |
93 | // Define pins for DCS-BIOS per interconnect diagram.
94 | #define OBOGS_SW1 A3 ///< Onboard Oxygenerator
95 | #define OXY_FLOW_SW1 2 ///< Oxygen Flow Rate
96 | #define NUC_SW1 A2 ///< Nuclear Weapon Consent Switch (**NOT** implemented in DCS).
97 | #define MC_SW1 3 ///< MC 1 OFF
98 | #define MC_SW2 A1 ///< MC 2 OFF
99 | #define HYD_SW1 4 ///< HYD Override
100 |
101 | //DCSBios OXY FLOW workaround
102 | #define OXY_MSG "OXY_FLOW" ///< DCSBios Message to move the OXY_FLOW knob.
103 | #define MAX_FLOW "+65535" ///< The OXY FLOW knob in the sim is a 90 degree pot, with max = 65535 we'll add the full on value.
104 | #define MIN_FLOW "-65535" ///< The OXY FLOW Knob in the sim is a 90 degree pot, with min = 0 we'll subtract the full on value.
105 | #define REVERSE_OXY_FLOW true ///< If OXY FLOW knob rotates in the opposite direction in the sim compared to the physical switch then change this to false.
106 |
107 | bool lastBtnState = LOW; ///< Last button state for oxy flow logic, initialize to off.
108 | bool buttonDebounceState = LOW; ///< Button debounce state for oxy flow logic.
109 | unsigned long lastDebounceTime = 0; ///< Variable to hold last button update time for Oxy flow logic, initialize to 0.
110 | unsigned long debounceDelay = 10; ///< The debounce delay duration in ms, **increase if the output flickers**.
111 |
112 | // Connect switches to DCS-BIOS
113 | //OBGS Panel
114 | DcsBios::Switch2Pos obogsSw("OBOGS_SW", OBOGS_SW1);
115 |
116 | //Mission Computer and Hydraulic Isolate Panel
117 | DcsBios::Switch2Pos hydIsolateOverrideSw("HYD_ISOLATE_OVERRIDE_SW", HYD_SW1);
118 | DcsBios::Switch3Pos mcSw("MC_SW", MC_SW1, MC_SW2);
119 |
120 | /**
121 | * @note The NUC Weapon Switch has no function in DCS. This will only move the switch in the sim to match the physical cockpit.
122 | */
123 | DcsBios::Switch2Pos nucWpnSw("NUC_WPN_SW", NUC_SW1);
124 |
125 | /**
126 | * Arduino Setup Function
127 | *
128 | * Arduino standard Setup Function. Code who should be executed
129 | * only once at the programm start, belongs in this function.
130 | */
131 | void setup() {
132 |
133 | // Run DCS Bios setup function
134 | DcsBios::setup();
135 |
136 | pinMode(OXY_FLOW_SW1, INPUT_PULLUP);
137 | }
138 |
139 | /**
140 | * Arduino Loop Function
141 | *
142 | * Arduino standard Loop Function. Code who should be executed
143 | * over and over in a loop, belongs in this function.
144 | *
145 | * @note DCSBios control reference has 2 options for the OXY FLOW knob, Potentiometer or Rotary Encoder.
146 | * To use the Rotary Encoder built-in-option requires each postion to be connected to an Arduino Pin.
147 | * It is possible to connect the spec'd knob to a second pin on the Arduino to use the Rotary Encoder sample code
148 | * with the step size set to "-65535", "+65535" for full-off and full-on.
149 | *
150 | * ###OXY_FLOW Logic
151 | * To overcome the difference between physical switch and the sim's modeling of it, the custom logic follows DCSBios switch methodology for debounce.\n
152 | * -# Read the current button position.
153 | -# If REVERSE_OXY_FLOW direction = true, then reverse current button position read.
154 | -# Then by tracking the current state versus an intermediary state and comparing the time difference from when the button last changed is longer than the debounce delay,
155 | send the DCSBios message to move the OXY FLOW knob to either full-on or full-off and update the variables to be ready for the next switch movement.
156 | *
157 | *
158 | */
159 | void loop() {
160 |
161 | //Run DCS Bios loop function
162 | DcsBios::loop();
163 |
164 | bool buttonState = digitalRead(OXY_FLOW_SW1);
165 | if (REVERSE_OXY_FLOW == true) { // if reverse the button position move is true
166 | buttonState = !buttonState; // then set button state to opposite.
167 | }
168 | unsigned long now = millis(); // get current time.
169 |
170 |
171 | if (buttonState != buttonDebounceState) { // If the button state changed from the button debounce state
172 | lastDebounceTime = now; // then save the current time.
173 | buttonDebounceState = buttonState; // and save the current button state to the debounce state.
174 | }
175 |
176 | if ((now - lastDebounceTime) >= debounceDelay) { // if the difference in time between now and when the switch last changed is greater than the debounce time
177 | if (buttonDebounceState != lastBtnState) { // and if the button debounce state is not the same as the last button state
178 | if (DcsBios::tryToSendDcsBiosMessage(OXY_MSG, buttonState == HIGH ? MIN_FLOW : MAX_FLOW)) { // then send the corresponding DCSBios Message to move the switch in the correct direction.
179 | lastBtnState = buttonDebounceState; // and then save the button's current state to the last state in preparation for the next time it's flipped.
180 | }
181 | }
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A5A1-FUEL_PANEL/4A5A1-FUEL_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A5A1-FUEL_PANEL.ino
35 | * @author Arribe
36 | * @date 03.03.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the FUEL panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 4A5A1
44 | * * **Intended Board:** ABSIS ALE w/ Relay Module
45 | * * **RS485 Bus Address:** 6
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * 15 | PROBE Emergency Extend
51 | * 6 | PROBE Extend
52 | * 14 | External Tanks Wing Stop
53 | * 7 | External Tanks Wing Override
54 | * 16 | External Tanks Center Stop
55 | * 8 | External Tanks Center Override
56 | * 10 | Fuel Dump mag-switch
57 | *
58 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
59 | * It also sets the address of this slave device. The slave address should be
60 | * between 1 and 126 and must be unique among all devices on the same bus.
61 | *
62 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
63 |
64 | #define DCSBIOS_RS485_SLAVE 6 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
65 | */
66 |
67 | /**
68 | * Check if we're on a Mega328 or Mega2560 and define the correct
69 | * serial interface
70 | *
71 | */
72 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
73 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
74 | #else
75 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
76 | #endif
77 |
78 | #ifdef __AVR__
79 | #include
80 | #endif
81 |
82 | /**
83 | * The Arduino pin that is connected to the
84 | * RE and DE pins on the RS-485 transceiver.
85 | */
86 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
87 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
88 |
89 | #include "DcsBios.h"
90 |
91 | // Define pins for DCS-BIOS per interconnect diagram.
92 | #define PROB_SW1 15 ///< PROBE Emergency Extend
93 | #define PROB_SW2 6 ///< PROBE Extend
94 | #define WING_SW1 14 ///< External Tanks Wing Stop
95 | #define WING_SW2 7 ///< External Tanks Wing Override
96 | #define CTR_SW1 16 ///< External Tanks Center Stop
97 | #define CTR_SW2 8 ///< External Tanks Center Override
98 | #define DUMP 10 ///< Fuel Dump switch
99 | #define DUMP_MAG 2 ///< Fuel Dump mag
100 |
101 | //Declare variables for custom non-DCSBios logic for fuel dump mag-switch.
102 | bool fuelDumpState = LOW; ///< Fuel dump switch state
103 | int bingo = 0; ///< Bingo quantity, initialize to cold/dark state of 0.
104 | int fuelQty = 0; ///< Fuel quantity variable for fuel dump logic.
105 | bool dumpHold = LOW; ///< Fuel dump mag-switch hold
106 | bool wowLeft = true; ///< Initializing weight-on-wheel value for cold/ground start.
107 | bool wowRight = true; ///< Initializing weight-on-wheel value for cold/ground start.
108 | bool wowNose = true; ///< Initializing weight-on-wheel value for cold/ground start.
109 |
110 | // Connect switches to DCS-BIOS
111 | DcsBios::Switch2Pos fuelDumpSw("FUEL_DUMP_SW", DUMP);
112 | DcsBios::Switch3Pos probeSw("PROBE_SW", PROB_SW1, PROB_SW2);
113 | DcsBios::Switch3Pos extWngTankSw("EXT_WNG_TANK_SW", WING_SW1, WING_SW2);
114 | DcsBios::Switch3Pos extCntTankSw("EXT_CNT_TANK_SW", CTR_SW1, CTR_SW2);
115 |
116 | /**
117 | * @brief DCSBios read back of fuel dump switch position. If the Switch is turned off virtually in the sim, then turn off the fuel dump mag.
118 | * @note The Fuel Dump mag-switch will not hold with weight on wheels.
119 | */
120 | void onFuelDumpSwChange(unsigned int newValue) {
121 | if (newValue == fuelDumpState) {
122 | return; // no state change, no magnet update.
123 | } else {
124 | switch (newValue) {
125 | case 0: // switch turned off manually in game...disengage magnet.
126 | digitalWrite(DUMP_MAG, LOW);
127 | dumpHold = LOW;
128 | break;
129 | case 1:
130 | if(wowLeft == wowRight == wowNose == false){
131 | digitalWrite(DUMP_MAG, HIGH); // switch turned on, either physically or virtually, engage magnet. May get overridden by bingo logic in loop.
132 | dumpHold = HIGH; // set dumpHold flag to HIGH for bingo logic.
133 | }
134 | break;
135 | default:
136 | break;
137 | }
138 | fuelDumpState = newValue;
139 | }
140 | } DcsBios::IntegerBuffer fuelDumpSwBuffer(0x74b4, 0x0100, 8, onFuelDumpSwChange);
141 |
142 | /// @brief Read the IFEI panel's BINGO setting and convert value to int for fuel dump mag-switch logic.
143 | void onIfeiBingoChange(char* newValue) {
144 | bingo = atoi(newValue);
145 | } DcsBios::StringBuffer<5> ifeiBingoBuffer(0x7468, onIfeiBingoChange);
146 |
147 | void onExtWowLeftChange(unsigned int newValue) {
148 | wowLeft = newValue;
149 | } DcsBios::IntegerBuffer extWowLeftBuffer(0x74d8, 0x0100, 8, onExtWowLeftChange);
150 |
151 | void onExtWowNoseChange(unsigned int newValue) {
152 | wowNose = newValue;
153 | } DcsBios::IntegerBuffer extWowNoseBuffer(0x74d6, 0x4000, 14, onExtWowNoseChange);
154 |
155 | void onExtWowRightChange(unsigned int newValue) {
156 | wowRight = newValue;
157 | } DcsBios::IntegerBuffer extWowRightBuffer(0x74d6, 0x8000, 15, onExtWowRightChange);
158 |
159 | /**
160 | * @brief Read the IFEI panel's Fuel state value when it's going down, and convert to int for fuel dump logic.
161 | * @note Fuel dump logic doesn't care if the fuel quantity is going up.
162 | */
163 | void onIfeiFuelDownChange(char* newValue) {
164 | fuelQty = atoi(newValue);
165 | } DcsBios::StringBuffer<6> ifeiFuelDownBuffer(0x748a, onIfeiFuelDownChange);
166 |
167 | /**
168 | * Arduino Setup Function
169 | *
170 | * Arduino standard Setup Function. Code who should be executed
171 | * only once at the program start, belongs in this function.
172 | */
173 | void setup() {
174 |
175 | // Run DCS Bios setup function
176 | DcsBios::setup();
177 |
178 | pinMode(DUMP_MAG, OUTPUT);
179 |
180 | digitalWrite(DUMP_MAG, LOW);
181 | }
182 |
183 | /**
184 | * Arduino Loop Function
185 | *
186 | * Arduino standard Loop Function. Code who should be executed
187 | * over and over in a loop, belongs in this function.
188 | */
189 | void loop() {
190 |
191 | //Run DCS Bios loop function
192 | DcsBios::loop();
193 |
194 | /**
195 | * ### Fuel Dump mag-switch cancel logic:
196 | * If BINGO setting value is greater than current fuel quantity, or if fuel level below critical cutoff floor of 1,950 lbs, then:
197 | -# If the fuel dump mag-switch is already off nothing happens. \n
198 | * -# Turn off the fuel dump mag-switch. \n
199 | * @note If the fuel quantity is lower than BINGO or lower than the 1,950 lbs safety floor the fuel dump mag-switch will not hold.
200 | *
201 | */
202 | if (bingo >= fuelQty || fuelQty <= 1950) { //if bingo greater than fuel quantity, or if fuel quantity under 1,950 lbs then deactivate the magnet.
203 | switch (dumpHold) {
204 | case LOW:
205 | break; // mag-switch already off no action.
206 | case HIGH:
207 | digitalWrite(DUMP_MAG, LOW); //magnet is high, turn off as fuel state reached bingo or is below 1,950lb safety margin.
208 | dumpHold = LOW; //set magnet flag to LOW to match that it was just turned off.
209 | break;
210 | default:
211 | break;
212 | }
213 | }
214 | }
215 |
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A7A1-COMM_PANEL/4A7A1-COMM_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A7A1-COMM_PANEL.ino
35 | * @author Arribe
36 | * @date 03.03.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief @brief Controls the COMM panel & ANT SEL panel.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 4A7A1
44 | * * **Intended Board:** ABSIS_Mega
45 | * * **RS485 Bus Address:** 8
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * A0 | VOX MIC COLD - HOT
51 | * A15 | ICS Volume
52 | * A1 | RWR Volume
53 | * A14 | WPN Volume
54 | * A2 | MIDSB Volume
55 | * A13 | MIDSA Volume
56 | * A3 | TCN Volume
57 | * A12 | AUX Volume
58 | * A6 | ILS Channel 1
59 | * A9 | ILS Channel 2
60 | * A7 | ILS Channel 3
61 | * A8 | ILS Channel 4
62 | * 52 | RLY PLAIN
63 | * 53 | RLY CIPHER
64 | * 50 | GXMT COMM2
65 | * 51 | GXMT COMM1
66 | * 48 | ILS Manual or UFC
67 | * 49 | IFF CRYPTO ZERO
68 | * 46 | IFF CRYPTO HOLD
69 | * 47 | IFFMAS NORM or EMERG
70 | * 44 | MODE4 OFF
71 | * 45 | MODE4 DIS/AUD
72 | * 43 | ANT SEL Panel COMM 1 LOWER
73 | * 40 | ANT SEL Panel COMM 1 UPPER
74 | * 41 | ANT SEL Panel IFF LOWER
75 | * 38 | ANT SEL Panel IFF UPPER
76 | * 36 | ILS Channel 5
77 | * 37 | ILS Channel 6
78 | * 34 | ILS Channel 7
79 | * 35 | ILS Channel 8
80 | * 32 | ILS Channel 9
81 | * 33 | ILS Channel 10
82 | * 30 | ILS Channel 11
83 | * 31 | ILS Channel 12
84 | * 28 | ILS Channel 13
85 | * 29 | ILS Channel 14
86 | * 26 | ILS Channel 15
87 | * 27 | ILS Channel 16
88 | * 24 | ILS Channel 17
89 | * 25 | ILS Channel 18
90 | * 22 | ILS Channel 19
91 | * 23 | ILS Channel 20
92 | *
93 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
94 | * It also sets the address of this slave device. The slave address should be
95 | * between 1 and 126 and must be unique among all devices on the same bus.
96 | *
97 | * @bug RS485 currently does not work with the Pro Micro (32U4), Fails to compile.
98 | @todo When the RS485 is resolved for the Pro Micro finish coding for RS485 on the Comm Panel's Mega.
99 |
100 | #define DCSBIOS_RS485_SLAVE 8 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
101 | */
102 |
103 | /**
104 | * Check if we're on a Mega328 or Mega2560 and define the correct
105 | * serial interface
106 | *
107 | */
108 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
109 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
110 | #else
111 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
112 | #endif
113 |
114 | #ifdef __AVR__
115 | #include
116 | #endif
117 |
118 | /**
119 | * The Arduino pin that is connected to the
120 | * RE and DE pins on the RS-485 transceiver.
121 | */
122 | #define UART1_TXENABLE_PIN 1 ///< Sets TXENABLE_PIN to Arduino Mega pin Tx0
123 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
124 |
125 | #include "DcsBios.h"
126 |
127 | // Define pins for DCS-BIOS per interconnect diagram.
128 | #define VOX_A A0 ///< VOX MIC COLD - HOT
129 | #define ICS_A A15 ///< ICS Volume
130 | #define RWR_A A1 ///< RWR Volume
131 | #define WPN_A A14 ///< WPN Volume
132 | #define MIDSB_A A2 ///< MIDSB Volume
133 | #define MIDSA_A A13 ///< MIDSA Volume
134 | #define TCN_A A3 ///< TCN Volume
135 | #define AUX_A A12 ///< AUX Volume
136 | #define ILS_SW1 A6 ///< ILS Channel 1
137 | #define ILS_SW2 A9 ///< ILS Channel 2
138 | #define ILS_SW3 A7 ///< ILS Channel 3
139 | #define ILS_SW4 A8 ///< ILS Channel 4
140 | #define RLY_SW1 52 ///< RLY PLAIN
141 | #define RLY_SW2 53 ///< RLY CIPHER
142 | #define GXMT_SW1 50 ///< GXMT COMM2
143 | #define GXMT_SW2 51 ///< GXMT COMM1
144 | #define ILSUFC_SW1 48 ///< ILS Manual or UFC
145 | #define IFFCRY_SW1 49 ///< IFF CRYPTO ZERO
146 | #define IFFCRY_SW2 46 ///< IFF CRYPTO HOLD
147 | #define IFFMAS_SW1 47 ///< IFFMAS NORM or EMERG
148 | #define MODE4_SW1 44 ///< MODE4 OFF
149 | #define MODE4_SW2 45 ///< MODE4 DIS/AUD
150 | #define COMANT_SW1 43 ///< ANT SEL Panel COMM 1 LOWER
151 | #define COMANT_SW2 40 ///< ANT SEL Panel COMM 1 UPPER
152 | #define IFFANT_SW1 41 ///< ANT SEL Panel IFF LOWER
153 | #define IFFANT_SW2 38 ///< ANT SEL Panel IFF UPPER
154 | #define ILS_SW5 36 ///< ILS Channel 5
155 | #define ILS_SW6 37 ///< ILS Channel 6
156 | #define ILS_SW7 34 ///< ILS Channel 7
157 | #define ILS_SW8 35 ///< ILS Channel 8
158 | #define ILS_SW9 32 ///< ILS Channel 9
159 | #define ILS_SW10 33 ///< ILS Channel 10
160 | #define ILS_SW11 30 ///< ILS Channel 11
161 | #define ILS_SW12 31 ///< ILS Channel 12
162 | #define ILS_SW13 28 ///< ILS Channel 13
163 | #define ILS_SW14 29 ///< ILS Channel 14
164 | #define ILS_SW15 26 ///< ILS Channel 15
165 | #define ILS_SW16 27 ///< ILS Channel 16
166 | #define ILS_SW17 24 ///< ILS Channel 17
167 | #define ILS_SW18 25 ///< ILS Channel 18
168 | #define ILS_SW19 22 ///< ILS Channel 19
169 | #define ILS_SW20 23 ///< ILS Channel 20
170 |
171 | // Connect switches to DCS-BIOS
172 |
173 | //Volume Knobs
174 | DcsBios::Potentiometer comAux("COM_AUX", AUX_A);
175 | DcsBios::Potentiometer comIcs("COM_ICS", 69);
176 | DcsBios::Potentiometer comMidsA("COM_MIDS_A", MIDSA_A);
177 | DcsBios::Potentiometer comMidsB("COM_MIDS_B", MIDSB_A);
178 | DcsBios::Potentiometer comRwr("COM_RWR", RWR_A);
179 | DcsBios::Potentiometer comTacan("COM_TACAN", TCN_A);
180 | DcsBios::Potentiometer comVox("COM_VOX", VOX_A);
181 | DcsBios::Potentiometer comWpn("COM_WPN", WPN_A);
182 |
183 | //SWITCHES
184 | DcsBios::Switch3Pos comCommGXmtSw("COM_COMM_G_XMT_SW", GXMT_SW1, GXMT_SW2);
185 | DcsBios::Switch3Pos comCommRelaySw("COM_COMM_RELAY_SW", RLY_SW1, RLY_SW2);
186 | DcsBios::Switch3Pos comCryptoSw("COM_CRYPTO_SW", IFFCRY_SW1, IFFCRY_SW2);
187 | DcsBios::Switch2Pos comIffMasterSw("COM_IFF_MASTER_SW", IFFMAS_SW1);
188 | DcsBios::Switch3Pos comIffMode4Sw("COM_IFF_MODE4_SW", MODE4_SW1, MODE4_SW2);
189 | DcsBios::Switch2Pos comIlsUfcManSw("COM_ILS_UFC_MAN_SW", ILSUFC_SW1);
190 |
191 | /**
192 | * @brief ILS Rotary pin assignments for DCSBios Multi-position Switch.
193 | *
194 | */
195 | const byte comIlsChannelSwPins[20] =
196 | {ILS_SW1, ILS_SW2, ILS_SW3, ILS_SW4, ILS_SW5, ILS_SW6, ILS_SW7,
197 | ILS_SW8, ILS_SW9, ILS_SW10, ILS_SW11, ILS_SW12, ILS_SW13, ILS_SW14,
198 | ILS_SW15, ILS_SW16, ILS_SW17, ILS_SW18, ILS_SW19, ILS_SW20};
199 | /**
200 | * @attention It is possible to spin the ILS rotary faster than the DCSBios debounce time,
201 | * causing some channels to be skipped over in the sim. If you want to see each channel's click you may
202 | * need to slow down.
203 | *
204 | */
205 | DcsBios::SwitchMultiPos comIlsChannelSw("COM_ILS_CHANNEL_SW", comIlsChannelSwPins, 20);
206 |
207 | //ANT SEL PANEL
208 | DcsBios::Switch3Pos comm1AntSelectSw("COMM1_ANT_SELECT_SW", COMANT_SW1, COMANT_SW2);
209 | DcsBios::Switch3Pos iffAntSelectSw("IFF_ANT_SELECT_SW", IFFANT_SW1, IFFANT_SW2);
210 |
211 | /**
212 | * Arduino Setup Function
213 | *
214 | * Arduino standard Setup Function. Code who should be executed
215 | * only once at the program start, belongs in this function.
216 | */
217 | void setup() {
218 |
219 | // Run DCS Bios setup function
220 | DcsBios::setup();
221 | }
222 |
223 | /**
224 | * Arduino Loop Function
225 | *
226 | * Arduino standard Loop Function. Code who should be executed
227 | * over and over in a loop, belongs in this function.
228 | */
229 | void loop() {
230 |
231 | //Run DCS Bios loop function
232 | DcsBios::loop();
233 | }
234 |
--------------------------------------------------------------------------------
/embedded/OH1_Upper_Instrument_Panel/1A3-L_DDI_AND_EWI/1A3-L_DDI_AND_EWI.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 1A3-L_DDI_AND_EWI.ino
35 | * @author Peter Sawka, OH Community, Arribe
36 | * @date 02.29.2024
37 | * @version 0.0.3
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the left DDI & EWI module.
40 | * adapted from Peter Sawka's original Nano code
41 | *
42 | * @details
43 | *
44 | * * **Reference Designator:** 1A3
45 | * * **Intended Board:** CONTROLLER_AMPCD DDI
46 | * * **RS485 Bus Address:** 2
47 | *
48 | * **Wiring diagram:**
49 | * PIN | Function
50 | * --- | ---
51 | * A0 | LDDI Rotary - Day
52 | * A1 | LDDI Rotary - Night
53 | * A2 | LDDI Rotary - Off
54 | * A6 | LDDI Brightness Encoder A
55 | * 7 | LDDI Brightness Encoder B
56 | * 8 | LDDI Contrast Encoder A
57 | * A10 | LDDI Contrast Encoder B
58 | * 14 | LEWI Fire
59 | * 16 | LEWI Master Caution
60 | * A9 | DDI Backlighting PWM
61 | *
62 | *
63 | * @brief following #define tells DCS-BIOS that this is a RS-485 slave device.
64 | * It also sets the address of this slave device. The slave address should be
65 | * between 1 and 126 and must be unique among all devices on the same bus.
66 | *
67 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile
68 | *
69 | //#define DCSBIOS_RS485_SLAVE 2
70 | *
71 | */
72 |
73 | /**
74 | * Check if we're on a Mega328 or Mega2560 and define the correct
75 | * serial interface
76 | *
77 | */
78 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
79 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
80 | #else
81 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
82 | #endif
83 |
84 | #ifdef __AVR__
85 | #include
86 | #endif
87 |
88 |
89 | /**
90 | * The Arduino pin that is connected to the
91 | * RE and DE pins on the RS-485 transceiver.
92 | */
93 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
94 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
95 |
96 | #include "DcsBios.h"
97 | #include "TCA9534.h"
98 |
99 | // Define pins per the OH Interconnect.
100 | #define LDDI_ROT_DAY A0 ///< LDDI Rotary - Day
101 | #define LDDI_ROT_NIGHT A1 ///< LDDI Rotary - Night
102 | #define LDDI_ROT_OFF A2 ///< LDDI Rotary - Off
103 | #define LDDI_BRT_A A6 ///< LDDI Brightness Encoder A
104 | #define LDDI_BRT_B 7 ///< LDDI Brightness Encoder B
105 | #define LDDI_CONT_A 8 ///< LDDI Contrast Encoder A
106 | #define LDDI_CONT_B A10 ///< LDDI Contrast Encoder B
107 | #define LEWI_FIRE_SW 14 ///< LEWI Fire
108 | #define LEWI_MC_SW 16 ///< LEWI Master Caution
109 | #define DDI_BACK_LIGHT A9 ///< DDI Backlighting PWM
110 |
111 | /**
112 | * TCA9534 Chip Array
113 | * Array for the 4 TCA9534 chips to read the DDI Buttons (indices): Left = 0, Top = 1, Right = 2, Bottom = 3
114 | *
115 | */
116 | TCA9534 ddiButtons[4] = {
117 | TCA9534(0x23), //Left Row
118 | TCA9534(0x20), //Top Row
119 | TCA9534(0x22), // Right Row
120 | TCA9534(0x21)}; // Bottom Row
121 |
122 |
123 |
124 | // Setup global variables for reading DDI button presses.
125 | bool lastBtnState[20]; ///< Array to hold the last state of the 20 DDI buttons.
126 | bool buttonState[20]; ///< Array to hold the current state of the 20 DDI buttons.
127 | uint8_t inputRegister[4]; ///< Input register for button read logic.
128 | unsigned long lastDebounceTime[20]; ///< Array to hold last time of DDI button update for debounce.
129 | unsigned long debounceDelay = 10; ///< The debounce delay duration in ms, **increase if the output flickers**.
130 |
131 | //Connect switches to DCS-BIOS
132 | DcsBios::RotaryEncoder leftDdiBrtCtl("LEFT_DDI_BRT_CTL", "-3200", "+3200", LDDI_BRT_A, LDDI_BRT_B);
133 | DcsBios::RotaryEncoder leftDdiContCtl("LEFT_DDI_CONT_CTL", "-3200", "+3200", LDDI_CONT_A, LDDI_CONT_B);
134 | DcsBios::Switch2Pos masterCautionResetSw("MASTER_CAUTION_RESET_SW", LEWI_MC_SW);
135 | DcsBios::SwitchWithCover2Pos leftFireBtn("LEFT_FIRE_BTN", "LEFT_FIRE_BTN_COVER", LEWI_FIRE_SW);
136 |
137 | /**
138 | * @brief Initialize pin array for DCSBios multi-position switch call per BORT command reference.
139 | *
140 | */
141 | const byte leftDdiBrtSelectPins[3] = { LDDI_ROT_OFF, LDDI_ROT_NIGHT, LDDI_ROT_DAY };
142 | DcsBios::SwitchMultiPos leftDdiBrtSelect("LEFT_DDI_BRT_SELECT", leftDdiBrtSelectPins, 3);
143 |
144 | /**
145 | * @brief Setup DCS-BIOS control for DDI backlighting
146 | *
147 | * @bug Potential bug with backlighting, the lights are either full on when DCSBios reports the intensity >50% or full off <50%. May be an electrical / PCB issue.
148 | *
149 | */
150 | void onInstrIntLtChange(unsigned int newValue) {
151 | analogWrite(DDI_BACK_LIGHT, map(newValue, 0, 65535, 0, 255));
152 | } DcsBios::IntegerBuffer instrIntLtBuffer(0x7560, 0xffff, 0, onInstrIntLtChange);
153 |
154 | /**
155 | * Arduino Setup Function
156 | *
157 | * Arduino standard Setup Function. Code who should be executed
158 | * only once at the program start, belongs in this function.
159 | */
160 | void setup() {
161 |
162 | // Run DCS Bios setup function
163 | DcsBios::setup();
164 |
165 | /**
166 | * @brief Initialize last button state array to all 0's.
167 | *
168 | */
169 | for (int i = 0; i < sizeof(lastBtnState) / sizeof(lastBtnState[0]); i++) {
170 | lastBtnState[i] = 0;
171 | }
172 |
173 | /**
174 | * @brief For each TCA9534 chip 'Begin', and set all of its DDI buttons to PinMode = INPUT
175 | *
176 | */
177 | for (int i = 0; i < sizeof(ddiButtons) / sizeof(ddiButtons[0]); i++) {
178 | ddiButtons[i].Begin();
179 | for (int j = 0; j < 5; j++) {
180 | ddiButtons[i].PinMode(j, INPUT);
181 | }
182 | }
183 | }
184 |
185 | /**
186 | * Arduino Loop Function
187 | *
188 | * Arduino standard Loop Function. Code who should be executed
189 | * over and over in a loop, belongs in this function.
190 | *
191 | * @attention If DDI button output flickers increase debounceDelay.
192 | */
193 | void loop() {
194 |
195 | //Run DCS Bios loop function
196 | DcsBios::loop();
197 |
198 | /**
199 | * Read all the DDI button states and send DCSBios Commands in the following TCA9534 order: Left, Top (buttons reversed), Right (buttons reversed), Bottom.
200 | *
201 | */
202 | for (int i = 0; i < sizeof(ddiButtons) / sizeof(ddiButtons[0]); i++) { // Left = 0, Top = 1, Right = 2, Bottom = 3
203 | inputRegister[i] = ddiButtons[i].ReadAll();
204 |
205 | /**
206 | * @brief Fix button index for Top and Right buttons to be in the same order as Left and Bottom buttons.
207 | *
208 | */
209 | for (int j = 0; j < 5; j++) {
210 | int index;
211 | if (i == 1 || i == 2) { //button order reversed, adjust the index accordingly.
212 | index = ((4 - j) + 5 * i);
213 | } else {
214 | index = (j + 5 * i);
215 | }
216 |
217 | /**
218 | * Set button current state from the inputRegister. If button state changed and longer than the debounce delay, then send the
219 | * corresponding DCSBios message by building the proper "LEFT_DDI_PB_" + fixed index number string.
220 | *
221 | */
222 | bool btnState = (inputRegister[i] >> (4 - j)) & 1;
223 |
224 | if (btnState != lastBtnState[index]) {
225 | lastDebounceTime[index] = millis();
226 | }
227 |
228 | if ((millis() - lastDebounceTime[index]) > debounceDelay) {
229 | if (btnState != buttonState[index]) {
230 | buttonState[index] = btnState;
231 | char btnName[14];
232 | sprintf(btnName, "LEFT_DDI_PB_%02d", index + 1);
233 | DcsBios::tryToSendDcsBiosMessage(btnName, btnState == 1 ? "0" : "1");
234 | }
235 | }
236 | lastBtnState[index] = btnState;
237 | }
238 | }
239 | }
--------------------------------------------------------------------------------
/embedded/OH5_Right_Console/5A8A1-SIM_CNTL_PANEL/5A8A1-SIM_CNTL_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 5A8A1-SIM_CNTL_PANEL.ino
35 | * @author Arribe
36 | * @date 03.08.2024
37 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
38 | * @brief Controls the SIM CNTL panel.
39 | *
40 | * @details
41 | *
42 | * * **Reference Designator:** 5A8A1
43 | * * **Intended Board:** ABSIS ALE
44 | * * **RS485 Bus Address:** 7
45 | *
46 | * ### Wiring diagram:
47 | * PIN | Function
48 | * --- | ---
49 | * A3 | View Chase
50 | * 2 | View External
51 | * A2 | View Flyby
52 | * 3 | View Weapon
53 | * A1 | View Enemy
54 | * 4 | View Hud
55 | * A0 | View Map
56 | * 15 | Head Tracking Freeze
57 | * 6 | Head Tracking Center
58 | * 14 | Time Fast
59 | * 7 | Time Real
60 | * 16 | Toggle NVG
61 | * 8 | Toggle Labels
62 | * 10 | Game Pause
63 | * 9 | Game Freeze
64 | * No Pin | View Cockpit
65 |
66 | * @note This is a HID only panel. The switches need to be mapped in the DCS controller setup for the views, and functions.
67 | *
68 | *
69 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
70 | * It also sets the address of this slave device. The slave address should be
71 | * between 1 and 126 and must be unique among all devices on the same bus.
72 | *
73 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
74 |
75 | #define DCSBIOS_RS485_SLAVE 7 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
76 | */
77 |
78 | /**
79 | * Check if we're on a Mega328 or Mega2560 and define the correct
80 | * serial interface
81 | *
82 | */
83 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
84 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
85 | #else
86 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
87 | #endif
88 |
89 | #ifdef __AVR__
90 | #include
91 | #endif
92 |
93 | /**
94 | * The Arduino pin that is connected to the
95 | * RE and DE pins on the RS-485 transceiver.
96 | */
97 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
98 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
99 |
100 | #include "DcsBios.h"
101 | #include "Joystick.h"
102 |
103 | // Define pins for DCS-BIOS per interconnect diagram.
104 | #define VIEW_CHASE A3 ///< View Chase
105 | #define VIEW_EXT 2 ///< View External
106 | #define VIEW_FLYBY A2 ///< View Flyby
107 | #define VIEW_WPN 3 ///< View Weapon
108 | #define VIEW_ENMY A1 ///< View Enemy
109 | #define VIEW_HUD 4 ///< View Hud
110 | #define VIEW_MAP A0 ///< View Map
111 | #define HT_FRZE 15 ///< Head Tracking Freeze
112 | #define HT_CTR 6 ///< Head Tracking Center
113 | #define TIME_FAST 14 ///< Time Fast
114 | #define TIME_REAL 7 ///< Time Real
115 | #define TOG_NVG 16 ///< Toggle NVG
116 | #define TOG_LABL 8 ///< Toggle Labels
117 | #define GME_PAUSE 10 ///< Game Pause
118 | #define GME_FREEZE 9 ///< Game Freeze
119 |
120 | /// Array of pins to simplify the code working with the switches as joystick buttons.
121 | const int* pins[15]{ VIEW_CHASE, VIEW_EXT, VIEW_FLYBY, VIEW_WPN, VIEW_ENMY, VIEW_HUD, VIEW_MAP, HT_FRZE, HT_CTR, TIME_FAST, TIME_REAL, TOG_NVG, TOG_LABL, GME_PAUSE, GME_FREEZE };
122 |
123 | bool currentViewState[7]{ LOW, LOW, LOW, LOW, LOW, LOW, LOW }; ///< Initilize the array of view rotary state, for logic to determine if View Cockpit is selected.
124 | const bool allOff[7]{ LOW, LOW, LOW, LOW, LOW, LOW, LOW }; ///< Initializes an array for allOff comparison.
125 | unsigned int debounceDelay = 250; ///< View rotary debounce, if the view jumps to the Cockpit view while rotating increase the debounce delay.
126 | unsigned long cockpitViewSteadyStateTime = 0; ///< Variable to hold the view steady state time for debounce logic.
127 | bool cockpitView = false; ///< variable to hold if cockpit view is on or not
128 |
129 | /// Joystick consiting of 16 buttons and no axis.
130 | Joystick_ Joystick = Joystick_(
131 | 0x5A81,
132 | JOYSTICK_TYPE_JOYSTICK,
133 | 16,
134 | 0,
135 | false,
136 | false,
137 | false,
138 | false,
139 | false,
140 | false,
141 | false,
142 | false,
143 | false,
144 | false,
145 | false);
146 |
147 | /**
148 | * Arduino Setup Function
149 | *
150 | * Arduino standard Setup Function. Code who should be executed
151 | * only once at the programm start, belongs in this function.
152 | */
153 | void setup() {
154 |
155 | for (int j = 0; j < 15; j++) {
156 | pinMode(pins[j], INPUT_PULLUP);
157 |
158 | Serial.begin(9600);
159 |
160 | Joystick.begin();
161 | }
162 | }
163 |
164 | /**
165 | * Arduino Loop Function
166 | *
167 | * Arduino standard Loop Function. Code who should be executed
168 | * over and over in a loop, belongs in this function.
169 | *
170 | * The view rotary switch doesn't have position 1 connected to a pin on the Arduino.
171 | * The logic loops over the pins, reading the button states. The first 6 pins are for the view rotary.
172 | * The view rotary position state is saved to an array. If the current values is equal to the 'all off' values, then:
173 | * -# It is assumed that the rotary is pointing to CKPT.
174 | * -# While the rotary switch rotates all of the positions are not connected to ground.
175 | * To prevent false readings debounce logic is used to ensure that the view won't flip excessively.
176 | * -# The switch needs to point to CKPT position for at least the debounceDelay duration before turning on.
177 | *
178 | * @attention Be deliberate in the view rotation, clicking one spot at a time at a smooth pace.
179 | * Rapid movements, or delayed rotation with the knob pointing between the stops may lead to false readings
180 | * that the switch is pointing to CKPT.
181 | */
182 | void loop() {
183 |
184 |
185 |
186 | for (int j = 0; j < 15; j++) {
187 | if (j < 7) { // If reading view rotary need to save state to later determine if the rotary is pointing to CKPT.
188 | currentViewState[j] = !digitalRead(pins[j]); // Read the view rotary positions.
189 | Joystick.setButton(j, currentViewState[j]); // Set the view rotary joystick button as read.
190 | } else {
191 | Joystick.setButton(j, !digitalRead(pins[j])); // Not the view rotary, set the joystick button as read.
192 | }
193 | unsigned long now = millis();
194 | if (memcmp(currentViewState, allOff, 7) == 0) { // Determine view rotary reads were all off
195 | if (cockpitView == false) { // No view read, rotary pointing to CKPTstate, check if changing to true
196 | if ((now - cockpitViewSteadyStateTime) > debounceDelay) { // Wait until the switch is certain to be in the CKPT position.
197 | Joystick.setButton(15, HIGH); // Set the CKPT button to on.
198 | cockpitView = true; // Update the cockpitView to indicate the button is on.
199 | } else {
200 | //do nothing wait for the debounce time to elapse to esure it wasn't caused from rotating the switch.
201 | }
202 | } else {
203 | // cockpit view is already on, no change.
204 | }
205 | } else {
206 | Joystick.setButton(15, LOW); // At least one view reads as on, rotary NOT pointing to CKPT.
207 | cockpitView = false; // Set the cockpitView to false so it can be turned on next time.
208 | cockpitViewSteadyStateTime = now; // Update the cockpitViewSteadyStateTime in prep for the next iteration.
209 | }
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/embedded/OH5_Right_Console/5A10-DEFOG_PANEL/5A10-DEFOG_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 5A10-DEFOG_PANEL.ino
35 | * @author Arribe
36 | * @date 03.06.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | **
40 | * @brief Controls the DEFOG panel, R CRKT BRKRs & CANOPY module.
41 | *
42 | * @details
43 | *
44 | * * **Reference Designator:** 5A10
45 | * * **Intended Board:** ABSIS ALE w/ Relay Module
46 | * * **RS485 Bus Address:** 9
47 | *
48 | * ### Wiring diagram:
49 | * PIN | Function
50 | * --- | ---
51 | * 15 | Defog - Anti-ice
52 | * 6 | Defog Lever Potentiometer
53 | * 14 | Defog - Rain
54 | * 7 | Canopy Open
55 | * 16 | Canopy Close
56 | * 8 | Canopy Aux 1 Buton
57 | * 10 | Canopy Aux 2 Buton
58 | * A3 | Right Circuit Breaker Landing Ger
59 | * 2 | Right Circuit Breaker Hook
60 | * A2 | Right Circuit Breaker FCS4
61 | * A1 | Right Circuit BreaKer FCS3
62 | * 4 | Right Circuit Breaker Panel FCSbit On
63 | * 2 | Canopy Open Mag-switch
64 | *
65 | * @attention This sketch includes a Joystick for the 2 bonus auxiliary buttons on the under-side of the canopy switch housing, and as an x-axis for the defog lever handle.
66 | * In DCS the buttons must be mapped to the functions of your choice, and the defog lever must be mapped as an axis control.
67 | *
68 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
69 | * It also sets the address of this slave device. The slave address should be
70 | * between 1 and 126 and must be unique among all devices on the same bus.
71 | *
72 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
73 | *
74 | * #define DCSBIOS_RS485_SLAVE 9 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
75 | */
76 |
77 | /**
78 | * Check if we're on a Mega328 or Mega2560 and define the correct
79 | * serial interface
80 | *
81 | */
82 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
83 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
84 | #else
85 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
86 | #endif
87 |
88 | #ifdef __AVR__
89 | #include
90 | #endif
91 |
92 | /**
93 | * The Arduino pin that is connected to the
94 | * RE and DE pins on the RS-485 transceiver.
95 | */
96 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
97 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
98 |
99 | #include "DcsBios.h"
100 | #include "Joystick.h"
101 |
102 | // Define pins for DCS-BIOS per interconnect diagram.
103 | #define DF_ANTIICE 15 ///< Defog - Anti-ice
104 | #define DF_A A0 ///< 6 Defog Lever Potentiometer
105 | #define DF_RAIN 14 ///< Defog - Rain
106 | #define CN_OPEN 7 ///< Canopy Open
107 | #define CN_CLOSE 16 ///< Canopy Close
108 | #define CN_AUX1 8 ///< Canopy Aux 1 Buton
109 | #define CN_AUX2 10 ///< Canopy Aux 2 Buton
110 | #define RC_LG A3 ///< Right Circuit Breaker Landing Ger
111 | #define RC_HOOK A2 ///< Right Circuit Breaket Hook
112 | #define RC_FCS4 3 ///< Right Circuit Breaker FCS4
113 | #define RC_FCS3 A1 ///< Right Circuit BreaKer FCS3
114 | #define RC_FCSBIT 4 ///< Right Circuit Breaker Panel FCSbit On
115 | #define CN_OPEN_MAG 2 ///< Canaopy Open Hold mag-switch
116 |
117 | //Declare variables for custom non-DCS logic
118 | bool wowLeft = true; ///< Initializing weight-on-wheel value for cold/ground start.
119 | bool wowRight = true; ///< Initializing weight-on-wheel value for cold/ground start.
120 | bool wowNose = true; ///< Initializing weight-on-wheel value for cold/ground start.
121 | bool canopyOpenState = true; ///< Initializing canopy state as open for cold/ground start.
122 | bool canopyMagHold = false; ///< Initializing canopy mag hold to off.
123 |
124 | /**
125 | * Joystick Setup for defog lever on x-axis, and the 2 canopy aux buttons.
126 | */
127 | Joystick_ Joystick = Joystick_(
128 | 0x4910,
129 | JOYSTICK_TYPE_JOYSTICK,
130 | 2,
131 | 0,
132 | true,
133 | false,
134 | false,
135 | false,
136 | false,
137 | false,
138 | false,
139 | false,
140 | false,
141 | false,
142 | false);
143 |
144 |
145 | // Connect switches to DCS-BIOS
146 | DcsBios::Switch3Pos wshieldAntiIceSw("WSHIELD_ANTI_ICE_SW", DF_ANTIICE, DF_RAIN);
147 | DcsBios::Switch3Pos canopySw("CANOPY_SW", CN_OPEN, CN_CLOSE);
148 | DcsBios::Switch2Pos cbFcsChan3("CB_FCS_CHAN3", RC_FCS3);
149 | DcsBios::Switch2Pos cbFcsChan4("CB_FCS_CHAN4", RC_FCS4);
150 | DcsBios::Switch2Pos cbHoook("CB_HOOOK", RC_HOOK);
151 | DcsBios::Switch2Pos cbLg("CB_LG", RC_LG);
152 | DcsBios::Switch2Pos fcsBitSw("FCS_BIT_SW", RC_FCSBIT);
153 |
154 | // DCSBios reads to save airplane state information.
155 |
156 | /**
157 | * If the Canopy Switch is moved to open with weight-on-wheels the mag-switch will hold.
158 | * The program loop will release the mag-switch when the canopy is fully opened.
159 | */
160 | void onCanopySwChange(unsigned int newValue) {
161 | if (newValue == 2) {
162 | if (wowRight == wowLeft == wowNose == true) {
163 | digitalWrite(CN_OPEN_MAG, HIGH);
164 | canopyMagHold = true;
165 | }
166 | } else {
167 | digitalWrite(CN_OPEN_MAG, LOW);
168 | canopyMagHold = false;
169 | }
170 | } DcsBios::IntegerBuffer canopySwBuffer(0x74ce, 0x0300, 8, onCanopySwChange);
171 |
172 | /**
173 | * Determine the canopy open state by reading if the value is over 58,900 (determined by testing in DCS).
174 | */
175 | void onCanopyPosChange(unsigned int newValue) {
176 | if (newValue >= 58900) {
177 | canopyOpenState = true;
178 | } else {
179 | canopyOpenState = false;
180 | }
181 | } DcsBios::IntegerBuffer canopyPosBuffer(0x7552, 0xffff, 0, onCanopyPosChange);
182 |
183 | void onExtWowLeftChange(unsigned int newValue) {
184 | wowLeft = newValue;
185 | } DcsBios::IntegerBuffer extWowLeftBuffer(0x74d8, 0x0100, 8, onExtWowLeftChange);
186 |
187 | void onExtWowNoseChange(unsigned int newValue) {
188 | wowNose = newValue;
189 | } DcsBios::IntegerBuffer extWowNoseBuffer(0x74d6, 0x4000, 14, onExtWowNoseChange);
190 |
191 | void onExtWowRightChange(unsigned int newValue) {
192 | wowRight = newValue;
193 | } DcsBios::IntegerBuffer extWowRightBuffer(0x74d6, 0x8000, 15, onExtWowRightChange);
194 |
195 |
196 | /**
197 | * Arduino Setup Function
198 | *
199 | * Arduino standard Setup Function. Code who should be executed
200 | * only once at the programm start, belongs in this function.
201 | */
202 | void setup() {
203 |
204 | // Run DCS Bios setup function
205 | DcsBios::setup();
206 |
207 | Joystick.begin();
208 | Joystick.setXAxisRange(0, 1024);
209 |
210 | pinMode(CN_AUX1, INPUT_PULLUP);
211 | pinMode(CN_AUX2, INPUT_PULLUP);
212 | pinMode(DF_A, INPUT);
213 |
214 | pinMode(CN_OPEN_MAG, OUTPUT);
215 | digitalWrite(CN_OPEN_MAG, LOW);
216 | }
217 |
218 | /**
219 | * Arduino Loop Function
220 | *
221 | * Arduino standard Loop Function. Code who should be executed
222 | * over and over in a loop, belongs in this function.
223 | *
224 | * @note Defog lever didn't work well using DCSBios' potentiometer method. The min and max range was too far off, could potentially work if values maped to a different range,
225 | * but the potentimeter's roation is much larger than the fog handle's range. Found it easier within DCS to control it as a Joystick axis.
226 | * Then one could calibrate it in the Window's Game Controllers utility, and map it as an axis in DCS.\n\n
227 | * This is the command to use if one wants to try the pontentiometer approach - DcsBios::Potentiometer defogHandle("DEFOG_HANDLE", DF_A);
228 | *
229 | * @details If the canopy mag-switch is held in the open positon, then when the canopy reaches the fully open position the mag-switch is released.
230 | *
231 | */
232 | void loop() {
233 |
234 | //Run DCS Bios loop function
235 | DcsBios::loop();
236 |
237 | Joystick.setButton(0, !digitalRead(CN_AUX1)); // Set the aux 1 joystick button state.
238 | Joystick.setButton(1, !digitalRead(CN_AUX2)); // Set the aux 2 joystick button state.
239 | Joystick.setXAxis(analogRead(DF_A)); // Set the defog lever position.
240 |
241 | if(canopyMagHold && canopyOpenState){ // Release mag-switch when the canopy is open and the mag is on.
242 | digitalWrite(CN_OPEN_MAG, LOW); // Release the mag-switch.
243 | canopyMagHold = false; // Set canopy mode to false.
244 | }
245 | }
246 |
247 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright © 2016-2024 OpenHornet
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Apache License
16 | Version 2.0, January 2004
17 | http://www.apache.org/licenses/
18 |
19 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
20 |
21 | 1. Definitions.
22 |
23 | "License" shall mean the terms and conditions for use, reproduction,
24 | and distribution as defined by Sections 1 through 9 of this document.
25 |
26 | "Licensor" shall mean the copyright owner or entity authorized by
27 | the copyright owner that is granting the License.
28 |
29 | "Legal Entity" shall mean the union of the acting entity and all
30 | other entities that control, are controlled by, or are under common
31 | control with that entity. For the purposes of this definition,
32 | "control" means (i) the power, direct or indirect, to cause the
33 | direction or management of such entity, whether by contract or
34 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
35 | outstanding shares, or (iii) beneficial ownership of such entity.
36 |
37 | "You" (or "Your") shall mean an individual or Legal Entity
38 | exercising permissions granted by this License.
39 |
40 | "Source" form shall mean the preferred form for making modifications,
41 | including but not limited to software source code, documentation
42 | source, and configuration files.
43 |
44 | "Object" form shall mean any form resulting from mechanical
45 | transformation or translation of a Source form, including but
46 | not limited to compiled object code, generated documentation,
47 | and conversions to other media types.
48 |
49 | "Work" shall mean the work of authorship, whether in Source or
50 | Object form, made available under the License, as indicated by a
51 | copyright notice that is included in or attached to the work
52 | (an example is provided in the Appendix below).
53 |
54 | "Derivative Works" shall mean any work, whether in Source or Object
55 | form, that is based on (or derived from) the Work and for which the
56 | editorial revisions, annotations, elaborations, or other modifications
57 | represent, as a whole, an original work of authorship. For the purposes
58 | of this License, Derivative Works shall not include works that remain
59 | separable from, or merely link (or bind by name) to the interfaces of,
60 | the Work and Derivative Works thereof.
61 |
62 | "Contribution" shall mean any work of authorship, including
63 | the original version of the Work and any modifications or additions
64 | to that Work or Derivative Works thereof, that is intentionally
65 | submitted to Licensor for inclusion in the Work by the copyright owner
66 | or by an individual or Legal Entity authorized to submit on behalf of
67 | the copyright owner. For the purposes of this definition, "submitted"
68 | means any form of electronic, verbal, or written communication sent
69 | to the Licensor or its representatives, including but not limited to
70 | communication on electronic mailing lists, source code control systems,
71 | and issue tracking systems that are managed by, or on behalf of, the
72 | Licensor for the purpose of discussing and improving the Work, but
73 | excluding communication that is conspicuously marked or otherwise
74 | designated in writing by the copyright owner as "Not a Contribution."
75 |
76 | "Contributor" shall mean Licensor and any individual or Legal Entity
77 | on behalf of whom a Contribution has been received by Licensor and
78 | subsequently incorporated within the Work.
79 |
80 | 2. Grant of Copyright License. Subject to the terms and conditions of
81 | this License, each Contributor hereby grants to You a perpetual,
82 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83 | copyright license to reproduce, prepare Derivative Works of,
84 | publicly display, publicly perform, sublicense, and distribute the
85 | Work and such Derivative Works in Source or Object form.
86 |
87 | 3. Grant of Patent License. Subject to the terms and conditions of
88 | this License, each Contributor hereby grants to You a perpetual,
89 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
90 | (except as stated in this section) patent license to make, have made,
91 | use, offer to sell, sell, import, and otherwise transfer the Work,
92 | where such license applies only to those patent claims licensable
93 | by such Contributor that are necessarily infringed by their
94 | Contribution(s) alone or by combination of their Contribution(s)
95 | with the Work to which such Contribution(s) was submitted. If You
96 | institute patent litigation against any entity (including a
97 | cross-claim or counterclaim in a lawsuit) alleging that the Work
98 | or a Contribution incorporated within the Work constitutes direct
99 | or contributory patent infringement, then any patent licenses
100 | granted to You under this License for that Work shall terminate
101 | as of the date such litigation is filed.
102 |
103 | 4. Redistribution. You may reproduce and distribute copies of the
104 | Work or Derivative Works thereof in any medium, with or without
105 | modifications, and in Source or Object form, provided that You
106 | meet the following conditions:
107 |
108 | (a) You must give any other recipients of the Work or
109 | Derivative Works a copy of this License; and
110 |
111 | (b) You must cause any modified files to carry prominent notices
112 | stating that You changed the files; and
113 |
114 | (c) You must retain, in the Source form of any Derivative Works
115 | that You distribute, all copyright, patent, trademark, and
116 | attribution notices from the Source form of the Work,
117 | excluding those notices that do not pertain to any part of
118 | the Derivative Works; and
119 |
120 | (d) If the Work includes a "NOTICE" text file as part of its
121 | distribution, then any Derivative Works that You distribute must
122 | include a readable copy of the attribution notices contained
123 | within such NOTICE file, excluding those notices that do not
124 | pertain to any part of the Derivative Works, in at least one
125 | of the following places: within a NOTICE text file distributed
126 | as part of the Derivative Works; within the Source form or
127 | documentation, if provided along with the Derivative Works; or,
128 | within a display generated by the Derivative Works, if and
129 | wherever such third-party notices normally appear. The contents
130 | of the NOTICE file are for informational purposes only and
131 | do not modify the License. You may add Your own attribution
132 | notices within Derivative Works that You distribute, alongside
133 | or as an addendum to the NOTICE text from the Work, provided
134 | that such additional attribution notices cannot be construed
135 | as modifying the License.
136 |
137 | You may add Your own copyright statement to Your modifications and
138 | may provide additional or different license terms and conditions
139 | for use, reproduction, or distribution of Your modifications, or
140 | for any such Derivative Works as a whole, provided Your use,
141 | reproduction, and distribution of the Work otherwise complies with
142 | the conditions stated in this License.
143 |
144 | 5. Submission of Contributions. Unless You explicitly state otherwise,
145 | any Contribution intentionally submitted for inclusion in the Work
146 | by You to the Licensor shall be under the terms and conditions of
147 | this License, without any additional terms or conditions.
148 | Notwithstanding the above, nothing herein shall supersede or modify
149 | the terms of any separate license agreement you may have executed
150 | with Licensor regarding such Contributions.
151 |
152 | 6. Trademarks. This License does not grant permission to use the trade
153 | names, trademarks, service marks, or product names of the Licensor,
154 | except as required for reasonable and customary use in describing the
155 | origin of the Work and reproducing the content of the NOTICE file.
156 |
157 | 7. Disclaimer of Warranty. Unless required by applicable law or
158 | agreed to in writing, Licensor provides the Work (and each
159 | Contributor provides its Contributions) on an "AS IS" BASIS,
160 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
161 | implied, including, without limitation, any warranties or conditions
162 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
163 | PARTICULAR PURPOSE. You are solely responsible for determining the
164 | appropriateness of using or redistributing the Work and assume any
165 | risks associated with Your exercise of permissions under this License.
166 |
167 | 8. Limitation of Liability. In no event and under no legal theory,
168 | whether in tort (including negligence), contract, or otherwise,
169 | unless required by applicable law (such as deliberate and grossly
170 | negligent acts) or agreed to in writing, shall any Contributor be
171 | liable to You for damages, including any direct, indirect, special,
172 | incidental, or consequential damages of any character arising as a
173 | result of this License or out of the use or inability to use the
174 | Work (including but not limited to damages for loss of goodwill,
175 | work stoppage, computer failure or malfunction, or any and all
176 | other commercial damages or losses), even if such Contributor
177 | has been advised of the possibility of such damages.
178 |
179 | 9. Accepting Warranty or Additional Liability. While redistributing
180 | the Work or Derivative Works thereof, You may choose to offer,
181 | and charge a fee for, acceptance of support, warranty, indemnity,
182 | or other liability obligations and/or rights consistent with this
183 | License. However, in accepting such obligations, You may act only
184 | on Your own behalf and on Your sole responsibility, not on behalf
185 | of any other Contributor, and only if You agree to indemnify,
186 | defend, and hold each Contributor harmless for any liability
187 | incurred by, or claims asserted against, such Contributor by reason
188 | of your accepting any such warranty or additional liability.
189 |
190 | END OF TERMS AND CONDITIONS
191 |
--------------------------------------------------------------------------------
/embedded/OH4_Left_Console/4A5A2-APU_PANEL/4A5A2-APU_PANEL.ino:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * ____ _ _ _
3 | * / __ \ | | | | | |
4 | * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 | * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 | * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 | * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 | * | |
9 | * |_|
10 | * ----------------------------------------------------------------------------------
11 | * Copyright 2016-2024 OpenHornet
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * ----------------------------------------------------------------------------------
25 | * Note: All other portions of OpenHornet not within the 'OpenHornet-Software'
26 | * GitHub repository is released under the Creative Commons Attribution -
27 | * Non-Commercial - Share Alike License. (CC BY-NC-SA 4.0)
28 | * ----------------------------------------------------------------------------------
29 | * This Project uses Doxygen as a documentation generator.
30 | * Please use Doxygen capable comments.
31 | **************************************************************************************/
32 |
33 | /**
34 | * @file 4A5A2-APU_PANEL.ino
35 | * @author Arribe
36 | * @date 03.03.2024
37 | * @version 0.0.1
38 | * @copyright Copyright 2016-2024 OpenHornet. Licensed under the Apache License, Version 2.0.
39 | * @brief Controls the APU panel & L CIRCUIT BREAKERS.
40 | *
41 | * @details
42 | *
43 | * * **Reference Designator:** 4A5A2
44 | * * **Intended Board:** ABSIS ALE w/ Relay Module
45 | * * **RS485 Bus Address:** 5
46 | *
47 | * ### Wiring diagram:
48 | * PIN | Function
49 | * --- | ---
50 | * 15 | APU Switch
51 | * 6 | APU Lamp
52 | * 14 | Engine Crank Right
53 | * 7 | Engine Crank Left
54 | * 16 | Circuit Breaker FCS Channel 1
55 | * 8 | Circuit Breaker FCS Channel 2
56 | * 10 | Circuit Breaker Speed Break
57 | * 9 | Circuit Breaker Launch Bar
58 | * 2 | APU Switch Magnet
59 | * 3 | Engine Crank Magnet
60 | *
61 | * @brief The following #define tells DCS-BIOS that this is a RS-485 slave device.
62 | * It also sets the address of this slave device. The slave address should be
63 | * between 1 and 126 and must be unique among all devices on the same bus.
64 | *
65 | * @bug Currently does not work with the Pro Micro (32U4), Fails to compile.
66 |
67 | #define DCSBIOS_RS485_SLAVE 5 ///DCSBios RS485 Bus Address, once bug resolved move line below comment.
68 | */
69 |
70 | /**
71 | * Check if we're on a Mega328 or Mega2560 and define the correct
72 | * serial interface
73 | *
74 | */
75 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)
76 | #define DCSBIOS_IRQ_SERIAL ///< This enables interrupt-driven serial communication for DCS-BIOS. (Only used with the ATmega328P or ATmega2560 microcontrollers.)
77 | #else
78 | #define DCSBIOS_DEFAULT_SERIAL ///< This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
79 | #endif
80 |
81 | #ifdef __AVR__
82 | #include
83 | #endif
84 |
85 | /**
86 | * The Arduino pin that is connected to the
87 | * RE and DE pins on the RS-485 transceiver.
88 | */
89 | #define TXENABLE_PIN 5 ///< Sets TXENABLE_PIN to Arduino Pin 5
90 | #define UART1_SELECT ///< Selects UART1 on Arduino for serial communication
91 |
92 | #include "DcsBios.h"
93 |
94 | // Define pins for DCS-BIOS per interconnect diagram.
95 | #define APU_SW1 15 ///< APU Mag Switch
96 | #define APU_LAMP 6 ///< APU Lamp
97 | #define CRANK_SW1 14 ///< Engine Crank Right
98 | #define CRANK_SW2 7 ///< Engine Crank Left
99 | #define FCS_CH1 16 ///< Circuit Breaker FCS Channel 1
100 | #define FCS_CH2 8 ///< Circuit Breaker FCS Channel 2
101 | #define LCSPDBRK 10 ///< Circuit Breaker Speed Break
102 | #define LCLBAR 9 ///< Circuit Breaker Launch Bar
103 | #define APU_SW_MAG 2 ///< APU Switch Magnet
104 | #define ENG_CRANK_MAG 3 ///< Engine Crank Magnet
105 |
106 |
107 | //Declare variables for custom non-DCS logic
108 | bool apuHold = LOW; ///< Initializing for cold/ground start switch releases on power off.
109 | bool apuState = LOW; ///< Initializing for cold/ground start switch releases on power off.
110 | bool apuLightSate = LOW; ///< Initializing for cold/ground start switch releases on power off.
111 | bool engCrankHold = LOW; ///< Initializing for cold/ground start switch releases on power off.
112 | byte engCrankState = 1; ///< Three position switch, 1 is middle
113 | unsigned int rpmL = 0; ///< Initializing engine RPM for cold start
114 | unsigned int rpmR = 0; ///< Initializing engine RPM for cold start
115 |
116 | // Connect switches to DCS-BIOS
117 | DcsBios::Switch2Pos apuControlSw("APU_CONTROL_SW", APU_SW1);
118 | DcsBios::Switch3Pos engineCrankSw("ENGINE_CRANK_SW", CRANK_SW2, CRANK_SW1);
119 | DcsBios::Switch2Pos cbFcsChan1("CB_FCS_CHAN1", FCS_CH1);
120 | DcsBios::Switch2Pos cbFcsChan2("CB_FCS_CHAN2", FCS_CH2);
121 | DcsBios::Switch2Pos cbLaunchBar("CB_LAUNCH_BAR", LCLBAR);
122 | DcsBios::Switch2Pos cbSpdBrk("CB_SPD_BRK", LCSPDBRK);
123 |
124 | // DCSBios reads to save airplane state information.
125 |
126 | /**
127 | * This function monitors the state of the APU light from DCSBios and updates the APU switch's magnet.
128 | * The APU shuts down, and light is turned off 1 minute after the second engine is running.
129 | *
130 | * APU magnet logic: When APU light state changes to 1 turn on the light, but no change to APU magnet.
131 | * When APU light state changes to 0 turn off light and turn off APU switch magnet if it's on.
132 | *
133 | */
134 | void onApuReadyLtChange(unsigned int newValue) {
135 | if (apuLightSate == newValue) {
136 | return; // No change continue
137 | }
138 | switch (newValue) {
139 | case 0: // Light turned off
140 | digitalWrite(APU_LAMP, LOW);
141 | if (apuHold == HIGH) { // If APU mag on, turn it off.
142 | digitalWrite(APU_SW_MAG, LOW);
143 | apuHold = LOW;
144 | }
145 | break;
146 | case 1: // APU light is on.
147 | digitalWrite(APU_LAMP, HIGH);
148 | break;
149 | default:
150 | break;
151 | }
152 | apuLightSate = newValue;
153 | } DcsBios::IntegerBuffer apuReadyLtBuffer(0x74c2, 0x0800, 11, onApuReadyLtChange);
154 |
155 | /**
156 | * @brief DCSBios read back of APU switch position. If the Switch is turned off virtually in the sim, then turn off the APU mag.
157 | *
158 | */
159 | void onApuControlSwChange(unsigned int newValue) {
160 | if (newValue == apuState) {
161 | return; // No state change, no magnet update.
162 | } else {
163 | switch (newValue) {
164 | case 0: // Switch turned off in SIM.
165 | digitalWrite(APU_SW_MAG, LOW);
166 | apuHold = LOW;
167 | break;
168 | case 1: // Switch is on in SIM.
169 | digitalWrite(APU_SW_MAG, HIGH);
170 | apuHold = HIGH;
171 | break;
172 | default:
173 | break;
174 | }
175 | }
176 | apuState = newValue;
177 | } DcsBios::IntegerBuffer apuControlSwBuffer(0x74c2, 0x0100, 8, onApuControlSwChange);
178 |
179 | /**
180 | * @brief DCSBios read back of Engine Crank switch position. If the Switch is turned off virtually in the sim,
181 | * then turn off the Engine Crank mag.
182 | *
183 | * @note the Engine Crank mag-switch won't hold when the engine's RPM is over 65%.
184 | */
185 | void onEngineCrankSwChange(unsigned int newValue) {
186 | if (newValue == engCrankState) {
187 | return; // no state change, no magnet update.
188 | } else {
189 | switch (newValue) {
190 | case 0:
191 | digitalWrite(ENG_CRANK_MAG, HIGH); // switch turned on, either physically or virtually, engage magnet. May get overridden by engine RPM logic in loop.
192 | engCrankHold = HIGH; // set engCrankHold flag to HIGH for rpm logic.
193 | break;
194 | case 1: // switch turned off disengage magnet.
195 | digitalWrite(ENG_CRANK_MAG, LOW);
196 | engCrankHold = LOW;
197 | break;
198 | case 2:
199 | digitalWrite(ENG_CRANK_MAG, HIGH); // switch turned on, either physically or virtually, engage magnet. May get overridden by engine RPM logic in loop.
200 | engCrankHold = HIGH; // set engCrankHold flag to HIGH for rpm logic.
201 | break;
202 | default:
203 | break;
204 | }
205 | engCrankState = newValue;
206 | }
207 | } DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange);
208 |
209 | //Engine RPM needed for Engine Crank mag-switch
210 | void onIfeiRpmLChange(char* newValue) {
211 | rpmL = atoi(newValue);
212 | } DcsBios::StringBuffer<3> ifeiRpmLBuffer(0x749e, onIfeiRpmLChange);
213 |
214 | void onIfeiRpmRChange(char* newValue) {
215 | rpmR = atoi(newValue);
216 | } DcsBios::StringBuffer<3> ifeiRpmRBuffer(0x74a2, onIfeiRpmRChange);
217 |
218 | /**
219 | * Arduino Setup Function
220 | *
221 | * Arduino standard Setup Function. Code who should be executed
222 | * only once at the program start, belongs in this function.
223 | */
224 | void setup() {
225 |
226 | // Run DCS Bios setup function
227 | DcsBios::setup();
228 |
229 | pinMode(APU_SW_MAG, OUTPUT);
230 | pinMode(ENG_CRANK_MAG, OUTPUT);
231 | pinMode(APU_LAMP, OUTPUT);
232 |
233 | digitalWrite(APU_SW_MAG, LOW);
234 | digitalWrite(ENG_CRANK_MAG, LOW);
235 | digitalWrite(APU_LAMP, LOW);
236 | }
237 |
238 | /**
239 | * Arduino Loop Function
240 | *
241 | * Arduino standard Loop Function. Code who should be executed
242 | * over and over in a loop, belongs in this function.
243 | *
244 | */
245 | void loop() {
246 |
247 | //Run DCS Bios loop function
248 | DcsBios::loop();
249 |
250 | /**
251 | * ### Engine Crank Mag-Switch Logic
252 | * If the engine crank mag-switch is held in an engine start position, then: \n
253 | * -# If switch towards left engine and left engine's RPM >= 65%, turn off the mag-switch. \n
254 | * -# If switch towards right engine and right engine's RPM >= 65%, turn off the mag-switch. \n
255 | * @note If the switch is in the middle the code will ensure the engine crank mag-switch is off.
256 | *
257 | */
258 | if (engCrankHold == HIGH) { // If engCrankHold mag is on check RPM to turn off based on which way the SWITCH is facing
259 | switch (engCrankState) {
260 | case 0: //switch Left
261 | if (rpmL >= 65) { //if over 65% rpm turn off mag
262 | digitalWrite(ENG_CRANK_MAG, LOW);
263 | engCrankHold = LOW; //note mag is off
264 | }
265 | break;
266 | case 1: //switch in the middle, mag shouldn't be on
267 | digitalWrite(ENG_CRANK_MAG, LOW);
268 | engCrankHold = LOW; //note mag is off
269 | break;
270 | case 2: //switch Right
271 | if (rpmR >= 65) { //if over 65% rpm turn off mag
272 | digitalWrite(ENG_CRANK_MAG, LOW);
273 | engCrankHold = LOW; //note mag is off
274 | }
275 | break;
276 | }
277 | }
278 | }
279 |
--------------------------------------------------------------------------------