Skip to content

Commit 86e03bc

Browse files
committed
show the current PTT and parrot state next to the VFO controls
1 parent 57878ff commit 86e03bc

File tree

6 files changed

+73
-24
lines changed

6 files changed

+73
-24
lines changed

core/entry/entry.go

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type View interface {
2929
SetMode(text string)
3030
SetXITActive(active bool)
3131
SetXIT(active bool, offset core.Frequency)
32+
SetTXState(ptt bool, parrotActive bool, parrotTimeLeft time.Duration)
3233
SetMyExchange(int, string)
3334
SetTheirExchange(int, string)
3435

@@ -140,6 +141,10 @@ type Controller struct {
140141
editQSO core.QSO
141142
ignoreQSOSelection bool
142143
ignoreFrequencyJump bool
144+
145+
ptt bool
146+
parrotActive bool
147+
parrotTimeLeft time.Duration
143148
}
144149

145150
func (c *Controller) Notify(listener any) {
@@ -543,15 +548,22 @@ func (c *Controller) XITActiveChanged(active bool) {
543548
}
544549

545550
func (c *Controller) VFOPTTChanged(active bool) {
546-
log.Printf("PTT active: %t", active)
551+
c.ptt = active
552+
c.updateTXState()
547553
}
548554

549555
func (c *Controller) ParrotActive(active bool) {
550-
log.Printf("Parrot active: %t", active)
556+
c.parrotActive = active
557+
c.updateTXState()
551558
}
552559

553560
func (c *Controller) ParrotTimeLeft(timeLeft time.Duration) {
554-
log.Printf("Parrot time left: %v", timeLeft)
561+
c.parrotTimeLeft = timeLeft
562+
c.updateTXState()
563+
}
564+
565+
func (c *Controller) updateTXState() {
566+
c.view.SetTXState(c.ptt, c.parrotActive, c.parrotTimeLeft)
555567
}
556568

557569
func (c *Controller) SendQuestion() {
@@ -968,24 +980,25 @@ func (c *Controller) EntrySelected(entry core.BandmapEntry) {
968980

969981
type nullView struct{}
970982

971-
func (n *nullView) SetUTC(string) {}
972-
func (n *nullView) SetMyCall(string) {}
973-
func (n *nullView) SetFrequency(core.Frequency) {}
974-
func (n *nullView) SetCallsign(string) {}
975-
func (n *nullView) SetBand(text string) {}
976-
func (n *nullView) SetMode(text string) {}
977-
func (n *nullView) SetXITActive(active bool) {}
978-
func (n *nullView) SetXIT(active bool, offset core.Frequency) {}
979-
func (n *nullView) SetMyExchange(int, string) {}
980-
func (n *nullView) SetTheirExchange(int, string) {}
981-
func (n *nullView) SetMyExchangeFields([]core.ExchangeField) {}
982-
func (n *nullView) SetTheirExchangeFields([]core.ExchangeField) {}
983-
func (n *nullView) SetActiveField(core.EntryField) {}
984-
func (n *nullView) SelectText(core.EntryField, string) {}
985-
func (n *nullView) SetDuplicateMarker(bool) {}
986-
func (n *nullView) SetEditingMarker(bool) {}
987-
func (n *nullView) ShowMessage(...interface{}) {}
988-
func (n *nullView) ClearMessage() {}
983+
func (n *nullView) SetUTC(string) {}
984+
func (n *nullView) SetMyCall(string) {}
985+
func (n *nullView) SetFrequency(core.Frequency) {}
986+
func (n *nullView) SetCallsign(string) {}
987+
func (n *nullView) SetBand(text string) {}
988+
func (n *nullView) SetMode(text string) {}
989+
func (n *nullView) SetXITActive(active bool) {}
990+
func (n *nullView) SetXIT(active bool, offset core.Frequency) {}
991+
func (n *nullView) SetTXState(ptt bool, parrotActive bool, parrotTimeLeft time.Duration) {}
992+
func (n *nullView) SetMyExchange(int, string) {}
993+
func (n *nullView) SetTheirExchange(int, string) {}
994+
func (n *nullView) SetMyExchangeFields([]core.ExchangeField) {}
995+
func (n *nullView) SetTheirExchangeFields([]core.ExchangeField) {}
996+
func (n *nullView) SetActiveField(core.EntryField) {}
997+
func (n *nullView) SelectText(core.EntryField, string) {}
998+
func (n *nullView) SetDuplicateMarker(bool) {}
999+
func (n *nullView) SetEditingMarker(bool) {}
1000+
func (n *nullView) ShowMessage(...interface{}) {}
1001+
func (n *nullView) ClearMessage() {}
9891002

9901003
type nullVFO struct{}
9911004

core/mocked/mocked.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ func (m *EntryView) SetXIT(active bool, offset core.Frequency) {
257257
m.Called(active, offset)
258258
}
259259

260+
func (m *EntryView) SetTXState(ptt bool, parrotActive bool, parrotTimeLeft time.Duration) {
261+
if !m.active {
262+
return
263+
}
264+
m.Called(ptt, parrotActive, parrotTimeLeft)
265+
}
266+
260267
func (m *EntryView) SetMyExchange(index int, value string) {
261268
if !m.active {
262269
return

ui/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121

2222
const AppID = "ft.hellocontest"
2323

24+
const parrot = "🦜"
25+
2426
type Script interface {
2527
app.Script
2628
Now() time.Time

ui/entryView.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"strings"
7+
"time"
78

89
"github.com/gotk3/gotk3/gdk"
910
"github.com/gotk3/gotk3/gtk"
@@ -45,6 +46,7 @@ type entryView struct {
4546
band *gtk.ComboBoxText
4647
mode *gtk.ComboBoxText
4748
xit *gtk.CheckButton
49+
txIndicator *gtk.Label
4850
myExchangesParent *gtk.Grid
4951
myExchanges []*gtk.Entry
5052
logButton *gtk.Button
@@ -64,6 +66,7 @@ func setupEntryView(builder *gtk.Builder) *entryView {
6466
result.band = getUI(builder, "bandCombo").(*gtk.ComboBoxText)
6567
result.mode = getUI(builder, "modeCombo").(*gtk.ComboBoxText)
6668
result.xit = getUI(builder, "xitCheckbox").(*gtk.CheckButton)
69+
result.txIndicator = getUI(builder, "txIndicatorLabel").(*gtk.Label)
6770
result.myExchangesParent = getUI(builder, "myExchangesGrid").(*gtk.Grid)
6871
result.logButton = getUI(builder, "logButton").(*gtk.Button)
6972
result.clearButton = getUI(builder, "clearButton").(*gtk.Button)
@@ -267,6 +270,24 @@ func (v *entryView) SetXIT(active bool, offset core.Frequency) {
267270
}
268271
}
269272

273+
func (v *entryView) SetTXState(ptt bool, parrotActive bool, parrotTimeLeft time.Duration) {
274+
log.Printf("new tx state: %t %t %v", ptt, parrotActive, parrotTimeLeft)
275+
276+
var text string
277+
switch {
278+
case parrotActive:
279+
text = fmt.Sprintf("%s", parrot) // TODO: append parrotTimeLeft when available
280+
case ptt:
281+
text = "TX"
282+
default:
283+
text = "RX"
284+
}
285+
286+
// TODO: set the background color to red while transmitting
287+
288+
v.txIndicator.SetText(text)
289+
}
290+
270291
func (v *entryView) SetMyExchange(index int, text string) {
271292
i := index - 1
272293
if i < 0 || i >= len(v.myExchanges) {

ui/glade/contest.glade

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,15 @@ For more details see &lt;a href="https://github.com/ftl/hellocontest/wiki/Main-W
23852385
</packing>
23862386
</child>
23872387
<child>
2388-
<placeholder/>
2388+
<object class="GtkLabel" id="txIndicatorLabel">
2389+
<property name="visible">True</property>
2390+
<property name="can-focus">False</property>
2391+
<property name="label" translatable="yes">RX</property>
2392+
</object>
2393+
<packing>
2394+
<property name="left-attach">5</property>
2395+
<property name="top-attach">2</property>
2396+
</packing>
23892397
</child>
23902398
<child>
23912399
<placeholder/>

ui/keyerButtonView.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"github.com/gotk3/gotk3/gtk"
99
)
1010

11-
const parrot = "🦜"
12-
1311
// KeyerController controls the keyer.
1412
type KeyerController interface {
1513
Send(int)

0 commit comments

Comments
 (0)