flight-indicators 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -2
- package/dist/index.cjs +678 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -1
- package/dist/index.d.ts +187 -1
- package/dist/index.js +662 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# flight-indicators
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
Modern SVG flight instruments for React, with no runtime dependencies.
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Thirteen instruments: **Attitude**, **Heading**, **Airspeed**, **Altimeter**, **Vertical speed**, **Turn coordinator**, **VOR / CDI**, **Wind / runway**, **Fuel**, **Flaps**, **Angle of attack**, **Engine monitor** and a custom **Data panel** for any readouts you like
|
|
8
8
|
- Pure SVG with no image files, so instruments stay sharp at any size and work with any bundler
|
|
9
9
|
- Written in TypeScript and ships its type declarations
|
|
10
10
|
- Ships ESM and CommonJS builds, works with server-side rendering, and is marked `"use client"` for the Next.js App Router
|
|
@@ -30,7 +30,13 @@ import {
|
|
|
30
30
|
Altimeter,
|
|
31
31
|
VerticalSpeed,
|
|
32
32
|
TurnCoordinator,
|
|
33
|
+
VorIndicator,
|
|
33
34
|
WindIndicator,
|
|
35
|
+
FuelIndicator,
|
|
36
|
+
FlapIndicator,
|
|
37
|
+
AoaIndicator,
|
|
38
|
+
EngineIndicator,
|
|
39
|
+
DataPanel,
|
|
34
40
|
} from 'flight-indicators';
|
|
35
41
|
|
|
36
42
|
export function Panel({ data }) {
|
|
@@ -43,6 +49,19 @@ export function Panel({ data }) {
|
|
|
43
49
|
<HeadingIndicator heading={data.heading} />
|
|
44
50
|
<VerticalSpeed verticalSpeed={data.vs} />
|
|
45
51
|
<WindIndicator runway={90} windDirection={data.windDir} windSpeed={data.windSpeed} />
|
|
52
|
+
<VorIndicator course={data.obs} radial={data.navRadial} />
|
|
53
|
+
<FuelIndicator capacity={26} tanks={[{ name: 'Left', quantity: data.fuelL }, { name: 'Right', quantity: data.fuelR }]} />
|
|
54
|
+
<FlapIndicator flaps={data.flaps} airspeed={data.ias} speedLimits={[{ flaps: 0, speed: 160 }, { flaps: 10, speed: 110 }]} />
|
|
55
|
+
<EngineIndicator manifold={{ value: data.map }} rpm={{ value: data.rpm }} cht={data.cht} egt={data.egt} fuelLeft={data.fuelL} fuelRight={data.fuelR} />
|
|
56
|
+
<DataPanel
|
|
57
|
+
heading="Radios"
|
|
58
|
+
fields={[
|
|
59
|
+
{ name: 'OAT', value: data.oat, unit: '°C' },
|
|
60
|
+
{ name: 'VLOC', value: data.nav1, unit: 'MHz', decimals: 2 },
|
|
61
|
+
{ name: 'COM', value: data.com1, unit: 'MHz', decimals: 3 },
|
|
62
|
+
{ name: 'Squawk', value: data.squawk },
|
|
63
|
+
]}
|
|
64
|
+
/>
|
|
46
65
|
</div>
|
|
47
66
|
);
|
|
48
67
|
}
|
|
@@ -121,6 +140,106 @@ A north-up compass rose with the runway drawn to scale on its heading and the wi
|
|
|
121
140
|
| `windGust` | `number` | | Gust speed in knots. Shown when higher than `windSpeed`. |
|
|
122
141
|
| `crosswindLimit` | `number` | `15` | Crosswind in knots (gusts included) above which the crosswind turns amber. |
|
|
123
142
|
|
|
143
|
+
### `<VorIndicator />`
|
|
144
|
+
|
|
145
|
+
A VOR / course deviation indicator with an OBS card. The card turns so the selected course sits under the top index, the needle shows how far the course line is to the left or right (5 dots each side, 2° per dot, ±10° full scale) and a triangle points TO or FROM the station. Give it the selected `course` and the `radial` the aircraft is on, and it works out the deflection and the TO/FROM flag. Alternatively pass `deviation` and `toFrom` straight from your avionics data.
|
|
146
|
+
|
|
147
|
+
| Prop | Type | Default | Description |
|
|
148
|
+
| ----------- | ------------------------ | ------- | ------------------------------------------------------------------ |
|
|
149
|
+
| `course` | `number` | `0` | Selected course (OBS) in degrees. |
|
|
150
|
+
| `radial` | `number` | | Radial from the station the aircraft is on, in degrees. Drives the needle and the TO/FROM flag. |
|
|
151
|
+
| `deviation` | `number` | | Course deviation in degrees, positive when the course is to the right. Clamped to ±10. Overrides `radial`. |
|
|
152
|
+
| `toFrom` | `"TO" \| "FROM" \| "OFF"` | | TO/FROM flag. Overrides `radial`. `"OFF"` hides both triangles. |
|
|
153
|
+
| `signal` | `boolean` | `true` | `false` shows the red NAV flag, centres the needle and hides TO/FROM. |
|
|
154
|
+
|
|
155
|
+
`vorDeviation(course, radial)` is exported too and returns `{ deviation, toFrom }` if you want the same maths without the drawing.
|
|
156
|
+
|
|
157
|
+
### `<FuelIndicator />`
|
|
158
|
+
|
|
159
|
+
A digital fuel quantity gauge: one vertical bar graph per tank with a numeric readout underneath, `FULL` when a tank is at capacity, and red when it drops to the low threshold.
|
|
160
|
+
|
|
161
|
+
| Prop | Type | Default | Description |
|
|
162
|
+
| ---------- | ------------ | --------- | ------------------------------------------------------------------- |
|
|
163
|
+
| `tanks` | `FuelTank[]` | Left and Right, empty | Tanks shown left to right, each `{ name, quantity, capacity? }`. Up to four. |
|
|
164
|
+
| `capacity` | `number` | `50` | Full-tank quantity for tanks that don't set their own. |
|
|
165
|
+
| `unit` | `string` | `"gal"` | Unit printed under each readout. |
|
|
166
|
+
| `low` | `number` | 10% of capacity | Quantity at or below which a tank turns red. |
|
|
167
|
+
| `decimals` | `number` | `1` | Decimal places in the readouts. |
|
|
168
|
+
| `label` | `string` | `"FUEL"` | Caption along the bottom of the display. |
|
|
169
|
+
|
|
170
|
+
### `<FlapIndicator />`
|
|
171
|
+
|
|
172
|
+
A wing flap position indicator: a vertical LED bar graph that fills from the top as the flaps extend, green at the top through yellow and orange to red at full deflection, with a degree scale beside it and a pointer at the exact position. Optionally shows the maximum flap extension speed for the current setting, which turns red when `airspeed` exceeds it.
|
|
173
|
+
|
|
174
|
+
| Prop | Type | Default | Description |
|
|
175
|
+
| ------------- | ------------------ | -------------- | ----------------------------------------------------------------- |
|
|
176
|
+
| `flaps` | `number` | `0` | Flap position in degrees. Clamped to `0…max`. |
|
|
177
|
+
| `max` | `number` | `40` | Full flap deflection in degrees. |
|
|
178
|
+
| `detents` | `number[]` | every 10° | Scale labels in degrees. |
|
|
179
|
+
| `segments` | `number` | `20` | Number of LED segments in the bar. |
|
|
180
|
+
| `speedLimits` | `FlapSpeedLimit[]` | | `{ flaps, speed }` pairs in knots: the max speed once flaps are at or beyond `flaps`. The highest reached entry is shown. Omit to hide the readout. |
|
|
181
|
+
| `airspeed` | `number` | | Current airspeed in knots, used to flag an overspeed. |
|
|
182
|
+
| `showMph` | `boolean` | `true` | Also print the limit in mph. |
|
|
183
|
+
| `label` | `string` | `"WING FLAP"` | Caption at the bottom of the dial. |
|
|
184
|
+
|
|
185
|
+
### `<AoaIndicator />`
|
|
186
|
+
|
|
187
|
+
An angle of attack indicator modelled on panel-mount LED AoA displays. Eleven rows light from the bottom up as the AoA rises: four green bars, a green donut at the optimum AoA, an amber bar, an amber split bar, two amber chevrons and two red chevrons pointing down ("lower the nose"). Rows below the donut are spaced evenly from `min` to `optimum`, rows above it from `optimum` to `max`. At `max` every row is lit and the chevrons flash.
|
|
188
|
+
|
|
189
|
+
| Prop | Type | Default | Description |
|
|
190
|
+
| ----------- | --------- | ------------------- | -------------------------------------------------------- |
|
|
191
|
+
| `aoa` | `number` | `0` | Current angle of attack in degrees. |
|
|
192
|
+
| `min` | `number` | `0` | AoA at which the bottom bar lights. |
|
|
193
|
+
| `optimum` | `number` | halfway to `max` | AoA at which the green donut lights (approach / L/Dmax). |
|
|
194
|
+
| `max` | `number` | `20` | Critical AoA: all rows lit and the chevrons flash. |
|
|
195
|
+
| `showValue` | `boolean` | `false` | Print the AoA in degrees under the display. |
|
|
196
|
+
| `label` | `string` | `"AOA"` | Caption at the bottom of the dial. |
|
|
197
|
+
|
|
198
|
+
### `<EngineIndicator />`
|
|
199
|
+
|
|
200
|
+
An all-in-one engine monitor in the style of a JPI EDM. The top holds a percent-power readout and two arc gauges for manifold pressure and RPM. The left half shows the hottest CHT, EGT and TIT with a per-cylinder bar graph (green CHT, blue EGT, white TIT) and a dashed red CHT limit line. The right half has up to four horizontal bar gauges, and the bottom row shows alternator amps, the two fuel tanks and bus volts. Sections you pass no data for are left blank.
|
|
201
|
+
|
|
202
|
+
Scaled gauges share one shape, `EngineGauge`: `{ value, min, max, green?, yellow?, low?, high?, unit?, decimals? }`. `green` and `yellow` are `[from, to]` bands; `low` and `high` are red limits. A readout turns yellow inside the yellow band and red at or beyond a red limit.
|
|
203
|
+
|
|
204
|
+
| Prop | Type | Default | Description |
|
|
205
|
+
| ----------------- | ----------------- | -------------- | ------------------------------------------------------------------ |
|
|
206
|
+
| `power` | `number` | | Percent power printed at the top. |
|
|
207
|
+
| `manifold` | `EngineGauge` | 10–35 inHg | Manifold pressure arc. Only `value` is needed to use the default scale. |
|
|
208
|
+
| `rpm` | `EngineGauge` | 0–3000 | Engine speed arc. |
|
|
209
|
+
| `cht` | `number[]` | `[]` | CHT per cylinder, up to six. |
|
|
210
|
+
| `egt` | `number[]` | `[]` | EGT per cylinder, up to six. |
|
|
211
|
+
| `tit` | `number` | | Turbine inlet temperature, drawn as the `T` column. |
|
|
212
|
+
| `chtLimit` | `number` | `400` | CHT at which the dashed red line is drawn. |
|
|
213
|
+
| `chtScale` | `number` | `500` | CHT that fills a bar to the top. |
|
|
214
|
+
| `egtScale` | `number` | `1700` | EGT or TIT that fills a bar to the top. |
|
|
215
|
+
| `temperatureUnit` | `string` | `"°F"` | Printed after the CHT/EGT/TIT headings. |
|
|
216
|
+
| `gauges` | `EngineBarGauge[]`| oil P, oil T, fuel P, fuel F | Horizontal bar gauges, each an `EngineGauge` plus a `label`. Up to four. |
|
|
217
|
+
| `amps` | `number` | | Alternator current. |
|
|
218
|
+
| `volts` | `number` | | Bus voltage, shown with one decimal. |
|
|
219
|
+
| `fuelLeft` | `number` | | Left tank quantity. |
|
|
220
|
+
| `fuelRight` | `number` | | Right tank quantity. |
|
|
221
|
+
| `fuelCapacity` | `number` | `30` | Full quantity of each tank, used to fill the tank icons. |
|
|
222
|
+
| `fuelUnit` | `string` | `"GAL"` | Printed under the fuel quantities. |
|
|
223
|
+
|
|
224
|
+
### `<DataPanel />`
|
|
225
|
+
|
|
226
|
+
A general-purpose instrument for readouts that have no dedicated gauge: temperatures, radio frequencies, transponder code, fuel, timers, anything. It draws a square panel inside the usual round bezel and fills it with a grid of up to six cells. Each cell shows a name, a value and an optional unit. One or two fields stack vertically; three or more use two columns. Long values shrink to fit.
|
|
227
|
+
|
|
228
|
+
| Prop | Type | Default | Description |
|
|
229
|
+
| --------- | ------------- | ------- | ------------------------------------------------------------------------ |
|
|
230
|
+
| `fields` | `DataField[]` | `[]` | Readouts to show. Only the first six are drawn. |
|
|
231
|
+
| `heading` | `string` | | Caption printed above the panel, also used in the accessible label. |
|
|
232
|
+
|
|
233
|
+
Each `DataField`:
|
|
234
|
+
|
|
235
|
+
| Field | Type | Default | Description |
|
|
236
|
+
| ---------- | ------------------ | ------- | --------------------------------------------------------------- |
|
|
237
|
+
| `name` | `string` | | Caption above the value, e.g. `"COM1"`. |
|
|
238
|
+
| `value` | `string \| number` | | Strings are printed as given. Numbers are formatted with `decimals`; `NaN` shows as `---`. |
|
|
239
|
+
| `unit` | `string` | | Printed in the corner of the cell, e.g. `"MHz"`. |
|
|
240
|
+
| `decimals` | `number` | `0` | Decimal places for numeric values. |
|
|
241
|
+
| `color` | `string` | white | Colour of the value text, e.g. amber for a caution. |
|
|
242
|
+
|
|
124
243
|
## Development
|
|
125
244
|
|
|
126
245
|
```bash
|