Skip to content

Commit 1ae6cad

Browse files
committed
move VFO related actions into one file
1 parent f717e4a commit 1ae6cad

2 files changed

Lines changed: 51 additions & 63 deletions

File tree

pkg/action/selectvfo.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

pkg/action/vfo.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,66 @@ import (
88
)
99

1010
const (
11+
SelectVFOUUID = "com.thecodingflow.hamlibplugin.selectvfo"
1112
VFOOpUUID = "com.thecodingflow.hamlibplugin.vfoop"
1213
VFOOpEncoderUUID = "com.thecodingflow.hamlibplugin.vfoopencoder"
1314
)
1415

1516
func init() {
17+
Factories[SelectVFOUUID] = NewSelectVFO
1618
Factories[VFOOpUUID] = NewVFOOp
1719
Factories[VFOOpEncoderUUID] = NewVFOOpEncoder
1820
}
1921

22+
type SelectVFO struct {
23+
basicAction
24+
}
25+
26+
func NewSelectVFO(context string, client RigClient, deck Deck) Action {
27+
return &SelectVFO{
28+
basicAction: basicAction{
29+
context: context,
30+
client: client,
31+
deck: deck,
32+
},
33+
}
34+
}
35+
36+
func (a *SelectVFO) parseSettings(settings map[string]any) hl.VFO {
37+
vfo, ok := settings["vfo"].(string)
38+
if !ok {
39+
vfo = ""
40+
}
41+
return hl.VFO(vfo)
42+
}
43+
44+
func (a *SelectVFO) DidReceiveSettings(payload *sdk.ReceivedEventPayload) error {
45+
a.UpdateVisual(payload)
46+
return nil
47+
}
48+
49+
func (a *SelectVFO) UpdateVisual(payload *sdk.ReceivedEventPayload) error {
50+
vfo := a.parseSettings(payload.Settings)
51+
if vfo == "" {
52+
vfo = "VFO"
53+
}
54+
a.deck.SetTitle(a.context, string(vfo), sdk.HardwareAndSoftware)
55+
return nil
56+
}
57+
58+
func (a *SelectVFO) KeyDown(payload *sdk.ReceivedEventPayload) error {
59+
vfo := a.parseSettings(payload.Settings)
60+
if vfo == "" {
61+
return nil
62+
}
63+
64+
err := a.client.SetVFO(vfo)
65+
if err != nil {
66+
log.Printf("[ERROR] select vfo: %v", err)
67+
}
68+
return nil
69+
}
70+
2071
type VFOOperation struct {
2172
basicAction
2273
}

0 commit comments

Comments
 (0)