Skip to content

Commit 59fa86a

Browse files
authoredAug 17, 2021
feat(efb): tabbed settings page and new autobrightness option (flybywiresim#5524)
* changelog * init commit * add margin * I forgor 💀 * remove the div and change styling * add duration * create a ternary * remove the test div * darker grey color * get rid of OtherSettings and move it into FlyPadPage component * refactor: change layout * rename hooks and display names to be more appropriate * remove _, and replace with empty comma * feat: add autobrightness option * change b value * refactor: drastically improve autobrightness brightness calculation * fix: wrong navbar option showing and flickering brightness slider
1 parent 1c1133f commit 59fa86a

File tree

5 files changed

+386
-300
lines changed

5 files changed

+386
-300
lines changed
 

‎.github/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
1. [MISC] Change back to airliner hud in external view for SU5 - @donstim (donbikes#4084)
164164
1. [TEXTURE] Improved cockpit textures and screen reflections - @MoreRightRudder (Mike), @tyler58546 (tyler58546)
165165
1. [MCDU] DEST EFOB and ALT DEST EFOB amber coloring fixed - @erso44 (Ersin Karakilic)
166+
1. [EFB] Add tabbed settings page to EFB - @ErickSharp (Erick [Z-6]#6484)
166167
1. [FCU] Added LVAR for selected speed and only fill active LVAR for VS or FPA mode
167168
1. [MODEL] Removed unused material to fix potential crash to desktop - @aguther (Andreas Guther)
168169
1. [ARCH] Failures are supported - @davidwalschots (David Walschots)

‎src/instruments/src/EFB/Efb.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState, useReducer } from 'react';
22

33
import { Provider } from 'react-redux';
44
import { Route, Switch, useHistory } from 'react-router-dom';
5+
import { useSimVar } from '@instruments/common/simVars';
56
import { usePersistentProperty } from '../Common/persistence';
67
import NavigraphClient, { NavigraphContext } from './ChartsApi/Navigraph';
78
import { getSimbriefData, IFuel, IWeights } from './SimbriefApi';
@@ -118,9 +119,24 @@ const navigraph = new NavigraphClient();
118119
const Efb = () => {
119120
const history = useHistory();
120121

122+
const [currentLocalTime] = useSimVar('E:LOCAL TIME', 'seconds', 3000);
123+
const [, setBrightness] = useSimVar('L:A32NX_EFB_BRIGHTNESS', 'number');
124+
const [usingAutobrightness] = useSimVar('L:A32NX_EFB_USING_AUTOBRIGHTNESS', 'bool', 5000);
125+
126+
// handle setting brightness if user is using autobrightness
127+
useEffect(() => {
128+
if (usingAutobrightness) {
129+
const localTime = currentLocalTime / 3600;
130+
// the below code defines a semicircular function.
131+
// eslint-disable-next-line no-restricted-properties
132+
setBrightness(((Math.sqrt(48 - Math.pow((localTime - 14), 2))) * 14.431) || 0);
133+
}
134+
}, [currentLocalTime]);
135+
121136
const [performanceState, performanceDispatch] = useReducer(PerformanceReducer, performanceInitialState);
122137
const [simbriefData, setSimbriefData] = useState<SimbriefData>(emptySimbriefData);
123138
const [simbriefUsername, setSimbriefUsername] = usePersistentProperty('SimbriefUsername');
139+
124140
const [timeState, setTimeState] = useState<TimeState>({
125141
currentTime: new Date(),
126142
initTime: new Date(),

0 commit comments

Comments
 (0)
Please sign in to comment.