SWT20 was written from memory of the reference rather than from Table 7, and 20 is not an ATU switch at all — it would have pressed something else on a real K3. An operator read the table out for us: switch 19 is the ATU row, TAP for a tuning cycle and HOLD for tuner in line or bypassed. Adds the HOLD as its own ATU button, because on the radio they are two different things: tuning is a cycle you start, bypassing is a state you leave it in. Power takes 0-110 W on an Elecraft, per the reference — a K3 makes a little over its rated output — while a Kenwood keeps 200.
116 lines
4.1 KiB
Go
116 lines
4.1 KiB
Go
package main
|
|
|
|
// Elecraft K3/K4 panel bindings.
|
|
//
|
|
// The controls the operator asked for and nothing else: power, volume, the
|
|
// S-meter and SWR, MOX, and an ATU tune. A K3 exposes dozens of commands, but a
|
|
// panel earns its place by covering what is reached for during a QSO — and each
|
|
// one added without a radio to test it against is a control that may or may not
|
|
// do what its label says. See internal/cat/kenwood_panel.go.
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"hamlog/internal/cat"
|
|
)
|
|
|
|
// GetKenwoodState returns the K3/K4 panel snapshot. Zero value when the active
|
|
// CAT backend is something else, which is how the UI knows to hide the panel.
|
|
func (a *App) GetKenwoodState() cat.KenwoodTXState {
|
|
if a.cat == nil {
|
|
return cat.KenwoodTXState{}
|
|
}
|
|
st, _ := a.cat.KenwoodState()
|
|
return st
|
|
}
|
|
|
|
func (a *App) SetKenwoodPower(w int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodPower(w) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodAFGain(p int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodAFGain(p) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodRFGain(p int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodRFGain(p) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodMicGain(p int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodMicGain(p) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodSquelch(p int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodSquelch(p) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodPreamp(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodPreamp(on) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodAtt(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodAtt(on) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodNB(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodNB(on) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodNR(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodNR(on) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodAGC(name string) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodAGC(name) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodFilter(hz int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodFilter(hz) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodAntenna(n int) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodAntenna(n) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodRIT(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodRIT(on) })
|
|
}
|
|
|
|
func (a *App) SetKenwoodXIT(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodXIT(on) })
|
|
}
|
|
|
|
// ClearKenwoodRIT zeroes the RIT and XIT offsets together, which is what the
|
|
// radio's own RC does and what an operator means by "clear it".
|
|
func (a *App) ClearKenwoodRIT() error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.ClearKenwoodRIT() })
|
|
}
|
|
|
|
// SetKenwoodTX is the panel's MOX.
|
|
func (a *App) SetKenwoodTX(on bool) error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.SetKenwoodTX(on) })
|
|
}
|
|
|
|
// ToggleKenwoodATU puts the tuner in line or bypasses it (the HOLD of the same
|
|
// front-panel switch the tune uses).
|
|
func (a *App) ToggleKenwoodATU() error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.ToggleKenwoodATU() })
|
|
}
|
|
|
|
func (a *App) TuneKenwoodATU() error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.TuneKenwoodATU() })
|
|
}
|
|
|
|
// RefreshKenwood re-reads the settings on the next poll — for when a knob was
|
|
// turned on the radio itself.
|
|
func (a *App) RefreshKenwood() error {
|
|
return a.kenwoodPanelDo(func(k cat.KenwoodPanelController) error { return k.RefreshKenwood() })
|
|
}
|
|
|
|
func (a *App) kenwoodPanelDo(fn func(cat.KenwoodPanelController) error) error {
|
|
if a.cat == nil {
|
|
return fmt.Errorf("CAT not initialized")
|
|
}
|
|
return a.cat.KenwoodPanelDo(fn)
|
|
}
|