fix: Flex with multiple slices opened was always showing slice A s-meter.

This commit is contained in:
2026-07-10 23:13:06 +02:00
parent 6c39204301
commit 73f3ec51f7
10 changed files with 192 additions and 15 deletions
+10 -2
View File
@@ -37,7 +37,7 @@ type FlexState = {
};
type FlexSlice = { index: number; letter: string; freq_hz: number; mode?: string; band?: string; active: boolean; tx: boolean };
type Meter = { id: number; src?: string; name?: string; unit?: string; value: number; lo: number; hi: number };
type Meter = { id: number; src?: string; name?: string; unit?: string; slice?: number; value: number; lo: number; hi: number };
const ZERO: FlexState = {
available: false, rf_power: 0, tune_power: 0, tune: false, transmitting: false,
@@ -356,7 +356,15 @@ export function FlexPanel({ onCWSpeed, onReportRST }: { onCWSpeed?: (wpm: number
// Radio meters (exclude the amplifier's, which we show separately).
const radio = (name: string) => meters.find((m) =>
(m.name || '').toUpperCase().includes(name) && !(m.src || '').toUpperCase().includes('AMP'));
const sig = radio('LEVEL') || radio('SIGNAL');
// Per-slice (SLC) meters — S-meter — exist once PER SLICE, so pick the
// one for the ACTIVE slice; otherwise we'd always show slice A's level.
const activeSlice = (st.slices || []).find((s) => s.active)?.index ?? -1;
const sliceMeter = (name: string) => {
const m = meters.filter((x) => (x.name || '').toUpperCase().includes(name) && !(x.src || '').toUpperCase().includes('AMP'));
if (m.length === 0) return undefined;
return m.find((x) => (x.src || '').toUpperCase().includes('SLC') && x.slice === activeSlice) || m[0];
};
const sig = sliceMeter('LEVEL') || sliceMeter('SIGNAL');
const fwd = radio('FWDPWR');
const swr = radio('SWR');
// Mic input level + speech-compression (voltage & PA temp live in the
@@ -321,7 +321,6 @@ function EditDialog({
<Label>{t('udpp.name')}</Label>
<Input
autoFocus
placeholder={draft.direction === 'inbound' ? t('udpp.namePhInbound') : t('udpp.namePhOutbound')}
value={draft.name}
onChange={(e) => setDraft((d) => ({ ...d, name: e.target.value }))}
/>
+2
View File
@@ -504,6 +504,7 @@ export namespace cat {
src?: string;
name?: string;
unit?: string;
slice: number;
value: number;
lo: number;
hi: number;
@@ -518,6 +519,7 @@ export namespace cat {
this.src = source["src"];
this.name = source["name"];
this.unit = source["unit"];
this.slice = source["slice"];
this.value = source["value"];
this.lo = source["lo"];
this.hi = source["hi"];